diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-11-20 23:19:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-11-20 23:19:45 +0000 |
commit | 0cc709e2604756a92d42fc7339e48b9103abc432 (patch) | |
tree | 3cd4fbf4fb470bfb6579905e2d3cf18efc170385 /usr.bin | |
parent | a773d207e5326979dbae610af9f727ba9d9aab9a (diff) |
In private version of popen(), only wrap a command to be run in a
shell if it contains meta chars. Sneaky hack to work around a ksh
bug.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mail/popen.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 3e038b11263..ebfc6f37e51 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.27 2001/09/04 23:16:11 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.28 2001/11/20 23:19:44 millert Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: popen.c,v 1.27 2001/09/04 23:16:11 millert Exp $"; +static char rcsid[] = "$OpenBSD: popen.c,v 1.28 2001/11/20 23:19:44 millert Exp $"; #endif #endif /* not lint */ @@ -136,8 +136,15 @@ Popen(cmd, mode) fd1 = -1; } sigemptyset(&nset); - if ((pid = start_command(value("SHELL"), &nset, fd0, fd1, - "-c", cmd, NULL)) < 0) { + /* + * If cmd contains meta chars wrap it in a shell. + */ + if (strpbrk(cmd, "$&*(){}[]'\";\\|?<>~`")) + pid = start_command(value("SHELL"), &nset, fd0, fd1, + "-c", cmd, NULL); + else + pid = start_command(cmd, &nset, fd0, fd1, NULL); + if (pid < 0) { (void)close(p[READ]); (void)close(p[WRITE]); return(NULL); |