* `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"
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 {
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 */