AboutSummaryRefsLogTreeCommitDiffStats
diff options
context:
space:
mode:
authordale_mellor <dale_mellor>2005-10-23 12:29:19 +0000
committerdale_mellor <dale_mellor>2005-10-23 12:29:19 +0000
commitb1e921ffc81d460ef0ed7ab6163eb38b654ddf3b (patch)
tree4d5a51b409075d5c1617b7cab96a3b863d0b4f2a
parent863b755293610f84bc0f871264195076f99a9392 (diff)
downloadmcron-1.0.2.rc1.tar.gz
mcron-1.0.2.rc1.tar.bz2
mcron-1.0.2.rc1.zip
Changes requested by David D. Smith.1.0.2.rc1
Non-root install.
-rw-r--r--ChangeLog17
-rw-r--r--configure.ac44
-rw-r--r--crontab.scm2
-rw-r--r--job-specifier.scm3
-rw-r--r--main.scm3
-rw-r--r--makefile.am50
-rw-r--r--mcron-core.scm44
-rw-r--r--mcron.c.template49
-rw-r--r--mcron.texinfo.in29
-rw-r--r--vixie-specification.scm1
10 files changed, 161 insertions, 81 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a440d9..9f57f57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2005-09-02 hydro23 <Dale Mellor <dale@dmellor.dabsol.co.uk>>
+
+ * makefile.am, mcron.c.template (main): Modified install-exec-hook
+ so that a proper installation of a Vixie-compatible cron only
+ takes place if we are root - otherwise only mcron is installed as
+ a user-owned program. The guile modules are now installed under
+ mcron's shared data directory, not guile's global directories.
+
+ * mcron-core.scm: Removed job:advance-time, put the code inline
+ where it was called, and changed the instance in the main loop to
+ compute the new time based on the current-time, rather than the
+ previous job time (this makes things behave more reasonably when a
+ laptop awakes from suspend mode).
+
+ * Bumped version to 1.0.2.
+
+
2004-05-15 Dale Mellor <dale_mellor@users.sourceforge.net>
* Modified all auxiliary files to reflect that the package is now
diff --git a/configure.ac b/configure.ac
index 8dbe8dc..0a1d511 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,14 +1,34 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
+
+# Copyright (C) 2003, 2005 Dale Mellor
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+# USA.
+
+
AC_PREREQ(2.59)
-AC_INIT([mcron],[1.0.2],[dale_mellor@users.sourceforge.net])
+AC_INIT([mcron], [1.0.2rc1], [dale_mellor@users.sourceforge.net])
AM_INIT_AUTOMAKE
AC_MSG_CHECKING([whether debugging is requested])
AC_ARG_ENABLE(debug,
- AS_HELP_STRING(--enable-debug,enable debugging and traceback on error),
+ AC_HELP_STRING([--enable-debug],
+ [enable debugging and traceback on error]),
CONFIG_DEBUG=$enableval,
CONFIG_DEBUG=no)
AC_MSG_RESULT($CONFIG_DEBUG)
@@ -76,7 +96,7 @@ else
AC_CHECK_PROGS(SENDMAIL, mail)
if test "x$ac_cv_prog_SENDMAIL" != "x"; then
AC_MSG_CHECKING(mail path)
- ac_cv_prog_SENDMAIL="`$ac_cv_prog_WHICH sendmail` -d "
+ ac_cv_prog_SENDMAIL="`$ac_cv_prog_WHICH mail` -d "
AC_MSG_RESULT($ac_cv_prog_SENDMAIL)
else
AC_MSG_RESULT(No mail program found)
@@ -89,7 +109,8 @@ SENDMAIL=$ac_cv_prog_SENDMAIL
AC_MSG_CHECKING([which spool directory to use])
AC_ARG_WITH(spool-dir,
- AS_HELP_STRING(--with-spool-dir,the crontab spool directory (/var/cron/tabs)),
+ AC_HELP_STRING([--with-spool-dir],
+ [the crontab spool directory (/var/cron/tabs)]),
CONFIG_SPOOL_DIR=$withval,
CONFIG_SPOOL_DIR=[/var/cron/tabs])
AC_MSG_RESULT($CONFIG_SPOOL_DIR)
@@ -97,7 +118,8 @@ AC_SUBST(CONFIG_SPOOL_DIR)
AC_MSG_CHECKING([name of socket])
AC_ARG_WITH(socket-file,
- AS_HELP_STRING(--with-socket-file,unix pathname for cron socket (/var/cron/socket)),
+ AC_HELP_STRING([--with-socket-file],
+ [unix pathname for cron socket (/var/cron/socket)]),
CONFIG_SOCKET_FILE=$withval,
CONFIG_SOCKET_FILE=[/var/cron/socket])
AC_MSG_RESULT($CONFIG_SOCKET_FILE)
@@ -105,7 +127,8 @@ AC_SUBST(CONFIG_SOCKET_FILE)
AC_MSG_CHECKING([name of allow file])
AC_ARG_WITH(allow-file,
- AS_HELP_STRING(--with-allow-file,the file of allowed users (/var/cron/allow)),
+ AC_HELP_STRING([--with-allow-file],
+ [the file of allowed users (/var/cron/allow)]),
CONFIG_ALLOW_FILE=$withval,
CONFIG_ALLOW_FILE=[/var/cron/allow])
AC_MSG_RESULT($CONFIG_ALLOW_FILE)
@@ -113,7 +136,8 @@ AC_SUBST(CONFIG_ALLOW_FILE)
AC_MSG_CHECKING([name of deny file])
AC_ARG_WITH(deny-file,
- AS_HELP_STRING(--with-deny-file,the file of barred users (/var/cron/deny)),
+ AC_HELP_STRING([--with-deny-file],
+ [the file of barred users (/var/cron/deny)]),
CONFIG_DENY_FILE=$withval,
CONFIG_DENY_FILE=[/var/cron/deny])
AC_MSG_RESULT($CONFIG_DENY_FILE)
@@ -121,7 +145,8 @@ AC_SUBST(CONFIG_DENY_FILE)
AC_MSG_CHECKING([name of PID file])
AC_ARG_WITH(pid-file,
- AS_HELP_STRING(--with-pid-file,the file to record cron's PID (/var/run/cron.pid)),
+ AC_HELP_STRING([--with-pid-file],
+ [the file to record cron's PID (/var/run/cron.pid)]),
CONFIG_PID_FILE=$withval,
CONFIG_PID_FILE=[/var/run/cron.pid])
AC_MSG_RESULT($CONFIG_PID_FILE)
@@ -129,7 +154,8 @@ AC_SUBST(CONFIG_PID_FILE)
AC_MSG_CHECKING([directory to hold temporary files])
AC_ARG_WITH(tmp-dir,
- AS_HELP_STRING(--with-tmp-dir,directory to hold temporary files (/tmp)),
+ AC_HELP_STRING([--with-tmp-dir],
+ [directory to hold temporary files (/tmp)]),
CONFIG_TMP_DIR=$withval,
CONFIG_TMP_DIR=[/tmp])
AC_MSG_RESULT($CONFIG_TMP_DIR)
diff --git a/crontab.scm b/crontab.scm
index d347445..e5dfa29 100644
--- a/crontab.scm
+++ b/crontab.scm
@@ -163,6 +163,8 @@
noop))
+ ;; !!!! This comment is wrong.
+
;; In the case of the replace personality we loop over all the arguments on the
;; command line, and for each one parse the file to make sure it is parseable
;; (but subsequently ignore the configuration), and all being well we copy it
diff --git a/job-specifier.scm b/job-specifier.scm
index 3bba9b3..fd4d11b 100644
--- a/job-specifier.scm
+++ b/job-specifier.scm
@@ -243,7 +243,6 @@
((list? time-proc) (lambda (current-time)
(primitive-eval time-proc)))
(else
-
(display "job: invalid first argument (next-time-function; should ")
(display "be function, string or list)")
(primitive-exit 3))))
@@ -254,7 +253,7 @@
((list? action) (with-output-to-string
(lambda () (display action)))))))
(add-job (lambda (current-time)
- (set! current-action-time current-time)
+ (set! current-action-time current-time) ;; ?? !!!!
(time-proc current-time))
action
displayable
diff --git a/main.scm b/main.scm
index 0795324..82b6464 100644
--- a/main.scm
+++ b/main.scm
@@ -298,8 +298,9 @@ Report bugs to " config-package-bugreport ".\n
(do ((file-name (readdir directory) (readdir directory)))
((eof-object? file-name))
(and-let* ((user (valid-user file-name)))
- (set-configuration-user user)
+ (set-configuration-user user) ;; / ?? !!!!
(read-vixie-file (string-append config-spool-dir
+ "/"
file-name))))))
(lambda (key . args)
(display "You do not have permission to access the system crontabs.\n")
diff --git a/makefile.am b/makefile.am
index e5efea0..1bc2d94 100644
--- a/makefile.am
+++ b/makefile.am
@@ -17,7 +17,7 @@
## Process this file with automake to produce Makefile.in
-ED = @ED@
+ED = @ED@ # !!!! Are these needed?
CP = @CP@
MAINTAINERCLEANFILES = configure makefile makefile.in \
@@ -28,17 +28,16 @@ CLEANFILES = mcron.c core.scm
EXTRA_DIST = makefile.ed main.scm mcron-core.scm vixie-specification.scm \
crontab.scm environment.scm job-specifier.scm redirect.scm \
- vixie-time.scm mcron.c.template
+ vixie-time.scm mcron.c.template BUGS
info_TEXINFOS = mcron.texinfo
bin_PROGRAMS = mcron
mcron_SOURCES = mcron.c
mcron_LDFLAGS = @GUILE_LDFLAGS@
-mcron_CFLAGS = @GUILE_CFLAGS@
+mcron_CFLAGS = @GUILE_CFLAGS@ -DGUILE_LOAD_PATH=\"$(datadir)\"
-moddir = @GUILE_SITE@/mcron
-mod_DATA = core.scm environment.scm job-specifier.scm redirect.scm \
- vixie-time.scm vixie-specification.scm config.scm
+pkgdata_DATA = core.scm environment.scm job-specifier.scm redirect.scm \
+ vixie-time.scm vixie-specification.scm config.scm
# If you're wondering, the configure script keeps deleting all files with a name
@@ -53,24 +52,35 @@ mcron.c : main.scm crontab.scm makefile.ed mcron.c.template
@$(ED) < makefile.ed > /dev/null 2>&1
@rm -f mcron.escaped.scm > /dev/null 2>&1
-install-exec-local:
- @if [ `id -u` -ne 0 ]; then \
- echo "*** MUST BE ROOT TO INSTALL MCRON ***"; \
- exit 1; \
- fi
+
+# !!!! Want to be able to install as non-root.
+
+# install-exec-local:
+# @if [ `id -u` -ne 0 ]; then \
+# echo "*** MUST BE ROOT TO INSTALL MCRON ***"; \
+# exit 1; \
+# fi
#full program prefix
fpp = $(DESTDIR)$(bindir)/@real_program_prefix@
install-exec-hook:
- rm -f $(fpp)cron$(EXEEXT) > /dev/null 2>&1
- $(INSTALL) --mode='u=rwx' mcron$(EXEEXT) $(fpp)cron$(EXEEXT)
- rm -f $(fpp)crontab$(EXEEXT) > /dev/null 2>&1
- $(INSTALL) --mode='u=rwxs,og=rx' mcron$(EXEEXT) $(fpp)crontab$(EXEEXT)
- ./mkinstalldirs -m 'u=rwx' /var/cron
- ./mkinstalldirs -m 'u=rwx,og=rx' /var/run
- ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@
- ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@/mcron
+ @if [ "`id -u`" -eq "0" ]; then \
+ rm -f $(fpp)cron$(EXEEXT) > /dev/null 2>&1; \
+ $(INSTALL) --mode='u=rwx' mcron$(EXEEXT) $(fpp)cron$(EXEEXT); \
+ rm -f $(fpp)crontab$(EXEEXT) > /dev/null 2>&1; \
+ $(INSTALL) --mode='u=rwxs,og=rx' mcron$(EXEEXT) $(fpp)crontab$(EXEEXT); \
+ ./mkinstalldirs -m 'u=rwx' /var/cron; \
+ ./mkinstalldirs -m 'u=rwx,og=rx' /var/run; \
+ ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@; \
+ ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@/mcron; \
+ else \
+ echo "+++ WARNING: NON-ROOT INSTALL: ONLY mcron WILL BE INSTALLED, NOT ANY OF THE VIXIE REPLACEMENT PROGRAMS"; \
+ fi
+
uninstall-hook:
- rm -f $(fpp){cron,crontab}$(EXEEXT)
+ if [ "`id -u`" -eq "0" ]; then \
+ rm -f $(fpp){cron,crontab}$(EXEEXT); \
+ fi
+
diff --git a/mcron-core.scm b/mcron-core.scm
index 0aaacc6..631311a 100644
--- a/mcron-core.scm
+++ b/mcron-core.scm
@@ -70,8 +70,6 @@
(define (job:environment job) (vector-ref job 3))
(define (job:displayable job) (vector-ref job 4))
(define (job:next-time job) (vector-ref job 5))
-(define (job:advance-time! job)
- (vector-set! job 5 ((job:next-time-function job) (job:next-time job))))
@@ -99,21 +97,15 @@
(define (add-job time-proc action displayable configuration-time
configuration-user)
- (if (eq? configuration-source 'user)
- (set! user-job-list (cons (vector configuration-user
- time-proc
- action
- (get-current-environment-mods-copy)
- displayable
- (time-proc configuration-time))
- user-job-list))
- (set! system-job-list (cons (vector configuration-user
- time-proc
- action
- (get-current-environment-mods-copy)
- displayable
- (time-proc configuration-time))
- system-job-list))))
+ (let ((entry (vector configuration-user
+ time-proc
+ action
+ (get-current-environment-mods-copy)
+ displayable
+ (time-proc configuration-time))))
+ (if (eq? configuration-source 'user)
+ (set! user-job-list (cons entry user-job-list))
+ (set! system-job-list (cons entry system-job-list)))))
@@ -176,10 +168,14 @@
(and-let* ((next-jobs (find-next-jobs))
(time (car next-jobs))
(date-string (strftime "%c\n" (localtime time))))
- (for-each (lambda (job) (display date-string)
- (display (job:displayable job))
- (newline)(newline)
- (job:advance-time! job))
+ (for-each (lambda (job)
+ (display date-string)
+ (display (job:displayable job))
+ (newline)(newline)
+ (vector-set! job
+ 5
+ ((job:next-time-function job)
+ (job:next-time job))))
(cdr next-jobs)))))))
@@ -202,6 +198,7 @@
(for-each (lambda (job)
(if (eqv? (primitive-fork) 0)
(begin
+ (setgid (passwd:gid (job:user job)))
(setuid (passwd:uid (job:user job)))
(chdir (passwd:dir (job:user job)))
(modify-environment (job:environment job) (job:user job))
@@ -209,7 +206,10 @@
(primitive-exit 0))
(begin
(set! number-children (+ number-children 1))
- (job:advance-time! job))))
+ (vector-set! job
+ 5
+ ((job:next-time-function job)
+ (current-time))))))
jobs-list))
diff --git a/mcron.c.template b/mcron.c.template
index d99e492..4612f67 100644
--- a/mcron.c.template
+++ b/mcron.c.template
@@ -62,10 +62,11 @@
which are supposed to initiate shutdown of this program. It calls the scheme
procedure (see mcron.scm for details) to do all the work, and then exits. */
-void react_to_terminal_signal (int sig)
+void
+react_to_terminal_signal (int sig)
{
- scm_eval_string (scm_take0str ("(delete-run-file)") );
- exit (1);
+ scm_eval_string (scm_take0str ("(delete-run-file)") );
+ exit (1);
}
@@ -73,17 +74,18 @@ void react_to_terminal_signal (int sig)
/* This is a function designed to be callable from scheme, and sets up all the
signal handlers required by the cron personality. */
-SCM set_cron_signals ()
+SCM
+set_cron_signals ()
{
- static struct sigaction sa;
- memset (&sa, 0, sizeof (sa));
- sa.sa_handler = react_to_terminal_signal;
- sigaction (SIGTERM, &sa, 0);
- sigaction (SIGINT, &sa, 0);
- sigaction (SIGQUIT, &sa, 0);
- sigaction (SIGHUP, &sa, 0);
-
- return SCM_BOOL_T;
+ static struct sigaction sa;
+ memset (&sa, 0, sizeof (sa));
+ sa.sa_handler = react_to_terminal_signal;
+ sigaction (SIGTERM, &sa, 0);
+ sigaction (SIGINT, &sa, 0);
+ sigaction (SIGQUIT, &sa, 0);
+ sigaction (SIGHUP, &sa, 0);
+
+ return SCM_BOOL_T;
}
@@ -92,21 +94,26 @@ SCM set_cron_signals ()
register the function above with the guile system, and then execute the mcron
guile program. */
-void inner_main ()
+void
+inner_main ()
{
- scm_c_define_gsubr ("c-set-cron-signals", 0, 0, 0, set_cron_signals);
+ scm_c_define_gsubr ("c-set-cron-signals", 0, 0, 0, set_cron_signals);
- scm_eval_string (scm_take0str (
- GUILE_PROGRAM_GOES_HERE
- ) );
+ scm_eval_string (scm_take0str (
+ GUILE_PROGRAM_GOES_HERE
+ ) );
}
/* The real main function. Does nothing but start up the guile subsystem. */
-int main (int argc, char **argv)
+int
+main (int argc, char **argv)
{
- scm_boot_guile (argc, argv, inner_main, 0);
- return 0;
+ setenv ("GUILE_LOAD_PATH", GUILE_LOAD_PATH, 1);
+
+ scm_boot_guile (argc, argv, inner_main, 0);
+
+ return 0;
}
diff --git a/mcron.texinfo.in b/mcron.texinfo.in
index 75abfe9..f4a5c08 100644
--- a/mcron.texinfo.in
+++ b/mcron.texinfo.in
@@ -1,13 +1,13 @@
\input texinfo
@c %**start of header
@setfilename mcron.info
-@settitle mcron 1.0.1
+@settitle mcron 1.0.2
@c %**end of header
@syncodeindex fn cp
@copying
-Copyright (C) 2003 Dale Mellor
+Copyright (C) 2003, 2005 Dale Mellor
This is free software. See the source files for the terms of the
copyright.
@@ -107,7 +107,8 @@ Detailed invoking
* Running mcron::
* Running cron or crond::
-* Running crontab::
+* Running crontab::
+* Behaviour on laptops::
* Exit codes::
Guile modules
@@ -809,7 +810,8 @@ place in the part which implements the mcron personality.
@menu
* Running mcron::
* Running cron or crond::
-* Running crontab::
+* Running crontab::
+* Behaviour on laptops::
* Exit codes::
@end menu
@@ -965,7 +967,7 @@ recommended that this option be used (and further that the
@end table
-@node Running crontab, Exit codes, Running cron or crond, Invoking
+@node Running crontab, Behaviour on laptops, Running cron or crond, Invoking
@section Running crontab
@cindex crontab, invoking
@cindex running crontab
@@ -1032,8 +1034,23 @@ become immediately effective.
@end table
+@node Behaviour on laptops, Exit codes, Running crontab, Invoking
+@section Behaviour on laptops
+@cindex laptops
+@cindex power suspend
+While mcron has not been designed to work anachronistically, the behaviour of
+mcron when a laptop emerges from a suspended state is well defined, and the
+following description explains what happens in this situation.
-@node Exit codes, , Running crontab, Invoking
+When a laptop awakes from a suspended state, all jobs which would have run while
+the laptop was suspended will run exactly once immediately (and simultaneously)
+when the laptop awakes, and then the next time that those jobs run will be
+computed based on the time the laptop was awoken. Any jobs which would not have
+run during the suspense period will be unaffected, and will still run at their
+proper times.
+
+
+@node Exit codes, , Behaviour on laptops, Invoking
@section Exit codes
@cindex exit codes
@cindex error conditions
diff --git a/vixie-specification.scm b/vixie-specification.scm
index 4af327f..08a8699 100644
--- a/vixie-specification.scm
+++ b/vixie-specification.scm
@@ -29,6 +29,7 @@
read-vixie-port
read-vixie-file
check-system-crontab)
+ #:use-module ((mcron config) :select (config-socket-file))
#:use-module (mcron core)
#:use-module (mcron job-specifier)
#:use-module (mcron redirect)