summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-03-10 19:09:30 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-03-10 19:09:30 +0000
commitd22a9a817c515acc064d7766ce700069ff3db84d (patch)
tree6867d5463035f7211b5d3e5fab6b768a0b447bdb
parent7360172a8ae56f50fdbfdad8721b6406e3314daf (diff)
kill few lines, saving one seteuid(2) call; ok gilles@
-rw-r--r--usr.sbin/smtpd/smtpd.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index 200b66c3fe2..f687dbc0364 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.46 2009/03/10 18:44:28 jacekm Exp $ */
+/* $OpenBSD: smtpd.c,v 1.47 2009/03/10 19:09:29 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -1108,13 +1108,6 @@ parent_external_mda(char *path, struct passwd *pw, struct batch *batchp)
fatal("parent_external_mda: pipe");
}
- /* raise privileges before fork so that the child can
- * revoke them permanently instead of inheriting the
- * saved uid.
- */
- if (seteuid(0) == -1)
- fatal("privraise failed");
-
pid = fork();
if (pid == -1) {
log_warn("parent_external_mda: fork");
@@ -1127,6 +1120,8 @@ parent_external_mda(char *path, struct passwd *pw, struct batch *batchp)
if (pid == 0) {
setproctitle("external MDA");
+ if (seteuid(0) == -1)
+ fatal("privraise failed");
if (setgroups(1, &pw->pw_gid) ||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
@@ -1153,9 +1148,6 @@ parent_external_mda(char *path, struct passwd *pw, struct batch *batchp)
_exit(1);
}
- if (seteuid(pw->pw_uid) == -1)
- fatal("privdrop failed");
-
mdaproc = calloc(1, sizeof (struct mdaproc));
if (mdaproc == NULL)
fatal("calloc");