Commit 1a80a019 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Solaris sandbox changes.

Submitted by:	Nils Goroll
parent 3b73cf0e
...@@ -70,6 +70,7 @@ void mgt_sandbox(void); ...@@ -70,6 +70,7 @@ void mgt_sandbox(void);
#ifdef HAVE_SETPPRIV #ifdef HAVE_SETPPRIV
void mgt_sandbox_solaris_init(void); void mgt_sandbox_solaris_init(void);
void mgt_sandbox_solaris_fini(void); void mgt_sandbox_solaris_fini(void);
void mgt_sandbox_solaris_privsep(void);
#endif #endif
/* mgt_shmem.c */ /* mgt_shmem.c */
......
...@@ -63,17 +63,17 @@ ...@@ -63,17 +63,17 @@
void void
mgt_sandbox(void) mgt_sandbox(void)
{ {
#ifdef HAVE_SETPPRIV #ifdef HAVE_SETPPRIV
mgt_sandbox_solaris_init(); mgt_sandbox_solaris_init();
#endif mgt_sandbox_solaris_privsep();
#else
if (geteuid() == 0) { if (geteuid() == 0) {
XXXAZ(setgid(params->gid)); XXXAZ(setgid(params->gid));
XXXAZ(setuid(params->uid)); XXXAZ(setuid(params->uid));
} else { } else {
REPORT0(LOG_INFO, "Not running as root, no priv-sep"); REPORT0(LOG_INFO, "Not running as root, no priv-sep");
} }
#endif
/* On Linux >= 2.4, you need to set the dumpable flag /* On Linux >= 2.4, you need to set the dumpable flag
to get core dumps after you have done a setuid. */ to get core dumps after you have done a setuid. */
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <syslog.h> #include <syslog.h>
#include <unistd.h>
#include "mgt.h" #include "mgt.h"
...@@ -153,6 +154,20 @@ mgt_sandbox_solaris_init(void) ...@@ -153,6 +154,20 @@ mgt_sandbox_solaris_init(void)
priv_freeset(priv_all); priv_freeset(priv_all);
} }
void
mgt_sandbox_solaris_privsep(void)
{
if (priv_ineffect(PRIV_PROC_SETID)) {
if (getgid() != params->gid)
XXXAZ(setgid(params->gid));
if (getuid() != params->uid)
XXXAZ(setuid(params->uid));
} else {
REPORT(LOG_INFO, "Privilege %s missing, will not change uid/gid",
PRIV_PROC_SETID);
}
}
/* /*
* Waive most privileges in the child * Waive most privileges in the child
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment