diff --git a/policycoreutils/sandbox/Makefile b/policycoreutils/sandbox/Makefile index ff0ee7c3..21df0c42 100644 --- a/policycoreutils/sandbox/Makefile +++ b/policycoreutils/sandbox/Makefile @@ -10,7 +10,7 @@ SHAREDIR ?= $(PREFIX)/share/sandbox override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DPACKAGE="\"policycoreutils\"" LDLIBS += -lselinux -lcap-ng -all: sandbox seunshare sandboxX.sh +all: sandbox seunshare sandboxX.sh start seunshare: seunshare.o $(EXTRA_OBJS) $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) @@ -20,14 +20,18 @@ install: all install -m 755 sandbox $(BINDIR) -mkdir -p $(MANDIR)/man8 install -m 644 sandbox.8 $(MANDIR)/man8/ + install -m 644 seunshare.8 $(MANDIR)/man8/ + -mkdir -p $(MANDIR)/man5 + install -m 644 sandbox.conf.5 $(MANDIR)/man5/ -mkdir -p $(SBINDIR) install -m 4755 seunshare $(SBINDIR)/ -mkdir -p $(SHAREDIR) install -m 755 sandboxX.sh $(SHAREDIR) + install -m 755 start $(SHAREDIR) -mkdir -p $(INITDIR) install -m 755 sandbox.init $(INITDIR)/sandbox -mkdir -p $(SYSCONFDIR) - install -m 644 sandbox.config $(SYSCONFDIR)/sandbox + install -m 644 sandbox.conf $(SYSCONFDIR)/sandbox test: @python test_sandbox.py -v diff --git a/policycoreutils/sandbox/sandbox.conf b/policycoreutils/sandbox/sandbox.conf new file mode 100644 index 00000000..7c35808c --- /dev/null +++ b/policycoreutils/sandbox/sandbox.conf @@ -0,0 +1,7 @@ +# Space separate list of homedirs +HOMEDIRS="/home" +# Control group configuration +NAME=sandbox +CPUAFFINITY=ALL +MEMUSAGE=80% +CPUUSAGE=80% diff --git a/policycoreutils/sandbox/sandbox.conf.5 b/policycoreutils/sandbox/sandbox.conf.5 new file mode 100644 index 00000000..b3ee67d7 --- /dev/null +++ b/policycoreutils/sandbox/sandbox.conf.5 @@ -0,0 +1,40 @@ +.TH sandbox.conf "5" "June 2010" "sandbox.conf" "Linux System Administration" +.SH NAME +sandbox.conf \- user config file for the SELinux sandbox +.SH DESCRIPTION +.PP +When running sandbox with the -C argument, it will be confined using control groups and a system administrator can specify how the sandbox is confined. + +.PP +Everything after "#" is ignored, as are empty lines. All arguments should be separated by and equals sign ("="). + +.PP +These keywords are allowed. + +.RS +.TP +.B NAME +The name of the sandbox control group. Default is "sandbox". + +.TP +.B CPUAFFINITY +Which cpus to assign sandbox to. The default is ALL, but users can specify a comma-separated list with dashes ("-") to represent ranges. Ex: 0-2,5 + +.TP +.B MEMUSAGE +How much memory to allow sandbox to use. The default is 80%. Users can specify either a percentage or a value in the form of a number followed by one of the suffixes K, M, G to denote kilobytes, megabytes or gigabytes respectively. Ex: 50% or 100M + +.TP +.B CPUUSAGE +Percentage of cpu sandbox should be allowed to use. The default is 80%. Specify a value followed by a percent sign ("%"). Ex: 50% + + + +.SH "SEE ALSO" +.TP +sandbox(8) +.PP + +.SH AUTHOR +This manual page was written by +.I Thomas Liu diff --git a/policycoreutils/sandbox/seunshare.8 b/policycoreutils/sandbox/seunshare.8 new file mode 100644 index 00000000..d3eff967 --- /dev/null +++ b/policycoreutils/sandbox/seunshare.8 @@ -0,0 +1,37 @@ +.TH SEUNSHARE "8" "May 2010" "seunshare" "User Commands" +.SH NAME +seunshare \- Run cmd with alternate homedir, tmpdir and/or SELinux context +.SH SYNOPSIS +.B seunshare +[ -v ] [ -c ] [ -t tmpdir ] [ -h homedir ] [ -Z context ] -- executable [args] +.br +.SH DESCRIPTION +.PP +Run the +.I executable +within the specified context, using the alternate home directory and /tmp directory. The seunshare command unshares from the default namespace, then mounts the specified homedir and tmpdir over the default homedir and /tmp. Finally it tells the kernel to execute the application under the specified SELinux context. + +.TP +\fB\-h homedir\fR +Alternate homedir to be used by the application. Homedir must be owned by the user. +.TP +\fB\-t\ tmpdir +Use alternate temporary directory to mount on /tmp. tmpdir must be owned by the user. +.TP +\fB\-c --cgroups\fR +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. +.TP +\fB\-Z\ context +Use alternate SELinux context while runing the executable. +.TP +\fB\-v\fR +Verbose output +.SH "SEE ALSO" +.TP +runcon(1), sandbox(8), selinux(8) +.PP +.SH AUTHOR +This manual page was written by +.I Dan Walsh +and +.I Thomas Liu diff --git a/policycoreutils/sandbox/start b/policycoreutils/sandbox/start new file mode 100644 index 00000000..52950d7d --- /dev/null +++ b/policycoreutils/sandbox/start @@ -0,0 +1,9 @@ +#! /usr/bin/python -Es +import gtk, commands, sys +rc = [-1,''] +try: + rc=commands.getstatusoutput(sys.argv[1]) +except: + pass +if rc[0] == 0: + print rc[1]