From: Thibault Godouet Date: Tue, 10 Jul 2001 14:22:15 +0000 (+0000) Subject: bug (??) fixed in read_file() (for freebsd) X-Git-Tag: ver2_9_4~282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6d9559ece5d0f61486c2bb204f3e5c00f792353;p=thirdparty%2Ffcron.git bug (??) fixed in read_file() (for freebsd) --- diff --git a/conf.c b/conf.c index fba63d6..c019354 100644 --- 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 */