From: thib Date: Fri, 16 Jun 2000 11:52:31 +0000 (+0000) Subject: uneeded initialization has been deleted X-Git-Tag: ver1564~620 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c67d768bc8aa3f0c8fd31f5b5e0b1f4cea17cb7;p=fcron uneeded initialization has been deleted --- diff --git a/fcron.c b/fcron.c index 64dee66..439e5fd 100644 --- a/fcron.c +++ b/fcron.c @@ -21,11 +21,11 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: fcron.c,v 1.12 2000-06-15 20:12:57 thib Exp $ */ + /* $Id: fcron.c,v 1.13 2000-06-16 11:52:31 thib Exp $ */ #include "fcron.h" -char rcs_info[] = "$Id: fcron.c,v 1.12 2000-06-15 20:12:57 thib Exp $"; +char rcs_info[] = "$Id: fcron.c,v 1.13 2000-06-16 11:52:31 thib Exp $"; void main_loop(void); void info(void); @@ -44,7 +44,6 @@ char foreground = FOREGROUND; /* set to 1 when we are on foreground, else 0 */ char *cdir = FCRONTABS; /* the dir where are stored users' fcrontabs */ /* process identity */ -int daemon_uid; pid_t daemon_pid; char *prog_name = NULL; @@ -317,7 +316,11 @@ main(int argc, char **argv) if ( strrchr(argv[0], '/') == NULL) prog_name = argv[0]; else prog_name = strrchr(argv[0], '/') + 1; - daemon_uid = getuid(); + { + int daemon_uid; + if ( (daemon_uid = getuid()) != 0 ) + die("Fcron must be executed as root"); + } /* we have to set daemon_pid before the fork because it's * used in die() and die_e() functions */ @@ -434,7 +437,7 @@ void main_loop() { time_t save; /* time remaining until next save */ struct timeval tv; /* we use usec field to get more precision */ - time_t stime = 0; /* time to sleep until next job + time_t stime; /* time to sleep until next job * execution */ debug("Entering main loop"); diff --git a/job.c b/job.c index 7df3eb3..d104088 100644 --- a/job.c +++ b/job.c @@ -22,7 +22,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: job.c,v 1.8 2000-06-15 20:18:15 thib Exp $ */ + /* $Id: job.c,v 1.9 2000-06-16 11:53:24 thib Exp $ */ #include "fcron.h" @@ -88,8 +88,8 @@ run_job(CL *line) /* fork(), redirect outputs to a temp file, and execl() the task */ { - pid_t pid = 0; - struct job *j = NULL; + pid_t pid; + struct job *j; /* append job to the list of executed job */ Alloc(j, job); @@ -106,9 +106,9 @@ run_job(CL *line) case 0: /* child */ { - char *shell = NULL; - char *home = NULL; - env_t *env = NULL; + char *shell; + char *home; + env_t *env; int mailfd = 0; short int mailpos = 0; /* 'empty mail file' size */ int status = 0; @@ -214,10 +214,6 @@ run_job(CL *line) default: /* parent */ - //////// -// debug("run job - parent"); - //////// - line->cl_pid = pid; line->cl_file->cf_running += 1; @@ -236,9 +232,6 @@ end_job(CL *line, int status, int mailfd, short mailpos) char mail_output; char *m; -////// - debug(" end_job"); -////// if ( ( lseek(mailfd, 0, SEEK_END) - strlen (line->cl_shell) ) > mailpos ){ if ( line->cl_file->cf_mailto != NULL && @@ -281,10 +274,6 @@ launch_mailer(CL *line, int mailfd) { char *mailto = NULL; -//////// - debug(" launch mailer"); -//////// - foreground = 0; /* set stdin to the job's output */ @@ -310,7 +299,7 @@ int temp_file(void) /* Open a temporary file and return its file descriptor */ { - const int max_retries=50; + const int max_retries = 50; char *name; int fd,i;