3 * FCRON - periodic command scheduler
5 * Copyright 2000-2016 Thibault Godouet <fcron@free.fr>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * The GNU General Public License can also be found in the file
22 * `LICENSE' that comes with the fcron source distribution.
31 int read_file(const char *file_name, cf_t * cf, int is_system_startup);
32 int add_line_to_file(cl_t * cl, cf_t * cf, uid_t runas, char *runas_str,
33 time_t t_save, int is_system_startup);
34 int read_strn(int fd, char **str, short int size);
35 int read_type(int fd, short int *type, short int *size);
36 void synchronize_file(char *file_name, int is_system_startup);
39 /* this is used to create a list of files to remove, to add */
40 typedef struct list_t {
47 reload_all(const char *dir_name)
48 /* save all current configuration, remove it from the memory,
49 * and reload from dir_name */
53 explain("Removing current configuration from memory");
57 if (f->cf_running > 0)
58 wait_all(&f->cf_running);
60 delete_file(f->cf_user);
62 /* delete_file remove the f file from the list :
63 * next file to remove is now pointed by file_base. */
67 synchronize_dir(dir_name, 0);
73 synchronize_dir(const char *dir_name, int is_system_startup)
74 /* read dir_name and create three list of files to remove,
75 * new files and normal files. Then remove each file
76 * listed in the first list, then read normal files,
77 * finally add new files. */
80 list_t *rm_list = NULL;
81 list_t *new_list = NULL;
82 list_t *file_list = NULL;
83 list_t *list_cur = NULL;
87 if (strcmp(dir_name, ".") == 0)
88 explain("updating configuration from %s", fcrontabs);
90 explain("updating configuration from %s", dir_name);
92 if ((dir = opendir("."))) {
93 while ((den = readdir(dir))) {
95 if (strncmp(den->d_name, "rm.", 3) == 0) {
96 /* this is a file to remove from database */
97 Alloc(list_cur, list_t);
98 list_cur->str = strdup2(den->d_name);
99 list_cur->next = rm_list;
102 else if (strncmp(den->d_name, "new.", 4) == 0) {
103 /* this is a file to append to database */
104 Alloc(list_cur, list_t);
105 list_cur->str = strdup2(den->d_name);
106 list_cur->next = new_list;
109 else if (strchr(den->d_name, '.') != NULL)
112 /* this is a normal file : if file_base is not null,
113 * so if a database has already been created, we
115 if (file_base == NULL) {
116 Alloc(list_cur, list_t);
117 list_cur->str = strdup2(den->d_name);
118 list_cur->next = file_list;
119 file_list = list_cur;
126 die("Unable to open current dir!");
129 /* proceed to adds or removes */
131 /* begin by removing files which are no longer wanted */
132 for (list_cur = rm_list; list_cur; list_cur = list_cur->next) {
133 explain("removing file %s", list_cur->str + 3);
134 delete_file(list_cur->str + 3); /* len("rm.") = 3 */
135 if (remove(list_cur->str + 3) != 0 && errno != ENOENT)
136 error_e("Could not remove %s", list_cur->str + 3);
137 if (remove(list_cur->str) != 0 && errno != ENOENT)
138 error_e("Could not remove %s", list_cur->str);
141 /* then add normal files, if any, to database */
142 for (list_cur = file_list; list_cur; list_cur = list_cur->next) {
144 if (getpwnam(list_cur->str)
146 || strcmp(list_cur->str, SYSFCRONTAB) == 0
149 explain("adding file %s", list_cur->str);
150 synchronize_file(list_cur->str, is_system_startup);
153 error_e("ignoring file \"%s\" : not in passwd file.",
157 /* finally add new files */
158 for (list_cur = new_list; list_cur; list_cur = list_cur->next) {
159 /* len("new.") = 4 : */
161 if (getpwnam(list_cur->str + 4)
163 || strcmp(list_cur->str + 4, SYSFCRONTAB) == 0
166 explain("adding new file %s", list_cur->str + 4);
167 synchronize_file(list_cur->str, is_system_startup);
170 error_e("ignoring file %s : not in passwd file.",
171 (list_cur->str + 4));
180 while ((l = next) != NULL) {
187 while ((l = next) != NULL) {
194 while ((l = next) != NULL) {
206 synchronize_file(char *file_name, int is_system_startup)
212 if (strchr(file_name, '.') != NULL) {
213 /* this is a new file : we have to check if there is an old
214 * version in database in order to keep a maximum of fields
215 * (cl_nextexe) to their current value */
220 /* we add 4 to file_name pointer because of the "new."
221 * string at the beginning of a new file */
222 user = (file_name + 4);
224 for (cur_f = file_base; cur_f; cur_f = cur_f->cf_next) {
225 if (strcmp(user, cur_f->cf_user) == 0)
231 /* an old version of this file exist in database */
236 /* size used when comparing two line :
237 * it's the size of all time table (mins, days ...) */
238 const size_t size = (bitstr_size(60) + bitstr_size(24) +
239 bitstr_size(32) + bitstr_size(12) +
246 if (read_file(file_name, cur_f, is_system_startup) != 0) {
247 /* an error as occured */
251 /* assign old pointer to the old file, and move it to the first
252 * place of the list : delete_file() only remove the first
253 * occurrence of the file which has the name given in argument */
255 prev->cf_next = old->cf_next;
256 old->cf_next = file_base;
260 /* this is the first file in the list : no need to move it */
263 /* compare each lines between the new and the old
264 * version of the file */
265 for (new_l = cur_f->cf_line_base; new_l; new_l = new_l->cl_next)
266 for (old_l = old->cf_line_base; old_l; old_l = old_l->cl_next) {
268 /* compare the shell command and the fields
269 * from cl_mins down to cl_runfreq or the timefreq */
270 if (strcmp(new_l->cl_shell, old_l->cl_shell) == 0
271 && ((is_freq(new_l->cl_option)
272 && new_l->cl_timefreq == old_l->cl_timefreq)
273 || (is_td(new_l->cl_option)
274 && memcmp(&(new_l->cl_mins), &(old_l->cl_mins),
276 && is_dayor(new_l->cl_option) ==
277 is_dayor(old_l->cl_option))
280 if (new_l->cl_runfreq == old_l->cl_runfreq)
281 new_l->cl_remain = old_l->cl_remain;
282 /* check if there is a change about the tz diff */
283 if ((new_l->cl_file->cf_tzdiff !=
284 old_l->cl_file->cf_tzdiff) &&
285 (old_l->cl_nextexe - old_l->cl_file->cf_tzdiff
286 + new_l->cl_file->cf_tzdiff > now))
287 new_l->cl_nextexe = old_l->cl_nextexe
288 - old_l->cl_file->cf_tzdiff +
289 new_l->cl_file->cf_tzdiff;
291 new_l->cl_nextexe = old_l->cl_nextexe;
293 if (is_runonce(new_l->cl_option)
294 && is_runonce(old_l->cl_option)
295 && is_hasrun(old_l->cl_option)) {
297 (" from last conf: job '%s' with runonce set has "
298 "already run since last system startup: not "
299 "re-scheduling.", new_l->cl_shell);
300 set_hasrun(new_l->cl_option);
301 /* job has already run: remove from the queue */
302 job_queue_remove(new_l);
305 /* update the position in the queue */
306 insert_nextexe(new_l);
308 if (debug_opt && !is_hasrun(new_l->cl_option)) {
310 ftime = localtime(&new_l->cl_nextexe);
312 (" from last conf: '%s' next exec %04d-%02d-%02d"
313 " wday:%d %02d:%02d:%02d (system time)",
314 new_l->cl_shell, (ftime->tm_year + 1900),
315 (ftime->tm_mon + 1), ftime->tm_mday,
316 ftime->tm_wday, ftime->tm_hour, ftime->tm_min,
325 /* remove old file from the list */
328 /* insert new file in the list */
329 cur_f->cf_next = file_base;
332 /* save final file */
335 /* delete new.user file */
336 if (remove(file_name) != 0)
337 error_e("could not remove %s", file_name);
342 /* no old version exist in database : load this file
343 * as a normal file, but change its name */
347 if (read_file(file_name, cur_f, is_system_startup) != 0) {
348 /* an error as occured */
352 /* insert the file in the list */
353 cur_f->cf_next = file_base;
356 /* save as a normal file */
359 /* delete new.user file */
360 if (remove(file_name) != 0)
361 error_e("could not remove %s", file_name);
367 /* this is a normal file */
371 if (read_file(file_name, cur_f, is_system_startup) != 0) {
372 /* an error as occured */
376 /* insert the file in the list */
377 cur_f->cf_next = file_base;
386 read_strn(int fd, char **str, short int size)
387 /* read a "size"-length string in a binary fcrontab file */
389 if ((*str = calloc(size + 1, sizeof(char))) == NULL)
392 if (read(fd, *str, size) < size)
404 read_type(int fd, short int *type, short int *size)
405 /* read the type and size of the next field in a binary fcrontab file */
407 if (read(fd, type, sizeof(short int)) < sizeof(short int))
409 if (read(fd, size, sizeof(short int)) < sizeof(short int))
420 /* macros for read_file() */
421 /* read "size" bytes from file "ff", put them in "to", and check for errors */
422 #define Read(TO, SIZE, ERR_STR) \
424 if ( read(fileno(ff), &(TO), SIZE) < SIZE ) { \
430 #define Read_strn(TO, SIZE, ERR_STR) \
432 if ( read_strn(fileno(ff), &(TO), SIZE) != OK ) { \
439 read_file(const char *file_name, cf_t * cf, int is_system_startup)
440 /* read a formated fcrontab.
441 * return ERR on error, OK otherwise */
448 char *runas_str = NULL;
449 struct stat file_stat;
450 struct passwd *pass = NULL;
451 short int type = 0, size = 0;
453 int has_read_cl_first = 0; /* have we read S_FIRST_T? */
455 int flask_enabled = is_selinux_enabled();
457 struct av_decision avd;
458 char *user_name = NULL;
462 if ((ff = fopen(file_name, "r")) == NULL) {
463 warn_e("Could not read %s (may have just been removed)", file_name);
467 /* check if this file is owned by root : otherwise, all runas fields
468 * of this file should be set to the owner */
469 rc = fstat(fileno(ff), &file_stat);
471 error_e("Could not stat %s", file_name);
475 if (flask_enabled && fgetfilecon(fileno(ff), &cf->cf_file_context) < 0) {
476 error_e("Could not get context of %s", file_name);
481 if (strncmp(file_name, "new.", 4) == 0) {
482 if (file_stat.st_uid == rootuid) {
483 /* file is owned by root : no test needed : set runas to rootuid */
487 /* this is a standard user's new fcrontab : set the runas field to
488 * the owner of the file */
489 runas = file_stat.st_uid;
490 if ((pass = getpwuid(file_stat.st_uid)) == NULL) {
491 error_e("Could not getpwuid(%d)", file_stat.st_uid);
494 runas_str = strdup2(pass->pw_name);
496 cf->cf_user = strdup2(file_name + 4);
500 cf->cf_user = strdup2(file_name);
501 if (file_stat.st_uid == rootuid) {
502 /* file is owned by root : either this file has already been parsed
503 * at least once by fcron, or it is root's fcrontab */
507 error("Non-new file %s owned by someone else than root", file_name);
514 * Since fcrontab files are not directly executed,
515 * fcron daemon must ensure that the fcrontab file has
516 * a context that is appropriate for the context of
517 * the user fcron job. It performs an entrypoint
518 * permission check for this purpose.
524 /* first, get the SELinux user for that Linux user */
526 if (!strcmp(cf->cf_user, SYSFCRONTAB))
527 /* system_u is the default SELinux user for running system services */
528 user_name = "system_u";
530 #endif /* def SYSFCRONTAB */
532 if (getseuserbyname(cf->cf_user, &sename, &selevl) < 0) {
533 error_e("Cannot find SELinux user for user \"%s\"\n",
540 if (get_default_context(user_name, NULL, &cf->cf_user_context))
541 error_e("NO CONTEXT for Linux user '%s' (SELinux user '%s')",
542 cf->cf_user, user_name);
544 security_compute_av(cf->cf_user_context, cf->cf_file_context,
545 SECCLASS_FILE, FILE__ENTRYPOINT, &avd);
547 if (retval || ((FILE__ENTRYPOINT & avd.allowed) != FILE__ENTRYPOINT)) {
548 syslog(LOG_ERR, "ENTRYPOINT FAILED for Linux user '%s' "
549 "(CONTEXT %s) for file CONTEXT %s", cf->cf_user,
550 cf->cf_user_context, cf->cf_file_context);
559 debug("User %s Entry", file_name);
561 /* get version of fcrontab file: it permits to daemon not to load
562 * a file which he won't understand the syntax, for example
563 * a file using a depreciated format generated by an old fcrontab,
564 * if the syntax has changed */
565 if (read_type(fileno(ff), &type, &size) != OK || type != S_HEADER_T ||
566 read(fileno(ff), &bufi, size) < size || bufi != S_FILEVERSION) {
567 error("File %s is not valid: ignored.", file_name);
568 error("This file may have been generated by an old version of fcron.");
569 error("In that case, you should try to use the converter given in the "
570 "source package, or install it again using fcrontab.");
574 if (read_type(fileno(ff), &type, &size) != OK || type != S_USER_T) {
575 error("Invalid binary fcrontab (no USER field)");
578 /* get the owner's name */
579 /* we set cf->cf_user before for SE Linux, so we need to free it here */
580 Free_safe(cf->cf_user);
581 if (read_strn(fileno(ff), &cf->cf_user, size) != OK) {
582 error("Cannot read user's name : file ignored");
585 if (runas != rootuid) {
586 /* we use file owner's name for more security (see above) */
587 /* free the value obtained by read_strn() (we need to read it anyway
588 * to set the file ptr to the next thing to read) */
589 Free_safe(cf->cf_user);
590 cf->cf_user = runas_str;
593 /* get the time & date of the saving */
594 /* a new file generated by fcrontab has t_save set to 0 */
595 if (read_type(fileno(ff), &type, &size) != OK || type != S_TIMEDATE_T
596 || read(fileno(ff), &t_save, size) < size) {
597 error("could not get time and date of saving");
601 debug("file saved at %lu.", t_save);
604 if (cf->cf_env_list == NULL)
605 cf->cf_env_list = env_list_init();
608 /* main loop : read env variables, and lines */
609 while (read_type(fileno(ff), &type, &size) == OK) {
610 /* action is determined by the type of the field */
614 /* read a env variable and add it to the env var list */
618 /* Read_strn go to "err" on error */
619 Read_strn(envvar, size, "Error while reading env var");
620 debug(" Env: \"%s\"", envvar);
621 /* we do not allow USER or LOGNAME assignment.
622 * this was already checked by fcrontab, but we check again
624 if (strcmp_until(envvar, "USER", '=') == 0
625 || strcmp_until(envvar, "LOGNAME", '=') == 0) {
627 ("USER or LOGNAME assignement is not allowed: ignored.");
630 env_list_putenv(cf->cf_env_list, envvar, 1);
637 /* time diff between local (real) and system hour */
638 Read(bufi, size, "Error while reading tzdiff field");
639 cf->cf_tzdiff = (signed char)bufi;
643 /* read the timezone (string) in which the line should run */
644 Read_strn(cl->cl_tz, size, "Error while reading timezone field");
648 Read_strn(cl->cl_shell, size, "Error while reading shell field");
652 Read_strn(cl->cl_runas, size, "Error while reading runas field");
656 Read_strn(cl->cl_mailfrom, size,
657 "Error while reading mailfrom field");
661 Read_strn(cl->cl_mailto, size, "Error while reading mailto field");
665 Read(bufi, size, "Error while reading nextexe field");
666 cl->cl_nextexe = (time_t) bufi;
670 Read(bufi, size, "Error while reading first field");
671 cl->cl_first = (time_t) bufi;
672 has_read_cl_first = 1;
676 if (size < OPTION_SIZE)
677 /* set the options not defined in the savefile to default */
678 set_default_opt(cl->cl_option);
679 Read(cl->cl_option, size, "Error while reading option field");
683 Read(cl->cl_numexe, size, "Error while reading numexe field");
687 Read(cl->cl_lavg, size, "Error while reading lavg field");
691 Read(bufi, size, "Error while reading until field");
692 cl->cl_until = (time_t) bufi;
696 Read(cl->cl_nice, size, "Error while reading nice field");
700 Read(bufi, size, "Error while reading runfreq field");
701 cl->cl_runfreq = (unsigned short)bufi;
705 Read(bufi, size, "Error while reading remain field");
706 cl->cl_remain = (unsigned short)bufi;
710 Read(bufi, size, "Error while reading timefreq field");
711 cl->cl_timefreq = (time_t) bufi;
715 /* read the jitter (uchar) to use to set next execution time */
716 Read(bufi, size, "Error while reading jitter field");
717 cl->cl_jitter = (unsigned char)bufi;
721 Read(cl->cl_mins, size, "Error while reading mins field");
725 Read(cl->cl_hrs, size, "Error while reading hrs field");
729 Read(cl->cl_days, size, "Error while reading days field");
733 Read(cl->cl_mons, size, "Error while reading mons field");
737 Read(cl->cl_dow, size, "Error while reading dow field");
741 if (is_freq(cl->cl_option) && !has_read_cl_first) {
742 /* Up to fcron 3.0.X, cl_first/S_FIRST_T was not saved for all @-lines */
743 cl->cl_first = cl->cl_nextexe;
746 (cl, cf, runas, runas_str, t_save, is_system_startup) != 0)
751 /* default case in "switch(type)" */
753 error("Error while loading %s : unknown field type %d (ignored)",
757 /* skip the data corresponding to the unknown field */
759 /* we avoid using fseek(), as it seems not to work correctly
760 * on some systems when we use read() on the FILE stream */
762 for (i = 0; i < size; i++)
769 /* free last cl Alloc : unused */
772 /* check for an error */
774 error("file %s is truncated : you should reinstall it with fcrontab",
777 xfclose_check(&ff, file_name);
783 xfclose_check(&ff, file_name);
785 if (cl != NULL && cl->cl_next == NULL) {
786 /* line is not yet in the line list of the file : free it */
787 Free_safe(cl->cl_shell);
788 Free_safe(cl->cl_runas);
789 Free_safe(cl->cl_mailfrom);
790 Free_safe(cl->cl_mailto);
794 /* check if we have started to read the lines and env var */
796 /* insert the line in the file list in order to be able to free
797 * the memory using delete_file() */
799 cf->cf_next = file_base;
802 delete_file(cf->cf_user);
806 Free_safe(cf->cf_user);
815 add_line_to_file(cl_t * cl, cf_t * cf, uid_t runas, char *runas_str,
816 time_t t_save, int is_system_startup)
817 /* check if the line is valid, and if yes, add it to the file cf */
819 time_t sleep_duration = now - t_save;
821 if (cl->cl_shell == NULL || cl->cl_runas == NULL || cl->cl_mailto == NULL) {
822 error("Line is not valid (empty shell, runas or mailto field)"
827 /* set runas field if necessary (to improve security) */
828 if (runas != rootuid) {
829 if (strcmp(cl->cl_runas, runas_str) != 0)
830 warn("warning: runas(%s) is not owner (%s): overridden.",
831 cl->cl_runas, runas_str);
832 Set(cl->cl_runas, runas_str);
835 /* we need that here because the user's name contained in the
836 * struct cf_t may be required */
839 /* check if the mailfrom and mailto fields are safe */
840 if (cl->cl_mailfrom && (*(cl->cl_mailfrom) == '-' ||
841 strcspn(cl->cl_mailfrom,
842 " \t\n;|") != strlen(cl->cl_mailfrom))) {
844 ("mailfrom field \'%s\' is not safe : unsetting to use default value.",
846 Free_safe(cl->cl_mailfrom);
848 if (cl->cl_mailto && (*(cl->cl_mailto) == '-' ||
849 strcspn(cl->cl_mailto,
850 " \t\n;|") != strlen(cl->cl_mailto))) {
851 error("mailto field \'%s\' is not safe : setting to owner %s.",
852 cl->cl_mailto, cl->cl_file->cf_user);
853 Set(cl->cl_mailto, cl->cl_file->cf_user);
856 /* make sure the timefreq is valid on @-lines or we could end up with
858 if (!is_td(cl->cl_option) && cl->cl_timefreq < 1) {
859 error("Invalid timefreq %ld for job '%s': setting to 1 day",
860 cl->cl_timefreq, cl->cl_shell);
861 cl->cl_timefreq = 3600 * 24;
864 set_next_exe_startup(cl, is_system_startup ? CONTEXT_BOOT : CONTEXT_DEFAULT,
867 /* add the current line to the list, and allocate a new line */
868 if ((cl->cl_id = next_id++) >= ULONG_MAX - 1) {
869 warn("Line id reached %ld: cycling back to zero.", ULONG_MAX);
872 cl->cl_next = cf->cf_line_base;
873 cf->cf_line_base = cl;
878 delete_file(const char *user_name)
879 /* free a file if user_name is not null
880 * otherwise free all files */
883 cf_t *prev_file = NULL;
886 struct job_t *j = NULL;
887 struct job_t *prev_j;
889 struct cl_t **s_a = NULL;
894 while (file != NULL) {
895 if (strcmp(user_name, file->cf_user) != 0) {
897 file = file->cf_next;
901 for (e = exe_list_first(exe_list); e != NULL;
902 e = exe_list_next(exe_list))
903 if (e->e_line != NULL && e->e_line->cl_file == file) {
904 /* we set the e_line to NULL, as so we know in wait_chld()
905 * and wait_all() the corresponding file has been removed.
906 * Plus, we decrement serial_running and lavg_serial_running
907 * as we won't be able to do it at the end of the job */
908 if ((is_serial(e->e_line->cl_option) ||
909 is_serial_once(e->e_line->cl_option)) &&
910 !is_lavg(e->e_line->cl_option))
912 else if (is_serial(e->e_line->cl_option) &&
913 is_lavg(e->e_line->cl_option))
914 lavg_serial_running--;
918 /* free lavg queue entries */
919 for (l = lavg_list_first(lavg_list); l != NULL;
920 l = lavg_list_next(lavg_list))
921 if (l->l_line->cl_file == file) {
922 debug("removing '%s' from lavg queue", l->l_line->cl_shell);
923 lavg_list_remove_cur(lavg_list);
926 /* free serial queue entries */
927 for (i = 0; i < serial_array_size; i++)
928 if (serial_array[i] != NULL && serial_array[i]->cl_file == file) {
931 alloc_safe(serial_array_size * sizeof(cl_t *),
934 debug("removing '%s' from serial queue",
935 serial_array[i]->cl_shell);
937 serial_array[i]->cl_numexe--;
938 serial_array[i] = NULL;
940 /* remove from queue and move the rest of the jobs to get
941 * a queue in order without empty entries */
943 goto end_of_serial_recomputing;
945 if ((k = serial_array_index + serial_num) >= serial_array_size)
946 k -= serial_array_size;
947 for (i = k = 0; i < serial_array_size; i++) {
948 if (serial_array_index + i < serial_array_size) {
949 if ((s_a[k] = serial_array[serial_array_index + i]) != NULL)
953 serial_array[serial_array_index + i - serial_array_size])
957 Free_safe(serial_array);
959 serial_array_index = 0;
961 end_of_serial_recomputing:
964 cur_line = file->cf_line_base;
965 while ((line = cur_line) != NULL) {
966 cur_line = line->cl_next;
968 /* remove from the main queue */
970 for (j = queue_base; j != NULL; j = j->j_next)
971 if (j->j_line == line) {
973 prev_j->j_next = j->j_next;
975 queue_base = j->j_next;
982 /* free line itself */
985 /* delete_file() MUST remove only the first occurrence :
986 * this is needed by synchronize_file() */
991 /* file not in the file list */
994 /* remove file from file list */
995 if (prev_file == NULL)
996 file_base = file->cf_next;
998 prev_file->cf_next = file->cf_next;
1000 /* free env variables */
1001 env_list_destroy(file->cf_env_list);
1003 /* finally free file itself */
1004 Free_safe(file->cf_user);
1011 save_file(cf_t * arg_file)
1012 /* Store the informations relatives to the executions
1013 * of tasks at a defined frequency of system's running time */
1016 cf_t *start_file = NULL;
1018 if (arg_file != NULL)
1019 start_file = arg_file;
1021 start_file = file_base;
1024 for (file = start_file; file; file = file->cf_next) {
1026 debug("Saving %s...", file->cf_user);
1028 /* save the file safely : save it to a temporary name, then rename() it */
1029 /* chown the file to root:root : this file should only be read and
1030 * modified by fcron (not fcrontab) */
1031 save_file_safe(file, file->cf_user, "fcron", rootuid, rootgid, now);
1033 if (arg_file != NULL)
1034 /* we have to save only a single file */