summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2015-11-17 21:56:57 +0000
committermillert <millert@openbsd.org>2015-11-17 21:56:57 +0000
commit89f79ae10c92493c428a7aafc4bf613a823e1654 (patch)
tree21dc97a7da6d74ea3f034f5fb2ce90656af05796
parentRemove register keyword. (diff)
downloadwireguard-openbsd-89f79ae10c92493c428a7aafc4bf613a823e1654.tar.xz
wireguard-openbsd-89f79ae10c92493c428a7aafc4bf613a823e1654.zip
Check for setgid() failure before executing editor and warn if
exec of shell + editor fails.
-rw-r--r--usr.sbin/cron/crontab.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index d78cce59c20..ce26afc493a 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crontab.c,v 1.90 2015/11/14 13:09:14 millert Exp $ */
+/* $OpenBSD: crontab.c,v 1.91 2015/11/17 21:56:57 millert Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -561,9 +561,13 @@ editit(const char *pathname)
if ((pid = fork()) == -1)
goto fail;
if (pid == 0) {
- setgid(getgid());
- setuid(getuid());
- execv(_PATH_BSHELL, argp);
+ /* Drop setgid and exec the command. */
+ if (setgid(user_gid) == -1) {
+ warn("unable to set gid to %u", user_gid);
+ } else {
+ execv(_PATH_BSHELL, argp);
+ warn("unable to execute %s", _PATH_BSHELL);
+ }
_exit(127);
}
while (waitpid(pid, &st, 0) == -1)