diff options
author | millert <millert@openbsd.org> | 2015-11-09 16:37:07 +0000 |
---|---|---|
committer | millert <millert@openbsd.org> | 2015-11-09 16:37:07 +0000 |
commit | 22126b7b4bcf7f9cccff79091ea525766ec8d684 (patch) | |
tree | 5ddc20eeb9168ad1ba8b878ea19c6705d5f65fe7 /usr.sbin/cron | |
parent | 3 pledge calls; 2 are for secure mode and will help track down if this (diff) | |
download | wireguard-openbsd-22126b7b4bcf7f9cccff79091ea525766ec8d684.tar.xz wireguard-openbsd-22126b7b4bcf7f9cccff79091ea525766ec8d684.zip |
Remove unused xpid argument to log_it().
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r-- | usr.sbin/cron/atrun.c | 40 | ||||
-rw-r--r-- | usr.sbin/cron/cron.c | 20 | ||||
-rw-r--r-- | usr.sbin/cron/crontab.c | 16 | ||||
-rw-r--r-- | usr.sbin/cron/database.c | 22 | ||||
-rw-r--r-- | usr.sbin/cron/do_command.c | 12 | ||||
-rw-r--r-- | usr.sbin/cron/entry.c | 10 | ||||
-rw-r--r-- | usr.sbin/cron/funcs.h | 4 | ||||
-rw-r--r-- | usr.sbin/cron/misc.c | 4 |
8 files changed, 63 insertions, 65 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c index 96d55d23e0b..132ea1c500b 100644 --- a/usr.sbin/cron/atrun.c +++ b/usr.sbin/cron/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.37 2015/11/09 15:57:39 millert Exp $ */ +/* $OpenBSD: atrun.c,v 1.38 2015/11/09 16:37:07 millert Exp $ */ /* * Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -66,11 +66,11 @@ scan_atjobs(at_db **db, struct timespec *ts) struct stat sb; if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1) { - log_it("CRON", getpid(), "OPEN FAILED", AT_SPOOL); + log_it("CRON", "OPEN FAILED", AT_SPOOL); return (0); } if (fstat(dfd, &sb) != 0) { - log_it("CRON", getpid(), "FSTAT FAILED", AT_SPOOL); + log_it("CRON", "FSTAT FAILED", AT_SPOOL); close(dfd); return (0); } @@ -80,7 +80,7 @@ scan_atjobs(at_db **db, struct timespec *ts) } if ((atdir = fdopendir(dfd)) == NULL) { - log_it("CRON", getpid(), "OPENDIR FAILED", AT_SPOOL); + log_it("CRON", "OPENDIR FAILED", AT_SPOOL); close(dfd); return (0); } @@ -222,7 +222,7 @@ run_job(atjob *job, char *atfile) /* Open the file and unlink it so we don't try running it again. */ if ((fd = open(atfile, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) < 0) { - log_it("CRON", getpid(), "CAN'T OPEN", atfile); + log_it("CRON", "CAN'T OPEN", atfile); return; } unlink(atfile); @@ -238,7 +238,7 @@ run_job(atjob *job, char *atfile) break; case -1: /* error */ - log_it("CRON", getpid(), "error", "can't fork"); + log_it("CRON", "error", "can't fork"); /* FALLTHROUGH */ default: /* parent */ @@ -257,39 +257,39 @@ run_job(atjob *job, char *atfile) */ pw = getpwuid(job->uid); if (pw == NULL) { - log_it("CRON", getpid(), "ORPHANED JOB", atfile); + log_it("CRON", "ORPHANED JOB", atfile); _exit(EXIT_FAILURE); } if (pw->pw_expire && time(NULL) >= pw->pw_expire) { - log_it(pw->pw_name, getpid(), "ACCOUNT EXPIRED, JOB ABORTED", + log_it(pw->pw_name, "ACCOUNT EXPIRED, JOB ABORTED", atfile); _exit(EXIT_FAILURE); } /* Sanity checks */ if (fstat(fd, &sb) < 0) { - log_it(pw->pw_name, getpid(), "FSTAT FAILED", atfile); + log_it(pw->pw_name, "FSTAT FAILED", atfile); _exit(EXIT_FAILURE); } if (!S_ISREG(sb.st_mode)) { - log_it(pw->pw_name, getpid(), "NOT REGULAR", atfile); + log_it(pw->pw_name, "NOT REGULAR", atfile); _exit(EXIT_FAILURE); } if ((sb.st_mode & ALLPERMS) != (S_IRUSR | S_IWUSR | S_IXUSR)) { - log_it(pw->pw_name, getpid(), "BAD FILE MODE", atfile); + log_it(pw->pw_name, "BAD FILE MODE", atfile); _exit(EXIT_FAILURE); } if (sb.st_uid != 0 && sb.st_uid != job->uid) { - log_it(pw->pw_name, getpid(), "WRONG FILE OWNER", atfile); + log_it(pw->pw_name, "WRONG FILE OWNER", atfile); _exit(EXIT_FAILURE); } if (sb.st_nlink > 1) { - log_it(pw->pw_name, getpid(), "BAD LINK COUNT", atfile); + log_it(pw->pw_name, "BAD LINK COUNT", atfile); _exit(EXIT_FAILURE); } if ((fp = fdopen(dup(fd), "r")) == NULL) { - log_it("CRON", getpid(), "error", "dup(2) failed"); + log_it("CRON", "error", "dup(2) failed"); _exit(EXIT_FAILURE); } @@ -343,11 +343,11 @@ run_job(atjob *job, char *atfile) if (!safe_p(pw->pw_name, mailto)) _exit(EXIT_FAILURE); if ((uid_t)nuid != job->uid) { - log_it(pw->pw_name, getpid(), "UID MISMATCH", atfile); + log_it(pw->pw_name, "UID MISMATCH", atfile); _exit(EXIT_FAILURE); } if ((gid_t)ngid != job->gid) { - log_it(pw->pw_name, getpid(), "GID MISMATCH", atfile); + log_it(pw->pw_name, "GID MISMATCH", atfile); _exit(EXIT_FAILURE); } @@ -359,12 +359,12 @@ run_job(atjob *job, char *atfile) /* Fork again, child will run the job, parent will catch output. */ switch ((pid = fork())) { case -1: - log_it("CRON", getpid(), "error", "can't fork"); + log_it("CRON", "error", "can't fork"); _exit(EXIT_FAILURE); /*NOTREACHED*/ case 0: /* Write log message now that we have our real pid. */ - log_it(pw->pw_name, getpid(), "ATJOB", atfile); + log_it(pw->pw_name, "ATJOB", atfile); /* Close log file (or syslog) */ log_close(); @@ -498,7 +498,7 @@ run_job(atjob *job, char *atfile) snprintf(buf, sizeof(buf), "mailed %lu byte%s of output" " but got status 0x%04x\n", (unsigned long)bytes, (bytes == 1) ? "" : "s", status); - log_it(pw->pw_name, getpid(), "MAIL", buf); + log_it(pw->pw_name, "MAIL", buf); } } @@ -521,6 +521,6 @@ run_job(atjob *job, char *atfile) _exit(EXIT_SUCCESS); bad_file: - log_it(pw->pw_name, getpid(), "BAD FILE FORMAT", atfile); + log_it(pw->pw_name, "BAD FILE FORMAT", atfile); _exit(EXIT_FAILURE); } diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index 4e00df83aae..ffef86492ac 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.65 2015/11/09 15:57:39 millert Exp $ */ +/* $OpenBSD: cron.c,v 1.66 2015/11/09 16:37:07 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -101,21 +101,21 @@ main(int argc, char *argv[]) if (pledge("stdio rpath wpath cpath fattr getpw unix flock id dns proc exec", NULL) == -1) - log_it("CRON", getpid(), "pledge", strerror(errno)); + log_it("CRON", "pledge", strerror(errno)); cronSock = open_socket(); if (putenv("PATH="_PATH_DEFPATH) < 0) { - log_it("CRON", getpid(), "DEATH", "can't malloc"); + log_it("CRON", "DEATH", "can't malloc"); exit(EXIT_FAILURE); } if (NoFork == 0) { if (daemon(1, 0) == -1) { - log_it("CRON",getpid(),"DEATH","can't fork"); + log_it("CRON", "DEATH", "can't fork"); exit(EXIT_FAILURE); } - log_it("CRON",getpid(),"STARTUP",CRON_VERSION); + log_it("CRON", "STARTUP", CRON_VERSION); } load_database(&database); @@ -425,21 +425,21 @@ open_socket(void) if (sock == -1) { fprintf(stderr, "%s: can't create socket: %s\n", __progname, strerror(errno)); - log_it("CRON", getpid(), "DEATH", "can't create socket"); + log_it("CRON", "DEATH", "can't create socket"); exit(EXIT_FAILURE); } bzero(&s_un, sizeof(s_un)); if (snprintf(s_un.sun_path, sizeof(s_un.sun_path), "%s/%s", CRON_SPOOL, CRONSOCK) >= sizeof(s_un.sun_path)) { fprintf(stderr, "%s/%s: path too long\n", CRON_SPOOL, CRONSOCK); - log_it("CRON", getpid(), "DEATH", "path too long"); + log_it("CRON", "DEATH", "path too long"); exit(EXIT_FAILURE); } s_un.sun_family = AF_UNIX; if (connect(sock, (struct sockaddr *)&s_un, sizeof(s_un)) == 0) { fprintf(stderr, "%s: already running\n", __progname); - log_it("CRON", getpid(), "DEATH", "already running"); + log_it("CRON", "DEATH", "already running"); exit(EXIT_FAILURE); } if (errno != ENOENT) @@ -451,13 +451,13 @@ open_socket(void) if (rc != 0) { fprintf(stderr, "%s: can't bind socket: %s\n", __progname, strerror(errno)); - log_it("CRON", getpid(), "DEATH", "can't bind socket"); + log_it("CRON", "DEATH", "can't bind socket"); exit(EXIT_FAILURE); } if (listen(sock, SOMAXCONN)) { fprintf(stderr, "%s: can't listen on socket: %s\n", __progname, strerror(errno)); - log_it("CRON", getpid(), "DEATH", "can't listen on socket"); + log_it("CRON", "DEATH", "can't listen on socket"); exit(EXIT_FAILURE); } chmod(s_un.sun_path, 0660); diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index bf42a4d9309..99f8ea07087 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.84 2015/11/09 15:57:39 millert Exp $ */ +/* $OpenBSD: crontab.c,v 1.85 2015/11/09 16:37:07 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -43,7 +43,6 @@ enum opt_t { opt_unknown, opt_list, opt_delete, opt_edit, opt_replace }; -static pid_t Pid; static gid_t crontab_gid; static gid_t user_gid; static char User[MAX_UNAME], RealUser[MAX_UNAME]; @@ -81,7 +80,6 @@ main(int argc, char *argv[]) { int exitstatus; - Pid = getpid(); user_gid = getgid(); crontab_gid = getegid(); @@ -101,7 +99,7 @@ main(int argc, char *argv[]) "You (%s) are not allowed to use this program (%s)\n", User, __progname); fprintf(stderr, "See crontab(1) for more information\n"); - log_it(RealUser, Pid, "AUTH", "crontab command not allowed"); + log_it(RealUser, "AUTH", "crontab command not allowed"); exit(EXIT_FAILURE); } exitstatus = EXIT_SUCCESS; @@ -235,7 +233,7 @@ list_cmd(void) char n[MAX_FNAME]; FILE *f; - log_it(RealUser, Pid, "LIST", User); + log_it(RealUser, "LIST", User); if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) { fprintf(stderr, "path too long\n"); exit(EXIT_FAILURE); @@ -261,7 +259,7 @@ delete_cmd(void) { char n[MAX_FNAME]; - log_it(RealUser, Pid, "DELETE", User); + log_it(RealUser, "DELETE", User); if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) { fprintf(stderr, "path too long\n"); exit(EXIT_FAILURE); @@ -292,7 +290,7 @@ edit_cmd(void) struct stat statbuf, xstatbuf; struct timespec ts[2]; - log_it(RealUser, Pid, "BEGIN EDIT", User); + log_it(RealUser, "BEGIN EDIT", User); if (snprintf(n, sizeof n, "%s/%s", CRON_SPOOL, User) >= sizeof(n)) { fprintf(stderr, "path too long\n"); exit(EXIT_FAILURE); @@ -420,7 +418,7 @@ edit_cmd(void) remove: unlink(Filename); done: - log_it(RealUser, Pid, "END EDIT", User); + log_it(RealUser, "END EDIT", User); } /* returns 0 on success @@ -549,7 +547,7 @@ replace_cmd(void) goto done; } TempFilename[0] = '\0'; - log_it(RealUser, Pid, "REPLACE", User); + log_it(RealUser, "REPLACE", User); poke_daemon(CRON_SPOOL, RELOAD_CRON); diff --git a/usr.sbin/cron/database.c b/usr.sbin/cron/database.c index 6a4227e2d47..332ead7ad1f 100644 --- a/usr.sbin/cron/database.c +++ b/usr.sbin/cron/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.30 2015/11/09 15:57:39 millert Exp $ */ +/* $OpenBSD: database.c,v 1.31 2015/11/09 16:37:07 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -56,7 +56,7 @@ load_database(cron_db **db) * cached any of the database), we'll see the changes next time. */ if (stat(CRON_SPOOL, &statbuf) < 0) { - log_it("CRON", getpid(), "STAT FAILED", CRON_SPOOL); + log_it("CRON", "STAT FAILED", CRON_SPOOL); return; } @@ -93,7 +93,7 @@ load_database(cron_db **db) * we fork a lot more often than the mtime of the dir changes. */ if (!(dir = opendir(CRON_SPOOL))) { - log_it("CRON", getpid(), "OPENDIR FAILED", CRON_SPOOL); + log_it("CRON", "OPENDIR FAILED", CRON_SPOOL); /* Restore system crontab entry as needed. */ if (!TAILQ_EMPTY(&new_db->users) && (u = TAILQ_FIRST(&old_db->users))) { @@ -181,39 +181,39 @@ process_crontab(const char *uname, const char *fname, const char *tabname, } else if ((pw = getpwnam(uname)) == NULL) { /* file doesn't have a user in passwd file. */ - log_it(fname, getpid(), "ORPHAN", "no passwd entry"); + log_it(fname, "ORPHAN", "no passwd entry"); goto next_crontab; } if ((crontab_fd = open(tabname, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) < 0) { /* crontab not accessible? */ - log_it(fname, getpid(), "CAN'T OPEN", tabname); + log_it(fname, "CAN'T OPEN", tabname); goto next_crontab; } if (fstat(crontab_fd, statbuf) < 0) { - log_it(fname, getpid(), "FSTAT FAILED", tabname); + log_it(fname, "FSTAT FAILED", tabname); goto next_crontab; } if (!S_ISREG(statbuf->st_mode)) { - log_it(fname, getpid(), "NOT REGULAR", tabname); + log_it(fname, "NOT REGULAR", tabname); goto next_crontab; } if ((statbuf->st_mode & 07577) != 0400) { /* Looser permissions on system crontab. */ if (pw != NULL || (statbuf->st_mode & 022) != 0) { - log_it(fname, getpid(), "BAD FILE MODE", tabname); + log_it(fname, "BAD FILE MODE", tabname); goto next_crontab; } } if (statbuf->st_uid != 0 && (pw == NULL || statbuf->st_uid != pw->pw_uid || strcmp(uname, pw->pw_name) != 0)) { - log_it(fname, getpid(), "WRONG FILE OWNER", tabname); + log_it(fname, "WRONG FILE OWNER", tabname); goto next_crontab; } if (pw != NULL && statbuf->st_nlink != 1) { - log_it(fname, getpid(), "BAD LINK COUNT", tabname); + log_it(fname, "BAD LINK COUNT", tabname); goto next_crontab; } @@ -237,7 +237,7 @@ process_crontab(const char *uname, const char *fname, const char *tabname, */ TAILQ_REMOVE(&old_db->users, u, entries); free_user(u); - log_it(fname, getpid(), "RELOAD", tabname); + log_it(fname, "RELOAD", tabname); } u = load_user(crontab_fd, pw, fname); if (u != NULL) { diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index a3218c9a776..d953d8c7a2a 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.52 2015/11/04 20:28:17 millert Exp $ */ +/* $OpenBSD: do_command.c,v 1.53 2015/11/09 16:37:07 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -57,7 +57,7 @@ do_command(entry *e, user *u) */ switch (fork()) { case -1: - log_it("CRON", getpid(), "error", "can't fork"); + log_it("CRON", "error", "can't fork"); break; case 0: /* child process */ @@ -138,7 +138,7 @@ child_process(entry *e, user *u) */ switch (fork()) { case -1: - log_it("CRON", getpid(), "error", "can't fork"); + log_it("CRON", "error", "can't fork"); _exit(EXIT_FAILURE); /*NOTREACHED*/ case 0: @@ -150,7 +150,7 @@ child_process(entry *e, user *u) if ((e->flags & DONT_LOG) == 0) { char *x; if (stravis(&x, e->cmd, 0) != -1) { - log_it(usernm, getpid(), "CMD", x); + log_it(usernm, "CMD", x); free(x); } } @@ -431,7 +431,7 @@ child_process(entry *e, user *u) "mailed %d byte%s of output but got status 0x%04x\n", bytes, (bytes==1)?"":"s", status); - log_it(usernm, getpid(), "MAIL", buf); + log_it(usernm, "MAIL", buf); } } /*if data from grandchild*/ @@ -469,7 +469,7 @@ safe_p(const char *usernm, const char *s) (isalnum(ch) || ch == '_' || (!first && strchr(safe_delim, ch)))) continue; - log_it(usernm, getpid(), "UNSAFE", s); + log_it(usernm, "UNSAFE", s); return (FALSE); } return (TRUE); diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c index 927793cb740..e50f7400e6c 100644 --- a/usr.sbin/cron/entry.c +++ b/usr.sbin/cron/entry.c @@ -1,4 +1,4 @@ -/* $OpenBSD: entry.c,v 1.46 2015/11/08 14:40:23 millert Exp $ */ +/* $OpenBSD: entry.c,v 1.47 2015/11/09 16:37:07 millert Exp $ */ /* * Copyright 1988,1990,1993,1994 by Paul Vixie @@ -290,7 +290,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (!env_get("SHELL", e->envp)) { if (snprintf(envstr, sizeof envstr, "SHELL=%s", _PATH_BSHELL) >= sizeof(envstr)) - log_it("CRON", getpid(), "error", "can't set SHELL"); + log_it("CRON", "error", "can't set SHELL"); else { if ((tenvp = env_set(e->envp, envstr)) == NULL) { ecode = e_memory; @@ -302,7 +302,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, if (!env_get("HOME", e->envp)) { if (snprintf(envstr, sizeof envstr, "HOME=%s", pw->pw_dir) >= sizeof(envstr)) - log_it("CRON", getpid(), "error", "can't set HOME"); + log_it("CRON", "error", "can't set HOME"); else { if ((tenvp = env_set(e->envp, envstr)) == NULL) { ecode = e_memory; @@ -313,7 +313,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, } if (snprintf(envstr, sizeof envstr, "LOGNAME=%s", pw->pw_name) >= sizeof(envstr)) - log_it("CRON", getpid(), "error", "can't set LOGNAME"); + log_it("CRON", "error", "can't set LOGNAME"); else { if ((tenvp = env_set(e->envp, envstr)) == NULL) { ecode = e_memory; @@ -323,7 +323,7 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw, } if (snprintf(envstr, sizeof envstr, "USER=%s", pw->pw_name) >= sizeof(envstr)) - log_it("CRON", getpid(), "error", "can't set USER"); + log_it("CRON", "error", "can't set USER"); else { if ((tenvp = env_set(e->envp, envstr)) == NULL) { ecode = e_memory; diff --git a/usr.sbin/cron/funcs.h b/usr.sbin/cron/funcs.h index e15568c3bc5..82bb7c6833c 100644 --- a/usr.sbin/cron/funcs.h +++ b/usr.sbin/cron/funcs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: funcs.h,v 1.25 2015/11/09 01:12:27 millert Exp $ */ +/* $OpenBSD: funcs.h,v 1.26 2015/11/09 16:37:07 millert Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -31,7 +31,7 @@ void set_cron_cwd(void), unget_char(int, FILE *), free_entry(entry *), skip_comments(FILE *), - log_it(const char *, int, const char *, const char *), + log_it(const char *, const char *, const char *), log_close(void), poke_daemon(const char *, unsigned char), atrun(at_db *, double, time_t); diff --git a/usr.sbin/cron/misc.c b/usr.sbin/cron/misc.c index 8a8180f2581..fa1756bbb71 100644 --- a/usr.sbin/cron/misc.c +++ b/usr.sbin/cron/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.69 2015/11/06 23:47:42 millert Exp $ */ +/* $OpenBSD: misc.c,v 1.70 2015/11/09 16:37:07 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -121,7 +121,7 @@ skip_comments(FILE *file) } void -log_it(const char *username, pid_t xpid, const char *event, const char *detail) +log_it(const char *username, const char *event, const char *detail) { char **info, *info_events[] = { "CMD", "ATJOB", "BEGIN EDIT", "DELETE", "END EDIT", "LIST", "MAIL", "RELOAD", "REPLACE", "STARTUP", NULL }; |