|
|
b9dfc8c |
diff -up policycoreutils-2.0.86/restorecond/restorecond_user.conf.sandbox policycoreutils-2.0.86/restorecond/restorecond_user.conf
|
|
|
b9dfc8c |
--- policycoreutils-2.0.86/restorecond/restorecond_user.conf.sandbox 2011-06-13 13:47:06.552590955 -0400
|
|
|
b9dfc8c |
+++ policycoreutils-2.0.86/restorecond/restorecond_user.conf 2011-06-13 13:47:27.757820459 -0400
|
|
|
b9dfc8c |
@@ -4,4 +4,4 @@
|
|
|
b9dfc8c |
~/local/*
|
|
|
b9dfc8c |
~/.fonts/*
|
|
|
b9dfc8c |
~/.cache/*
|
|
|
b9dfc8c |
-
|
|
|
b9dfc8c |
+~/.config/*
|
|
|
b9dfc8c |
diff -up policycoreutils-2.0.86/sandbox/sandbox.8.sandbox policycoreutils-2.0.86/sandbox/sandbox.8
|
|
|
b9dfc8c |
--- policycoreutils-2.0.86/sandbox/sandbox.8.sandbox 2011-07-07 14:42:18.298415909 -0400
|
|
|
b9dfc8c |
+++ policycoreutils-2.0.86/sandbox/sandbox.8 2011-07-07 14:42:30.567508958 -0400
|
|
|
b9dfc8c |
@@ -3,11 +3,11 @@
|
|
|
b9dfc8c |
sandbox \- Run cmd under an SELinux sandbox
|
|
|
b9dfc8c |
.SH SYNOPSIS
|
|
|
b9dfc8c |
.B sandbox
|
|
|
b9dfc8c |
-[-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [ -w windowsize ] [[-i file ]...] [ -t type ] cmd
|
|
|
b9dfc8c |
+[-C] [-c] [-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [ -w windowsize ] [[-i file ]...] [ -t type ] cmd
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
.br
|
|
|
b9dfc8c |
.B sandbox
|
|
|
b9dfc8c |
-[-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [ -w windowsize ] [[-i file ]...] [ -t type ] -S
|
|
|
b9dfc8c |
+[-C] [-c] [-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [ -w windowsize ] [[-i file ]...] [ -t type ] -S
|
|
|
b9dfc8c |
.br
|
|
|
b9dfc8c |
.SH DESCRIPTION
|
|
|
b9dfc8c |
.PP
|
|
|
b9dfc8c |
@@ -60,8 +60,11 @@ Default to /usr/bin/matchbox-window-mana
|
|
|
b9dfc8c |
Create an X based Sandbox for gui apps, temporary files for
|
|
|
b9dfc8c |
$HOME and /tmp, secondary Xserver, defaults to sandbox_x_t
|
|
|
b9dfc8c |
.TP
|
|
|
b9dfc8c |
-\fB\-C\fR
|
|
|
b9dfc8c |
+\fB\-c\fR
|
|
|
b9dfc8c |
Use control groups to control this copy of sandbox. Specify parameters in /etc/sysconfig/sandbox. Max memory usage and cpu usage are to be specified in percent. You can specify which CPUs to use by numbering them 0,1,2... etc.
|
|
|
b9dfc8c |
+.TP
|
|
|
b9dfc8c |
+\fB\-C\fR
|
|
|
b9dfc8c |
+Use capabilities within the sandbox. By default applications executed within the sandbox will not be allowed to use capabilities (setuid apps), with the -C flag, you can use programs requiring capabilities.
|
|
|
b9dfc8c |
.PP
|
|
|
b9dfc8c |
.SH "SEE ALSO"
|
|
|
b9dfc8c |
.TP
|
|
|
b9dfc8c |
diff -up policycoreutils-2.0.86/sandbox/sandbox.sandbox policycoreutils-2.0.86/sandbox/sandbox
|
|
|
b9dfc8c |
--- policycoreutils-2.0.86/sandbox/sandbox.sandbox 2011-06-13 13:44:44.678086035 -0400
|
|
|
b9dfc8c |
+++ policycoreutils-2.0.86/sandbox/sandbox 2011-07-07 14:42:50.587660702 -0400
|
|
|
b9dfc8c |
@@ -88,9 +88,7 @@ def copyfile(file, srcdir, dest):
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
except shutil.Error, elist:
|
|
|
b9dfc8c |
for e in elist.message:
|
|
|
b9dfc8c |
- # ignore files that are missing
|
|
|
b9dfc8c |
- if not e[2].startswith("[Errno 2]"):
|
|
|
b9dfc8c |
- sys.stderr.write(e[2])
|
|
|
b9dfc8c |
+ sys.stderr.write(e[2])
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
SAVE_FILES[file] = (dest, os.path.getmtime(dest))
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
@@ -311,17 +309,21 @@ sandbox [-h] [-l level ] [-[X|M] [-H hom
|
|
|
b9dfc8c |
parser.add_option("-l", "--level", dest="level",
|
|
|
b9dfc8c |
help=_("MCS/MLS level for the sandbox"))
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
- parser.add_option("-C", "--cgroups",
|
|
|
b9dfc8c |
+ parser.add_option("-c", "--cgroups",
|
|
|
b9dfc8c |
action="store_true", dest="usecgroup", default=False,
|
|
|
b9dfc8c |
help="Use cgroups to limit this sandbox.")
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
+ parser.add_option("-C", "--capabilities",
|
|
|
b9dfc8c |
+ action="store_true", dest="usecaps", default=False,
|
|
|
b9dfc8c |
+ help="Allow apps requiring capabilities to run within the sandbox.")
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
self.__parser=parser
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
self.__options, cmds = parser.parse_args()
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
if self.__options.X_ind:
|
|
|
b9dfc8c |
self.setype = DEFAULT_X_TYPE
|
|
|
b9dfc8c |
-
|
|
|
b9dfc8c |
+ self.dpi=commands.getoutput("xrdb -query | grep dpi | /bin/cut -f 2")
|
|
|
b9dfc8c |
if self.__options.setype:
|
|
|
b9dfc8c |
self.setype = self.__options.setype
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
@@ -392,8 +394,12 @@ sandbox [-h] [-l level ] [-[X|M] [-H hom
|
|
|
b9dfc8c |
def __execute(self):
|
|
|
b9dfc8c |
try:
|
|
|
b9dfc8c |
cmds = [ SEUNSHARE, "-Z", self.__execcon ]
|
|
|
b9dfc8c |
- if self.__options.usecgroup == True:
|
|
|
b9dfc8c |
+ if self.__options.usecgroup:
|
|
|
b9dfc8c |
cmds.append('-c')
|
|
|
b9dfc8c |
+ if self.__options.usecaps:
|
|
|
b9dfc8c |
+ cmds.append('-C')
|
|
|
b9dfc8c |
+ if not self.__options.level:
|
|
|
b9dfc8c |
+ cmds.append('-k')
|
|
|
b9dfc8c |
if self.__mount:
|
|
|
b9dfc8c |
cmds += [ "-t", self.__tmpdir, "-h", self.__homedir ]
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
@@ -405,7 +411,7 @@ sandbox [-h] [-l level ] [-[X|M] [-H hom
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
self.__setup_sandboxrc(self.__options.wm)
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
- cmds += [ "--", SANDBOXSH, self.__options.windowsize ]
|
|
|
b9dfc8c |
+ cmds += [ "--", SANDBOXSH, self.__options.windowsize, self.dpi ]
|
|
|
b9dfc8c |
else:
|
|
|
b9dfc8c |
cmds += [ "--" ] + self.__paths
|
|
|
b9dfc8c |
return subprocess.Popen(cmds).wait()
|
|
|
b9dfc8c |
diff -up policycoreutils-2.0.86/sandbox/sandboxX.sh.sandbox policycoreutils-2.0.86/sandbox/sandboxX.sh
|
|
|
b9dfc8c |
--- policycoreutils-2.0.86/sandbox/sandboxX.sh.sandbox 2011-06-13 13:44:44.684086096 -0400
|
|
|
b9dfc8c |
+++ policycoreutils-2.0.86/sandbox/sandboxX.sh 2011-07-07 14:41:50.536205201 -0400
|
|
|
b9dfc8c |
@@ -1,10 +1,12 @@
|
|
|
b9dfc8c |
#!/bin/bash
|
|
|
b9dfc8c |
-context=`id -Z | secon -t `
|
|
|
b9dfc8c |
-export TITLE="`grep ^#TITLE: ~/.sandboxrc | /usr/bin/cut -b8-80` ($context)"
|
|
|
b9dfc8c |
-[ $# -eq 1 ] && export SCREENSIZE="$1" || export SCREENSIZE="1000x700"
|
|
|
b9dfc8c |
+trap "" TERM
|
|
|
b9dfc8c |
+context=`id -Z | secon -t -l -P`
|
|
|
b9dfc8c |
+export TITLE="Sandbox $context -- `grep ^#TITLE: ~/.sandboxrc | /usr/bin/cut -b8-80`"
|
|
|
b9dfc8c |
+[ -z $1 ] && export SCREENSIZE="1000x700" || export SCREENSIZE="$1"
|
|
|
b9dfc8c |
+[ -z $2 ] && export DPI="96" || export DPI="$2"
|
|
|
b9dfc8c |
trap "exit 0" HUP
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
-(/usr/bin/Xephyr -nolisten tcp -title "$TITLE" -terminate -screen $SCREENSIZE -displayfd 5 5>&1 2>/dev/null) | while read D; do
|
|
|
b9dfc8c |
+(/usr/bin/Xephyr -title "$TITLE" -terminate -screen $SCREENSIZE -dpi $DPI -displayfd 5 5>&1 2>/dev/null) | while read D; do
|
|
|
b9dfc8c |
export DISPLAY=:$D
|
|
|
b9dfc8c |
cat > ~/seremote << __EOF
|
|
|
b9dfc8c |
#!/bin/sh
|
|
|
b9dfc8c |
@@ -13,7 +15,7 @@ __EOF
|
|
|
b9dfc8c |
chmod +x ~/seremote
|
|
|
b9dfc8c |
/usr/share/sandbox/start $HOME/.sandboxrc
|
|
|
b9dfc8c |
export EXITCODE=$?
|
|
|
b9dfc8c |
- kill -HUP 0
|
|
|
b9dfc8c |
+ kill -TERM 0
|
|
|
b9dfc8c |
break
|
|
|
b9dfc8c |
done
|
|
|
b9dfc8c |
exit 0
|
|
|
b9dfc8c |
diff -up policycoreutils-2.0.86/sandbox/seunshare.8.sandbox policycoreutils-2.0.86/sandbox/seunshare.8
|
|
|
b9dfc8c |
--- policycoreutils-2.0.86/sandbox/seunshare.8.sandbox 2011-07-07 14:41:16.065943281 -0400
|
|
|
b9dfc8c |
+++ policycoreutils-2.0.86/sandbox/seunshare.8 2011-07-07 14:41:26.300021079 -0400
|
|
|
b9dfc8c |
@@ -3,7 +3,7 @@
|
|
|
b9dfc8c |
seunshare \- Run cmd with alternate homedir, tmpdir and/or SELinux context
|
|
|
b9dfc8c |
.SH SYNOPSIS
|
|
|
b9dfc8c |
.B seunshare
|
|
|
b9dfc8c |
-[ -v ] [ -t tmpdir ] [ -h homedir ] [ -Z context ] -- executable [args]
|
|
|
b9dfc8c |
+[-v] [-c] [-C] [-k] [ -t tmpdir ] [ -h homedir ] [ -Z context ] -- executable [args]
|
|
|
b9dfc8c |
.br
|
|
|
b9dfc8c |
.SH DESCRIPTION
|
|
|
b9dfc8c |
.PP
|
|
|
b9dfc8c |
@@ -18,9 +18,15 @@ Alternate homedir to be used by the appl
|
|
|
b9dfc8c |
\fB\-t\ tmpdir
|
|
|
b9dfc8c |
Use alternate tempory directory to mount on /tmp. tmpdir must be owned by the user.
|
|
|
b9dfc8c |
.TP
|
|
|
b9dfc8c |
-\fB\-c cgroups\fR
|
|
|
b9dfc8c |
+\fB\-c --cgroups\fR
|
|
|
b9dfc8c |
Use cgroups to control this copy of seunshare. Specify parameters in /etc/sysconfig/sandbox. Max memory usage and cpu usage are to be specified in percent. You can specify which CPUs to use by numbering them 0,1,2... etc.
|
|
|
b9dfc8c |
.TP
|
|
|
b9dfc8c |
+\fB\-C --capabilities\fR
|
|
|
b9dfc8c |
+Allow apps executed within the namespace to use capabilities. Default is no capabilities.
|
|
|
b9dfc8c |
+.TP
|
|
|
b9dfc8c |
+\fB\-k --kill\fR
|
|
|
b9dfc8c |
+Kill all processes with matching MCS level.
|
|
|
b9dfc8c |
+.TP
|
|
|
b9dfc8c |
\fB\-Z\ context
|
|
|
b9dfc8c |
Use alternate SELinux context while runing the executable.
|
|
|
b9dfc8c |
.TP
|
|
|
b9dfc8c |
diff -up policycoreutils-2.0.86/sandbox/seunshare.c.sandbox policycoreutils-2.0.86/sandbox/seunshare.c
|
|
|
b9dfc8c |
--- policycoreutils-2.0.86/sandbox/seunshare.c.sandbox 2011-06-13 13:44:44.687086129 -0400
|
|
|
b9dfc8c |
+++ policycoreutils-2.0.86/sandbox/seunshare.c 2011-07-07 14:41:08.038882237 -0400
|
|
|
b9dfc8c |
@@ -29,6 +29,7 @@
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
#include <selinux/selinux.h>
|
|
|
b9dfc8c |
#include <selinux/context.h> /* for context-mangling functions */
|
|
|
b9dfc8c |
+#include <dirent.h>
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
#ifdef USE_NLS
|
|
|
b9dfc8c |
#include <locale.h> /* for setlocale() */
|
|
|
b9dfc8c |
@@ -53,20 +54,22 @@
|
|
|
b9dfc8c |
#define BUF_SIZE 1024
|
|
|
b9dfc8c |
#define DEFAULT_PATH "/usr/bin:/bin"
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
-#define USAGE_STRING _("USAGE: seunshare [ -v ] [ -c ] -t tmpdir -h homedir [-Z context] -- executable [args]")
|
|
|
b9dfc8c |
+#define USAGE_STRING _("USAGE: seunshare [ -v ] [ -c ] -C -t tmpdir -h homedir [-Z context] -- executable [args]")
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
static int verbose = 0;
|
|
|
b9dfc8c |
+static int child = 0;
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
+static capng_select_t cap_set = CAPNG_SELECT_BOTH;
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
/**
|
|
|
b9dfc8c |
* This function will drop all capabilities.
|
|
|
b9dfc8c |
*/
|
|
|
b9dfc8c |
static int drop_caps()
|
|
|
b9dfc8c |
{
|
|
|
b9dfc8c |
- if (capng_have_capabilities(CAPNG_SELECT_BOTH) == CAPNG_NONE)
|
|
|
b9dfc8c |
+ if (capng_have_capabilities(cap_set) == CAPNG_NONE)
|
|
|
b9dfc8c |
return 0;
|
|
|
b9dfc8c |
- capng_clear(CAPNG_SELECT_BOTH);
|
|
|
b9dfc8c |
- if (capng_lock() == -1 || capng_apply(CAPNG_SELECT_BOTH) == -1) {
|
|
|
b9dfc8c |
+ capng_clear(cap_set);
|
|
|
b9dfc8c |
+ if (capng_lock() == -1 || capng_apply(cap_set) == -1) {
|
|
|
b9dfc8c |
fprintf(stderr, _("Failed to drop all capabilities\n"));
|
|
|
b9dfc8c |
return -1;
|
|
|
b9dfc8c |
}
|
|
|
b9dfc8c |
@@ -86,6 +89,13 @@ static int drop_privs(uid_t uid)
|
|
|
b9dfc8c |
}
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
/**
|
|
|
b9dfc8c |
+ * If the user sends a siginto to seunshare, kill the child's session
|
|
|
b9dfc8c |
+ */
|
|
|
b9dfc8c |
+void handler(int sig) {
|
|
|
b9dfc8c |
+ if (child > 0) kill(-child,sig);
|
|
|
b9dfc8c |
+}
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+/**
|
|
|
b9dfc8c |
* Take care of any signal setup.
|
|
|
b9dfc8c |
*/
|
|
|
b9dfc8c |
static int set_signal_handles(void)
|
|
|
b9dfc8c |
@@ -101,7 +111,12 @@ static int set_signal_handles(void)
|
|
|
b9dfc8c |
(void)sigprocmask(SIG_SETMASK, &empty, NULL);
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
/* Terminate on SIGHUP */
|
|
|
b9dfc8c |
- if (signal(SIGHUP, SIG_IGN) == SIG_ERR) {
|
|
|
b9dfc8c |
+ if (signal(SIGHUP, SIG_DFL) == SIG_ERR) {
|
|
|
b9dfc8c |
+ perror("Unable to set SIGHUP handler");
|
|
|
b9dfc8c |
+ return -1;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ if (signal(SIGINT, handler) == SIG_ERR) {
|
|
|
b9dfc8c |
perror("Unable to set SIGHUP handler");
|
|
|
b9dfc8c |
return -1;
|
|
|
b9dfc8c |
}
|
|
|
b9dfc8c |
@@ -334,6 +349,7 @@ static int setup_cgroups()
|
|
|
b9dfc8c |
char buf[BUF_SIZE];
|
|
|
b9dfc8c |
char *tok = NULL;
|
|
|
b9dfc8c |
int rc = -1;
|
|
|
b9dfc8c |
+ char *str = NULL;
|
|
|
b9dfc8c |
const char* fname = "/etc/sysconfig/sandbox";
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
if ((fp = fopen(fname, "rt")) == NULL) {
|
|
|
b9dfc8c |
@@ -346,7 +362,8 @@ static int setup_cgroups()
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
/* Copy the string, ignoring whitespace */
|
|
|
b9dfc8c |
int len = strlen(buf);
|
|
|
b9dfc8c |
- char *str = malloc((len + 1) * sizeof(char));
|
|
|
b9dfc8c |
+ free(str);
|
|
|
b9dfc8c |
+ str = malloc((len + 1) * sizeof(char));
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
int ind = 0;
|
|
|
b9dfc8c |
int i;
|
|
|
b9dfc8c |
@@ -487,6 +504,8 @@ static int setup_cgroups()
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
rc = 0;
|
|
|
b9dfc8c |
err:
|
|
|
b9dfc8c |
+ fclose(fp);
|
|
|
b9dfc8c |
+ free(str);
|
|
|
b9dfc8c |
free(mem);
|
|
|
b9dfc8c |
free(cgroupname);
|
|
|
b9dfc8c |
free(cpus);
|
|
|
b9dfc8c |
@@ -734,12 +753,75 @@ good:
|
|
|
b9dfc8c |
return tmpdir;
|
|
|
b9dfc8c |
}
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
+#define PROC_BASE "/proc"
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+static int
|
|
|
b9dfc8c |
+killall (security_context_t execcon)
|
|
|
b9dfc8c |
+{
|
|
|
b9dfc8c |
+ DIR *dir;
|
|
|
b9dfc8c |
+ security_context_t scon;
|
|
|
b9dfc8c |
+ struct dirent *de;
|
|
|
b9dfc8c |
+ pid_t *pid_table, pid, self;
|
|
|
b9dfc8c |
+ int i;
|
|
|
b9dfc8c |
+ int pids, max_pids;
|
|
|
b9dfc8c |
+ int running = 0;
|
|
|
b9dfc8c |
+ self = getpid();
|
|
|
b9dfc8c |
+ if (!(dir = opendir(PROC_BASE))) {
|
|
|
b9dfc8c |
+ return -1;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+ max_pids = 256;
|
|
|
b9dfc8c |
+ pid_table = malloc(max_pids * sizeof (pid_t));
|
|
|
b9dfc8c |
+ if (!pid_table) {
|
|
|
b9dfc8c |
+ return -1;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+ pids = 0;
|
|
|
b9dfc8c |
+ context_t con;
|
|
|
b9dfc8c |
+ con = context_new(execcon);
|
|
|
b9dfc8c |
+ const char *mcs = context_range_get(con);
|
|
|
b9dfc8c |
+ printf("mcs=%s\n", mcs);
|
|
|
b9dfc8c |
+ while ((de = readdir (dir)) != NULL) {
|
|
|
b9dfc8c |
+ if (!(pid = (pid_t)atoi(de->d_name)) || pid == self)
|
|
|
b9dfc8c |
+ continue;
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ if (pids == max_pids) {
|
|
|
b9dfc8c |
+ if (!(pid_table = realloc(pid_table, 2*pids*sizeof(pid_t)))) {
|
|
|
b9dfc8c |
+ return -1;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+ max_pids *= 2;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+ pid_table[pids++] = pid;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ (void)closedir(dir);
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ for (i = 0; i < pids; i++) {
|
|
|
b9dfc8c |
+ pid_t id = pid_table[i];
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ if (getpidcon(id, &scon) == 0) {
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ context_t pidcon = context_new(scon);
|
|
|
b9dfc8c |
+ /* Attempt to kill remaining processes */
|
|
|
b9dfc8c |
+ if (strcmp(context_range_get(pidcon), mcs) == 0)
|
|
|
b9dfc8c |
+ kill(id, SIGKILL);
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ context_free(pidcon);
|
|
|
b9dfc8c |
+ freecon(scon);
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+ running++;
|
|
|
b9dfc8c |
+ }
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ context_free(con);
|
|
|
b9dfc8c |
+ free(pid_table);
|
|
|
b9dfc8c |
+ return running;
|
|
|
b9dfc8c |
+}
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
int main(int argc, char **argv) {
|
|
|
b9dfc8c |
int status = -1;
|
|
|
b9dfc8c |
security_context_t execcon = NULL;
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
int clflag; /* holds codes for command line flags */
|
|
|
b9dfc8c |
int usecgroups = 0;
|
|
|
b9dfc8c |
+ int kill_all = 0;
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
char *homedir_s = NULL; /* homedir spec'd by user in argv[] */
|
|
|
b9dfc8c |
char *tmpdir_s = NULL; /* tmpdir spec'd by user in argv[] */
|
|
|
b9dfc8c |
@@ -752,9 +834,11 @@ int main(int argc, char **argv) {
|
|
|
b9dfc8c |
const struct option long_options[] = {
|
|
|
b9dfc8c |
{"homedir", 1, 0, 'h'},
|
|
|
b9dfc8c |
{"tmpdir", 1, 0, 't'},
|
|
|
b9dfc8c |
+ {"kill", 1, 0, 'k'},
|
|
|
b9dfc8c |
{"verbose", 1, 0, 'v'},
|
|
|
b9dfc8c |
{"cgroups", 1, 0, 'c'},
|
|
|
b9dfc8c |
{"context", 1, 0, 'Z'},
|
|
|
b9dfc8c |
+ {"capabilities", 1, 0, 'C'},
|
|
|
b9dfc8c |
{NULL, 0, 0, 0}
|
|
|
b9dfc8c |
};
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
@@ -783,7 +867,7 @@ int main(int argc, char **argv) {
|
|
|
b9dfc8c |
}
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
while (1) {
|
|
|
b9dfc8c |
- clflag = getopt_long(argc, argv, "cvh:t:Z:", long_options, NULL);
|
|
|
b9dfc8c |
+ clflag = getopt_long(argc, argv, "Ccvh:t:Z:", long_options, NULL);
|
|
|
b9dfc8c |
if (clflag == -1)
|
|
|
b9dfc8c |
break;
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
@@ -791,6 +875,9 @@ int main(int argc, char **argv) {
|
|
|
b9dfc8c |
case 't':
|
|
|
b9dfc8c |
tmpdir_s = optarg;
|
|
|
b9dfc8c |
break;
|
|
|
b9dfc8c |
+ case 'k':
|
|
|
b9dfc8c |
+ kill_all = 1;
|
|
|
b9dfc8c |
+ break;
|
|
|
b9dfc8c |
case 'h':
|
|
|
b9dfc8c |
homedir_s = optarg;
|
|
|
b9dfc8c |
break;
|
|
|
b9dfc8c |
@@ -800,6 +887,9 @@ int main(int argc, char **argv) {
|
|
|
b9dfc8c |
case 'c':
|
|
|
b9dfc8c |
usecgroups = 1;
|
|
|
b9dfc8c |
break;
|
|
|
b9dfc8c |
+ case 'C':
|
|
|
b9dfc8c |
+ cap_set = CAPNG_SELECT_CAPS;
|
|
|
b9dfc8c |
+ break;
|
|
|
b9dfc8c |
case 'Z':
|
|
|
b9dfc8c |
execcon = optarg;
|
|
|
b9dfc8c |
break;
|
|
|
b9dfc8c |
@@ -851,7 +941,7 @@ int main(int argc, char **argv) {
|
|
|
b9dfc8c |
}
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
/* spawn child process */
|
|
|
b9dfc8c |
- int child = fork();
|
|
|
b9dfc8c |
+ child = fork();
|
|
|
b9dfc8c |
if (child == -1) {
|
|
|
b9dfc8c |
perror(_("Unable to fork"));
|
|
|
b9dfc8c |
goto err;
|
|
|
b9dfc8c |
@@ -926,6 +1016,12 @@ childerr:
|
|
|
b9dfc8c |
waitpid(child, &status, 0);
|
|
|
b9dfc8c |
status_to_retval(status, status);
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
+ /* Make sure all child processes exit */
|
|
|
b9dfc8c |
+ kill(-child,SIGTERM);
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
+ if (execcon && kill)
|
|
|
b9dfc8c |
+ killall(execcon);
|
|
|
b9dfc8c |
+
|
|
|
b9dfc8c |
if (tmpdir_r) cleanup_tmpdir(tmpdir_r, tmpdir_s, pwd, 1);
|
|
|
b9dfc8c |
|
|
|
b9dfc8c |
err:
|