AboutSummaryRefsLogTreeCommitDiffStats
diff options
context:
space:
mode:
authorMathieu Lirzin <mthl@gnu.org>2016-05-07 18:51:49 +0200
committerMathieu Lirzin <mthl@gnu.org>2016-05-07 23:38:53 +0200
commit31baff1a5187d8ddc89324cbe42dbeffc309c962 (patch)
tree2f221745df5c525ad32967c996d052577612c64f
parent45b062490a9924bcc6d582d10061244ced73f3f8 (diff)
downloadmcron-31baff1a5187d8ddc89324cbe42dbeffc309c962.tar.gz
mcron-31baff1a5187d8ddc89324cbe42dbeffc309c962.tar.bz2
mcron-31baff1a5187d8ddc89324cbe42dbeffc309c962.zip
job-specifier: job: Add #:user keyword argument.
* src/mcron/job-specifier.scm (job): Add #:user keyword argument. * doc/mcron.texi (Job specification): Document it.
-rw-r--r--doc/mcron.texi25
-rw-r--r--src/mcron/job-specifier.scm12
2 files changed, 21 insertions, 16 deletions
diff --git a/doc/mcron.texi b/doc/mcron.texi
index 340faca..a59505d 100644
--- a/doc/mcron.texi
+++ b/doc/mcron.texi
@@ -271,11 +271,13 @@ on your system, as root.
@cindex guile syntax
@cindex syntax, guile
@findex job
-In Guile-formatted configuration files each command that needs
-executing is introduced with the @code{job} function. This function
-always takes two arguments, the first a time specification, and the
-second a command specification. An optional third argument may contain
-a string to display when this job is listed in a schedule.
+In Guile-formatted configuration files each command that needs executing is
+introduced with the @code{job} function. This function always takes two
+arguments, the first a time specification, and the second a command
+specification. An optional third argument may contain a string to display
+when this job is listed in a schedule. Additionally a @var{user} keyword
+argument can be supplied to use a different user than the one defined in
+@code{configuration-user} global variable.
@cindex time specification, procedure
@cindex procedure time specification
@@ -342,13 +344,12 @@ on Vixie syntax for this.
@cindex job execution
@cindex command execution
@cindex execution
-The second argument to the @code{(job)} function can be either a
-string, a list, or a function. In all cases the command is executed in
-the user's home directory, under the user's own UID. If a string is
-passed, it is assumed to be shell script and is executed with the
-user's default shell. If a list is passed it is assumed to be scheme
-code and is eval'd as such. A supplied function should take exactly
-zero arguments, and will be called at the pertinent times.
+The second argument to the @code{(job)} function can be either a string, a
+list, or a function. The command is executed in the home directory and with
+the UID of @var{user}. If a string is passed, it is assumed to be shell
+script and is executed with the user's default shell. If a list is passed it
+is assumed to be scheme code and is eval'd as such. A supplied function
+should take exactly zero arguments, and will be called at the pertinent times.
@subsection Sending output as e-mail
@cindex email output
diff --git a/src/mcron/job-specifier.scm b/src/mcron/job-specifier.scm
index 9e13551..6dacece 100644
--- a/src/mcron/job-specifier.scm
+++ b/src/mcron/job-specifier.scm
@@ -212,7 +212,8 @@ go into the list. For example, (range 1 6 2) returns '(1 3 5)."
;; finding the next legitimate time from the current configuration time (set
;; right at the top of this program).
-(define (job time-proc action . displayable)
+(define* (job time-proc action #:optional displayable
+ #:key (user configuration-user))
(let ((action (cond ((procedure? action) action)
((list? action) (lambda () (primitive-eval action)))
((string? action) (lambda () (system action)))
@@ -231,11 +232,14 @@ go into the list. For example, (range 1 6 2) returns '(1 3 5)."
"job: invalid first argument (next-time-function; "
"should be function, string or list)"))))
(displayable
- (cond ((not (null? displayable)) (car displayable))
+ (cond (displayable displayable)
((procedure? action) "Lambda function")
((string? action) action)
((list? action) (with-output-to-string
- (lambda () (display action)))))))
+ (lambda () (display action))))))
+ (user* (if (or (string? user) (integer? user))
+ (getpw user)
+ user)))
(add-job (lambda (current-time)
(set! current-action-time current-time) ;; ?? !!!! Code
@@ -251,4 +255,4 @@ go into the list. For example, (range 1 6 2) returns '(1 3 5)."
action
displayable
configuration-time
- configuration-user)))
+ user*)))