* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: conf.c,v 1.56 2002-08-25 17:24:14 thib Exp $ */
+ /* $Id: conf.c,v 1.57 2002-08-30 20:05:51 thib Exp $ */
#include "fcron.h"
/* then add normal files, if any, to database */
for (list_cur = file_list; list_cur; list_cur = list_cur->next ) {
- if ( getpwnam(list_cur->str) ) {
+ if ( getpwnam(list_cur->str)
+#ifdef SYSFCRONTAB
+ || strcmp(list_cur->str, SYSFCRONTAB) == 0
+#endif
+ ) {
explain("adding file %s", list_cur->str);
synchronize_file(list_cur->str);
}
/* finally add new files */
for (list_cur = new_list; list_cur; list_cur = list_cur->next ) {
- if ( getpwnam(list_cur->str + 4) ) { /* len("new.") = 4 */
+ /* len("new.") = 4 : */
+ if ( getpwnam(list_cur->str + 4)
+#ifdef SYSFCRONTAB
+ || strcmp(list_cur->str + 4, SYSFCRONTAB) == 0
+#endif
+ ) {
explain("adding new file %s", list_cur->str + 4);
synchronize_file(list_cur->str);
}
debug("User %s Entry", file_name);
bzero(buf, sizeof(buf));
- /* get version of fcrontab file: it permit to daemon not to load
+ /* get version of fcrontab file: it permits to daemon not to load
* a file which he won't understand the syntax, for exemple
* a file using a depreciated format generated by an old fcrontab,
* if the syntax has changed */
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: config.h.in,v 1.45 2002-08-29 17:34:14 thib Exp $ */
+ /* $Id: config.h.in,v 1.46 2002-08-30 20:06:01 thib Exp $ */
/* *********************************************************** */
#define FCRON_DENY "fcron.deny"
#define FCRON_CONF "fcron.conf"
-#define SENDMAIL_ARGS "-Ffcron", "-odi" /* args of mail command */
-
+#define SENDMAIL_ARGS "-Ffcron", "-odi" /* args of mail command */
/* *** time *** */
#define FIRST_SLEEP 20 /* fcron sleep at least this time after startup
#undef USERNAME
#undef GROUPNAME
+/* special user for the system fcrontab */
+#undef SYSFCRONTAB
+
/* Define to empty if the keyword does not work. */
#undef const
fi
+sysfcrontab="systab"
+use_sysfcrontab=1
+AC_MSG_CHECKING(use a system fcrontab)
+AC_ARG_WITH(sysfcrontab,
+[ --with-sysfcrontab=NAME Use (or not) a system fcrontab (default: yes)],
+[ case "$withval" in
+ no)
+ use_sysfcrontab=0
+ AC_MSG_RESULT(no)
+ ;;
+ yes)
+ AC_MSG_RESULT(yes)
+ ;;
+ *)
+ sysfcrontab="$withval"
+ AC_MSG_RESULT($sysfcrontab)
+ esac ],
+ AC_MSG_RESULT(yes)
+)
+if test "$use_sysfcrontab" -eq 1 ; then
+ AC_DEFINE_UNQUOTED(SYSFCRONTAB, "$sysfcrontab")
+fi
+
+
dnl ---------------------------------------------------------------------
dnl DocBook
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: dyncom.h,v 1.3 2002-08-25 17:25:35 thib Exp $ */
+ /* $Id: dyncom.h,v 1.4 2002-08-30 20:05:58 thib Exp $ */
/* This file describe the communication protocol between fcron and fcrondyn */
#define CUR_USER (-2)
#define ARG_REQUIRED (-3)
+#ifdef SYSFCRONTAB
+#define SYSFCRONTAB_UID (-100)
+#endif
+
/* commands : if you change something here, please update fcrondyn.c's cmd_list
* and fcron's socket.c . */
#define NUM_CMD 9
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fcrondyn.c,v 1.5 2002-08-25 17:10:11 thib Exp $ */
+ /* $Id: fcrondyn.c,v 1.6 2002-08-30 20:04:28 thib Exp $ */
/* fcrondyn : interact dynamically with running fcron process :
* - list jobs, with their status, next time of execution, etc
#include "allow.h"
#include "read_string.h"
-char rcs_info[] = "$Id: fcrondyn.c,v 1.5 2002-08-25 17:10:11 thib Exp $";
+char rcs_info[] = "$Id: fcrondyn.c,v 1.6 2002-08-30 20:04:28 thib Exp $";
void info(void);
void usage(void);
int i = 0, j = 0, rank = -1;
long int int_buf = 0;
struct passwd *pass = NULL;
+#ifdef SYSFCRONTAB
+ long int sysfcrontab_uid = SYSFCRONTAB_UID;
+#endif
bzero(buf, sizeof(buf));
*cmd_len = 0;
case USER:
int_buf = (long int) *(cmd_str + word_size);
*(cmd_str + word_size) = '\0';
- if ( (pass = getpwnam(cmd_str) ) == NULL ) {
- fprintf(stderr, "Error : '%s' is not a valid user name.\n", cmd_str);
- return INVALID_ARG;
+#ifdef SYSFCRONTAB
+ if ( strcmp(cmd_str, SYSFCRONTAB) == 0 ) {
+ Write_cmd(sysfcrontab_uid);
}
+ else {
+#endif
+ if ( ( pass = getpwnam(cmd_str) ) == NULL ) {
+ fprintf(stderr,"Error : '%s' isn't a valid username.\n",cmd_str);
+ return INVALID_ARG;
+ }
+ Write_cmd(pass->pw_uid);
+#ifdef SYSFCRONTAB
+ }
+#endif
*(cmd_str + word_size) = (char) int_buf;
cmd_str += word_size;
- Write_cmd(pass->pw_uid);
if ( debug_opt )
- fprintf(stderr, " uid = %d\n", pass->pw_uid);
+ fprintf(stderr, " uid = %d\n",
+#ifdef SYSFCRONTAB
+ (pass) ? pass->pw_uid : SYSFCRONTAB_UID
+#else
+ pass->pw_uid
+#endif
+ );
break;
case JOBID:
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fcrontab.h,v 1.15 2002-03-02 17:26:05 thib Exp $ */
+ /* $Id: fcrontab.h,v 1.16 2002-08-30 20:05:27 thib Exp $ */
#ifndef __FCRONTAB_H__
#define __FCRONTAB_H__
extern char dosyslog;
extern struct CF *file_base;
extern char *user;
+extern char *runas;
extern uid_t uid;
extern uid_t asuid;
extern uid_t fcrontab_uid;
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fileconf.c,v 1.60 2002-08-25 17:12:05 thib Exp $ */
+ /* $Id: fileconf.c,v 1.61 2002-08-30 20:05:39 thib Exp $ */
#include "fcrontab.h"
}
int
-read_file(char *filename, char *user)
+read_file(char *filename)
/* read file "name" and append CF list */
{
CF *cf = NULL;
Alloc(cf, CF);
cf->cf_user = strdup2(user);
default_line.cl_file = cf;
- default_line.cl_runas = strdup2(user);
- default_line.cl_mailto = strdup2(user);
+ default_line.cl_runas = strdup2(runas);
+ default_line.cl_mailto = strdup2(runas);
set_default_opt(default_line.cl_option);
if ( debug_opt )
fprintf(stderr, "FILE %s\n", file_name);
- if (strcmp(user, "root") == 0)
+ if (strcmp(runas, "root") == 0)
max_entries = 65535;
/* max_lines acts here as a security counter to avoid endless loop. */
Handle_err;
if ( i == 1 ) {
bzero(cl, sizeof(CL));
- Set(cl->cl_runas, user);
- Set(cl->cl_mailto, user);
+ Set(cl->cl_runas, runas);
+ Set(cl->cl_mailto, runas);
set_default_opt(cl->cl_option);
}
if (debug_opt)
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: fileconf.h,v 1.3 2001-12-23 22:04:48 thib Exp $ */
+ /* $Id: fileconf.h,v 1.4 2002-08-30 20:05:42 thib Exp $ */
#ifndef __FILECONF_H__
#define __FILECONF_H__
/* functions prototypes */
-extern int read_file(char *filename, char *user);
+extern int read_file(char *filename);
extern void delete_file(const char *user_name);
extern int save_file(char *path);
* `LICENSE' that comes with the fcron source distribution.
*/
- /* $Id: socket.c,v 1.6 2002-08-25 17:27:14 thib Exp $ */
+ /* $Id: socket.c,v 1.7 2002-08-30 20:06:04 thib Exp $ */
/* This file contains all fcron's code (server) to handle communication with fcrondyn */
fields[TERM_LEN-1] = '\0';
- if ( send(fd, fields, len, 0) < 0 )
+ if ( send(fd, fields, (len < sizeof(fields)) ? len : sizeof(fields), 0) < 0 )
error_e("error in send()");
}
if ( bit_test(details, FIELD_OPTIONS) ) {
char opt[9];
int i = 0;
+ opt[0] = '\0';
if ( is_lavg(line->cl_option) )
i += snprintf(opt+i, sizeof(opt)-i, "L%.*s",
(is_lavg_sev(line->cl_option)) ? 0:1, "O");
}
if ( bit_test(details, FIELD_LAVG) ) {
len += snprintf(buf+len, sizeof(buf)-len, " %.1lf,%.1lf,%.1lf",
- ((double)((line->cl_lavg)[0]))/10, ((double)((line->cl_lavg)[1]))/10, ((double)((line->cl_lavg)[2]))/10);
+ ((double)((line->cl_lavg)[0]))/10,
+ ((double)((line->cl_lavg)[1]))/10,
+ ((double)((line->cl_lavg)[2]))/10);
if ( until > 0 ) {
ftime = localtime( &until );
len += snprintf(buf+len, sizeof(buf)-len, " %02d/%02d/%d %02d:%02d %s",
}
len += snprintf(buf+len, sizeof(buf)-len, " %s\n", line->cl_shell);
- if ( send(fd, buf, len + 1, 0) < 0 )
+ if ( send(fd, buf, (len < sizeof(buf)) ? len : sizeof(buf), 0) < 0 )
error_e("error in send()");
}
if (! all) {
struct passwd *pass;
- if ( (pass = getpwuid( (uid_t) cmd[1] )) == NULL ) {
- warn_e("Unable to find passwd entry for %ld", cmd[1]);
- send(fd, err_invalid_user_str, sizeof(err_invalid_user_str), 0);
- send(fd, END_STR, sizeof(END_STR), 0);
- return;
- }
- if ( ! is_root && strcmp(pass->pw_name, client->fcl_user) != 0 ) {
- warn_e("%s is not allowed to see %s's jobs. %ld", client->fcl_user,
- pass->pw_name);
- send(fd, err_others_nallowed_str, sizeof(err_others_nallowed_str), 0);
- send(fd, END_STR, sizeof(END_STR), 0);
- return;
+#ifdef SYSFCRONTAB
+ if ( cmd[1] == SYSFCRONTAB_UID )
+ user = SYSFCRONTAB;
+ else {
+#endif
+ if ( (pass = getpwuid( (uid_t) cmd[1] )) == NULL ) {
+ warn_e("Unable to find passwd entry for %ld", cmd[1]);
+ send(fd, err_invalid_user_str, sizeof(err_invalid_user_str), 0);
+ send(fd, END_STR, sizeof(END_STR), 0);
+ return;
+ }
+ if ( ! is_root && strcmp(pass->pw_name, client->fcl_user) != 0 ) {
+ warn_e("%s is not allowed to see %s's jobs. %ld", client->fcl_user,
+ pass->pw_name);
+ send(fd, err_others_nallowed_str, sizeof(err_others_nallowed_str),0);
+ send(fd, END_STR, sizeof(END_STR), 0);
+ return;
+ }
+ user = pass->pw_name;
+#ifdef SYSFCRONTAB
}
- user = pass->pw_name;
+#endif
}
/* list all jobs one by one and find the corresponding ones */