]> andersk Git - openssh.git/blobdiff - session.c
missed sshconnect.c part of:
[openssh.git] / session.c
index 74f5fe2558305f5e7e88e97e8a47d26c7d7ad077..92fb31e09c8b2e920cc26184f3e333499aea7239 100644 (file)
--- a/session.c
+++ b/session.c
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.46 2001/01/04 22:41:03 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.55 2001/02/08 19:30:52 itojun Exp $");
 
-#include "xmalloc.h"
 #include "ssh.h"
+#include "ssh1.h"
+#include "ssh2.h"
+#include "xmalloc.h"
 #include "pty.h"
 #include "packet.h"
 #include "buffer.h"
 #include "mpaux.h"
-#include "servconf.h"
 #include "uidswap.h"
 #include "compat.h"
 #include "channels.h"
 #include "nchan.h"
-
 #include "bufaux.h"
-#include "ssh2.h"
 #include "auth.h"
 #include "auth-options.h"
+#include "pathnames.h"
+#include "log.h"
+#include "servconf.h"
+#include "login.h"
+#include "serverloop.h"
+#include "canohost.h"
+#include "session.h"
 
 #ifdef WITH_IRIX_PROJECT
 #include <proj.h>
 #endif /* WITH_IRIX_PROJECT */
 #ifdef WITH_IRIX_JOBS
 #include <sys/resource.h>
-#endif 
+#endif
 #ifdef WITH_IRIX_AUDIT
 #include <sat.h>
 #endif /* WITH_IRIX_AUDIT */
@@ -145,7 +151,7 @@ extern int startup_pipe;
 static char *xauthfile;
 
 /* original command from peer. */
-char *original_command = NULL; 
+char *original_command = NULL;
 
 /* data */
 #define MAX_SESSIONS 10
@@ -405,10 +411,6 @@ do_authenticated(struct passwd * pw)
 
                case SSH_CMSG_EXEC_SHELL:
                case SSH_CMSG_EXEC_CMD:
