From b96c9b94317b31c6bb7e1335a4c7ba7a7dca7e4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=A0t=C4=9Bp=C3=A1n=20Kasal?= Date: Fri, 22 May 2009 09:05:10 +0200 Subject: [PATCH] Make the paths more configurable. --- .gitignore | 1 + configure.ac | 13 +++++++++++++ src/Makefile.am | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/pathnames.h | 36 ++++-------------------------------- 4 files changed, 67 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 135f2dd..09f00bd 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,6 @@ stamp-h1 *.o src/crond src/crontab +src/cron-paths.h *~ *.tar.* diff --git a/configure.ac b/configure.ac index c41b9cf..54d5778 100644 --- a/configure.ac +++ b/configure.ac @@ -211,6 +211,19 @@ AC_ARG_WITH(audit, fi ] ) +dnl CRON_VAR_DEFAULT (VAR, DESCRIPTION, DEFAULT) +dnl -------------------------------------------- +AC_DEFUN([CRONIE_CONF_VAR], +[AC_ARG_VAR([$1], [$2 @<:@$3@:>@]) +if test "$$1" = ""; then + $1='$3' +fi +]) +CRONIE_CONF_VAR([SYSCRONTAB], [the current working directory of the running daemon], [${sysconfdir}/crontab]) +CRONIE_CONF_VAR([SYS_CROND_DIR], [the current working directory of the running daemon], [${sysconfdir}/cron.d]) +CRONIE_CONF_VAR([CRONDIR], [the current working directory of the running daemon], [${localstatedir}/spool]) +CRONIE_CONF_VAR([SPOOL_DIR], [the directory where all the user cron tabs reside], [${CRONDIR}/cron]) + AC_CONFIG_FILES([Makefile src/Makefile man/Makefile]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 8f19065..59608f9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,6 +10,10 @@ crontab_SOURCES = crontab.c $(common_src) common_src = entry.c env.c misc.c pw_dup.c security.c cron.h \ externs.h funcs.h globals.h macros.h pathnames.h structs.h \ bitstring.h +common_nodist = cron-paths.h +nodist_crond_SOURCES = $(common_nodist) +nodist_crontab_SOURCES = $(common_nodist) +BUILT_SOURCES = $(common_nodist) LDADD = $(LIBSELINUX) $(LIBPAM) $(LIBAUDIT) @@ -17,3 +21,48 @@ LDADD = $(LIBSELINUX) $(LIBPAM) $(LIBAUDIT) ## if DEBUG ## noinst_PROGRAMS = debug ## endif + +# This header contains all the paths. +# If they are configurable, they are declared in configure script. +# Depends on this Makefile, because it uses make variables. +cron-paths.h: Makefile + @echo 'creating $@' + @sed >$@ 's/ *\\$$//' <<\END #\ + /* This file has been automatically generated. Do not edit. */ \ + \ + #ifndef _CRON_PATHS_H_ \ + #define _CRON_PATHS_H_ \ + \ + /* CRONDIR is where cron(8) and crontab(1) both chdir \ + * to; SPOOL_DIR, CRON_ALLOW, CRON_DENY, and LOG_FILE \ + * are all relative to this directory. \ + * FIXME: Hey, but do we need this at all? --kasal \ + */ \ + #define CRONDIR "$(CRONDIR)" \ + \ + /* SPOOLDIR is where the crontabs live. \ + * This directory will have its modtime updated \ + * whenever crontab(1) changes a crontab; this is \ + * the signal for cron(8) to look at each individual \ + * crontab file and reload those whose modtimes are \ + * newer than they were last time around (or which \ + * didn't exist last time around...) \ + */ \ + #define SPOOL_DIR "$(SPOOL_DIR)" \ + \ + /* cron allow/deny file. At least cron.deny must \ + * exist for ordinary users to run crontab. \ + */ \ + #define CRON_ALLOW "$(sysconfdir)/cron.allow" \ + #define CRON_DENY "$(sysconfdir)/cron.deny" \ + \ + /* 4.3BSD-style crontab */ \ + #define SYSCRONTAB "$(SYSCRONTAB)" \ + \ + /* system crontab dir */ \ + #define SYS_CROND_DIR "$(SYS_CROND_DIR)" \ + \ + #define SYSCONFDIR "$(sysconfdir)" \ + \ + #endif /* _CRON_PATHS_H_ */ \ + END diff --git a/src/pathnames.h b/src/pathnames.h index a7616e8..b5d5c70 100644 --- a/src/pathnames.h +++ b/src/pathnames.h @@ -30,48 +30,20 @@ # include #endif /*BSD*/ -#define REBOOT_LOCK "/var/run/cron.reboot" - -#ifndef CRONDIR - /* CRONDIR is where cron(8) and crontab(1) both chdir - * to; SPOOL_DIR, CRON_ALLOW, CRON_DENY, and LOG_FILE - * are all relative to this directory. - */ -#define CRONDIR "/var/spool" -#endif - - /* SPOOLDIR is where the crontabs live. - * This directory will have its modtime updated - * whenever crontab(1) changes a crontab; this is - * the signal for cron(8) to look at each individual - * crontab file and reload those whose modtimes are - * newer than they were last time around (or which - * didn't exist last time around...) - */ -#define SPOOL_DIR "cron" - - /* cron allow/deny file. At least cron.deny must - * exist for ordinary users to run crontab. - */ -#define CRON_ALLOW "/etc/cron.allow" -#define CRON_DENY "/etc/cron.deny" +#include "cron-paths.h" /* where should the daemon stick its PID? * PIDDIR must end in '/'. + * (Don't ask why the default is "/etc/".) */ #ifdef _PATH_VARRUN # define PIDDIR _PATH_VARRUN #else -# define PIDDIR "/etc/" +# define PIDDIR SYSCONFDIR "/" #endif #define PIDFILE "crond.pid" #define _PATH_CRON_PID PIDDIR PIDFILE - - /* 4.3BSD-style crontab */ -#define SYSCRONTAB "/etc/crontab" - - /* system crontab dir */ -#define SYS_CROND_DIR "/etc/cron.d" +#define REBOOT_LOCK PIDDIR "cron.reboot" /* what editor to use if no EDITOR or VISUAL * environment variable specified. -- 2.40.0