]> andersk Git - openssh.git/blobdiff - ssh.c
- (dtucker) [auth-pam.c scard-opensc.c] Tinderbox says auth-pam.c uses
[openssh.git] / ssh.c
diff --git a/ssh.c b/ssh.c
index 222aaab7ffa421f408f372d382440dd02455b786..3c21fa37d92fdd3789c3a0585a6e971eb4bfd1c9 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -40,7 +40,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.205 2003/12/09 17:30:05 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.213 2004/05/08 00:01:37 deraadt Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -62,12 +62,12 @@ RCSID("$OpenBSD: ssh.c,v 1.205 2003/12/09 17:30:05 markus Exp $");
 #include "log.h"
 #include "readconf.h"
 #include "sshconnect.h"
-#include "tildexpand.h"
 #include "dispatch.h"
 #include "misc.h"
 #include "kex.h"
 #include "mac.h"
-#include "sshtty.h"
+#include "sshpty.h"
+#include "match.h"
 
 #ifdef SMARTCARD
 #include "scard.h"
@@ -146,49 +146,12 @@ pid_t proxy_command_pid = 0;
 static void
 usage(void)
 {
-       fprintf(stderr, "Usage: %s [options] host [command]\n", __progname);
-       fprintf(stderr, "Options:\n");
-       fprintf(stderr, "  -l user     Log in using this user name.\n");
-       fprintf(stderr, "  -n          Redirect input from " _PATH_DEVNULL ".\n");
-       fprintf(stderr, "  -F config   Config file (default: ~/%s).\n",
-            _PATH_SSH_USER_CONFFILE);
-       fprintf(stderr, "  -A          Enable authentication agent forwarding.\n");
-       fprintf(stderr, "  -a          Disable authentication agent forwarding (default).\n");
-       fprintf(stderr, "  -X          Enable X11 connection forwarding.\n");
-       fprintf(stderr, "  -Y          Enable trusted X11 connection forwarding.\n");
-       fprintf(stderr, "  -x          Disable X11 connection forwarding (default).\n");
-       fprintf(stderr, "  -i file     Identity for public key authentication "
-           "(default: ~/.ssh/identity)\n");
-#ifdef SMARTCARD
-       fprintf(stderr, "  -I reader   Set smartcard reader.\n");
-#endif
-       fprintf(stderr, "  -t          Tty; allocate a tty even if command is given.\n");
-       fprintf(stderr, "  -T          Do not allocate a tty.\n");
-       fprintf(stderr, "  -v          Verbose; display verbose debugging messages.\n");
-       fprintf(stderr, "              Multiple -v increases verbosity.\n");
-       fprintf(stderr, "  -V          Display version number only.\n");
-       fprintf(stderr, "  -q          Quiet; don't display any warning messages.\n");
-       fprintf(stderr, "  -f          Fork into background after authentication.\n");
-       fprintf(stderr, "  -e char     Set escape character; ``none'' = disable (default: ~).\n");
-
-       fprintf(stderr, "  -c cipher   Select encryption algorithm\n");
-       fprintf(stderr, "  -m macs     Specify MAC algorithms for protocol version 2.\n");
-       fprintf(stderr, "  -p port     Connect to this port.  Server must be on the same port.\n");
-       fprintf(stderr, "  -L listen-port:host:port   Forward local port to remote address\n");
-       fprintf(stderr, "  -R listen-port:host:port   Forward remote port to local address\n");
-       fprintf(stderr, "              These cause %s to listen for connections on a port, and\n", __progname);
-       fprintf(stderr, "              forward them to the other side by connecting to host:port.\n");
-       fprintf(stderr, "  -D port     Enable dynamic application-level port forwarding.\n");
-       fprintf(stderr, "  -C          Enable compression.\n");
-       fprintf(stderr, "  -N          Do not execute a shell or command.\n");
-       fprintf(stderr, "  -g          Allow remote hosts to connect to forwarded ports.\n");
-       fprintf(stderr, "  -1          Force protocol version 1.\n");
-       fprintf(stderr, "  -2          Force protocol version 2.\n");
-       fprintf(stderr, "  -4          Use IPv4 only.\n");
-       fprintf(stderr, "  -6          Use IPv6 only.\n");
-       fprintf(stderr, "  -o 'option' Process the option as if it was read from a configuration file.\n");
-       fprintf(stderr, "  -s          Invoke command (mandatory) as SSH2 subsystem.\n");
-       fprintf(stderr, "  -b addr     Local IP address.\n");
+       fprintf(stderr,
+"usage: ssh [-1246AaCfghkNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]\n"
+"           [-D port] [-e escape_char] [-F configfile] [-i identity_file]\n"
+"           [-L port:host:hostport] [-l login_name] [-m mac_spec] [-o option]\n"
+"           [-p port] [-R port:host:hostport] [user@]hostname [command]\n"
+       );
        exit(1);
 }
 
@@ -347,12 +310,8 @@ again:
                        }
                        /* fallthrough */
                case 'V':
-                       fprintf(stderr,
-                           "%s, SSH protocols %d.%d/%d.%d, %s\n",
-                           SSH_VERSION,
-                           PROTOCOL_MAJOR_1, PROTOCOL_MINOR_1,
-                           PROTOCOL_MAJOR_2, PROTOCOL_MINOR_2,
-                           SSLeay_version(SSLEAY_VERSION));
+                       fprintf(stderr, "%s, %s\n",
+                           SSH_VERSION, SSLeay_version(SSLEAY_VERSION));
                        if (opt == 'V')
                                exit(0);
                        break;
@@ -567,16 +526,17 @@ again:
         * file if the user specifies a config file on the command line.
         */
        if (config != NULL) {
-               if (!read_config_file(config, host, &options))
+               if (!read_config_file(config, host, &options, 0))
                        fatal("Can't open user config file %.100s: "
                            "%.100s", config, strerror(errno));
        } else  {
                snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir,
                    _PATH_SSH_USER_CONFFILE);
-               (void)read_config_file(buf, host, &options);
+               (void)read_config_file(buf, host, &options, 1);
 
                /* Read systemwide configuration file after use config. */
-               (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, &options);
+               (void)read_config_file(_PATH_HOST_CONFIG_FILE, host, 
+                   &options, 0);
        }
 
        /* Fill configuration defaults. */
@@ -777,7 +737,7 @@ x11_get_proto(char **_proto, char **_data)
                                    xauthdir);
                                snprintf(cmd, sizeof(cmd),
                                    "%s -f %s generate %s " SSH_X11_PROTO
-                                   " untrusted timeout 120 2>" _PATH_DEVNULL,
+                                   " untrusted timeout 1200 2>" _PATH_DEVNULL,
                                    options.xauth_location, xauthfile, display);
                                debug2("x11_get_proto: %s", cmd);
                                if (system(cmd) == 0)
@@ -1029,16 +989,13 @@ client_subsystem_reply(int type, u_int32_t seq, void *ctxt)
 }
 
 void
-client_global_request_reply(int type, u_int32_t seq, void *ctxt)
+client_global_request_reply_fwd(int type, u_int32_t seq, void *ctxt)
 {
        int i;
 
        i = client_global_request_id++;
-       if (i >= options.num_remote_forwards) {
-               debug("client_global_request_reply: too many replies %d > %d",
-                   i, options.num_remote_forwards);
+       if (i >= options.num_remote_forwards)
                return;
-       }
        debug("remote forward %s for: listen %d, connect %s:%d",
            type == SSH2_MSG_REQUEST_SUCCESS ? "success" : "failure",
            options.remote_forwards[i].port,
@@ -1100,6 +1057,44 @@ ssh_session2_setup(int id, void *arg)
                packet_send();
        }
 
+       /* Transfer any environment variables from client to server */
+       if (options.num_send_env != 0) {
+               int i, j, matched;
+               extern char **environ;
+               char *name, *val;
+
+               debug("Sending environment.");
+               for (i = 0; environ && environ[i] != NULL; i++) {
+                       /* Split */
+                       name = xstrdup(environ[i]);
+                       if ((val = strchr(name, '=')) == NULL) {
+                               free(name);
+                               continue;
+                       }
+                       *val++ = '\0';
+
+                       matched = 0;
+                       for (j = 0; j < options.num_send_env; j++) {
+                               if (match_pattern(name, options.send_env[j])) {
+                                       matched = 1;
+                                       break;
+                               }
+                       }
+                       if (!matched) {
+                               debug3("Ignored env %s", name);
+                               free(name);
+                               continue;
+                       }
+
+                       debug("Sending env %s = %s", name, val);
+                       channel_request_start(id, "env", 0);
+                       packet_put_cstring(name);
+                       packet_put_cstring(val);
+                       packet_send();
+                       free(name);
+               }
+       }
+
        len = buffer_len(&command);
        if (len > 0) {
                if (len > 900)
This page took 0.093028 seconds and 4 git commands to generate.