summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-03-22 03:11:49 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-03-22 03:11:49 +0000
commitc7431341911e911993776c357ca57d1fb7ed1b23 (patch)
tree3e7fec3c3985b8f7584b4a03ce7df035d361c442 /sshd.c
parentf34e4eb6c730fa38640aeef5f6801035caaba460 (diff)
- stevesk@cvs.openbsd.org 2002/03/20 19:12:25
[servconf.c servconf.h ssh.h sshd.c] for unprivileged user, group do: pw=getpwnam(SSH_PRIVSEP_USER); do_setusercontext(pw). ok provos@
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c15
1 files changed, 10 insertions, 5 deletions
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