|
Lines 430-436
default_ssh_port(void)
Link Here
|
| 430 |
static int |
430 |
static int |
| 431 |
execute_in_shell(const char *cmd) |
431 |
execute_in_shell(const char *cmd) |
| 432 |
{ |
432 |
{ |
| 433 |
char *shell, *command_string; |
433 |
char *shell; |
| 434 |
pid_t pid; |
434 |
pid_t pid; |
| 435 |
int devnull, status; |
435 |
int devnull, status; |
| 436 |
extern uid_t original_real_uid; |
436 |
extern uid_t original_real_uid; |
|
Lines 438-449
execute_in_shell(const char *cmd)
Link Here
|
| 438 |
if ((shell = getenv("SHELL")) == NULL) |
438 |
if ((shell = getenv("SHELL")) == NULL) |
| 439 |
shell = _PATH_BSHELL; |
439 |
shell = _PATH_BSHELL; |
| 440 |
|
440 |
|
| 441 |
/* |
|
|
| 442 |
* Use "exec" to avoid "sh -c" processes on some platforms |
| 443 |
* (e.g. Solaris) |
| 444 |
*/ |
| 445 |
xasprintf(&command_string, "exec %s", cmd); |
| 446 |
|
| 447 |
/* Need this to redirect subprocess stdin/out */ |
441 |
/* Need this to redirect subprocess stdin/out */ |
| 448 |
if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) |
442 |
if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) |
| 449 |
fatal("open(/dev/null): %s", strerror(errno)); |
443 |
fatal("open(/dev/null): %s", strerror(errno)); |
|
Lines 468-474
execute_in_shell(const char *cmd)
Link Here
|
| 468 |
|
462 |
|
| 469 |
argv[0] = shell; |
463 |
argv[0] = shell; |
| 470 |
argv[1] = "-c"; |
464 |
argv[1] = "-c"; |
| 471 |
argv[2] = command_string; |
465 |
argv[2] = cmd; |
| 472 |
argv[3] = NULL; |
466 |
argv[3] = NULL; |
| 473 |
|
467 |
|
| 474 |
execv(argv[0], argv); |
468 |
execv(argv[0], argv); |
|
Lines 483-489
execute_in_shell(const char *cmd)
Link Here
|
| 483 |
fatal("%s: fork: %.100s", __func__, strerror(errno)); |
477 |
fatal("%s: fork: %.100s", __func__, strerror(errno)); |
| 484 |
|
478 |
|
| 485 |
close(devnull); |
479 |
close(devnull); |
| 486 |
free(command_string); |
|
|
| 487 |
|
480 |
|
| 488 |
while (waitpid(pid, &status, 0) == -1) { |
481 |
while (waitpid(pid, &status, 0) == -1) { |
| 489 |
if (errno != EINTR && errno != EAGAIN) |
482 |
if (errno != EINTR && errno != EAGAIN) |