]> granicus.if.org Git - cronie/commitdiff
Check user before job is run.
authorMarcela Mašláňová <mmaslano@redhat.com>
Mon, 11 Aug 2008 10:22:13 +0000 (12:22 +0200)
committerMarcela Mašláňová <mmaslano@redhat.com>
Mon, 11 Aug 2008 10:22:13 +0000 (12:22 +0200)
src/cron.c

index 0816901cd71bad74cd574b99d19c4d068659aa99..bcb877581804397ad065f9798db6aa527e095567 100644 (file)
@@ -411,6 +411,8 @@ find_jobs(int vtime, cron_db *db, int doWild, int doNonWild) {
        int minute, hour, dom, month, dow;
        user *u;
        entry *e;
+    const char *uname;
+    struct passwd *pw = NULL;
 
        /* make 0-based values out of these so we can use them as indicies
         */
@@ -447,21 +449,25 @@ find_jobs(int vtime, cron_db *db, int doWild, int doNonWild) {
                        Debug(DSCH|DEXT, ("user [%s:%ld:%ld:...] cmd=\"%s\"\n",
                            e->pwd->pw_name, (long)e->pwd->pw_uid,
                            (long)e->pwd->pw_gid, e->cmd))
-                       job_tz = env_get("CRON_TZ", e->envp);
-                       maketime(job_tz, orig_tz);
-                       /* here we test whether time is NOW */
-                       if (bit_test(e->minute, minute) &&
-                           bit_test(e->hour, hour) &&
-                           bit_test(e->month, month) &&
-                           ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
-                             ? (bit_test(e->dow,dow) && bit_test(e->dom,dom))
-                             : (bit_test(e->dow,dow) || bit_test(e->dom,dom))
-                           )
-                          ) {
-                               if ((doNonWild &&
-                                   !(e->flags & (MIN_STAR|HR_STAR))) || 
-                                   (doWild && (e->flags & (MIN_STAR|HR_STAR))))
-                                       job_add(e, u);  /*will add job, if it isn't in queue already for NOW.*/
+            uname = e->pwd->pw_name;
+                       /* check if user exists in time of job is being run f.e. ldap */
+                       if ((pw = getpwnam(uname)) != NULL) {
+                               job_tz = env_get("CRON_TZ", e->envp);
+                               maketime(job_tz, orig_tz);
+                               /* here we test whether time is NOW */
+                               if (bit_test(e->minute, minute) &&
+                               bit_test(e->hour, hour) &&
+                                   bit_test(e->month, month) &&
+                                   ( ((e->flags & DOM_STAR) || (e->flags & DOW_STAR))
+                                     ? (bit_test(e->dow,dow) && bit_test(e->dom,dom))
+                                     : (bit_test(e->dow,dow) || bit_test(e->dom,dom))
+                               )
+                                  ) {
+                                       if ((doNonWild &&
+                                           !(e->flags & (MIN_STAR|HR_STAR))) || 
+                                           (doWild && (e->flags & (MIN_STAR|HR_STAR))))
+                                                       job_add(e, u);  /*will add job, if it isn't in queue already for NOW.*/
+                                       }
                        }
                }
        }