diff options
author | Darren Tucker <dtucker@zip.com.au> | 2010-11-05 12:36:15 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2010-11-05 12:36:15 +1100 |
commit | 920612e45ae8183226e8841ff27cdc54a8287ba2 (patch) | |
tree | 18b9cf0af1c0c470d463b8e03cdd2504f5c3ca2f | |
parent | 97528353c2b4f27169ea9b81e5c4420c734ceea2 (diff) |
- (dtucker) [platform.c platform.h session.c] Add a platform hook to run
after the user's groups are established and move the selinux calls into it.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | platform.c | 23 | ||||
-rw-r--r-- | platform.h | 3 | ||||
-rw-r--r-- | session.c | 9 |
4 files changed, 27 insertions, 10 deletions
@@ -24,6 +24,8 @@ | |||
24 | openbsd-compat/port-solaris.{c,h}] Bug #1824: Add Solaris Project support. | 24 | openbsd-compat/port-solaris.{c,h}] Bug #1824: Add Solaris Project support. |
25 | Patch from cory.erickson at csu mnscu edu with a bit of rework from me. | 25 | Patch from cory.erickson at csu mnscu edu with a bit of rework from me. |
26 | ok djm@ | 26 | ok djm@ |
27 | - (dtucker) [platform.c platform.h session.c] Add a platform hook to run | ||
28 | after the user's groups are established and move the selinux calls into it. | ||
27 | 29 | ||
28 | 20101025 | 30 | 20101025 |
29 | - (tim) [openbsd-compat/glob.h] Remove sys/cdefs.h include that came with | 31 | - (tim) [openbsd-compat/glob.h] Remove sys/cdefs.h include that came with |
diff --git a/platform.c b/platform.c index c894190b2..730e7b718 100644 --- a/platform.c +++ b/platform.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: platform.c,v 1.4 2010/11/05 01:03:05 dtucker Exp $ */ | 1 | /* $Id: platform.c,v 1.5 2010/11/05 01:36:15 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2006 Darren Tucker. All rights reserved. | 4 | * Copyright (c) 2006 Darren Tucker. All rights reserved. |
@@ -57,9 +57,18 @@ platform_post_fork_child(void) | |||
57 | #endif | 57 | #endif |
58 | } | 58 | } |
59 | 59 | ||
60 | /* | ||
61 | * This gets called before switching UIDs, and is called even when sshd is | ||
62 | * not running as root. | ||
63 | */ | ||
60 | void | 64 | void |
61 | platform_setusercontext(struct passwd *pw) | 65 | platform_setusercontext(struct passwd *pw) |
62 | { | 66 | { |
67 | #ifdef WITH_SELINUX | ||
68 | /* Cache selinux status for later use */ | ||
69 | (void)ssh_selinux_enabled(); | ||
70 | #endif | ||
71 | |||
63 | #ifdef USE_SOLARIS_PROJECTS | 72 | #ifdef USE_SOLARIS_PROJECTS |
64 | /* if solaris projects were detected, set the default now */ | 73 | /* if solaris projects were detected, set the default now */ |
65 | if (getuid() == 0 || geteuid() == 0) | 74 | if (getuid() == 0 || geteuid() == 0) |
@@ -67,6 +76,18 @@ platform_setusercontext(struct passwd *pw) | |||
67 | #endif | 76 | #endif |
68 | } | 77 | } |
69 | 78 | ||
79 | /* | ||
80 | * This gets called after we've established the user's groups, and is only | ||
81 | * called if sshd is running as root. | ||
82 | */ | ||
83 | void | ||
84 | platform_setusercontext_post_groups(struct passwd *pw) | ||
85 | { | ||
86 | #ifdef WITH_SELINUX | ||
87 | ssh_selinux_setup_exec_context(pw->pw_name); | ||
88 | #endif | ||
89 | } | ||
90 | |||
70 | char * | 91 | char * |
71 | platform_krb5_get_principal_name(const char *pw_name) | 92 | platform_krb5_get_principal_name(const char *pw_name) |
72 | { | 93 | { |
diff --git a/platform.h b/platform.h index f0cdd8037..be66d55c6 100644 --- a/platform.h +++ b/platform.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: platform.h,v 1.5 2010/11/05 01:03:05 dtucker Exp $ */ | 1 | /* $Id: platform.h,v 1.6 2010/11/05 01:36:15 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2006 Darren Tucker. All rights reserved. | 4 | * Copyright (c) 2006 Darren Tucker. All rights reserved. |
@@ -25,6 +25,7 @@ void platform_pre_fork(void); | |||
25 | void platform_post_fork_parent(pid_t child_pid); | 25 | void platform_post_fork_parent(pid_t child_pid); |
26 | void platform_post_fork_child(void); | 26 | void platform_post_fork_child(void); |
27 | void platform_setusercontext(struct passwd *); | 27 | void platform_setusercontext(struct passwd *); |
28 | void platform_setusercontext_post_groups(struct passwd *); | ||
28 | char *platform_get_krb5_client(const char *); | 29 | char *platform_get_krb5_client(const char *); |
29 | char *platform_krb5_get_principal_name(const char *); | 30 | char *platform_krb5_get_principal_name(const char *); |
30 | 31 | ||
@@ -1471,11 +1471,6 @@ do_setusercontext(struct passwd *pw) | |||
1471 | 1471 | ||
1472 | platform_setusercontext(pw); | 1472 | platform_setusercontext(pw); |
1473 | 1473 | ||
1474 | #ifdef WITH_SELINUX | ||
1475 | /* Cache selinux status for later use */ | ||
1476 | (void)ssh_selinux_enabled(); | ||
1477 | #endif | ||
1478 | |||
1479 | #ifndef HAVE_CYGWIN | 1474 | #ifndef HAVE_CYGWIN |
1480 | if (getuid() == 0 || geteuid() == 0) | 1475 | if (getuid() == 0 || geteuid() == 0) |
1481 | #endif /* HAVE_CYGWIN */ | 1476 | #endif /* HAVE_CYGWIN */ |
@@ -1554,9 +1549,7 @@ do_setusercontext(struct passwd *pw) | |||
1554 | } | 1549 | } |
1555 | #endif /* HAVE_SETPCRED */ | 1550 | #endif /* HAVE_SETPCRED */ |
1556 | 1551 | ||
1557 | #ifdef WITH_SELINUX | 1552 | platform_setusercontext_post_groups(pw); |
1558 | ssh_selinux_setup_exec_context(pw->pw_name); | ||
1559 | #endif | ||
1560 | 1553 | ||
1561 | if (options.chroot_directory != NULL && | 1554 | if (options.chroot_directory != NULL && |
1562 | strcasecmp(options.chroot_directory, "none") != 0) { | 1555 | strcasecmp(options.chroot_directory, "none") != 0) { |