diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.317 2008/06/12 16:35:31 dtucker Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.318 2008/07/02 13:47:39 djm 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 |
@@ -860,9 +860,15 @@ ssh_confirm_remote_forward(int type, u_int32_t seq, void *ctxt) | |||
860 | logit("Warning: remote port forwarding failed for " | 860 | logit("Warning: remote port forwarding failed for " |
861 | "listen port %d", rfwd->listen_port); | 861 | "listen port %d", rfwd->listen_port); |
862 | } | 862 | } |
863 | if (++remote_forward_confirms_received == options.num_remote_forwards) | 863 | if (++remote_forward_confirms_received == options.num_remote_forwards) { |
864 | debug("All remote forwarding requests processed"); | 864 | debug("All remote forwarding requests processed"); |
865 | /* XXX fork-after-authentication */ | 865 | if (fork_after_authentication_flag) { |
866 | fork_after_authentication_flag = 0; | ||
867 | if (daemon(1, 1) < 0) | ||
868 | fatal("daemon() failed: %.200s", | ||
869 | strerror(errno)); | ||
870 | } | ||
871 | } | ||
866 | } | 872 | } |
867 | 873 | ||
868 | static void | 874 | static void |
@@ -1062,10 +1068,17 @@ ssh_session(void) | |||
1062 | options.permit_local_command) | 1068 | options.permit_local_command) |
1063 | ssh_local_cmd(options.local_command); | 1069 | ssh_local_cmd(options.local_command); |
1064 | 1070 | ||
1065 | /* If requested, let ssh continue in the background. */ | 1071 | /* |
1066 | if (fork_after_authentication_flag) | 1072 | * If requested and we are not interested in replies to remote |
1073 | * forwarding requests, then let ssh continue in the background. | ||
1074 | */ | ||
1075 | if (fork_after_authentication_flag && | ||
1076 | (!options.exit_on_forward_failure || | ||
1077 | options.num_remote_forwards == 0)) { | ||
1078 | fork_after_authentication_flag = 0; | ||
1067 | if (daemon(1, 1) < 0) | 1079 | if (daemon(1, 1) < 0) |
1068 | fatal("daemon() failed: %.200s", strerror(errno)); | 1080 | fatal("daemon() failed: %.200s", strerror(errno)); |
1081 | } | ||
1069 | 1082 | ||
1070 | /* | 1083 | /* |
1071 | * If a command was specified on the command line, execute the | 1084 | * If a command was specified on the command line, execute the |
@@ -1204,9 +1217,11 @@ ssh_session2(void) | |||
1204 | muxserver_listen(); | 1217 | muxserver_listen(); |
1205 | 1218 | ||
1206 | /* If requested, let ssh continue in the background. */ | 1219 | /* If requested, let ssh continue in the background. */ |
1207 | if (fork_after_authentication_flag) | 1220 | if (fork_after_authentication_flag) { |
1221 | fork_after_authentication_flag = 0; | ||
1208 | if (daemon(1, 1) < 0) | 1222 | if (daemon(1, 1) < 0) |
1209 | fatal("daemon() failed: %.200s", strerror(errno)); | 1223 | fatal("daemon() failed: %.200s", strerror(errno)); |
1224 | } | ||
1210 | 1225 | ||
1211 | return client_loop(tty_flag, tty_flag ? | 1226 | return client_loop(tty_flag, tty_flag ? |
1212 | options.escape_char : SSH_ESCAPECHAR_NONE, id); | 1227 | options.escape_char : SSH_ESCAPECHAR_NONE, id); |