diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -11,7 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "includes.h" | 13 | #include "includes.h" |
14 | RCSID("$OpenBSD: ssh.c,v 1.61 2000/08/20 18:42:40 millert Exp $"); | 14 | RCSID("$OpenBSD: ssh.c,v 1.63 2000/08/28 20:19:52 markus Exp $"); |
15 | 15 | ||
16 | #include <openssl/evp.h> | 16 | #include <openssl/evp.h> |
17 | #include <openssl/dsa.h> | 17 | #include <openssl/dsa.h> |
@@ -461,7 +461,7 @@ main(int ac, char **av) | |||
461 | } | 461 | } |
462 | 462 | ||
463 | /* Cannot fork to background if no command. */ | 463 | /* Cannot fork to background if no command. */ |
464 | if (fork_after_authentication_flag && buffer_len(&command) == 0) | 464 | if (fork_after_authentication_flag && buffer_len(&command) == 0 && !no_shell_flag) |
465 | fatal("Cannot fork into background without a command to execute."); | 465 | fatal("Cannot fork into background without a command to execute."); |
466 | 466 | ||
467 | /* Allocate a tty by default if no command specified. */ | 467 | /* Allocate a tty by default if no command specified. */ |
@@ -959,21 +959,25 @@ ssh_session2(void) | |||
959 | int window, packetmax, id; | 959 | int window, packetmax, id; |
960 | int in, out, err; | 960 | int in, out, err; |
961 | 961 | ||
962 | /* If requested, let ssh continue in the background. */ | 962 | if (stdin_null_flag) { |
963 | if (fork_after_authentication_flag) | 963 | in = open("/dev/null", O_RDONLY); |
964 | if (daemon(1, 1) < 0) | 964 | } else { |
965 | fatal("daemon() failed: %.200s", strerror(errno)); | 965 | in = dup(STDIN_FILENO); |
966 | 966 | } | |
967 | in = dup(STDIN_FILENO); | ||
968 | out = dup(STDOUT_FILENO); | 967 | out = dup(STDOUT_FILENO); |
969 | err = dup(STDERR_FILENO); | 968 | err = dup(STDERR_FILENO); |
970 | 969 | ||
971 | if (in < 0 || out < 0 || err < 0) | 970 | if (in < 0 || out < 0 || err < 0) |
972 | fatal("dump in/out/err failed"); | 971 | fatal("dup() in/out/err failed"); |
973 | 972 | ||
974 | /* should be pre-session */ | 973 | /* should be pre-session */ |
975 | init_local_fwd(); | 974 | init_local_fwd(); |
976 | 975 | ||
976 | /* If requested, let ssh continue in the background. */ | ||
977 | if (fork_after_authentication_flag) | ||
978 | if (daemon(1, 1) < 0) | ||
979 | fatal("daemon() failed: %.200s", strerror(errno)); | ||
980 | |||
977 | window = 32*1024; | 981 | window = 32*1024; |
978 | if (tty_flag) { | 982 | if (tty_flag) { |
979 | packetmax = window/8; | 983 | packetmax = window/8; |