]> andersk Git - openssh.git/blobdiff - session.c
- markus@cvs.openbsd.org 2001/06/19 15:40:45
[openssh.git] / session.c
index 65f6bac1536e50fd54e51ed5ec03066b74466949..fbdc419eb5d73d4d6e67487e8d275c8ee3c58cc1 100644 (file)
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.89 2001/06/13 09:10:31 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.92 2001/06/19 15:40:45 markus Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -128,6 +128,7 @@ int session_setup_x11fwd(Session *s);
 void   session_close(Session *s);
 void   do_exec_pty(Session *s, const char *command);
 void   do_exec_no_pty(Session *s, const char *command);
+void   do_exec(Session *s, const char *command);
 void   do_login(Session *s, const char *command);
 #ifdef LOGIN_NEEDS_UTMPX
 void   do_pre_login(Session *s);
@@ -149,7 +150,7 @@ extern int startup_pipe;
 extern void destroy_sensitive_data(void);
 
 /* original command from peer. */
-char *original_command = NULL;
+const char *original_command = NULL;
 
 /* data */
 #define MAX_SESSIONS 10
@@ -308,22 +309,12 @@ do_authenticated1(Authctxt *authctxt)
                        if (type == SSH_CMSG_EXEC_CMD) {
                                command = packet_get_string(&dlen);
                                debug("Exec command '%.500s'", command);
-                               packet_integrity_check(plen, 4 + dlen, type);
+                               do_exec(s, command);
+                               xfree(command);
                        } else {
-                               command = NULL;
-                               packet_integrity_check(plen, 0, type);
-                       }
-                       if (forced_command != NULL) {
-                               original_command = command;
-                               command = forced_command;
-                               debug("Forced command '%.500s'", forced_command);
+                               do_exec(s, NULL);
                        }
-                       if (s->ttyfd != -1)
-                               do_exec_pty(s, command);
-                       else
-                               do_exec_no_pty(s, command);
-                       if (command != NULL)
-                               xfree(command);
+                       packet_done();
                        session_close(s);
                        return;
 
@@ -598,6 +589,29 @@ do_pre_login(Session *s)
 }
 #endif
 
+/*
+ * This is called to fork and execute a command.  If another command is
+ * to be forced, execute that instead.
+ */
+void
+do_exec(Session *s, const char *command)
+{
+       if (forced_command) {
+               original_command = command;
+               command = forced_command;
+               forced_command = NULL;
+               debug("Forced command '%.900s'", command);
+       }
+
+       if (s->ttyfd != -1)
+               do_exec_pty(s, command);
+       else
+               do_exec_no_pty(s, command);
+
+       original_command = NULL;
+}
+
+
 /* administrative, login(1)-like work */
 void
 do_login(Session *s, const char *command)
@@ -1666,13 +1680,8 @@ session_x11_req(Session *s)
 int
 session_shell_req(Session *s)
 {
-       /* if forced_command == NULL, the shell is execed */
-       char *shell = forced_command;
        packet_done();
-       if (s->ttyfd == -1)
-               do_exec_no_pty(s, shell);
-       else
-               do_exec_pty(s, shell);
+       do_exec(s, NULL);
        return 1;
 }
 
@@ -1682,17 +1691,8 @@ session_exec_req(Session *s)
        u_int len;
        char *command = packet_get_string(&len);
        packet_done();
-       if (forced_command) {
-               original_command = command;
-               command = forced_command;
-               debug("Forced command '%.500s'", forced_command);
-       }
-       if (s->ttyfd == -1)
-               do_exec_no_pty(s, command);
-       else
-               do_exec_pty(s, command);
-       if (forced_command == NULL)
-               xfree(command);
+       do_exec(s, command);
+       xfree(command);
        return 1;
 }
 
@@ -1975,6 +1975,11 @@ session_setup_x11fwd(Session *s)
                packet_send_debug("No xauth program; cannot forward with spoofing.");
                return 0;
        }
+       if (options.use_login) {
+               packet_send_debug("X11 forwarding disabled; "
+                   "not compatible with UseLogin=yes.");
+               return 0;
+       }
        if (s->display != NULL) {
                debug("X11 display already set.");
                return 0;
This page took 0.052733 seconds and 4 git commands to generate.