summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--platform.c23
-rw-r--r--platform.h3
-rw-r--r--session.c9
4 files changed, 27 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 9622f1944..d1a0cd0fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
2820101025 3020101025
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 */
60void 64void
61platform_setusercontext(struct passwd *pw) 65platform_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 */
83void
84platform_setusercontext_post_groups(struct passwd *pw)
85{
86#ifdef WITH_SELINUX
87 ssh_selinux_setup_exec_context(pw->pw_name);
88#endif
89}
90
70char * 91char *
71platform_krb5_get_principal_name(const char *pw_name) 92platform_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);
25void platform_post_fork_parent(pid_t child_pid); 25void platform_post_fork_parent(pid_t child_pid);
26void platform_post_fork_child(void); 26void platform_post_fork_child(void);
27void platform_setusercontext(struct passwd *); 27void platform_setusercontext(struct passwd *);
28void platform_setusercontext_post_groups(struct passwd *);
28char *platform_get_krb5_client(const char *); 29char *platform_get_krb5_client(const char *);
29char *platform_krb5_get_principal_name(const char *); 30char *platform_krb5_get_principal_name(const char *);
30 31
diff --git a/session.c b/session.c
index ab32bb55f..7994dd60b 100644
--- a/session.c
+++ b/session.c
@@ -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) {