#include "mem.h"
cl_t *
-dups_cl(cl_t * orig)
+dups_cl(cl_t *orig)
/* Duplicate a line, including the strings it points to. */
{
cl_t *cl = NULL;
}
void
-free_line(cl_t * cl)
+free_line(cl_t *cl)
/* free a line, including its fields */
{
if (cl != NULL) {
}
int
-read_file(const char *file_name, cf_t * cf, int is_system_startup)
+read_file(const char *file_name, cf_t *cf, int is_system_startup)
/* read a formated fcrontab.
* return ERR on error, OK otherwise */
{
/* if we get here, sec_class and access_vec are both defined */
retval = security_compute_av(cf->cf_user_context, cf->cf_file_context,
- sec_class, access_vec, &avd);
+ sec_class, access_vec, &avd);
if (retval || ((access_vec & avd.allowed) != access_vec)) {
syslog(LOG_ERR, "ENTRYPOINT FAILED for Linux user '%s' "
int
-add_line_to_file(cl_t * cl, cf_t * cf, uid_t runas, char *runas_str,
+add_line_to_file(cl_t *cl, cf_t *cf, uid_t runas, char *runas_str,
time_t t_save, int is_system_startup)
/* check if the line is valid, and if yes, add it to the file cf */
{
void
-save_file(cf_t * arg_file)
+save_file(cf_t *arg_file)
/* Store the informations relatives to the executions
* of tasks at a defined frequency of system's running time */
{
char *
-read_str(FILE * f, char *buf, int max)
+read_str(FILE *f, char *buf, int max)
/* return a pointer to string read from file f
* if it is non-zero length */
{
void
-delete_file(cf_t * file)
+delete_file(cf_t *file)
/* free a file if user_name is not null
* otherwise free all files */
{
void
-run_normal_job(cl_t * line, int info_fd)
+run_normal_job(cl_t *line, int info_fd)
/* run a job, and write "log" on info_fd if positive */
{
}
void
-run_lavg_job(lavg_t * l)
+run_lavg_job(lavg_t *l)
{
run_queue_job(l->l_line);
void
-run_queue_job(cl_t * line)
+run_queue_job(cl_t *line)
/* run a job */
{
* Return 1 if there is a loop, 0 otherwise.
* Only intended to be used when running in debug mode really. */
{
- const int max_entries = 1000000 ;
+ const int max_entries = 1000000;
int i = 0;
struct job_t *j;
}
job_t *
-job_queue_remove(cl_t * line)
+job_queue_remove(cl_t *line)
/* remove a job from the queue list
* returns a pointer to the previous entry,
* or NULL if the line either wasn't in the queue or was the first entry */
Free_safe(j);
if (debug_opt && is_loop_in_queue()) {
- error("Loop found in job queue after removing line '%s': aborting.",
- line->cl_shell);
+ error("Loop found in job queue after removing line '%s': "
+ "aborting.", line->cl_shell);
abort();
}
}
void
-insert_nextexe(cl_t * line)
+insert_nextexe(cl_t *line)
/* insert a job at the right position in the job queue */
{
struct job_t *newjob = NULL;
struct job_t *jprev = NULL;
if (debug_opt && is_loop_in_queue()) {
- error("Detected loop in queue_base before adding job '%s' to the queue: aborting.",
- line->cl_shell);
+ error("Detected loop in queue_base before adding job '%s' "
+ "to the queue: aborting.", line->cl_shell);
abort();
}
}
if (debug_opt && is_loop_in_queue()) {
- error("Detected loop in queue_base after adding job '%s' to the queue: aborting.",
- line->cl_shell);
+ error("Detected loop in queue_base after adding job '%s' to the queue:"
+ " aborting.", line->cl_shell);
abort();
}
}
void
-add_serial_job(cl_t * line, int info_fd)
+add_serial_job(cl_t *line, int info_fd)
/* add the next queued job in serial queue */
{
short int i;
void
-add_lavg_job(cl_t * line, int info_fd)
+add_lavg_job(cl_t *line, int info_fd)
/* add the next queued job in lavg queue */
/* WARNING : must be run before a set_next_exe() to get the strict option
* working correctly */
if (debug_opt) {
if (lavg_entry->l_until == 0) {
send_msg_fd_debug(info_fd,
- " lavg entry added until:none cmd: '%s'",
- line->cl_shell);
+ " lavg entry added until:none cmd: '%s'",
+ line->cl_shell);
}
else {
struct tm ftime;
struct tm *ft = localtime(&(lavg_entry->l_until));
/* localtime() returns a statically allocated struct which might be
- overwritten by subsequent calls: take a copy.
- (note: localtime() is used in the debug() function too) */
+ * overwritten by subsequent calls: take a copy.
+ * (note: localtime() is used in the debug() function too) */
memcpy(&ftime, ft, sizeof(struct tm));
send_msg_fd_debug(info_fd,
- " lavg entry added until:%04d-%02d-%02d "
- "%02d:%02d:%02d (system time) cmd: '%s'",
- (ftime.tm_year + 1900), (ftime.tm_mon + 1),
- ftime.tm_mday, ftime.tm_hour,
- ftime.tm_min, ftime.tm_sec, line->cl_shell);
+ " lavg entry added until:%04d-%02d-%02d "
+ "%02d:%02d:%02d (system time) cmd: '%s'",
+ (ftime.tm_year + 1900), (ftime.tm_mon + 1),
+ ftime.tm_mday, ftime.tm_hour,
+ ftime.tm_min, ftime.tm_sec, line->cl_shell);
}
}
void
-goto_beginning_next_period_periodical(cl_t * line, struct tm *ftime)
+goto_beginning_next_period_periodical(cl_t *line, struct tm *ftime)
/* From ftime, search the first/nearest time and date of the line's next
* period of execution.
*
void
-move_time_to(int where, cl_t * line, struct tm *ftime)
+move_time_to(int where, cl_t *line, struct tm *ftime)
/* IF WHERE == BEGIN_NEXT_PERIOD: from ftime, search the first/nearest time and date
* of the line's next period of execution.
* IF WHERE == END_OF_INTERVAL: search the last time and date
void
-set_next_exe(cl_t * line, char option, int info_fd)
+set_next_exe(cl_t *line, char option, int info_fd)
/* set the cl_nextexe of a given cl_t and insert it in the queue */
{
}
void
-set_next_exe_notrun(cl_t * line, char context)
+set_next_exe_notrun(cl_t *line, char context)
/* set the time of the next execution and send a mail to tell user his job
* has not run if necessary */
{
void
-mail_notrun_time_t(cl_t * line, char context, time_t since_time_t)
+mail_notrun_time_t(cl_t *line, char context, time_t since_time_t)
/* Same as mail_notrun() but with 'since' defined as a time_t instead of a struct tm */
{
struct tm *since2 = NULL;
}
void
-mail_notrun(cl_t * line, char context, struct tm *since)
+mail_notrun(cl_t *line, char context, struct tm *since)
/* send a mail to tell user a job has not run (and why) */
{
int pid = 0;
}
env_list_t *
-env_list_copy(env_list_t * list)
+env_list_copy(env_list_t *list)
{
env_list_t *new_list = NULL;
env_t *e = NULL;
}
env_t *
-env_list_setenv(env_list_t * list, char *name, char *value, int overwrite)
+env_list_setenv(env_list_t *list, char *name, char *value, int overwrite)
{
env_t e = { NULL };
env_t *c = NULL;
}
env_t *
-env_list_putenv(env_list_t * list, char *envvar, int overwrite)
+env_list_putenv(env_list_t *list, char *envvar, int overwrite)
{
env_t e = { NULL };
env_t *c = NULL;
}
char *
-env_list_getenv(env_list_t * list, char *name)
+env_list_getenv(env_list_t *list, char *name)
{
env_t *c = NULL;
}
env_t *
-env_list_first(env_list_t * list)
+env_list_first(env_list_t *list)
{
return (env_t *) u_list_first((u_list_t *) list);
}
env_t *
-env_list_next(env_list_t * list)
+env_list_next(env_list_t *list)
{
return (env_t *) u_list_next((u_list_t *) list);
}
void
-env_list_end_iteration(env_list_t * list)
+env_list_end_iteration(env_list_t *list)
{
u_list_end_iteration((u_list_t *) list);
}
env_list_t *
-env_list_destroy(env_list_t * list)
+env_list_destroy(env_list_t *list)
/* free() the memory allocated for list and returns NULL */
{
env_t *c = NULL;
}
char **
-env_list_export_envp(env_list_t * list)
+env_list_export_envp(env_list_t *list)
/* export list data as a char **envp structure to use as an argument of execle() */
{
env_t *c = NULL;
}
exe_t *
-exe_list_add_line(exe_list_t * list, struct cl_t *line)
+exe_list_add_line(exe_list_t *list, struct cl_t *line)
{
exe_t e = { NULL, 0, 0 };
e.e_line = line; /* ANSI C does not allow us to directly replace NULL by line above */
}
exe_t *
-exe_list_add(exe_list_t * list, exe_t * e)
+exe_list_add(exe_list_t *list, exe_t *e)
{
return (exe_t *) u_list_add((u_list_t *) list, (u_list_entry_t *) e);
}
exe_t *
-exe_list_first(exe_list_t * list)
+exe_list_first(exe_list_t *list)
{
return (exe_t *) u_list_first((u_list_t *) list);
}
exe_t *
-exe_list_next(exe_list_t * list)
+exe_list_next(exe_list_t *list)
{
return (exe_t *) u_list_next((u_list_t *) list);
}
void
-exe_list_end_iteration(exe_list_t * list)
+exe_list_end_iteration(exe_list_t *list)
{
u_list_end_iteration((u_list_t *) list);
}
void
-exe_list_remove_cur(exe_list_t * list)
+exe_list_remove_cur(exe_list_t *list)
{
u_list_remove_cur((u_list_t *) list);
}
exe_list_t *
-exe_list_destroy(exe_list_t * list)
+exe_list_destroy(exe_list_t *list)
/* free() the memory allocated for list and returns NULL */
{
return (exe_list_t *) u_list_destroy((u_list_t *) list);
uid_t rootuid = 0;
void
-print_cur(exe_t * e)
+print_cur(exe_t *e)
{
printf("Current entry's shell command: %s\n",
e ? e->e_line->cl_shell : "NULL");
}
void
-print_list(exe_list_t * list)
+print_list(exe_list_t *list)
{
exe_t *e = NULL;
printf("Current list:\n");
set_signal_handler(int signal, void (*handler)(int), bool first_install)
/* (re)install a signal handler, with restartable syscalls retried. */
{
+/* *INDENT-OFF* */
#ifdef HAVE_SIGACTION
/* The signal handler stays set after the handler is called when set
- with sigaction(): we only need to install it once. */
+ * with sigaction(): we only need to install it once. */
if (first_install) {
- struct sigaction act = {0};
+ struct sigaction act = { 0 };
act.sa_flags = SA_RESTART;
act.sa_handler = handler;
if (sigaction(signal, &act, NULL) < 0) {
}
#elif defined(HAVE_SIGNAL)
/* Some systems reset the handler to SIG_DFL when the handler
- is called when the handler was set with signal(). So we have to install
- it (again) every time. */
+ * is called when the handler was set with signal(). So we have to install
+ * it (again) every time. */
if (signal(signal, handler) == SIG_ERR) {
die_e("signal() failed on signal %d", signal);
}
}
#elif defined(HAVE_SIGSET)
/* The signal handler stays set after the handler is called when set
- with sigset(): we only need to install it once. */
+ * with sigset(): we only need to install it once. */
if (first_install) {
if (sigset(signal, handler) == -1) {
die_e("sigset() failed on signal %d", signal);
#else
#error "No signal installation function found"
#endif
+/* *INDENT-ON* */
}
void
-install_signal_handler(int signal, void (*handler)(int)) {
+install_signal_handler(int signal, void (*handler)(int))
+{
set_signal_handler(signal, handler, true);
}
while (printed_len < read_len) {
int str_len = strlen(buf + printed_len);
printf("%s", buf + printed_len);
- if (str_len > 0 && buf[printed_len+str_len-1] != '\n') {
+ if (str_len > 0 && buf[printed_len + str_len - 1] != '\n') {
printf("\n");
}
- printed_len += str_len + 1; /* +1 to account for the end-of-string '\0' marker */
+ printed_len += str_len + 1; /* +1 to account for the end-of-string '\0' marker */
}
/* check for the end of command output marker */
if (read_len >= sizeof(END_STR) &&
memcmp(&buf[read_len - sizeof(END_STR)], END_STR,
- sizeof(END_STR)) == 0) {
+ sizeof(END_STR)) == 0) {
break;
}
}
void
-fcrondyn_socket_init(select_instance * si)
+fcrondyn_socket_init(select_instance *si)
/* do everything needed to get a working listening socket */
{
struct sockaddr_un addr;
Add_field(field_endline);
/* Extra safety (which should be redundant as strncat (used in Add_field
- and Test_add_field) always null-terminate the string: */
+ * and Test_add_field) always null-terminate the string: */
fields[sizeof(fields) - 1] = '\0';
/* add +1 to include the final end-of-string "\0" */
- if (send(fd, fields, (len+1 < sizeof(fields)) ? len+1 : sizeof(fields), 0) < 0)
+ if (send(fd, fields, (len + 1 < sizeof(fields)) ? len + 1 : sizeof(fields),
+ 0) < 0)
error_e("error in send()");
}
if (bit_test(details, FIELD_SCHEDULE)) {
ftime = localtime(&(line->cl_nextexe));
len +=
- snprintf(buf + len, sizeof(buf) - len, "|%04d-%02d-%02d %02d:%02d:%02d",
- (ftime->tm_year + 1900), (ftime->tm_mon + 1),
- ftime->tm_mday, ftime->tm_hour, ftime->tm_min, ftime->tm_sec);
+ snprintf(buf + len, sizeof(buf) - len,
+ "|%04d-%02d-%02d %02d:%02d:%02d", (ftime->tm_year + 1900),
+ (ftime->tm_mon + 1), ftime->tm_mday, ftime->tm_hour,
+ ftime->tm_min, ftime->tm_sec);
}
len += snprintf(buf + len, sizeof(buf) - len, "|%s\n", line->cl_shell);
/* snprintf() returns the length of what would have been written (excluding terminating null byte)
- if not limited by maxlen */
- if (len+1 > sizeof(buf)) {
+ * if not limited by maxlen */
+ if (len + 1 > sizeof(buf)) {
/* the shell command string was too long and was truncated */
strcpy(buf + sizeof(buf) - sizeof(truncated), truncated);
}
/* as extra safety to make sure the string is always null-terminated
- (even though snprintf man page suggests it does it already) */
+ * (even though snprintf man page suggests it does it already) */
buf[sizeof(buf) - 1] = '\0';
/* add +1 to include the final end-of-string "\0" */
- if (send(fd, buf, (len+1 < sizeof(buf)) ? len+1 : sizeof(buf), 0) < 0) {
+ if (send(fd, buf, (len + 1 < sizeof(buf)) ? len + 1 : sizeof(buf), 0) < 0) {
error_e("error in send()");
}
}
getloadavg(lavg, 3);
i = snprintf(lavg_str, sizeof(lavg_str), "Current load average : "
"%.1f, %.1f, %.1f\n", lavg[0], lavg[1], lavg[2]);
- send(fd, lavg_str, (i+1 < sizeof(lavg_str))? i+1 : sizeof(lavg_str), 0);
+ send(fd, lavg_str,
+ (i + 1 < sizeof(lavg_str)) ? i + 1 : sizeof(lavg_str), 0);
bit_set(fields, FIELD_LAVG);
}
void
-cmd_renice(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t * e,
+cmd_renice(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t *e,
int is_root)
/* change nice value of a running job */
{
void
-cmd_send_signal(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t * e)
+cmd_send_signal(struct fcrondyn_cl *client, long int *cmd, int fd, exe_t *e)
/* send a signal to a running job */
{
if (e->e_job_pid <= 0 || (int)cmd[1] <= 0) {
void
remove_connection(struct fcrondyn_cl **client, struct fcrondyn_cl *prev_client,
- select_instance * si)
+ select_instance *si)
/* close the connection, remove it from the list
and make client points to the next entry */
{
}
void
-fcrondyn_socket_check(select_instance * si)
+fcrondyn_socket_check(select_instance *si)
/* check for new connection, command, connection closed */
{
int fd = -1, avoid_fd = -1;
void
-fcrondyn_socket_close(select_instance * si)
+fcrondyn_socket_close(select_instance *si)
/* close connections, close socket, remove socket file.
* If si is not NULL, then remove the fds from si's readfds */
{
max_delay_s = MAX_FCRONTAB_RELOAD_DELAY_SECONDS;
#endif
if (uid == rootuid) {
- /* we don't need to make root wait */
- max_delay_s = 0;
+ /* we don't need to make root wait */
+ max_delay_s = 0;
}
if (max_delay_s > 0) {
now_epoch = time(NULL);
if (now_epoch % 60 < 50) {
- /* clocktime is < ##:##:50, so target 10s before the end of the current minute */
- delay_s = 50 - (now_epoch % 60);
- } else {
- /* clocktime is >= ##:##:50, so target 10s before the end of the next minute */
- delay_s = 50 + (60 - (now_epoch % 60));
+ /* clocktime is < ##:##:50, so target 10s before the end of the current minute */
+ delay_s = 50 - (now_epoch % 60);
+ }
+ else {
+ /* clocktime is >= ##:##:50, so target 10s before the end of the next minute */
+ delay_s = 50 + (60 - (now_epoch % 60));
}
if (delay_s > max_delay_s) {
- delay_s = max_delay_s;
+ delay_s = max_delay_s;
}
target_time_epoch = now_epoch + delay_s;
target_time_tm = localtime(&target_time_epoch);
- fprintf(stderr, "Modifications will be taken into account at %02d:%02d:%02d.\n",
- target_time_tm->tm_hour, target_time_tm->tm_min, target_time_tm->tm_sec);
+ fprintf(stderr, "Modifications will be taken into account at "
+ "%02d:%02d:%02d.\n", target_time_tm->tm_hour,
+ target_time_tm->tm_min, target_time_tm->tm_sec);
/* if fcrontabs is too long, snprintf will not be able to add "/fcrontab.sig"
* string at the end of sigfile */
Set(fcronconf, optarg);
}
else {
- char buf[sizeof(orig_dir)+1+strlen(optarg)+1];
+ char buf[sizeof(orig_dir) + 1 + strlen(optarg) + 1];
snprintf(buf, sizeof(buf), "%s/%s", orig_dir, optarg);
Set(fcronconf, buf);
}
if (file_opt) {
if (strcmp(argv[file_opt], "-") == 0)
-
xexit(install_stdin());
else {
if (*argv[file_opt] != '/') {
/* this is just the file name, not the path : complete it */
- size_t path_len = strlen(orig_dir) + 1 + strlen(argv[file_opt]) + 1;
+ size_t path_len =
+ strlen(orig_dir) + 1 + strlen(argv[file_opt]) + 1;
alloc_safe(path_len, fcrontab_file_path);
- snprintf(fcrontab_file_path, path_len, "%s/%s", orig_dir, argv[file_opt]);
+ snprintf(fcrontab_file_path, path_len, "%s/%s", orig_dir,
+ argv[file_opt]);
}
else {
fcrontab_file_path = strdup(argv[file_opt]);
}
fifo_list_entry_t *
-fifo_list_last(fifo_list_t * l)
+fifo_list_last(fifo_list_t *l)
/* Returns the pointer of the last entry in the list, or NULL if l is empty */
{
fifo_list_entry *e = NULL;
}
int
-fifo_list_resize_array(fifo_list_t * l)
+fifo_list_resize_array(fifo_list_t *l)
/* Resize l's entries_array up to l->max_entries
* Returns OK on success, ERR if the array is already at maximum size */
{
fifo_list_entry_t *
-fifo_list_add(fifo_list_t * l, fifo_list_entry_t * e)
+fifo_list_add(fifo_list_t *l, fifo_list_entry_t *e)
/* Add one entry to the list
* Returns a pointer to the added element, or NULL if list is already at max size */
{
}
fifo_list_entry_t *
-fifo_list_first(fifo_list_t * l)
+fifo_list_first(fifo_list_t *l)
/* Return the first entry of the list (then fifo_list_next() can be used) */
{
/* sanity check */
}
fifo_list_entry_t *
-fifo_list_next(fifo_list_t * l)
+fifo_list_next(fifo_list_t *l)
/* Return the entry after e */
{
/* // WHAT IF I CALL _ADD() (+RESIZE?) OR _REMOVE() BETWEEN TWO _NEXT CALLS? */
}
void
-fifo_list_end_iteration(fifo_list_t * list)
+fifo_list_end_iteration(fifo_list_t *list)
/* Stop an iteration before _next() reached the end of the list by itself */
{
list->cur_entry = NULL;
void
-fifo_list_remove_first(fifo_list_t * l)
+fifo_list_remove_first(fifo_list_t *l)
{
/* // MANAGE L->NEXT_ENTRY (+ SPECIAL CASE FIRST/LAST ENTRY) */
fifo_list_entry_t *last = NULL;
}
fifo_list_t *
-fifo_list_destroy(fifo_list_t * list)
+fifo_list_destroy(fifo_list_t *list)
/* free() the memory allocated for list and returns NULL */
{
if (list == NULL)
int
-get_line(char *str, size_t size, FILE * file)
+get_line(char *str, size_t size, FILE *file)
/* similar to fgets, but increase line if necessary,
* and continue over an "\" followed by an "\n" char */
{
}
void
-init_default_line(cl_t * cl, cf_t * cf)
+init_default_line(cl_t *cl, cf_t *cf)
/* clear all context/options from cl */
{
bzero(cl, sizeof(cl_t));
}
void
-read_env(char *ptr, cf_t * cf)
+read_env(char *ptr, cf_t *cf)
/* append env variable list.
* (remove blanks) */
{
char *
-read_opt(char *ptr, cl_t * cl)
+read_opt(char *ptr, cl_t *cl)
/* read one or several options and fill in the field "option" */
{
char opt_name[20];
char *
-get_time(char *ptr, time_t * time, int zero_allowed)
+get_time(char *ptr, time_t *time, int zero_allowed)
/* convert time read in string in time_t format */
{
time_t sum;
char *
-check_username(char *ptr, cf_t * cf, cl_t * cl)
+check_username(char *ptr, cf_t *cf, cl_t *cl)
/* check ptr to see if the first word is a username, returns new ptr */
{
short int indx = 0;
}
int
-read_shortcut(char *ptr, cf_t * cf)
+read_shortcut(char *ptr, cf_t *cf)
/* try to read a shortcut entry, and if it is one then append a line to cf
* Return 1 if that was a shortcut entry. If it wasn't, return 0 and make sure
* ptr is back to its orig value. */
}
void
-read_freq(char *ptr, cf_t * cf)
+read_freq(char *ptr, cf_t *cf)
/* read a freq entry, and append a line to cf */
{
cl_t *cl = NULL;
void
-read_arys(char *ptr, cf_t * cf)
+read_arys(char *ptr, cf_t *cf)
/* read a run freq number plus a normal fcron line */
{
cl_t *cl = NULL;
}
void
-read_period(char *ptr, cf_t * cf)
+read_period(char *ptr, cf_t *cf)
/* read a line to run periodically (i.e. once a day, once a week, etc) */
{
cl_t *cl = NULL;
char *
-read_field(char *ptr, bitstr_t * ary, int max, const char **names)
+read_field(char *ptr, bitstr_t *ary, int max, const char **names)
/* read a field like "2,5-8,10-20/2,21-30~25" and fill ary */
{
int start = 0;
/* fclose() a file, and set the FILE* to NULL.
* Returns fclose()'s return value and leaves errno as is. */
int
-xfclose(FILE ** f)
+xfclose(FILE **f)
{
int retval = EOF;
* Returns fclose()'s return value.
* WARNING: do NOT call from log.c to avoid potential infinite loops! */
int
-xfclose_check(FILE ** f, const char *filedesc)
+xfclose_check(FILE **f, const char *filedesc)
{
int retval = EOF;
#ifdef HAVE_LIBPAM
void
-die_mail_pame(cl_t * cl, int pamerrno, struct passwd *pas, char *str,
- env_list_t * env)
+die_mail_pame(cl_t *cl, int pamerrno, struct passwd *pas, char *str,
+ env_list_t *env)
/* log an error in syslog, mail user if necessary, and die */
{
char buf[MAX_MSG];
}
FILE *
-create_mail(cl_t * line, char *subject, char *content_type, char *encoding,
+create_mail(cl_t *line, char *subject, char *content_type, char *encoding,
char **env)
/* create a temp file and write in it a mail header */
{
#endif /* HAVE_GETHOSTNAME */
/* write mail header. Global 'maildisplayname' comes from fcronconf.h */
- if (maildisplayname[0] != '\0'){
+ if (maildisplayname[0] != '\0') {
/* New behavior -- RFC-compliant */
- mailbox_addr = make_mailbox_addr(maildisplayname, mailfrom, hostname_from);
- if (! mailbox_addr) {
+ mailbox_addr =
+ make_mailbox_addr(maildisplayname, mailfrom, hostname_from);
+ if (!mailbox_addr) {
warn("could not make the mailbox address");
}
}
if (mailbox_addr) {
- fprintf(mailf, FROM_HEADER_KEY"%s\n", mailbox_addr);
+ fprintf(mailf, FROM_HEADER_KEY "%s\n", mailbox_addr);
Free_safe(mailbox_addr);
}
else {
/* Old behavior */
- fprintf(mailf, FROM_HEADER_KEY"%s%s (fcron)\n", mailfrom, hostname_from);
+ fprintf(mailf, FROM_HEADER_KEY "%s%s (fcron)\n", mailfrom,
+ hostname_from);
}
fprintf(mailf, "To: %s%s\n", line->cl_mailto, hostname_to);
}
void
-run_job_grand_child_setup_stderr_stdout(cl_t * line, int *pipe_fd)
+run_job_grand_child_setup_stderr_stdout(cl_t *line, int *pipe_fd)
/* setup stderr and stdout correctly so as the mail containing
* the output of the job can be send at the end of the job.
* Close the pipe (both ways). */
}
void
-run_job_grand_child_setup_nice(cl_t * line)
+run_job_grand_child_setup_nice(cl_t *line)
/* set the nice value for the job */
{
if (line->cl_nice != 0) {
}
void
-end_job(cl_t * line, int status, FILE * mailf, short mailpos,
- char **sendmailenv)
+end_job(cl_t *line, int status, FILE *mailf, short mailpos, char **sendmailenv)
/* if task have made some output, mail it to user */
{
}
void
-launch_mailer(cl_t * line, FILE * mailf, char **sendmailenv)
+launch_mailer(cl_t *line, FILE *mailf, char **sendmailenv)
/* mail the output of a job to user */
{
#ifdef USE_SENDMAIL
#ifndef __JOB_H__
#define __JOB_H__
-#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */
+#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */
#define FROM_HEADER_KEY "From: "
/* functions prototypes */
}
lavg_t *
-lavg_list_add_line(lavg_list_t * list, struct cl_t * line)
+lavg_list_add_line(lavg_list_t *list, struct cl_t *line)
{
lavg_t e = { NULL, 0 };
e.l_line = line; /* ANSI C does not allow us to directly replace NULL by line above */
}
lavg_t *
-lavg_list_add(lavg_list_t * list, lavg_t * entry)
+lavg_list_add(lavg_list_t *list, lavg_t *entry)
{
return (lavg_t *) u_list_add((u_list_t *) list, (u_list_entry_t *) entry);
}
lavg_t *
-lavg_list_first(lavg_list_t * list)
+lavg_list_first(lavg_list_t *list)
{
return (lavg_t *) u_list_first((u_list_t *) list);
}
lavg_t *
-lavg_list_next(lavg_list_t * list)
+lavg_list_next(lavg_list_t *list)
{
return (lavg_t *) u_list_next((u_list_t *) list);
}
void
-lavg_list_end_iteration(lavg_list_t * list)
+lavg_list_end_iteration(lavg_list_t *list)
{
u_list_end_iteration((u_list_t *) list);
}
void
-lavg_list_remove_cur(lavg_list_t * list)
+lavg_list_remove_cur(lavg_list_t *list)
{
u_list_remove_cur((u_list_t *) list);
}
lavg_list_t *
-lavg_list_destroy(lavg_list_t * list)
+lavg_list_destroy(lavg_list_t *list)
{
return (lavg_list_t *) u_list_destroy((u_list_t *) list);
}
/* write a message to the file specified by logfile. */
static void
-print_line_prefix(FILE * logfile, int priority)
+print_line_prefix(FILE *logfile, int priority)
{
time_t t = time(NULL);
struct tm *ft;
/* Same as log_syslog(), but also appends an error description corresponding
* to the pam_error. */
static void
-log_pame(int priority, pam_handle_t * pamh, int pamerrno, char *fmt,
+log_pame(int priority, pam_handle_t *pamh, int pamerrno, char *fmt,
va_list args)
{
char *msg;
#ifdef HAVE_LIBPAM
/* Log a "complain" level message, with a PAM error description */
void
-error_pame(pam_handle_t * pamh, int pamerrno, char *fmt, ...)
+error_pame(pam_handle_t *pamh, int pamerrno, char *fmt, ...)
{
va_list args;
#ifdef HAVE_LIBPAM
/* Log a "complain" level message, with a PAM error description, and exit */
void
-die_pame(pam_handle_t * pamh, int pamerrno, char *fmt, ...)
+die_pame(pam_handle_t *pamh, int pamerrno, char *fmt, ...)
{
va_list args;
#include "fcron.h"
#include "mail.h"
-char
-*format_maildisplayname(char *displayname_conf)
+char *
+format_maildisplayname(char *displayname_conf)
/* Format the input string `conf_value` according to RFC5322 sec. 3.2.3.
* <https://datatracker.ietf.org/doc/html/rfc5322#section-3.2.3>.
* Returns: either the formatted displayname (possibly unchanged or empty)
{
bool need_quotes = false;
char c = '\0';
- char *ipos = NULL; /* Input position */
+ char *ipos = NULL; /* Input position */
char *output = NULL, *quoted_output = NULL;
const uint buf_len = MAIL_FROM_VALUE_LEN_MAX;
- uint cwritten = 0; /* how many chars we have written */
+ uint cwritten = 0; /* how many chars we have written */
- if (strlen(displayname_conf) == 0) return strdup2("");
+ if (strlen(displayname_conf) == 0) {
+ return strdup2("");
+ }
output = (char *)alloc_safe(buf_len * sizeof(char), "output buffer");
}
if (need_quotes) {
- quoted_output = (char *)alloc_safe(buf_len * sizeof(char), "quoted output buffer");
+ quoted_output =
+ (char *)alloc_safe(buf_len * sizeof(char), "quoted output buffer");
int needed_len = snprintf(quoted_output, buf_len, "\"%s\"", output);
- if (needed_len >= buf_len){
- error("Formatted 'displayname' too long: length:%u > max:%u chars", needed_len, buf_len);
+ if (needed_len >= buf_len) {
+ error("Formatted 'displayname' too long: length:%u > max:%u chars",
+ needed_len, buf_len);
Free_safe(output);
Free_safe(quoted_output);
return NULL;
uint written = 0;
bool need_anglebrackets = false;
- const uint buf_len = MAIL_FROM_VALUE_LEN_MAX+1;
+ const uint buf_len = MAIL_FROM_VALUE_LEN_MAX + 1;
buf = (char *)alloc_safe(buf_len * sizeof(char), "mailbox addr buffer");
#ifndef __MAIL_H__
#define __MAIL_H__
-#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */
+#define MAIL_LINE_LEN_MAX 998 /* RFC5322's max line length */
#define FROM_HEADER_KEY "From: "
#define MAIL_FROM_VALUE_LEN_MAX (MAIL_LINE_LEN_MAX - sizeof(FROM_HEADER_KEY))
extern char *format_maildisplayname(char *displayname_conf);
-extern char *make_mailbox_addr(char *displayname_conf, char *mail_from, char *hostname);
+extern char *make_mailbox_addr(char *displayname_conf, char *mail_from,
+ char *hostname);
#endif /* __MAIL_H__ */
int
-save_one_file(cf_t * file, char *filename, uid_t own_uid, gid_t own_gid,
+save_one_file(cf_t *file, char *filename, uid_t own_uid, gid_t own_gid,
time_t save_date)
/* save a given file to disk */
{
int
-save_file_safe(cf_t * file, char *final_path, char *prog_name, uid_t own_uid,
+save_file_safe(cf_t *file, char *final_path, char *prog_name, uid_t own_uid,
gid_t own_gid, time_t save_date)
/* save a file to a temp path, and then rename it (safely) to avoid loss of data
* if a system crash, hardware failure, etc happens. */
}
void
-select_add_read(select_instance * si, int fd)
+select_add_read(select_instance *si, int fd)
/* Add a fd to the read set */
{
FD_SET(fd, &si->__readfds_master);
}
void
-select_rm_read(select_instance * si, int fd)
+select_rm_read(select_instance *si, int fd)
/* remove a fd to the read set */
{
FD_CLR(fd, &si->__readfds_master);
char buf[PATH_LEN];
snprintf(buf, sizeof(buf) - 1, "%s=%s", name, value)
-
/* The final \0 may not have been copied because of lack of space:
* add it to make sure */
buf[sizeof(buf) - 1] = '\0';
}
void
-init_suspend(select_instance * si)
+init_suspend(select_instance *si)
{
#if defined(CLOCK_BOOTTIME) && defined(CLOCK_MONOTONIC)
void
check_suspend(time_t slept_from, time_t nwt, bool *sig_cont,
- select_instance * si)
+ select_instance *si)
/* Check if the machine was suspended (to mem or disk), and if so
* reschedule jobs accordingly */
{
long int scheduled_sleep = nwt - slept_from;
explain("suspend/hibernate detected: The system was suspended for "
- "%lus (and we woke up after %lus instead of our intended %lus sleep).",
- suspend_duration, actual_sleep, scheduled_sleep);
+ "%lus (and we woke up after %lus instead of our intended %lus sleep).",
+ suspend_duration, actual_sleep, scheduled_sleep);
reschedule_all_on_resume(suspend_duration);
}
}
}
u_list_t *
-u_list_copy(u_list_t * list)
+u_list_copy(u_list_t *list)
{
u_list_t *new_list = NULL;
int
-u_list_resize_array(u_list_t * l)
+u_list_resize_array(u_list_t *l)
/* Resize l's entries_array up to l->max_entries
* Returns OK on success, ERR if the array is already at maximum size */
{
}
u_list_entry_t *
-u_list_last(u_list_t * l)
+u_list_last(u_list_t *l)
/* Returns the pointer of the last entry in the list, or NULL if l is empty */
{
if (l->num_entries <= 0)
}
u_list_entry_t *
-u_list_add(u_list_t * l, u_list_entry_t * e)
+u_list_add(u_list_t *l, u_list_entry_t *e)
/* Add one entry to the list
* Returns a pointer to the added element, or NULL if list is already at max size */
{
}
int
-u_list_is_iterating(u_list_t * l)
+u_list_is_iterating(u_list_t *l)
{
/* sanity check */
if (l == NULL)
}
u_list_entry_t *
-u_list_first(u_list_t * l)
+u_list_first(u_list_t *l)
/* Return the first entry of the list (then u_list_next() can be used) */
{
/* sanity check */
}
u_list_entry_t *
-u_list_next(u_list_t * l)
+u_list_next(u_list_t *l)
/* Return the entry after e */
{
/* sanity checks */
}
void
-u_list_end_iteration(u_list_t * list)
+u_list_end_iteration(u_list_t *list)
/* Stop an iteration before _next() reached the end of the list by itself */
{
list->cur_entry = NULL;
void
-u_list_remove_cur(u_list_t * l)
+u_list_remove_cur(u_list_t *l)
{
u_list_entry_t *last = NULL;
}
u_list_t *
-u_list_destroy(u_list_t * list)
+u_list_destroy(u_list_t *list)
/* free() the memory allocated for list and returns NULL */
{
if (list == NULL)