Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Solaris sandbox changes.
Browse files Browse the repository at this point in the history
Submitted by:	Nils Goroll

Conflicts:

	bin/varnishd/mgt_sandbox_solaris.c
  • Loading branch information
bsdphk authored and Tollef Fog Heen committed Oct 18, 2011
1 parent 66ba62e commit 5cc9462
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions bin/varnishd/mgt.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void mgt_sandbox(void);
#ifdef HAVE_SETPPRIV
void mgt_sandbox_solaris_init(void);
void mgt_sandbox_solaris_fini(void);
void mgt_sandbox_solaris_privsep(void);
#endif

/* mgt_shmem.c */
Expand Down
6 changes: 3 additions & 3 deletions bin/varnishd/mgt_sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@
void
mgt_sandbox(void)
{

#ifdef HAVE_SETPPRIV
mgt_sandbox_solaris_init();
#endif

mgt_sandbox_solaris_privsep();
#else
if (geteuid() == 0) {
XXXAZ(setgid(params->gid));
XXXAZ(setuid(params->uid));
} else {
REPORT0(LOG_INFO, "Not running as root, no priv-sep");
}
#endif

/* On Linux >= 2.4, you need to set the dumpable flag
to get core dumps after you have done a setuid. */
Expand Down
18 changes: 18 additions & 0 deletions bin/varnishd/mgt_sandbox_solaris.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
#ifdef HAVE_PRIV_H
#include <priv.h>
#endif
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>

#include "mgt.h"
#include "heritage.h"
Expand Down Expand Up @@ -154,6 +158,20 @@ mgt_sandbox_solaris_init(void)
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
*
Expand Down

0 comments on commit 5cc9462

Please sign in to comment.