summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--servconf.c21
-rw-r--r--servconf.h5
-rw-r--r--ssh.h9
-rw-r--r--sshd.c15
5 files changed, 26 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index ed52bdc96..48a67cb04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -100,6 +100,10 @@
100 - markus@cvs.openbsd.org 2002/03/19 15:31:47 100 - markus@cvs.openbsd.org 2002/03/19 15:31:47
101 [auth.c] 101 [auth.c]
102 check for NULL; from provos@ 102 check for NULL; from provos@
103 - stevesk@cvs.openbsd.org 2002/03/20 19:12:25
104 [servconf.c servconf.h ssh.h sshd.c]
105 for unprivileged user, group do:
106 pw=getpwnam(SSH_PRIVSEP_USER); do_setusercontext(pw). ok provos@
103 107
10420020317 10820020317
105 - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted, 109 - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted,
@@ -7946,4 +7950,4 @@
7946 - Wrote replacements for strlcpy and mkdtemp 7950 - Wrote replacements for strlcpy and mkdtemp
7947 - Released 1.0pre1 7951 - Released 1.0pre1
7948 7952
7949$Id: ChangeLog,v 1.1953 2002/03/22 03:08:30 mouring Exp $ 7953$Id: ChangeLog,v 1.1954 2002/03/22 03:11:49 mouring Exp $
diff --git a/servconf.c b/servconf.c
index 085854908..8e6ee5bb3 100644
--- a/servconf.c
+++ b/servconf.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: servconf.c,v 1.104 2002/03/19 03:03:43 stevesk Exp $"); 13RCSID("$OpenBSD: servconf.c,v 1.105 2002/03/20 19:12:24 stevesk Exp $");
14 14
15#if defined(KRB4) || defined(KRB5) 15#if defined(KRB4) || defined(KRB5)
16#include <krb.h> 16#include <krb.h>
@@ -113,9 +113,6 @@ initialize_server_options(ServerOptions *options)
113 options->authorized_keys_file = NULL; 113 options->authorized_keys_file = NULL;
114 options->authorized_keys_file2 = NULL; 114 options->authorized_keys_file2 = NULL;
115 115
116 options->unprivileged_user = -1;
117 options->unprivileged_group = -1;
118
119 /* Needs to be accessable in many places */ 116 /* Needs to be accessable in many places */
120 use_privsep = -1; 117 use_privsep = -1;
121} 118}
@@ -247,10 +244,6 @@ fill_default_server_options(ServerOptions *options)
247 /* Turn privilege separation _off_ by default */ 244 /* Turn privilege separation _off_ by default */
248 if (use_privsep == -1) 245 if (use_privsep == -1)
249 use_privsep = 0; 246 use_privsep = 0;
250 if (options->unprivileged_user == -1)
251 options->unprivileged_user = 32767;
252 if (options->unprivileged_group == -1)
253 options->unprivileged_group = 32767;
254} 247}
255 248
256/* Keyword tokens. */ 249/* Keyword tokens. */
@@ -283,7 +276,7 @@ typedef enum {
283 sBanner, sVerifyReverseMapping, sHostbasedAuthentication, 276 sBanner, sVerifyReverseMapping, sHostbasedAuthentication,
284 sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, 277 sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
285 sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2, 278 sClientAliveCountMax, sAuthorizedKeysFile, sAuthorizedKeysFile2,
286 sUsePrivilegeSeparation, sUnprivUser, sUnprivGroup, 279 sUsePrivilegeSeparation,
287 sDeprecated 280 sDeprecated
288} ServerOpCodes; 281} ServerOpCodes;
289 282
@@ -360,8 +353,6 @@ static struct {
360 { "authorizedkeysfile", sAuthorizedKeysFile }, 353 { "authorizedkeysfile", sAuthorizedKeysFile },
361 { "authorizedkeysfile2", sAuthorizedKeysFile2 }, 354 { "authorizedkeysfile2", sAuthorizedKeysFile2 },
362 { "useprivilegeseparation", sUsePrivilegeSeparation}, 355 { "useprivilegeseparation", sUsePrivilegeSeparation},
363 { "unprivuser", sUnprivUser},
364 { "unprivgroup", sUnprivGroup},
365 { NULL, sBadOption } 356 { NULL, sBadOption }
366}; 357};
367 358
@@ -742,14 +733,6 @@ parse_flag:
742 intptr = &use_privsep; 733 intptr = &use_privsep;
743 goto parse_flag; 734 goto parse_flag;
744 735
745 case sUnprivUser:
746 intptr = &options->unprivileged_user;
747 goto parse_int;
748
749 case sUnprivGroup:
750 intptr = &options->unprivileged_group;
751 goto parse_int;
752
753 case sAllowUsers: 736 case sAllowUsers:
754 while ((arg = strdelim(&cp)) && *arg != '\0') { 737 while ((arg = strdelim(&cp)) && *arg != '\0') {
755 if (options->num_allow_users >= MAX_ALLOW_USERS) 738 if (options->num_allow_users >= MAX_ALLOW_USERS)
diff --git a/servconf.h b/servconf.h
index 06afaa3c8..c4e5b5f42 100644
--- a/servconf.h
+++ b/servconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: servconf.h,v 1.56 2002/03/19 03:03:43 stevesk Exp $ */ 1/* $OpenBSD: servconf.h,v 1.57 2002/03/20 19:12:25 stevesk Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -130,9 +130,6 @@ typedef struct {
130 char *authorized_keys_file; /* File containing public keys */ 130 char *authorized_keys_file; /* File containing public keys */
131 char *authorized_keys_file2; 131 char *authorized_keys_file2;
132 int pam_authentication_via_kbd_int; 132 int pam_authentication_via_kbd_int;
133
134 int unprivileged_user; /* User unprivileged child uses */
135 int unprivileged_group; /* Group unprivileged child uses */
136} ServerOptions; 133} ServerOptions;
137 134
138void initialize_server_options(ServerOptions *); 135void initialize_server_options(ServerOptions *);
diff --git a/ssh.h b/ssh.h
index fdf554df0..078c9f7c7 100644
--- a/ssh.h
+++ b/ssh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh.h,v 1.64 2002/03/04 17:27:39 stevesk Exp $ */ 1/* $OpenBSD: ssh.h,v 1.65 2002/03/20 19:12:25 stevesk Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -99,4 +99,11 @@
99/* Used to identify ``EscapeChar none'' */ 99/* Used to identify ``EscapeChar none'' */
100#define SSH_ESCAPECHAR_NONE -2 100#define SSH_ESCAPECHAR_NONE -2
101 101
102/*
103 * unprivileged user when UsePrivilegeSeparation=yes;
104 * sshd will change its pivileges to this user and its
105 * primary group.
106 */
107#define SSH_PRIVSEP_USER "nobody"
108
102#endif /* SSH_H */ 109#endif /* SSH_H */
diff --git a/sshd.c b/sshd.c
index b6e71d84a..dc109815f 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.234 2002/03/19 10:49:35 markus Exp $"); 45RCSID("$OpenBSD: sshd.c,v 1.235 2002/03/20 19:12:25 stevesk Exp $");
46 46
47#include <openssl/dh.h> 47#include <openssl/dh.h>
48#include <openssl/bn.h> 48#include <openssl/bn.h>
@@ -521,6 +521,7 @@ privsep_preauth_child(void)
521{ 521{
522 u_int32_t rand[256]; 522 u_int32_t rand[256];
523 int i; 523 int i;
524 struct passwd *pw;
524 525
525 /* Enable challenge-response authentication for privilege separation */ 526 /* Enable challenge-response authentication for privilege separation */
526 privsep_challenge_enable(); 527 privsep_challenge_enable();
@@ -532,6 +533,11 @@ privsep_preauth_child(void)
532 /* Demote the private keys to public keys. */ 533 /* Demote the private keys to public keys. */
533 demote_sensitive_data(); 534 demote_sensitive_data();
534 535
536 if ((pw = getpwnam(SSH_PRIVSEP_USER)) == NULL)
537 fatal("%s: no user", SSH_PRIVSEP_USER);
538 memset(pw->pw_passwd, 0, strlen(pw->pw_passwd));
539 endpwent();
540
535 /* Change our root directory*/ 541 /* Change our root directory*/
536 if (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1) 542 if (chroot(_PATH_PRIVSEP_CHROOT_DIR) == -1)
537 fatal("chroot(\"%s\"): %s", _PATH_PRIVSEP_CHROOT_DIR, 543 fatal("chroot(\"%s\"): %s", _PATH_PRIVSEP_CHROOT_DIR,
@@ -540,10 +546,9 @@ privsep_preauth_child(void)
540 fatal("chdir(/)"); 546 fatal("chdir(/)");
541 547
542 /* Drop our privileges */ 548 /* Drop our privileges */
543 setegid(options.unprivileged_group); 549 debug3("privsep user:group %u:%u", (u_int)pw->pw_uid,
544 setgid(options.unprivileged_group); 550 (u_int)pw->pw_gid);
545 seteuid(options.unprivileged_user); 551 do_setusercontext(pw);
546 setuid(options.unprivileged_user);
547} 552}
548 553
549static void 554static void