diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-03-09 23:35:05 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-03-09 23:35:05 +0000 |
commit | f4214c6b1d0e13d5695fa4f5790970f25bccf189 (patch) | |
tree | dbb959d8e29abab923d481ffb9f6eebb691a6c3c /usr.sbin/smtpd/smtpd.c | |
parent | 3107c7f02b22c8d6b9393f1d1baa1d716938f77a (diff) |
run external mda directly, not via sh -c; this steals addargs() API
from OpenSSH; ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/smtpd.c')
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 6d3217e8683..c9f491333ec 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.42 2009/03/08 17:54:20 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.43 2009/03/09 23:35:04 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -1093,6 +1093,8 @@ parent_external_mda(char *path, struct passwd *pw, struct batch *batchp) { pid_t pid; int pipefd[2]; + arglist args; + char *word; struct mdaproc *mdaproc; log_debug("executing filter as user: %s", pw->pw_name); @@ -1125,12 +1127,17 @@ parent_external_mda(char *path, struct passwd *pw, struct batch *batchp) setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) fatal("mta: cannot drop privileges"); + bzero(&args, sizeof(args)); + while ((word = strsep(&path, " \t")) != NULL) + if (*word != '\0') + addargs(&args, "%s", word); + close(pipefd[0]); close(STDOUT_FILENO); close(STDERR_FILENO); dup2(pipefd[1], 0); - execlp(_PATH_BSHELL, "sh", "-c", path, (void *)NULL); + execvp(args.list[0], args.list); _exit(1); } |