summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/afs/src/arlad/arlad.c9
-rw-r--r--usr.sbin/authpf/authpf.c9
-rw-r--r--usr.sbin/dhcpd/dhcpd.c6
-rw-r--r--usr.sbin/dhcrelay/dhcrelay.c6
-rw-r--r--usr.sbin/eeprom/main.c8
-rw-r--r--usr.sbin/mopd/mopd/mopd.c8
6 files changed, 25 insertions, 21 deletions
diff --git a/usr.sbin/afs/src/arlad/arlad.c b/usr.sbin/afs/src/arlad/arlad.c
index d017059f62f..45ff4ec9140 100644
--- a/usr.sbin/afs/src/arlad/arlad.c
+++ b/usr.sbin/afs/src/arlad/arlad.c
@@ -175,11 +175,10 @@ arla_start (char *device_file, const char *cache_dir)
kill(getppid(), SIGUSR1);
if (pw) {
- setgroups(1, &pw->pw_gid);
- setegid(pw->pw_gid);
- setgid(pw->pw_gid);
- seteuid(pw->pw_uid);
- setuid(pw->pw_uid);
+ if (setgroups(1, &pw->pw_gid) == -1 ||
+ setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1 ||
+ setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1)
+ arla_err (1, ADEBERROR, errno, "revoke");
}
LWP_WaitProcess ((char *)arla_start);
diff --git a/usr.sbin/authpf/authpf.c b/usr.sbin/authpf/authpf.c
index 1ae6aa452d5..8f32986e30e 100644
--- a/usr.sbin/authpf/authpf.c
+++ b/usr.sbin/authpf/authpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: authpf.c,v 1.89 2005/02/10 04:24:15 joel Exp $ */
+/* $OpenBSD: authpf.c,v 1.90 2005/05/02 02:29:26 djm Exp $ */
/*
* Copyright (C) 1998 - 2002 Bob Beck (beck@openbsd.org).
@@ -258,8 +258,11 @@ main(int argc, char *argv[])
} while (1);
/* revoke privs */
- seteuid(getuid());
- setuid(getuid());
+ uid = getuid();
+ if (setresuid(uid, uid, uid) == -1) {
+ syslog(LOG_INFO, "setresuid: %s", strerror(errno));
+ do_death(0);
+ }
openlog("authpf", LOG_PID | LOG_NDELAY, LOG_DAEMON);
diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c
index 93371992098..6afd37972f8 100644
--- a/usr.sbin/dhcpd/dhcpd.c
+++ b/usr.sbin/dhcpd/dhcpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.c,v 1.22 2004/10/31 10:43:38 canacar Exp $ */
+/* $OpenBSD: dhcpd.c,v 1.23 2005/05/02 02:29:27 djm Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org>
@@ -135,8 +135,8 @@ main(int argc, char *argv[])
if (chdir("/") == -1)
error("chdir(\"/\"): %m");
if (setgroups(1, &pw->pw_gid) ||
- setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
- seteuid(pw->pw_uid) || setuid(pw->pw_uid))
+ setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
+ setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
error("can't drop privileges: %m");
endpwent();
diff --git a/usr.sbin/dhcrelay/dhcrelay.c b/usr.sbin/dhcrelay/dhcrelay.c
index e2408e59929..f349ca46e1e 100644
--- a/usr.sbin/dhcrelay/dhcrelay.c
+++ b/usr.sbin/dhcrelay/dhcrelay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcrelay.c,v 1.23 2005/01/25 16:55:04 norby Exp $ */
+/* $OpenBSD: dhcrelay.c,v 1.24 2005/05/02 02:29:27 djm Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org>
@@ -179,8 +179,8 @@ main(int argc, char *argv[])
if (chdir("/") == -1)
error("chdir(\"/\"): %m");
if (setgroups(1, &pw->pw_gid) ||
- setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
- seteuid(pw->pw_uid) || setuid(pw->pw_uid))
+ setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
+ setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
error("can't drop privileges: %m");
endpwent();
diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c
index af4aa119372..3fdcf072cd6 100644
--- a/usr.sbin/eeprom/main.c
+++ b/usr.sbin/eeprom/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.12 2004/07/09 16:22:02 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.13 2005/05/02 02:29:27 djm Exp $ */
/* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */
/*-
@@ -120,6 +120,7 @@ main(int argc, char *argv[])
int ch, do_stdin = 0;
char *cp, line[BUFSIZE];
#ifdef __sparc__
+ gid_t gid;
char *optstring = "cf:ivN:-";
#else
char *optstring = "cf:i-";
@@ -162,8 +163,9 @@ main(int argc, char *argv[])
#ifdef __sparc__
if (system != NULL) {
- setegid(getgid());
- setgid(getgid());
+ gid = getgid();
+ if (setresgid(gid, gid, gid) == -1)
+ err(1, "setresgid");
}
if (getcputype() != CPU_SUN4)
use_openprom = 1;
diff --git a/usr.sbin/mopd/mopd/mopd.c b/usr.sbin/mopd/mopd/mopd.c
index 467c030e393..4274476e434 100644
--- a/usr.sbin/mopd/mopd/mopd.c
+++ b/usr.sbin/mopd/mopd/mopd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mopd.c,v 1.12 2004/05/12 10:43:44 henning Exp $ */
+/* $OpenBSD: mopd.c,v 1.13 2005/05/02 02:29:27 djm Exp $ */
/*
* Copyright (c) 1993-96 Mats O Jansson. All rights reserved.
@@ -26,7 +26,7 @@
#ifndef LINT
static const char rcsid[] =
- "$OpenBSD: mopd.c,v 1.12 2004/05/12 10:43:44 henning Exp $";
+ "$OpenBSD: mopd.c,v 1.13 2005/05/02 02:29:27 djm Exp $";
#endif
/*
@@ -147,8 +147,8 @@ main(int argc, char *argv[])
exit(1);
}
if (setgroups(1, &pw->pw_gid) ||
- setegid(pw->pw_gid) || setgid(pw->pw_gid) ||
- seteuid(pw->pw_uid) || setuid(pw->pw_uid)) {
+ setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
+ setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) {
syslog(LOG_CRIT, "can't drop privileges: %m");
exit(1);
}