diff options
author | Colin Watson <cjwatson@debian.org> | 2006-05-12 08:53:37 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2006-05-12 08:53:37 +0000 |
commit | 2ee73b36b9a35daeaa4b065046882dc1f5f551b6 (patch) | |
tree | f64a4ace625514e94759878c0b94ab0a79805bbd /session.c | |
parent | 3c190ec8e469477ea65fbf4cc83062c65c281434 (diff) | |
parent | 3e2e0ac10674d77618c4c7339e18b83ced247492 (diff) |
Merge 4.3p2 to the trunk.
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 58 |
1 files changed, 30 insertions, 28 deletions
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include "includes.h" | 35 | #include "includes.h" |
36 | RCSID("$OpenBSD: session.c,v 1.186 2005/07/25 11:59:40 markus Exp $"); | 36 | RCSID("$OpenBSD: session.c,v 1.191 2005/12/24 02:27:41 djm Exp $"); |
37 | 37 | ||
38 | #include "ssh.h" | 38 | #include "ssh.h" |
39 | #include "ssh1.h" | 39 | #include "ssh1.h" |
@@ -211,15 +211,6 @@ do_authenticated(Authctxt *authctxt) | |||
211 | { | 211 | { |
212 | setproctitle("%s", authctxt->pw->pw_name); | 212 | setproctitle("%s", authctxt->pw->pw_name); |
213 | 213 | ||
214 | /* | ||
215 | * Cancel the alarm we set to limit the time taken for | ||
216 | * authentication. | ||
217 | */ | ||
218 | alarm(0); | ||
219 | if (startup_pipe != -1) { | ||
220 | close(startup_pipe); | ||
221 | startup_pipe = -1; | ||
222 | } | ||
223 | /* setup the channel layer */ | 214 | /* setup the channel layer */ |
224 | if (!no_port_forwarding_flag && options.allow_tcp_forwarding) | 215 | if (!no_port_forwarding_flag && options.allow_tcp_forwarding) |
225 | channel_permit_all_opens(); | 216 | channel_permit_all_opens(); |
@@ -1423,7 +1414,7 @@ child_close_fds(void) | |||
1423 | endpwent(); | 1414 | endpwent(); |
1424 | 1415 | ||
1425 | /* | 1416 | /* |
1426 | * Close any extra open file descriptors so that we don\'t have them | 1417 | * Close any extra open file descriptors so that we don't have them |
1427 | * hanging around in clients. Note that we want to do this after | 1418 | * hanging around in clients. Note that we want to do this after |
1428 | * initgroups, because at least on Solaris 2.3 it leaves file | 1419 | * initgroups, because at least on Solaris 2.3 it leaves file |
1429 | * descriptors open. | 1420 | * descriptors open. |
@@ -1475,7 +1466,9 @@ do_child(Session *s, const char *command) | |||
1475 | if (!check_quietlogin(s, command)) | 1466 | if (!check_quietlogin(s, command)) |
1476 | do_motd(); | 1467 | do_motd(); |
1477 | #else /* HAVE_OSF_SIA */ | 1468 | #else /* HAVE_OSF_SIA */ |
1478 | do_nologin(pw); | 1469 | /* When PAM is enabled we rely on it to do the nologin check */ |
1470 | if (!options.use_pam) | ||
1471 | do_nologin(pw); | ||
1479 | do_setusercontext(pw); | 1472 | do_setusercontext(pw); |
1480 | /* | 1473 | /* |
1481 | * PAM session modules in do_setusercontext may have | 1474 | * PAM session modules in do_setusercontext may have |
@@ -1556,7 +1549,7 @@ do_child(Session *s, const char *command) | |||
1556 | } | 1549 | } |
1557 | #endif | 1550 | #endif |
1558 | 1551 | ||
1559 | /* Change current directory to the user\'s home directory. */ | 1552 | /* Change current directory to the user's home directory. */ |
1560 | if (chdir(pw->pw_dir) < 0) { | 1553 | if (chdir(pw->pw_dir) < 0) { |
1561 | fprintf(stderr, "Could not chdir to home directory %s: %s\n", | 1554 | fprintf(stderr, "Could not chdir to home directory %s: %s\n", |
1562 | pw->pw_dir, strerror(errno)); | 1555 | pw->pw_dir, strerror(errno)); |
@@ -1871,7 +1864,7 @@ session_x11_req(Session *s) | |||
1871 | 1864 | ||
1872 | if (s->auth_proto != NULL || s->auth_data != NULL) { | 1865 | if (s->auth_proto != NULL || s->auth_data != NULL) { |
1873 | error("session_x11_req: session %d: " | 1866 | error("session_x11_req: session %d: " |
1874 | "x11 fowarding already active", s->self); | 1867 | "x11 forwarding already active", s->self); |
1875 | return 0; | 1868 | return 0; |
1876 | } | 1869 | } |
1877 | s->single_connection = packet_get_char(); | 1870 | s->single_connection = packet_get_char(); |
@@ -2103,7 +2096,7 @@ session_close_x11(int id) | |||
2103 | { | 2096 | { |
2104 | Channel *c; | 2097 | Channel *c; |
2105 | 2098 | ||
2106 | if ((c = channel_lookup(id)) == NULL) { | 2099 | if ((c = channel_by_id(id)) == NULL) { |
2107 | debug("session_close_x11: x11 channel %d missing", id); | 2100 | debug("session_close_x11: x11 channel %d missing", id); |
2108 | } else { | 2101 | } else { |
2109 | /* Detach X11 listener */ | 2102 | /* Detach X11 listener */ |
@@ -2158,7 +2151,6 @@ static void | |||
2158 | session_exit_message(Session *s, int status) | 2151 | session_exit_message(Session *s, int status) |
2159 | { | 2152 | { |
2160 | Channel *c; | 2153 | Channel *c; |
2161 | u_int i; | ||
2162 | 2154 | ||
2163 | if ((c = channel_lookup(s->chanid)) == NULL) | 2155 | if ((c = channel_lookup(s->chanid)) == NULL) |
2164 | fatal("session_exit_message: session %d: no channel %d", | 2156 | fatal("session_exit_message: session %d: no channel %d", |
@@ -2188,7 +2180,14 @@ session_exit_message(Session *s, int status) | |||
2188 | 2180 | ||
2189 | /* disconnect channel */ | 2181 | /* disconnect channel */ |
2190 | debug("session_exit_message: release channel %d", s->chanid); | 2182 | debug("session_exit_message: release channel %d", s->chanid); |
2191 | channel_cancel_cleanup(s->chanid); | 2183 | |
2184 | /* | ||
2185 | * Adjust cleanup callback attachment to send close messages when | ||
2186 | * the channel gets EOF. The session will be then be closed | ||
2187 | * by session_close_by_channel when the childs close their fds. | ||
2188 | */ | ||
2189 | channel_register_cleanup(c->self, session_close_by_channel, 1); | ||
2190 | |||
2192 | /* | 2191 | /* |
2193 | * emulate a write failure with 'chan_write_failed', nobody will be | 2192 | * emulate a write failure with 'chan_write_failed', nobody will be |
2194 | * interested in data we write. | 2193 | * interested in data we write. |
@@ -2197,15 +2196,6 @@ session_exit_message(Session *s, int status) | |||
2197 | */ | 2196 | */ |
2198 | if (c->ostate != CHAN_OUTPUT_CLOSED) | 2197 | if (c->ostate != CHAN_OUTPUT_CLOSED) |
2199 | chan_write_failed(c); | 2198 | chan_write_failed(c); |
2200 | s->chanid = -1; | ||
2201 | |||
2202 | /* Close any X11 listeners associated with this session */ | ||
2203 | if (s->x11_chanids != NULL) { | ||
2204 | for (i = 0; s->x11_chanids[i] != -1; i++) { | ||
2205 | session_close_x11(s->x11_chanids[i]); | ||
2206 | s->x11_chanids[i] = -1; | ||
2207 | } | ||
2208 | } | ||
2209 | } | 2199 | } |
2210 | 2200 | ||
2211 | void | 2201 | void |
@@ -2249,7 +2239,9 @@ session_close_by_pid(pid_t pid, int status) | |||
2249 | } | 2239 | } |
2250 | if (s->chanid != -1) | 2240 | if (s->chanid != -1) |
2251 | session_exit_message(s, status); | 2241 | session_exit_message(s, status); |
2252 | session_close(s); | 2242 | if (s->ttyfd != -1) |
2243 | session_pty_cleanup(s); | ||
2244 | s->pid = 0; | ||
2253 | } | 2245 | } |
2254 | 2246 | ||
2255 | /* | 2247 | /* |
@@ -2260,6 +2252,7 @@ void | |||
2260 | session_close_by_channel(int id, void *arg) | 2252 | session_close_by_channel(int id, void *arg) |
2261 | { | 2253 | { |
2262 | Session *s = session_by_channel(id); | 2254 | Session *s = session_by_channel(id); |
2255 | u_int i; | ||
2263 | 2256 | ||
2264 | if (s == NULL) { | 2257 | if (s == NULL) { |
2265 | debug("session_close_by_channel: no session for id %d", id); | 2258 | debug("session_close_by_channel: no session for id %d", id); |
@@ -2279,6 +2272,15 @@ session_close_by_channel(int id, void *arg) | |||
2279 | } | 2272 | } |
2280 | /* detach by removing callback */ | 2273 | /* detach by removing callback */ |
2281 | channel_cancel_cleanup(s->chanid); | 2274 | channel_cancel_cleanup(s->chanid); |
2275 | |||
2276 | /* Close any X11 listeners associated with this session */ | ||
2277 | if (s->x11_chanids != NULL) { | ||
2278 | for (i = 0; s->x11_chanids[i] != -1; i++) { | ||
2279 | session_close_x11(s->x11_chanids[i]); | ||
2280 | s->x11_chanids[i] = -1; | ||
2281 | } | ||
2282 | } | ||
2283 | |||
2282 | s->chanid = -1; | 2284 | s->chanid = -1; |
2283 | session_close(s); | 2285 | session_close(s); |
2284 | } | 2286 | } |
@@ -2373,7 +2375,7 @@ session_setup_x11fwd(Session *s) | |||
2373 | } | 2375 | } |
2374 | for (i = 0; s->x11_chanids[i] != -1; i++) { | 2376 | for (i = 0; s->x11_chanids[i] != -1; i++) { |
2375 | channel_register_cleanup(s->x11_chanids[i], | 2377 | channel_register_cleanup(s->x11_chanids[i], |
2376 | session_close_single_x11); | 2378 | session_close_single_x11, 0); |
2377 | } | 2379 | } |
2378 | 2380 | ||
2379 | /* Set up a suitable value for the DISPLAY variable. */ | 2381 | /* Set up a suitable value for the DISPLAY variable. */ |