rpms/vixie-cron/FC-4 vixie_cron-4.1-162887.patch,NONE,1.1

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Mon Jul 11 22:18:11 UTC 2005


Author: jvdias

Update of /cvs/dist/rpms/vixie-cron/FC-4
In directory cvs.devel.redhat.com:/tmp/cvs-serv26922

Added Files:
	vixie_cron-4.1-162887.patch 
Log Message:
fix bug 162887: support crontab remove when multiple /etc/cron.d crontabs

vixie_cron-4.1-162887.patch:
 database.c |   14 ++++++++++----
 funcs.h    |    2 +-
 structs.h  |    3 ++-
 user.c     |    7 ++++++-
 4 files changed, 19 insertions(+), 7 deletions(-)

--- NEW FILE vixie_cron-4.1-162887.patch ---
--- vixie-cron-4.1/structs.h.162887	2005-07-11 14:10:09.243826000 -0400
+++ vixie-cron-4.1/structs.h	2005-07-11 13:33:59.348326000 -0400
@@ -48,11 +48,12 @@
 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 {
--- vixie-cron-4.1/funcs.h.162887	2005-07-11 14:10:09.234835000 -0400
+++ vixie-cron-4.1/funcs.h	2005-07-11 13:40:43.401868000 -0400
@@ -66,7 +66,7 @@
 		**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 **);
 
--- vixie-cron-4.1/user.c.162887	2005-07-11 14:10:11.115952000 -0400
+++ vixie-cron-4.1/user.c	2005-07-11 14:06:25.297996000 -0400
@@ -99,6 +99,7 @@
 	entry *e, *ne;
 
 	free(u->name);
+	free(u->tabname);
 	for (e = u->crontab;  e != NULL;  e = ne) {
 		ne = e->next;
 		free_entry(e);
@@ -130,12 +131,16 @@
 	 */
 	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.
--- vixie-cron-4.1/database.c.162887	2005-07-11 14:10:10.769299000 -0400
+++ vixie-cron-4.1/database.c	2005-07-11 13:44:49.568455000 -0400
@@ -218,12 +218,15 @@
 }
 
 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);
 }
 
@@ -234,6 +237,7 @@
 	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.
@@ -280,7 +284,9 @@
 	}
 
 	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.




More information about the fedora-cvs-commits mailing list