* `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);
char *cdir = FCRONTABS; /* the dir where are stored users' fcrontabs */
/* process identity */
-int daemon_uid;
pid_t daemon_pid;
char *prog_name = NULL;
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 */
{
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");
* `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"
/* 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);
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;
default:
/* parent */
- ////////
-// debug("run job - parent");
- ////////
-
line->cl_pid = pid;
line->cl_file->cf_running += 1;
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 &&
{
char *mailto = NULL;
-////////
- debug(" launch mailer");
-////////
-
foreground = 0;
/* set stdin to the job's output */
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;