]> granicus.if.org Git - cronie/commitdiff
Too many flags was set for lstating crontab. Time of change is
authormmaslano <mmaslano@redhat.com>
Fri, 17 Aug 2007 13:10:16 +0000 (15:10 +0200)
committermmaslano <mmaslano@redhat.com>
Fri, 24 Aug 2007 13:05:59 +0000 (15:05 +0200)
checked and uids for reading new crontab are ok.

crontab.c

index 1719216f84b38a2aaf0ffbd0175c9b23d6d7c3a5..b8c54824afaef933d789c06d15ce0fe2deed79d1 100644 (file)
--- a/crontab.c
+++ b/crontab.c
@@ -488,33 +488,39 @@ edit_cmd(void) {
        (void)signal(SIGHUP, SIG_DFL);
        (void)signal(SIGINT, SIG_DFL);
        (void)signal(SIGQUIT, SIG_DFL);      
+
        if (lstat(Filename, &statbuf) < 0) {
-               perror("fstat");
+               perror("lstat");
                goto fatal;
        }
-       if (utimebuf.modtime == statbuf.st_mtime) {
-               fprintf(stderr, "%s: no changes made to crontab\n",
-                       ProgramName);
-               goto remove;
-       }
 
-       if (  (!S_ISREG(statbuf.st_mode))
-           ||(S_ISLNK(statbuf.st_mode))
-           ||(S_ISDIR(statbuf.st_mode))
-            ||(S_ISCHR(statbuf.st_mode))
-           ||(S_ISBLK(statbuf.st_mode))
-            ||(S_ISFIFO(statbuf.st_mode))
-           ||(S_ISSOCK(statbuf.st_mode))
-           )
+       if ( !S_ISREG(statbuf.st_mode) )
        {
            fprintf(stderr, "%s: illegal crontab\n",
                        ProgramName);
                goto remove;        
        }
 
+       if (utimebuf.modtime == statbuf.st_mtime) {
+               fprintf(stderr, "%s: no changes made to crontab\n",
+                       ProgramName);
+               goto remove;
+       }
+
        fprintf(stderr, "%s: installing new crontab\n", ProgramName);
         fclose(NewCrontab);
-       NewCrontab=fopen(Filename,"r+");
+       if (swap_uids() < OK) {
+           perror("swapping uids");
+           goto remove;
+       }
+       if (!(NewCrontab = fopen(Filename, "r+"))) {
+           perror("cannot read new crontab");
+           goto remove;            
+       }
+       if (swap_uids_back() < OK) {
+           perror("swapping uids back");
+           exit(ERROR_EXIT);
+       }
        if( NewCrontab == 0L )
        {
            perror("fopen");