summaryrefslogtreecommitdiff
path: root/ssh.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh.c')
-rw-r--r--ssh.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/ssh.c b/ssh.c
index 58e4d7bd9..39512c5f1 100644
--- a/ssh.c
+++ b/ssh.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include "includes.h" 13#include "includes.h"
14RCSID("$OpenBSD: ssh.c,v 1.58 2000/07/16 08:27:22 markus Exp $"); 14RCSID("$OpenBSD: ssh.c,v 1.61 2000/08/20 18:42:40 millert Exp $");
15 15
16#include <openssl/evp.h> 16#include <openssl/evp.h>
17#include <openssl/dsa.h> 17#include <openssl/dsa.h>
@@ -253,8 +253,8 @@ main(int ac, char **av)
253 cp = strrchr(av0, '/') + 1; 253 cp = strrchr(av0, '/') + 1;
254 else 254 else
255 cp = av0; 255 cp = av0;
256 if (strcmp(cp, "rsh") != 0 && strcmp(cp, "ssh") != 0 && 256 if (strcmp(cp, "rsh") && strcmp(cp, "ssh") && strcmp(cp, "rlogin") &&
257 strcmp(cp, "rlogin") != 0 && strcmp(cp, "slogin") != 0) 257 strcmp(cp, "slogin") && strcmp(cp, "remsh"))
258 host = cp; 258 host = cp;
259 259
260 for (optind = 1; optind < ac; optind++) { 260 for (optind = 1; optind < ac; optind++) {
@@ -490,6 +490,9 @@ main(int ac, char **av)
490 pwcopy.pw_passwd = xstrdup(pw->pw_passwd); 490 pwcopy.pw_passwd = xstrdup(pw->pw_passwd);
491 pwcopy.pw_uid = pw->pw_uid; 491 pwcopy.pw_uid = pw->pw_uid;
492 pwcopy.pw_gid = pw->pw_gid; 492 pwcopy.pw_gid = pw->pw_gid;
493#ifdef HAVE_PW_CLASS_IN_PASSWD
494 pwcopy.pw_class = xstrdup(pw->pw_class);
495#endif
493 pwcopy.pw_dir = xstrdup(pw->pw_dir); 496 pwcopy.pw_dir = xstrdup(pw->pw_dir);
494 pwcopy.pw_shell = xstrdup(pw->pw_shell); 497 pwcopy.pw_shell = xstrdup(pw->pw_shell);
495 pw = &pwcopy; 498 pw = &pwcopy;
@@ -871,7 +874,7 @@ ssh_session(void)
871 } 874 }
872 875
873 /* Enter the interactive session. */ 876 /* Enter the interactive session. */
874 return client_loop(have_tty, tty_flag ? options.escape_char : -1); 877 return client_loop(have_tty, tty_flag ? options.escape_char : -1, 0);
875} 878}
876 879
877void 880void
@@ -954,9 +957,16 @@ int
954ssh_session2(void) 957ssh_session2(void)
955{ 958{
956 int window, packetmax, id; 959 int window, packetmax, id;
957 int in = dup(STDIN_FILENO); 960 int in, out, err;
958 int out = dup(STDOUT_FILENO); 961
959 int err = dup(STDERR_FILENO); 962 /* If requested, let ssh continue in the background. */
963 if (fork_after_authentication_flag)
964 if (daemon(1, 1) < 0)
965 fatal("daemon() failed: %.200s", strerror(errno));
966
967 in = dup(STDIN_FILENO);
968 out = dup(STDOUT_FILENO);
969 err = dup(STDERR_FILENO);
960 970
961 if (in < 0 || out < 0 || err < 0) 971 if (in < 0 || out < 0 || err < 0)
962 fatal("dump in/out/err failed"); 972 fatal("dump in/out/err failed");
@@ -972,13 +982,13 @@ ssh_session2(void)
972 packetmax = window/2; 982 packetmax = window/2;
973 } 983 }
974 984
985/*XXX MAXPACK */
975 id = channel_new( 986 id = channel_new(
976 "session", SSH_CHANNEL_OPENING, in, out, err, 987 "session", SSH_CHANNEL_OPENING, in, out, err,
977 window, packetmax, CHAN_EXTENDED_WRITE, xstrdup("client-session")); 988 window, packetmax, CHAN_EXTENDED_WRITE, xstrdup("client-session"));
978 989
979
980 channel_open(id); 990 channel_open(id);
981 channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, client_init, (void *)0); 991 channel_register_callback(id, SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, client_init, (void *)0);
982 992
983 return client_loop(tty_flag, tty_flag ? options.escape_char : -1); 993 return client_loop(tty_flag, tty_flag ? options.escape_char : -1, id);
984} 994}