summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-10-03 12:46:54 +0000
committertedu <tedu@openbsd.org>2015-10-03 12:46:54 +0000
commitf800b2d9fd81ead97cd475d3abd6675d530140d5 (patch)
tree1df04171a48c43f6b2444e6f2af72cb541bb48a2
parenttame "stdio" right between setlocale and getopt, it is easy to review (diff)
downloadwireguard-openbsd-f800b2d9fd81ead97cd475d3abd6675d530140d5.tar.xz
wireguard-openbsd-f800b2d9fd81ead97cd475d3abd6675d530140d5.zip
unifdef some features we will always have. ok benno zhuk
-rw-r--r--usr.sbin/cron/atrun.c25
-rw-r--r--usr.sbin/cron/cron.c4
-rw-r--r--usr.sbin/cron/do_command.c24
-rw-r--r--usr.sbin/cron/entry.c17
-rw-r--r--usr.sbin/cron/popen.c21
5 files changed, 5 insertions, 86 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c
index efcd73e1df5..7921a74c34c 100644
--- a/usr.sbin/cron/atrun.c
+++ b/usr.sbin/cron/atrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atrun.c,v 1.29 2015/08/25 20:09:27 millert Exp $ */
+/* $OpenBSD: atrun.c,v 1.30 2015/10/03 12:46:54 tedu Exp $ */
/*
* Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -266,13 +266,11 @@ run_job(atjob *job, char *atfile)
log_it("CRON", getpid(), "ORPHANED JOB", atfile);
_exit(EXIT_FAILURE);
}
-#ifdef HAVE_PW_EXPIRE
if (pw->pw_expire && time(NULL) >= pw->pw_expire) {
log_it(pw->pw_name, getpid(), "ACCOUNT EXPIRED, JOB ABORTED",
atfile);
_exit(EXIT_FAILURE);
}
-#endif
/* Sanity checks */
if (fstat(fd, &statbuf) < 0) {
@@ -397,12 +395,9 @@ run_job(atjob *job, char *atfile)
(void) setsid();
-#ifdef LOGIN_CAP
{
login_cap_t *lc;
-# ifdef BSD_AUTH
auth_session_t *as;
-# endif
if ((lc = login_getclass(pw->pw_class)) == NULL) {
fprintf(stderr,
"Cannot get login class for %s\n",
@@ -417,7 +412,6 @@ run_job(atjob *job, char *atfile)
pw->pw_name);
_exit(EXIT_FAILURE);
}
-# ifdef BSD_AUTH
as = auth_open();
if (as == NULL || auth_setpwd(as, pw) != 0) {
fprintf(stderr, "can't malloc\n");
@@ -429,25 +423,8 @@ run_job(atjob *job, char *atfile)
_exit(EXIT_FAILURE);
}
auth_close(as);
-# endif /* BSD_AUTH */
login_close(lc);
}
-#else
- if (setgid(pw->pw_gid) || initgroups(pw->pw_name, pw->pw_gid)) {
- fprintf(stderr,
- "unable to set groups for %s\n", pw->pw_name);
- _exit(EXIT_FAILURE);
- }
-#ifdef HAVE_SETLOGIN
- setlogin(pw->pw_name);
-#endif
- if (setuid(pw->pw_uid)) {
- fprintf(stderr, "unable to set uid to %lu\n",
- (unsigned long)pw->pw_uid);
- _exit(EXIT_FAILURE);
- }
-
-#endif /* LOGIN_CAP */
chdir("/"); /* at job will chdir to correct place */
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c
index aa243c0d09a..1f2a25daab9 100644
--- a/usr.sbin/cron/cron.c
+++ b/usr.sbin/cron/cron.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cron.c,v 1.53 2015/08/25 20:09:27 millert Exp $ */
+/* $OpenBSD: cron.c,v 1.54 2015/10/03 12:46:54 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -70,9 +70,7 @@ main(int argc, char *argv[])
bzero((char *)&sact, sizeof sact);
sigemptyset(&sact.sa_mask);
sact.sa_flags = 0;
-#ifdef SA_RESTART
sact.sa_flags |= SA_RESTART;
-#endif
sact.sa_handler = sigchld_handler;
(void) sigaction(SIGCHLD, &sact, NULL);
sact.sa_handler = sighup_handler;
diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c
index 6b9050288ca..b38db1a6141 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.46 2015/02/09 22:35:08 deraadt Exp $ */
+/* $OpenBSD: do_command.c,v 1.47 2015/10/03 12:46:54 tedu Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -165,11 +165,8 @@ child_process(entry *e, user *u)
/* set our directory, uid and gid. Set gid first, since once
* we set uid, we've lost root privileges.
*/
-#ifdef LOGIN_CAP
{
-#ifdef BSD_AUTH
auth_session_t *as;
-#endif
login_cap_t *lc;
char **p;
extern char **environ;
@@ -187,7 +184,6 @@ child_process(entry *e, user *u)
e->pwd->pw_name);
_exit(EXIT_FAILURE);
}
-#ifdef BSD_AUTH
as = auth_open();
if (as == NULL || auth_setpwd(as, e->pwd) != 0) {
fprintf(stderr, "can't malloc\n");
@@ -199,7 +195,6 @@ child_process(entry *e, user *u)
_exit(EXIT_FAILURE);
}
auth_close(as);
-#endif /* BSD_AUTH */
login_close(lc);
/* If no PATH specified in crontab file but
@@ -215,23 +210,6 @@ child_process(entry *e, user *u)
}
}
}
-#else
- if (setgid(e->pwd->pw_gid) || initgroups(usernm, e->pwd->pw_gid)) {
- fprintf(stderr,
- "unable to set groups for %s\n", e->pwd->pw_name);
- _exit(EXIT_FAILURE);
- }
-#ifdef HAVE_SETLOGIN
- setlogin(usernm);
-#endif
- if (setuid(e->pwd->pw_uid)) {
- fprintf(stderr,
- "unable to set uid to %lu\n",
- (unsigned long)e->pwd->pw_uid);
- _exit(EXIT_FAILURE);
- }
-
-#endif /* LOGIN_CAP */
chdir(env_get("HOME", e->envp));
(void) signal(SIGPIPE, SIG_DFL);
diff --git a/usr.sbin/cron/entry.c b/usr.sbin/cron/entry.c
index d313228d051..381fc99d58b 100644
--- a/usr.sbin/cron/entry.c
+++ b/usr.sbin/cron/entry.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entry.c,v 1.40 2015/02/09 22:35:08 deraadt Exp $ */
+/* $OpenBSD: entry.c,v 1.41 2015/10/03 12:46:54 tedu Exp $ */
/*
* Copyright 1988,1990,1993,1994 by Paul Vixie
@@ -293,21 +293,6 @@ load_entry(FILE *file, void (*error_func)(const char *), struct passwd *pw,
e->envp = tenvp;
}
}
-#ifndef LOGIN_CAP
- /* If login.conf is in use we will get the default PATH later. */
- if (!env_get("PATH", e->envp)) {
- if (snprintf(envstr, sizeof envstr, "PATH=%s", _PATH_DEFPATH) >=
- sizeof(envstr))
- log_it("CRON", getpid(), "error", "can't set PATH");
- else {
- if ((tenvp = env_set(e->envp, envstr)) == NULL) {
- ecode = e_memory;
- goto eof;
- }
- e->envp = tenvp;
- }
- }
-#endif /* LOGIN_CAP */
if (snprintf(envstr, sizeof envstr, "LOGNAME=%s", pw->pw_name) >=
sizeof(envstr))
log_it("CRON", getpid(), "error", "can't set LOGNAME");
diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c
index e3d2eb998b9..d083665c30e 100644
--- a/usr.sbin/cron/popen.c
+++ b/usr.sbin/cron/popen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popen.c,v 1.25 2015/01/23 19:07:27 tedu Exp $ */
+/* $OpenBSD: popen.c,v 1.26 2015/10/03 12:46:54 tedu Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -85,31 +85,12 @@ cron_popen(char *program, char *type, struct passwd *pw)
/* NOTREACHED */
case 0: /* child */
if (pw) {
-#ifdef LOGIN_CAP
if (setusercontext(0, pw, pw->pw_uid, LOGIN_SETALL) < 0) {
fprintf(stderr,
"setusercontext failed for %s\n",
pw->pw_name);
_exit(EXIT_FAILURE);
}
-#else
- if (setgid(pw->pw_gid) < 0 ||
- initgroups(pw->pw_name, pw->pw_gid) < 0) {
- fprintf(stderr,
- "unable to set groups for %s\n",
- pw->pw_name);
- _exit(1);
- }
-#ifdef HAVE_SETLOGIN
- setlogin(pw->pw_name);
-#endif
- if (setuid(pw->pw_uid)) {
- fprintf(stderr,
- "unable to set uid for %s\n",
- pw->pw_name);
- _exit(1);
- }
-#endif /* LOGIN_CAP */
}
if (*type == 'r') {
if (pdes[1] != STDOUT_FILENO) {