}
user *
-find_user(cron_db *db, const char *name) {
+find_user(cron_db *db, const char *name, const char *tabname) {
user *u;
for (u = db->head; u != NULL; u = u->next)
- if (strcmp(u->name, name) == 0)
- break;
+ if ( (strcmp(u->name, name) == 0)
+ &&( (tabname == NULL)
+ || ( strcmp(tabname, u->tabname) == 0 )
+ )
+ ) break;
return (u);
}
struct passwd *pw = NULL;
int crontab_fd = OK - 1;
user *u;
+ int crond_crontab = (fname == NULL) && (strcmp(tabname, SYSCRONTAB) != 0);
if (fname == NULL) {
/* must be set to something for logging purposes.
}
Debug(DLOAD, ("\t%s:", fname))
- u = find_user(old_db, fname);
+
+ u = find_user(old_db, fname, crond_crontab ? tabname : NULL );
+
if (u != NULL) {
/* if crontab has not changed since we last read it
* in, then we can just use our existing entry.
**env_set(char **, char *);
user *load_user(int, struct passwd *, const char *, const char *, const char *),
- *find_user(cron_db *, const char *);
+ *find_user(cron_db *, const char *, const char *);
entry *load_entry(FILE *, void (*)(), struct passwd *, char **);
typedef struct _user {
struct _user *next, *prev; /* links */
char *name;
+ char *tabname; /* /etc/cron.d/ file name or NULL */
time_t mtime; /* last modtime of crontab */
entry *crontab; /* this person's crontab */
#ifdef WITH_SELINUX
security_context_t scontext; /* SELinux security context */
-#endif
+#endif
} user;
typedef struct _cron_db {
entry *e, *ne;
free(u->name);
+ free(u->tabname);
for (e = u->crontab; e != NULL; e = ne) {
ne = e->next;
free_entry(e);
*/
if ((u = (user *) malloc(sizeof(user))) == NULL)
return (NULL);
- if ((u->name = strdup(fname)) == NULL) {
+
+ if ( ((u->name = strdup(fname)) == NULL)
+ ||((u->tabname = strdup(tabname)) == NULL)
+ ){
save_errno = errno;
free(u);
errno = save_errno;
return (NULL);
}
+
u->crontab = NULL;
/* init environment. this will be copied/augmented for each entry.