]> granicus.if.org Git - fcron/commitdiff
bug (??) fixed in read_file() (for freebsd)
authorthib <thib>
Tue, 10 Jul 2001 14:22:15 +0000 (14:22 +0000)
committerthib <thib>
Tue, 10 Jul 2001 14:22:15 +0000 (14:22 +0000)
conf.c

diff --git a/conf.c b/conf.c
index fba63d6d186433db6a72aae0ddd2d2fad70062d0..c0193543bef8582a788c735cebe84e24c24e70a8 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -22,7 +22,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: conf.c,v 1.47 2001-07-04 16:16:08 thib Exp $ */
+ /* $Id: conf.c,v 1.48 2001-07-10 14:22:15 thib Exp $ */
 
 #include "fcron.h"
 #include "conf.h"
@@ -450,8 +450,7 @@ read_file(const char *file_name, CF *cf)
                error_e("Could not getpwuid(%d)", file_stat.st_uid);
                goto err;
            }
-           /* set cf_user field */
-           runas_str = cf->cf_user = strdup2(pass->pw_name);
+           runas_str = strdup2(pass->pw_name);
        }
     }
     else {
@@ -485,19 +484,18 @@ read_file(const char *file_name, CF *cf)
        error("Invalid binary fcrontab (no USER field)");
        goto err;
     }
-    if ( runas == 0 ) {
-       /* get the owner's name */
-       if ( read_strn(fileno(ff), &cf->cf_user, size) != OK ) {
-           error("Cannot read user's name : file ignored");
-           goto err;
-       }
+    /* get the owner's name */
+    if ( read_strn(fileno(ff), &cf->cf_user, size) != OK ) {
+       error("Cannot read user's name : file ignored");
+       goto err;
+    }
+    if ( runas != 0 ) {
+       /* we use file owner's name for more security (see above) */
+       /* free the value obtained by read_strn() (we need to read it anyway
+        * to set the file ptr to the next thing to read) */
+       free(cf->cf_user);
+       cf->cf_user = runas_str;
     } 
-    else 
-       /* ignore the owner's name */
-       if ( fseek(ff, size, SEEK_CUR) < 0 ) {
-           error_e("Could not fseek file %s", file_name);
-           goto err;
-       }
 
     /* get the time & date of the saving */
     /* a new file generated by fcrontab has t_save set to 0 */