[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-mcron] [PATCH 32/33] main: Remove 'valid-user'.

From: Mathieu Lirzin
Subject: [Bug-mcron] [PATCH 32/33] main: Remove 'valid-user'.
Date: Sun, 27 Sep 2015 23:20:13 +0200

* scm/mcron/main.scm (valid-user): Delete variable.
  (process-files-in-system-directory): Adjust accordingly by using a
  local definition.
 scm/mcron/main.scm | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/scm/mcron/main.scm b/scm/mcron/main.scm
index ca0d051..3bf2342 100644
--- a/scm/mcron/main.scm
+++ b/scm/mcron/main.scm
@@ -225,26 +225,20 @@ $XDG_CONFIG_HOME is not defined uses ~/.config/cron 
       (mcron-error 13
         "Cannot read files in your ~/.config/cron (or ~/.cron) directory."))))
-(define (valid-user user-name)
-  "Check that USER-NAME is in the passwd database (it may happen that a user
-is removed after creating a crontab).  If the USER-NAME is valid, Return the
-full passwd entry for that user."
-  (setpwent)
-  (do ((entry (getpw) (getpw)))
-      ((or (not entry)
-           (string=? (passwd:name entry) user-name))
-       (endpwent)
-       entry)))
 (define (process-files-in-system-directory)
   "Process all the files in the crontab directory.  When the job procedure is
 run on behalf of the configuration files, the jobs are registered on the
 system with the appropriate user.  Only root should be able to perform this
 operation.  The permissions on the /var/cron/tabs directory enforce this."
+  (define (valid-user? user-name)
+    "Return the full user database entry if USER-NAME is in it, otherwise #f."
+    (false-if-exception (getpwnam user-name)))
   (catch #t
     (proc-in-directory config-spool-dir
       (lambda (user-name)
-        (and-let* ((user (valid-user user-name))) ;crontab without user?
+        (and-let* ((user (valid-user? user-name))) ;crontab without user?
                   (set-configuration-user user)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]