-/* $OpenBSD: cron.c,v 1.50 2015/01/23 01:03:03 tedu Exp $ */
+/* $OpenBSD: cron.c,v 1.51 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
static double batch_maxload = BATCH_MAXLOAD;
static void
-usage(void) {
+usage(void)
+{
fprintf(stderr, "usage: %s [-n] [-l load_avg]\n", ProgramName);
exit(EXIT_FAILURE);
}
int
-main(int argc, char *argv[]) {
+main(int argc, char *argv[])
+{
struct sigaction sact;
int fd;
}
static void
-run_reboot_jobs(cron_db *db) {
+run_reboot_jobs(cron_db *db)
+{
user *u;
entry *e;
}
static void
-find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild) {
+find_jobs(time_t vtime, cron_db *db, int doWild, int doNonWild)
+{
time_t virtualSecond = vtime * SECONDS_PER_MINUTE;
struct tm *tm = gmtime(&virtualSecond);
int minute, hour, dom, month, dow;
* Note that clockTime is a unix wallclock time converted to minutes.
*/
static void
-set_time(int initialize) {
+set_time(int initialize)
+{
struct tm tm;
static int isdst;
* Try to just hit the next minute.
*/
static void
-cron_sleep(time_t target) {
+cron_sleep(time_t target)
+{
int fd, nfds;
unsigned char poke;
struct timeval t1, t2, tv;
}
static void
-sighup_handler(int x) {
+sighup_handler(int x)
+{
got_sighup = 1;
}
static void
-sigchld_handler(int x) {
+sigchld_handler(int x)
+{
got_sigchld = 1;
}
static void
-quit(int x) {
+quit(int x)
+{
(void) unlink(_PATH_CRON_PID);
_exit(0);
}
static void
-sigchld_reaper(void) {
+sigchld_reaper(void)
+{
int waiter;
pid_t pid;
}
static void
-parse_args(int argc, char *argv[]) {
+parse_args(int argc, char *argv[])
+{
int argch;
char *ep;
-/* $OpenBSD: crontab.c,v 1.69 2015/01/23 02:37:25 tedu Exp $ */
+/* $OpenBSD: crontab.c,v 1.70 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
static int replace_cmd(void);
static void
-usage(const char *msg) {
+usage(const char *msg)
+{
fprintf(stderr, "%s: usage error: %s\n", ProgramName, msg);
fprintf(stderr, "usage: %s [-u user] file\n", ProgramName);
fprintf(stderr, " %s [-e | -l | -r] [-u user]\n", ProgramName);
}
int
-main(int argc, char *argv[]) {
+main(int argc, char *argv[])
+{
int exitstatus;
Pid = getpid();
}
static void
-parse_args(int argc, char *argv[]) {
+parse_args(int argc, char *argv[])
+{
int argch;
if (!(pw = getpwuid(getuid()))) {
}
static void
-list_cmd(void) {
+list_cmd(void)
+{
char n[MAX_FNAME];
FILE *f;
}
static void
-delete_cmd(void) {
+delete_cmd(void)
+{
char n[MAX_FNAME];
log_it(RealUser, Pid, "DELETE", User);
}
static void
-check_error(const char *msg) {
+check_error(const char *msg)
+{
CheckErrorCount++;
fprintf(stderr, "\"%s\":%d: %s\n", Filename, LineNumber-1, msg);
}
static void
-edit_cmd(void) {
+edit_cmd(void)
+{
char n[MAX_FNAME], q[MAX_TEMPSTR];
const char *tmpdir;
FILE *f;
* -2 on install error
*/
static int
-replace_cmd(void) {
+replace_cmd(void)
+{
char n[MAX_FNAME], envstr[MAX_ENVSTR];
FILE *tmp;
int ch, eof, fd;
}
static void
-die(int x) {
+die(int x)
+{
if (TempFilename[0])
(void) unlink(TempFilename);
_exit(EXIT_FAILURE);
}
static void
-copy_crontab(FILE *f, FILE *out) {
+copy_crontab(FILE *f, FILE *out)
+{
int ch, x;
/* ignore the top few comments since we probably put them there.
-/* $OpenBSD: database.c,v 1.23 2015/01/23 02:37:25 tedu Exp $ */
+/* $OpenBSD: database.c,v 1.24 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
cron_db *, cron_db *);
void
-load_database(cron_db *old_db) {
+load_database(cron_db *old_db)
+{
struct stat statbuf, syscron_stat;
cron_db new_db;
struct dirent *dp;
}
void
-link_user(cron_db *db, user *u) {
+link_user(cron_db *db, user *u)
+{
if (db->head == NULL)
db->head = u;
if (db->tail)
}
void
-unlink_user(cron_db *db, user *u) {
+unlink_user(cron_db *db, user *u)
+{
if (u->prev == NULL)
db->head = u->next;
else
}
user *
-find_user(cron_db *db, const char *name) {
+find_user(cron_db *db, const char *name)
+{
user *u;
for (u = db->head; u != NULL; u = u->next)
-/* $OpenBSD: do_command.c,v 1.44 2015/01/23 02:37:25 tedu Exp $ */
+/* $OpenBSD: do_command.c,v 1.45 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
static void child_process(entry *, user *);
void
-do_command(entry *e, user *u) {
+do_command(entry *e, user *u)
+{
/* fork to become asynchronous -- parent process is done immediately,
* and continues to run the normal cron code, which means return to
}
static void
-child_process(entry *e, user *u) {
+child_process(entry *e, user *u)
+{
FILE *in;
int stdin_pipe[2], stdout_pipe[2];
char *input_data, *usernm;
}
int
-safe_p(const char *usernm, const char *s) {
+safe_p(const char *usernm, const char *s)
+{
static const char safe_delim[] = "@!:%+-.,"; /* conservative! */
const char *t;
int ch, first;
-/* $OpenBSD: entry.c,v 1.38 2015/01/23 02:37:25 tedu Exp $ */
+/* $OpenBSD: entry.c,v 1.39 2015/01/23 19:07:27 tedu Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
set_element(bitstr_t *, int, int, int);
void
-free_entry(entry *e) {
+free_entry(entry *e)
+{
free(e->cmd);
free(e->pwd);
if (e->envp)
*/
entry *
load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw,
- char **envp) {
+ char **envp)
+{
/* this function reads one crontab entry -- the next -- from a file.
* it skips any leading blank lines, ignores comments, and returns
* NULL if for any reason the entry can't be read and parsed.
static int
get_number(int *numptr, int low, const char *names[], int ch, FILE *file,
- const char *terms) {
+ const char *terms)
+{
char temp[MAX_TEMPSTR], *pc;
int len, i;
}
static int
-set_element(bitstr_t *bits, int low, int high, int number) {
+set_element(bitstr_t *bits, int low, int high, int number)
+{
if (number < low || number > high)
return (EOF);
-/* $OpenBSD: env.c,v 1.27 2015/01/23 02:37:25 tedu Exp $ */
+/* $OpenBSD: env.c,v 1.28 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
#include "cron.h"
char **
-env_init(void) {
+env_init(void)
+{
char **p = malloc(sizeof(char **));
if (p != NULL)
}
void
-env_free(char **envp) {
+env_free(char **envp)
+{
char **p;
for (p = envp; *p != NULL; p++)
}
char **
-env_copy(char **envp) {
+env_copy(char **envp)
+{
int count, i, save_errno;
char **p;
}
char **
-env_set(char **envp, char *envstr) {
+env_set(char **envp, char *envstr)
+{
int count, found;
char **p, *envtmp;
* TRUE = was an env setting
*/
int
-load_env(char *envstr, FILE *f) {
+load_env(char *envstr, FILE *f)
+{
long filepos;
int fileline;
enum env_state state;
}
char *
-env_get(char *name, char **envp) {
+env_get(char *name, char **envp)
+{
int len = strlen(name);
char *p, *q;
-/* $OpenBSD: job.c,v 1.9 2015/01/22 22:38:55 tedu Exp $ */
+/* $OpenBSD: job.c,v 1.10 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
static job *jhead = NULL, *jtail = NULL;
void
-job_add(entry *e, user *u) {
+job_add(entry *e, user *u)
+{
job *j;
/* if already on queue, keep going */
}
int
-job_runqueue(void) {
+job_runqueue(void)
+{
job *j, *jn;
int run = 0;
-/* $OpenBSD: misc.c,v 1.53 2015/01/23 02:37:25 tedu Exp $ */
+/* $OpenBSD: misc.c,v 1.54 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
#endif
int
-strcmp_until(const char *left, const char *right, char until) {
+strcmp_until(const char *left, const char *right, char until)
+{
while (*left && *left != until && *left == *right) {
left++;
right++;
}
void
-set_cron_uid(void) {
+set_cron_uid(void)
+{
if (seteuid(ROOT_UID) < 0) {
perror("seteuid");
exit(EXIT_FAILURE);
}
void
-set_cron_cwd(void) {
+set_cron_cwd(void)
+{
struct stat sb;
struct group *grp = NULL;
* can rewrite our PID into _PATH_CRON_PID after the fork.
*/
void
-acquire_daemonlock(int closeflag) {
+acquire_daemonlock(int closeflag)
+{
static int fd = -1;
char buf[3*MAX_FNAME];
const char *pidfile;
/* get_char(file) : like getc() but increment LineNumber on newlines
*/
int
-get_char(FILE *file) {
+get_char(FILE *file)
+{
int ch;
ch = getc(file);
/* unget_char(ch, file) : like ungetc but do LineNumber processing
*/
void
-unget_char(int ch, FILE *file) {
+unget_char(int ch, FILE *file)
+{
ungetc(ch, file);
if (ch == '\n')
Set_LineNum(LineNumber - 1)
* (4) returns EOF or terminating character, whichever
*/
int
-get_string(char *string, int size, FILE *file, char *terms) {
+get_string(char *string, int size, FILE *file, char *terms)
+{
int ch;
while (EOF != (ch = get_char(file)) && !strchr(terms, ch)) {
/* skip_comments(file) : read past comment (if any)
*/
void
-skip_comments(FILE *file) {
+skip_comments(FILE *file)
+{
int ch;
while (EOF != (ch = get_char(file))) {
* root is always allowed.
*/
int
-allowed(const char *username, const char *allow_file, const char *deny_file) {
+allowed(const char *username, const char *allow_file, const char *deny_file)
+{
FILE *fp;
int isallowed;
}
void
-log_it(const char *username, pid_t xpid, const char *event, const char *detail) {
+log_it(const char *username, pid_t xpid, const char *event, const char *detail)
+{
#if defined(LOG_FILE) || DEBUGGING
pid_t pid = xpid;
#endif
}
void
-log_close(void) {
+log_close(void)
+{
if (LogFD != -1) {
close(LogFD);
LogFD = -1;
* (2) it returns a pointer to static storage
*/
char *
-first_word(char *s, char *t) {
+first_word(char *s, char *t)
+{
static char retbuf[2][MAX_TEMPSTR + 1]; /* sure wish C had GC */
static int retsel = 0;
char *rb, *rp;
}
void
-poke_daemon(const char *spool_dir, unsigned char cookie) {
+poke_daemon(const char *spool_dir, unsigned char cookie)
+{
int sock = -1;
struct sockaddr_un s_un;
-/* $OpenBSD: popen.c,v 1.24 2015/01/14 17:27:51 millert Exp $ */
+/* $OpenBSD: popen.c,v 1.25 2015/01/23 19:07:27 tedu Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
static int fds;
FILE *
-cron_popen(char *program, char *type, struct passwd *pw) {
+cron_popen(char *program, char *type, struct passwd *pw)
+{
char *cp;
FILE *iop;
int argc, pdes[2];
}
int
-cron_pclose(FILE *iop) {
+cron_pclose(FILE *iop)
+{
int fdes;
pid_t pid;
int status;
-/* $OpenBSD: user.c,v 1.12 2015/01/23 18:52:31 tedu Exp $ */
+/* $OpenBSD: user.c,v 1.13 2015/01/23 19:07:27 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
#include "cron.h"
void
-free_user(user *u) {
+free_user(user *u)
+{
entry *e, *ne;
free(u->name);
}
user *
-load_user(int crontab_fd, struct passwd *pw, const char *name) {
+load_user(int crontab_fd, struct passwd *pw, const char *name)
+{
char envstr[MAX_ENVSTR];
FILE *file;
user *u;