-                       /* Set interactive/non-interactive mode. */
-                       packet_set_interactive(have_pty || s->display != NULL,
-                           options.keepalives);
-
                        if (type == SSH_CMSG_EXEC_CMD) {
                                command = packet_get_string(&dlen);
                                debug("Exec command '%.500s'", command);
@@ -548,6 +550,8 @@ do_exec_no_pty(Session *s, const char *command, struct passwd * pw)
        if (pid < 0)
                packet_disconnect("fork failed: %.100s", strerror(errno));
        s->pid = pid;
+       /* Set interactive/non-interactive mode. */
+       packet_set_interactive(s->display != NULL);
 #ifdef USE_PIPES
        /* We are the parent.  Close the child sides of the pipes. */
        close(pin[0]);
@@ -665,6 +669,7 @@ do_exec_pty(Session *s, const char *command, struct passwd * pw)
        s->ptymaster = ptymaster;
 
        /* Enter interactive session. */
+       packet_set_interactive(1);
        if (compat20) {
                session_set_fds(s, ptyfd, fdout, -1);
        } else {
@@ -679,7 +684,7 @@ get_remote_name_or_ip(void)
 {
        static const char *remote = "";
        if (utmp_len > 0)
-               remote = get_canonical_hostname();
+               remote = get_canonical_hostname(options.reverse_mapping_check);
        if (utmp_len == 0 || strlen(remote) > utmp_len)
                remote = get_remote_ipaddr();
        return remote;
@@ -870,11 +875,11 @@ void do_pam_environment(char ***env, int *envsize)
 
        if ((pam_env = fetch_pam_environment()) == NULL)
                return;
-       
+
        for(i = 0; pam_env[i] != NULL; i++) {
                if ((equals = strstr(pam_env[i], "=")) == NULL)
                        continue;
-                       
+
                if (strlen(pam_env[i]) < (sizeof(var_name) - 1)) {
                        memset(var_name, '\0', sizeof(var_name));
                        memset(var_val, '\0', sizeof(var_val));
@@ -900,7 +905,7 @@ void copy_environment(char ***env, int *envsize)
        for(i = 0; environ[i] != NULL; i++) {
                if ((equals = strstr(environ[i], "=")) == NULL)
                        continue;
-                       
+
                if (strlen(environ[i]) < (sizeof(var_name) - 1)) {
                        memset(var_name, '\0', sizeof(var_name));
                        memset(var_val, '\0', sizeof(var_val));
@@ -1057,7 +1062,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
 #ifdef HAVE_OSF_SIA
                extern char **saved_argv;
                extern int saved_argc;
-               char *host = get_canonical_hostname ();
+               char *host = get_canonical_hostname(options.reverse_mapping_check);
 
                if (sia_become_user(NULL, saved_argc, saved_argv, host,
                    pw->pw_name, ttyname, 0, NULL, NULL, SIA_BEU_SETLUID) !=
@@ -1102,7 +1107,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
                        if (jid == -1) {
                                fatal("Failed to create job container: %.100s",
                                      strerror(errno));
-                        }
+                       }
 #  endif /* WITH_IRIX_JOBS */
 #  ifdef WITH_IRIX_ARRAY
                        /* initialize array session */
@@ -1334,28 +1339,28 @@ do_child(const char *command, struct passwd * pw, const char *term,
         * in this order).
         */
        if (!options.use_login) {
-               if (stat(SSH_USER_RC, &st) >= 0) {
+               if (stat(_PATH_SSH_USER_RC, &st) >= 0) {
                        if (debug_flag)
-                               fprintf(stderr, "Running %s %s\n", _PATH_BSHELL, SSH_USER_RC);
+                               fprintf(stderr, "Running %s %s\n", _PATH_BSHELL, _PATH_SSH_USER_RC);
 
-                       f = popen(_PATH_BSHELL " " SSH_USER_RC, "w");
+                       f = popen(_PATH_BSHELL " " _PATH_SSH_USER_RC, "w");
                        if (f) {
                                if (auth_proto != NULL && auth_data != NULL)
                                        fprintf(f, "%s %s\n", auth_proto, auth_data);
                                pclose(f);
                        } else
-                               fprintf(stderr, "Could not run %s\n", SSH_USER_RC);
-               } else if (stat(SSH_SYSTEM_RC, &st) >= 0) {
+                               fprintf(stderr, "Could not run %s\n", _PATH_SSH_USER_RC);
+               } else if (stat(_PATH_SSH_SYSTEM_RC, &st) >= 0) {
                        if (debug_flag)
-                               fprintf(stderr, "Running %s %s\n", _PATH_BSHELL, SSH_SYSTEM_RC);
+                               fprintf(stderr, "Running %s %s\n", _PATH_BSHELL, _PATH_SSH_SYSTEM_RC);
 
-                       f = popen(_PATH_BSHELL " " SSH_SYSTEM_RC, "w");
+                       f = popen(_PATH_BSHELL " " _PATH_SSH_SYSTEM_RC, "w");
                        if (f) {
                                if (auth_proto != NULL && auth_data != NULL)
                                        fprintf(f, "%s %s\n", auth_proto, auth_data);
                                pclose(f);
                        } else
-                               fprintf(stderr, "Could not run %s\n", SSH_SYSTEM_RC);
+                               fprintf(stderr, "Could not run %s\n", _PATH_SSH_SYSTEM_RC);
                } else if (options.xauth_location != NULL) {
                        /* Add authority data to .Xauthority if appropriate. */
                        if (auth_proto != NULL && auth_data != NULL) {
@@ -1380,7 +1385,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
                                        fprintf(f, "add %s %s %s\n", display,
                                            auth_proto, auth_data);
 #ifndef HAVE_CYGWIN /* Unix sockets are not supported */
-                                       if (screen != NULL) 
+                                       if (screen != NULL)
                                                fprintf(f, "add %.*s/unix%s %s %s\n",
                                                    (int)(screen-display), display,
                                                    screen, auth_proto, auth_data);
@@ -1964,7 +1969,7 @@ session_close_by_channel(int id, void *arg)
                session_close(s);
        } else {
                /* notify child, delay session cleanup */
-               if (s->pid <= 1) 
+               if (s->pid <= 1)
                        fatal("session_close_by_channel: Unsafe s->pid = %d", s->pid);
                if (kill(s->pid, (s->ttyfd == -1) ? SIGTERM : SIGHUP) < 0)
                        error("session_close_by_channel: kill %d: %s",
@@ -2001,11 +2006,8 @@ session_proctitle(Session *s)
 }
 
 void
-do_authenticated2(void)
+do_authenticated2(Authctxt *authctxt)
 {
-#ifdef HAVE_LOGIN_CAP
-       struct passwd *pw;
-#endif
 
        /*
         * Cancel the alarm we set to limit the time taken for
@@ -2017,8 +2019,7 @@ do_authenticated2(void)
                startup_pipe = -1;
        }
 #if defined(HAVE_LOGIN_CAP) && defined(HAVE_PW_CLASS_IN_PASSWD)
-       pw = auth_get_user();
-       if ((lc = login_getclass(pw->pw_class)) == NULL) {
+       if ((lc = login_getclass(authctxt->pw->pw_class)) == NULL) {
                error("unable to get login class");
                return;
        }
This page took 0.059008 seconds and 4 git commands to generate.