summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2004-05-01 11:41:25 +0000
committerColin Watson <cjwatson@debian.org>2004-05-01 11:41:25 +0000
commit915bfea2af69a3bb352a9b4e98e3434b8425124d (patch)
treeef732498a75f2e13a7a9827edc833dc58bc2a2af /sshd.c
parent89e7a2dfe6044f3980098911a7470d401ff70eb1 (diff)
parent16f1d21ea191deaaeeba719d01c0ad82aa044653 (diff)
Merge 3.8.1p1 to the trunk, minus RFC.nroff (#211640).
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/sshd.c b/sshd.c
index 1f0d7747a..a5ec0b3e7 100644
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
42 */ 42 */
43 43
44#include "includes.h" 44#include "includes.h"
45RCSID("$OpenBSD: sshd.c,v 1.286 2004/02/23 12:02:33 markus Exp $"); 45RCSID("$OpenBSD: sshd.c,v 1.290 2004/03/11 10:21:17 markus Exp $");
46 46
47#include <openssl/dh.h> 47#include <openssl/dh.h>
48#include <openssl/bn.h> 48#include <openssl/bn.h>
@@ -101,7 +101,6 @@ extern char *__progname;
101#else 101#else
102char *__progname; 102char *__progname;
103#endif 103#endif
104extern char **environ;
105 104
106/* Server configuration options. */ 105/* Server configuration options. */
107ServerOptions options; 106ServerOptions options;
@@ -568,7 +567,7 @@ privsep_preauth_child(void)
568 debug3("privsep user:group %u:%u", (u_int)pw->pw_uid, 567 debug3("privsep user:group %u:%u", (u_int)pw->pw_uid,
569 (u_int)pw->pw_gid); 568 (u_int)pw->pw_gid);
570#if 0 569#if 0
571 /* XXX not ready, to heavy after chroot */ 570 /* XXX not ready, too heavy after chroot */
572 do_setusercontext(pw); 571 do_setusercontext(pw);
573#else 572#else
574 gidset[0] = pw->pw_gid; 573 gidset[0] = pw->pw_gid;
@@ -764,26 +763,12 @@ drop_connection(int startups)
764static void 763static void
765usage(void) 764usage(void)
766{ 765{
767 fprintf(stderr, "sshd version %s, %s\n", 766 fprintf(stderr, "%s, %s\n",
768 SSH_VERSION, SSLeay_version(SSLEAY_VERSION)); 767 SSH_VERSION, SSLeay_version(SSLEAY_VERSION));
769 fprintf(stderr, "Usage: %s [options]\n", __progname); 768 fprintf(stderr,
770 fprintf(stderr, "Options:\n"); 769"usage: sshd [-46Ddeiqt] [-b bits] [-f config_file] [-g login_grace_time]\n"
771 fprintf(stderr, " -f file Configuration file (default %s)\n", _PATH_SERVER_CONFIG_FILE); 770" [-h host_key_file] [-k key_gen_time] [-o option] [-p port] [-u len]\n"
772 fprintf(stderr, " -d Debugging mode (multiple -d means more debugging)\n"); 771 );
773 fprintf(stderr, " -i Started from inetd\n");
774 fprintf(stderr, " -D Do not fork into daemon mode\n");
775 fprintf(stderr, " -t Only test configuration file and keys\n");
776 fprintf(stderr, " -q Quiet (no logging)\n");
777 fprintf(stderr, " -p port Listen on the specified port (default: 22)\n");
778 fprintf(stderr, " -k seconds Regenerate server key every this many seconds (default: 3600)\n");
779 fprintf(stderr, " -g seconds Grace period for authentication (default: 600)\n");
780 fprintf(stderr, " -b bits Size of server RSA key (default: 768 bits)\n");
781 fprintf(stderr, " -h file File from which to read host key (default: %s)\n",
782 _PATH_HOST_KEY_FILE);
783 fprintf(stderr, " -u len Maximum hostname length for utmp recording\n");
784 fprintf(stderr, " -4 Use IPv4 only\n");
785 fprintf(stderr, " -6 Use IPv6 only\n");
786 fprintf(stderr, " -o option Process the option as if it was read from a configuration file.\n");
787 exit(1); 772 exit(1);
788} 773}
789 774
@@ -832,6 +817,9 @@ main(int ac, char **av)
832 av = saved_argv; 817 av = saved_argv;
833#endif 818#endif
834 819
820 if (geteuid() == 0 && setgroups(0, NULL) == -1)
821 debug("setgroups(): %.200s", strerror(errno));
822
835 /* Initialize configuration options to their default values. */ 823 /* Initialize configuration options to their default values. */
836 initialize_server_options(&options); 824 initialize_server_options(&options);
837 825
@@ -945,6 +933,13 @@ main(int ac, char **av)
945 SYSLOG_FACILITY_AUTH : options.log_facility, 933 SYSLOG_FACILITY_AUTH : options.log_facility,
946 log_stderr || !inetd_flag); 934 log_stderr || !inetd_flag);
947 935
936#ifdef _AIX
937 /*
938 * Unset KRB5CCNAME, otherwise the user's session may inherit it from
939 * root's environment
940 */
941 unsetenv("KRB5CCNAME");
942#endif /* _AIX */
948#ifdef _UNICOS 943#ifdef _UNICOS
949 /* Cray can define user privs drop all prives now! 944 /* Cray can define user privs drop all prives now!
950 * Not needed on PRIV_SU systems! 945 * Not needed on PRIV_SU systems!
@@ -1111,11 +1106,6 @@ main(int ac, char **av)
1111 unmounted if desired. */ 1106 unmounted if desired. */
1112 chdir("/"); 1107 chdir("/");
1113 1108
1114#ifndef HAVE_CYGWIN
1115 /* Clear environment */
1116 environ[0] = NULL;
1117#endif
1118
1119 /* ignore SIGPIPE */ 1109 /* ignore SIGPIPE */
1120 signal(SIGPIPE, SIG_IGN); 1110 signal(SIGPIPE, SIG_IGN);
1121 1111
@@ -1394,6 +1384,7 @@ main(int ac, char **av)
1394 } 1384 }
1395 1385
1396 /* This is the child processing a new connection. */ 1386 /* This is the child processing a new connection. */
1387 setproctitle("%s", "[accepted]");
1397 1388
1398 /* 1389 /*
1399 * Create a new session and process group since the 4.4BSD 1390 * Create a new session and process group since the 4.4BSD