summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtpd.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2013-07-19 11:14:09 +0000
committerEric Faurot <eric@cvs.openbsd.org>2013-07-19 11:14:09 +0000
commite69f8efeb851880afaf846c6c6f9ab4f0fb25226 (patch)
tree33347af75abf372ce6faa6f682a058b17ae70346 /usr.sbin/smtpd/smtpd.c
parent6fff6905b9aa3bc12806712cb01ed4cbeb444ea7 (diff)
Get rid of env->sc_pw and env->sc_pwqueue. Early queue initialization
now happens in queue_init(), and backends take the queue passwd as parameter in their init function. Remove useless SMTPD_FILTER_USER while there.
Diffstat (limited to 'usr.sbin/smtpd/smtpd.c')
-rw-r--r--usr.sbin/smtpd/smtpd.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c
index cdc25f7d10f..aa733ccf225 100644
--- a/usr.sbin/smtpd/smtpd.c
+++ b/usr.sbin/smtpd/smtpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.c,v 1.192 2013/07/04 07:04:07 gilles Exp $ */
+/* $OpenBSD: smtpd.c,v 1.193 2013/07/19 11:14:08 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -588,7 +588,6 @@ main(int argc, char *argv[])
struct event ev_sigchld;
struct event ev_sighup;
struct timeval tv;
- struct passwd *pwq;
env = &smtpd;
@@ -715,33 +714,6 @@ main(int argc, char *argv[])
if (geteuid())
errx(1, "need root privileges");
- if ((env->sc_pw = getpwnam(SMTPD_USER)) == NULL)
- errx(1, "unknown user %s", SMTPD_USER);
- if ((env->sc_pw = pw_dup(env->sc_pw)) == NULL)
- err(1, NULL);
-
- env->sc_pwqueue = getpwnam(SMTPD_QUEUE_USER);
- if (env->sc_pwqueue)
- pwq = env->sc_pwqueue = pw_dup(env->sc_pwqueue);
- else
- pwq = env->sc_pwqueue = pw_dup(env->sc_pw);
- if (env->sc_pwqueue == NULL)
- err(1, NULL);
-
- if (ckdir(PATH_SPOOL, 0711, 0, 0, 1) == 0)
- errx(1, "error in spool directory setup");
- if (ckdir(PATH_SPOOL PATH_OFFLINE, 01777, 0, 0, 1) == 0)
- errx(1, "error in offline directory setup");
- if (ckdir(PATH_SPOOL PATH_PURGE, 0700, pwq->pw_uid, 0, 1) == 0)
- errx(1, "error in purge directory setup");
- if (ckdir(PATH_SPOOL PATH_TEMPORARY, 0700, pwq->pw_uid, 0, 1) == 0)
- errx(1, "error in purge directory setup");
-
- mvpurge(PATH_SPOOL PATH_INCOMING, PATH_SPOOL PATH_PURGE);
-
- if (ckdir(PATH_SPOOL PATH_INCOMING, 0700, pwq->pw_uid, 0, 1) == 0)
- errx(1, "error in incoming directory setup");
-
if (!queue_init(backend_queue, 1))
errx(1, "could not initialize queue backend");
@@ -913,6 +885,7 @@ child_add(pid_t pid, int type, const char *title)
static void
purge_task(int fd, short ev, void *arg)
{
+ struct passwd *pw;
DIR *d;
int n;
uid_t uid;
@@ -934,12 +907,14 @@ purge_task(int fd, short ev, void *arg)
log_warn("warn: purge_task: fork");
break;
case 0:
+ if ((pw = getpwnam(SMTPD_USER)) == NULL)
+ fatalx("unknown user " SMTPD_USER);
if (chroot(PATH_SPOOL PATH_PURGE) == -1)
fatal("smtpd: chroot");
if (chdir("/") == -1)
fatal("smtpd: chdir");
- uid = env->sc_pw->pw_uid;
- gid = env->sc_pw->pw_gid;
+ uid = pw->pw_uid;
+ gid = pw->pw_gid;
if (setgroups(1, &gid) ||
setresgid(gid, gid, gid) ||
setresuid(uid, uid, uid))