summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2015-10-25 23:14:03 +0000
committerDamien Miller <djm@mindrot.org>2015-10-29 19:07:11 +1100
commit97e184e508dd33c37860c732c0eca3fc57698b40 (patch)
tree0deab18eee7b77d305c570834bec2ec66080eeda
parent8db134e7f457bcb069ec72bc4ee722e2af557c69 (diff)
upstream commit
Do not prepend "exec" to the shell command run by "Match exec" in a config file. It's an unnecessary optimization from repurposed ProxyCommand code and prevents some things working with some shells. bz#2471, pointed out by res at qoxp.net. ok markus@ Upstream-ID: a1ead25ae336bfa15fb58d8c6b5589f85b4c33a3
-rw-r--r--readconf.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/readconf.c b/readconf.c
index 94bf7e1b4..01e3d23e3 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.242 2015/10/07 15:59:12 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.243 2015/10/25 23:14:03 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -442,7 +442,7 @@ default_ssh_port(void)
442static int 442static int
443execute_in_shell(const char *cmd) 443execute_in_shell(const char *cmd)
444{ 444{
445 char *shell, *command_string; 445 char *shell;
446 pid_t pid; 446 pid_t pid;
447 int devnull, status; 447 int devnull, status;
448 extern uid_t original_real_uid; 448 extern uid_t original_real_uid;
@@ -450,12 +450,6 @@ execute_in_shell(const char *cmd)
450 if ((shell = getenv("SHELL")) == NULL) 450 if ((shell = getenv("SHELL")) == NULL)
451 shell = _PATH_BSHELL; 451 shell = _PATH_BSHELL;
452 452
453 /*
454 * Use "exec" to avoid "sh -c" processes on some platforms
455 * (e.g. Solaris)
456 */
457 xasprintf(&command_string, "exec %s", cmd);
458
459 /* Need this to redirect subprocess stdin/out */ 453 /* Need this to redirect subprocess stdin/out */
460 if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) 454 if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1)
461 fatal("open(/dev/null): %s", strerror(errno)); 455 fatal("open(/dev/null): %s", strerror(errno));
@@ -480,7 +474,7 @@ execute_in_shell(const char *cmd)
480 474
481 argv[0] = shell; 475 argv[0] = shell;
482 argv[1] = "-c"; 476 argv[1] = "-c";
483 argv[2] = command_string; 477 argv[2] = cmd;
484 argv[3] = NULL; 478 argv[3] = NULL;
485 479
486 execv(argv[0], argv); 480 execv(argv[0], argv);
@@ -495,7 +489,6 @@ execute_in_shell(const char *cmd)
495 fatal("%s: fork: %.100s", __func__, strerror(errno)); 489 fatal("%s: fork: %.100s", __func__, strerror(errno));
496 490
497 close(devnull); 491 close(devnull);
498 free(command_string);
499 492
500 while (waitpid(pid, &status, 0) == -1) { 493 while (waitpid(pid, &status, 0) == -1) {
501 if (errno != EINTR && errno != EAGAIN) 494 if (errno != EINTR && errno != EAGAIN)