From 614ca03ae7a94da3481166de0b55fbec0b3ddb1d Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 13 Jul 2010 17:32:51 +0000 Subject: [PATCH] * Tue Jun 15 2010 Dan Walsh 2.0.83-3 - Change python scripts to use -s flag - Update po --- policycoreutils-rhat.patch | 1829 ++++++++++-------------------------- policycoreutils.spec | 16 +- 2 files changed, 497 insertions(+), 1348 deletions(-) diff --git a/policycoreutils-rhat.patch b/policycoreutils-rhat.patch index 4506e70..9c6f48c 100644 --- a/policycoreutils-rhat.patch +++ b/policycoreutils-rhat.patch @@ -1,6 +1,12 @@ -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/audit2allow policycoreutils-2.0.82/audit2allow/audit2allow +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/audit2allow policycoreutils-2.0.83/audit2allow/audit2allow --- nsapolicycoreutils/audit2allow/audit2allow 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/audit2allow/audit2allow 2010-05-04 13:10:14.000000000 -0400 ++++ policycoreutils-2.0.83/audit2allow/audit2allow 2010-07-13 13:09:10.000000000 -0400 +@@ -1,4 +1,4 @@ +-#! /usr/bin/python -E ++#! /usr/bin/python -Es + # Authors: Karl MacMillan + # + # Copyright (C) 2006-2007 Red Hat @@ -28,6 +28,7 @@ import sepolgen.defaults as defaults import sepolgen.module as module @@ -113,9 +119,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po if __name__ == "__main__": app = AuditToPolicy() -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/audit2allow.1 policycoreutils-2.0.82/audit2allow/audit2allow.1 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/audit2allow.1 policycoreutils-2.0.83/audit2allow/audit2allow.1 --- nsapolicycoreutils/audit2allow/audit2allow.1 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/audit2allow/audit2allow.1 2010-05-11 15:16:45.000000000 -0400 ++++ policycoreutils-2.0.83/audit2allow/audit2allow.1 2010-06-16 08:22:37.000000000 -0400 @@ -66,6 +66,9 @@ .B "\-M " Generate loadable module package, conflicts with -o @@ -126,122 +132,114 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po .B "\-o " | "\-\-output " append output to .I -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/Makefile policycoreutils-2.0.82/audit2allow/Makefile ---- nsapolicycoreutils/audit2allow/Makefile 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/audit2allow/Makefile 2010-04-28 17:12:19.000000000 -0400 -@@ -10,7 +10,6 @@ - install: all - -mkdir -p $(BINDIR) - install -m 755 audit2allow $(BINDIR) -- install -m 755 sepolgen-ifgen $(BINDIR) - -mkdir -p $(MANDIR)/man1 - install -m 644 audit2allow.1 $(MANDIR)/man1/ - -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/sepolgen-ifgen policycoreutils-2.0.82/audit2allow/sepolgen-ifgen +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/audit2allow/sepolgen-ifgen policycoreutils-2.0.83/audit2allow/sepolgen-ifgen --- nsapolicycoreutils/audit2allow/sepolgen-ifgen 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/audit2allow/sepolgen-ifgen 1969-12-31 19:00:00.000000000 -0500 -@@ -1,89 +0,0 @@ --#! /usr/bin/python -E --# --# Authors: Karl MacMillan --# --# Copyright (C) 2006 Red Hat --# see file 'COPYING' for use and warranty information --# --# This program is free software; you can redistribute it and/or --# modify it under the terms of the GNU General Public License as --# published by the Free Software Foundation; version 2 only --# --# This program is distributed in the hope that it will be useful, --# but WITHOUT ANY WARRANTY; without even the implied warranty of --# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --# GNU General Public License for more details. --# --# You should have received a copy of the GNU General Public License --# along with this program; if not, write to the Free Software --# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --# -- --# Parse interfaces and output extracted information about them --# suitable for policy generation. By default writes the output --# to the default location (obtained from sepolgen.defaults), but --# will output to another file provided as an argument: --# sepolgen-ifgen [headers] [output-filename] -- -- --import sys --import os -- --import sepolgen.refparser as refparser --import sepolgen.defaults as defaults --import sepolgen.interfaces as interfaces -- -- --VERSION = "%prog .1" -- --def parse_options(): -- from optparse import OptionParser -- -- parser = OptionParser(version=VERSION) -- parser.add_option("-o", "--output", dest="output", default=defaults.interface_info(), -- help="filename to store output") -- parser.add_option("-i", "--interfaces", dest="headers", default=defaults.headers(), -- help="location of the interface header files") -- parser.add_option("-v", "--verbose", action="store_true", default=False, -- help="print debuging output") -- parser.add_option("-d", "--debug", action="store_true", default=False, -- help="extra debugging output") -- options, args = parser.parse_args() -- -- return options -- -- --def main(): -- options = parse_options() -- -- # Open the output first to generate errors before parsing -- try: -- f = open(options.output, "w") -- except IOError, e: -- sys.stderr.write("could not open output file [%s]\n" % options.output) -- return 1 -- -- if options.verbose: -- log = sys.stdout -- else: -- log = None -- -- try: -- headers = refparser.parse_headers(options.headers, output=log, debug=options.debug) -- except ValueError, e: -- print "error parsing headers" -- print str(e) -- return 1 -- -- if_set = interfaces.InterfaceSet(output=log) -- if_set.add_headers(headers) -- if_set.to_file(f) -- f.close() -- -- if refparser.success: -- return 0 -- else: -- return 1 -- --if __name__ == "__main__": -- sys.exit(main()) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/Makefile policycoreutils-2.0.82/Makefile ---- nsapolicycoreutils/Makefile 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/Makefile 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/audit2allow/sepolgen-ifgen 2010-07-13 13:31:01.000000000 -0400 @@ -1,4 +1,4 @@ --SUBDIRS = setfiles semanage load_policy newrole run_init secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool po +-#! /usr/bin/python -E ++#! /usr/bin/python -Es + # + # Authors: Karl MacMillan + # +@@ -28,6 +28,10 @@ + + import sys + import os ++import tempfile ++import subprocess ++ ++import selinux + + import sepolgen.refparser as refparser + import sepolgen.defaults as defaults +@@ -35,6 +39,7 @@ + + + VERSION = "%prog .1" ++ATTR_HELPER = "/usr/bin/sepolgen-ifgen-attr-helper" + + def parse_options(): + from optparse import OptionParser +@@ -44,14 +49,43 @@ + help="filename to store output") + parser.add_option("-i", "--interfaces", dest="headers", default=defaults.headers(), + help="location of the interface header files") ++ parser.add_option("-a", "--attribute_info", dest="attribute_info") + parser.add_option("-v", "--verbose", action="store_true", default=False, + help="print debuging output") + parser.add_option("-d", "--debug", action="store_true", default=False, + help="extra debugging output") ++ parser.add_option("--no_attrs", action="store_true", default=False, ++ help="do not retrieve attribute access from kernel policy") + options, args = parser.parse_args() + + return options + ++def get_attrs(): ++ try: ++ policy_path = selinux.selinux_binary_policy_path() + "." + str(selinux.security_policyvers()) ++ outfile = tempfile.NamedTemporaryFile() ++ except IOError, e: ++ sys.stderr.write("could not open attribute output file\n") ++ return None ++ except OSError: ++ # SELinux Disabled Machine ++ return None ++ ++ fd = open("/dev/null","w") ++ ret = subprocess.Popen([ATTR_HELPER, policy_path, outfile.name], stdout=fd).wait() ++ fd.close() ++ if ret != 0: ++ sys.stderr.write("could not run attribute helper") ++ return None ++ ++ attrs = interfaces.AttributeSet() ++ try: ++ attrs.from_file(outfile) ++ except: ++ print "error parsing attribute info" ++ return None ++ ++ return attrs + + def main(): + options = parse_options() +@@ -68,6 +102,14 @@ + else: + log = None + ++ # Get the attibutes from the binary ++ attrs = None ++ if not options.no_attrs: ++ attrs = get_attrs() ++ if attrs is None: ++ return 1 ++ ++ # Parse the headers + try: + headers = refparser.parse_headers(options.headers, output=log, debug=options.debug) + except ValueError, e: +@@ -76,7 +118,7 @@ + return 1 + + if_set = interfaces.InterfaceSet(output=log) +- if_set.add_headers(headers) ++ if_set.add_headers(headers, attributes=attrs) + if_set.to_file(f) + f.close() + +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/Makefile policycoreutils-2.0.83/Makefile +--- nsapolicycoreutils/Makefile 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/Makefile 2010-06-16 08:22:37.000000000 -0400 +@@ -1,4 +1,4 @@ +-SUBDIRS = setfiles semanage load_policy newrole run_init sandbox secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool po +SUBDIRS = setfiles semanage semanage/default_encoding load_policy newrole run_init sandbox secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps sepolgen-ifgen setsebool po gui INOTIFYH = $(shell ls /usr/include/sys/inotify.h 2>/dev/null) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/newrole/newrole.c policycoreutils-2.0.82/newrole/newrole.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/newrole/newrole.c policycoreutils-2.0.83/newrole/newrole.c --- nsapolicycoreutils/newrole/newrole.c 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/newrole/newrole.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/newrole/newrole.c 2010-06-16 08:22:37.000000000 -0400 @@ -1334,6 +1334,9 @@ if (send_audit_message(1, old_context, new_context, ttyn)) @@ -252,9 +250,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po #ifdef NAMESPACE_PRIV if (transition_to_caller_uid()) goto err_close_pam_session; -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/Makefile policycoreutils-2.0.82/restorecond/Makefile +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/Makefile policycoreutils-2.0.83/restorecond/Makefile --- nsapolicycoreutils/restorecond/Makefile 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/restorecond/Makefile 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/Makefile 2010-06-16 08:22:37.000000000 -0400 @@ -1,17 +1,28 @@ # Installation directories. PREFIX ?= ${DESTDIR}/usr @@ -301,16 +299,16 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po relabel: install /sbin/restorecon $(SBINDIR)/restorecond -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/org.selinux.Restorecond.service policycoreutils-2.0.82/restorecond/org.selinux.Restorecond.service +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/org.selinux.Restorecond.service policycoreutils-2.0.83/restorecond/org.selinux.Restorecond.service --- nsapolicycoreutils/restorecond/org.selinux.Restorecond.service 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/restorecond/org.selinux.Restorecond.service 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/org.selinux.Restorecond.service 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.selinux.Restorecond +Exec=/usr/sbin/restorecond -u -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.8 policycoreutils-2.0.82/restorecond/restorecond.8 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.8 policycoreutils-2.0.83/restorecond/restorecond.8 --- nsapolicycoreutils/restorecond/restorecond.8 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/restorecond/restorecond.8 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond.8 2010-06-16 08:22:37.000000000 -0400 @@ -3,7 +3,7 @@ restorecond \- daemon that watches for file creation and then sets the default SELinux file context @@ -345,9 +343,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po .SH "SEE ALSO" .BR restorecon (8), -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.c policycoreutils-2.0.82/restorecond/restorecond.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.c policycoreutils-2.0.83/restorecond/restorecond.c --- nsapolicycoreutils/restorecond/restorecond.c 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/restorecond/restorecond.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond.c 2010-06-16 08:25:58.000000000 -0400 @@ -30,9 +30,11 @@ * and makes sure that there security context matches the systems defaults * @@ -389,7 +387,7 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po - -#include -#include -- + -/* size of the event structure, not counting name */ -#define EVENT_SIZE (sizeof (struct inotify_event)) -/* reasonable guess as to size of 1024 events */ @@ -474,7 +472,11 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po - } - firstDir = NULL; -} -- ++static char *server_watch_file = "/etc/selinux/restorecond.conf"; ++static char *user_watch_file = "/etc/selinux/restorecond_user.conf"; ++static char *watch_file; ++static struct restore_opts r_opts; + -/* - Set the file context to the default file context for this system. - Same as restorecon. @@ -522,7 +524,7 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po - return; - } - retcontext = fgetfilecon_raw(fd, &prev_context); - +- - if (retcontext >= 0 || errno == ENODATA) { - if (retcontext < 0) - prev_context = NULL; @@ -589,16 +591,11 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po - Files specified one per line. Files with "~" will be expanded to the logged in users - homedirs. -*/ -+static char *server_watch_file = "/etc/selinux/restorecond.conf"; -+static char *user_watch_file = "/etc/selinux/restorecond_user.conf"; -+static char *watch_file; -+static struct restore_opts r_opts; - +- -static void read_config(int fd) -{ - char *watch_file_path = "/etc/selinux/restorecond.conf"; -+#include - +- - FILE *cfg = NULL; - if (debug_mode) - printf("Read Config\n"); @@ -617,10 +614,7 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po - if (master_wd == -1) - exitApp("Error watching config file."); -} -+int debug_mode = 0; -+int terminate = 0; -+int master_wd = -1; -+int run_as_user = 0; ++#include -/* - Inotify watch loop @@ -664,7 +658,11 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po - break; - } - } -- ++int debug_mode = 0; ++int terminate = 0; ++int master_wd = -1; ++int run_as_user = 0; + - i += EVENT_SIZE + event->len; - } - return 0; @@ -784,7 +782,7 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po /* Register sighandlers */ sa.sa_flags = 0; -@@ -467,38 +174,60 @@ +@@ -467,36 +174,56 @@ set_matchpathcon_flags(MATCHPATHCON_NOTRANS); @@ -850,13 +848,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po if (pidfile) unlink(pidfile); - return 0; - } -+ -+ -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.82/restorecond/restorecond.conf +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.conf policycoreutils-2.0.83/restorecond/restorecond.conf --- nsapolicycoreutils/restorecond/restorecond.conf 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/restorecond/restorecond.conf 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond.conf 2010-06-16 08:22:37.000000000 -0400 @@ -4,8 +4,5 @@ /etc/mtab /var/run/utmp @@ -867,9 +861,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po /root/.ssh/* - - -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.desktop policycoreutils-2.0.82/restorecond/restorecond.desktop +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.desktop policycoreutils-2.0.83/restorecond/restorecond.desktop --- nsapolicycoreutils/restorecond/restorecond.desktop 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/restorecond/restorecond.desktop 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond.desktop 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=File Context maintainer @@ -878,9 +872,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +Encoding=UTF-8 +Type=Application +StartupNotify=false -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.h policycoreutils-2.0.82/restorecond/restorecond.h +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.h policycoreutils-2.0.83/restorecond/restorecond.h --- nsapolicycoreutils/restorecond/restorecond.h 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/restorecond/restorecond.h 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond.h 2010-06-16 08:22:37.000000000 -0400 @@ -24,7 +24,22 @@ #ifndef RESTORED_CONFIG_H #define RESTORED_CONFIG_H @@ -906,9 +900,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +extern int watch_list_isempty(); #endif -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.init policycoreutils-2.0.82/restorecond/restorecond.init +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond.init policycoreutils-2.0.83/restorecond/restorecond.init --- nsapolicycoreutils/restorecond/restorecond.init 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/restorecond/restorecond.init 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond.init 2010-06-16 08:22:37.000000000 -0400 @@ -26,7 +26,7 @@ # Source function library. . /etc/rc.d/init.d/functions @@ -937,15 +931,15 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po exit $RETVAL - -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond_user.conf policycoreutils-2.0.82/restorecond/restorecond_user.conf +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/restorecond_user.conf policycoreutils-2.0.83/restorecond/restorecond_user.conf --- nsapolicycoreutils/restorecond/restorecond_user.conf 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/restorecond/restorecond_user.conf 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/restorecond_user.conf 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,2 @@ +~/* +~/public_html/* -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/user.c policycoreutils-2.0.82/restorecond/user.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/user.c policycoreutils-2.0.83/restorecond/user.c --- nsapolicycoreutils/restorecond/user.c 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/restorecond/user.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/user.c 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,239 @@ +/* + * restorecond @@ -1186,9 +1180,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + return 0; +} + -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/watch.c policycoreutils-2.0.82/restorecond/watch.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/restorecond/watch.c policycoreutils-2.0.83/restorecond/watch.c --- nsapolicycoreutils/restorecond/watch.c 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/restorecond/watch.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/restorecond/watch.c 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,260 @@ +#define _GNU_SOURCE +#include @@ -1450,17 +1444,17 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + if (master_wd == -1) + exitApp("Error watching config file."); +} -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/deliverables/basicwrapper policycoreutils-2.0.82/sandbox/deliverables/basicwrapper +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/deliverables/basicwrapper policycoreutils-2.0.83/sandbox/deliverables/basicwrapper --- nsapolicycoreutils/sandbox/deliverables/basicwrapper 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/deliverables/basicwrapper 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/deliverables/basicwrapper 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,4 @@ +import os, sys +SANDBOX_ARGS = ['-f%s' % os.environ['_CONDOR_SCRATCH_DIR']] +SANDBOX_ARGS.extend(sys.argv[1::]) +os.execv('/usr/bin/sandbox',SANDBOX_ARGS) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/deliverables/README policycoreutils-2.0.82/sandbox/deliverables/README +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/deliverables/README policycoreutils-2.0.83/sandbox/deliverables/README --- nsapolicycoreutils/sandbox/deliverables/README 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/deliverables/README 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/deliverables/README 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,32 @@ +Files: +run-in-sandbox.py: @@ -1494,9 +1488,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + +Thanks for a great summer. +Chris Pardy -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/deliverables/run-in-sandbox.py policycoreutils-2.0.82/sandbox/deliverables/run-in-sandbox.py +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/deliverables/run-in-sandbox.py policycoreutils-2.0.83/sandbox/deliverables/run-in-sandbox.py --- nsapolicycoreutils/sandbox/deliverables/run-in-sandbox.py 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/deliverables/run-in-sandbox.py 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/deliverables/run-in-sandbox.py 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,49 @@ +import os +import os.path @@ -1547,430 +1541,119 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + def get_background_items(self, window, file): + return + -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/Makefile policycoreutils-2.0.82/sandbox/Makefile ---- nsapolicycoreutils/sandbox/Makefile 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/Makefile 2010-06-08 15:05:27.000000000 -0400 -@@ -0,0 +1,44 @@ -+# Installation directories. -+PREFIX ?= ${DESTDIR}/usr -+INITDIR ?= ${DESTDIR}/etc/rc.d/init.d/ -+SYSCONFDIR ?= ${DESTDIR}/etc/sysconfig -+BINDIR ?= $(PREFIX)/bin -+SBINDIR ?= $(PREFIX)/sbin -+MANDIR ?= $(PREFIX)/share/man -+LOCALEDIR ?= /usr/share/locale -+SHAREDIR ?= $(PREFIX)/share/sandbox +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/Makefile policycoreutils-2.0.83/sandbox/Makefile +--- nsapolicycoreutils/sandbox/Makefile 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/Makefile 2010-06-16 08:22:37.000000000 -0400 +@@ -7,8 +7,8 @@ + MANDIR ?= $(PREFIX)/share/man + LOCALEDIR ?= /usr/share/locale + SHAREDIR ?= $(PREFIX)/share/sandbox +-override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DPACKAGE="\"policycoreutils\"" +-LDLIBS += -lselinux -lcap-ng +override CFLAGS += $(LDFLAGS) -I$(PREFIX)/include -DPACKAGE="\"policycoreutils\"" -Wall -Werror -Wextra +LDLIBS += -lcgroup -lselinux -lcap-ng -+ -+all: sandbox seunshare sandboxX.sh -+ -+seunshare: seunshare.o $(EXTRA_OBJS) -+ $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) -+ -+install: all -+ -mkdir -p $(BINDIR) -+ install -m 755 sandbox $(BINDIR) -+ -mkdir -p $(MANDIR)/man8 -+ install -m 644 sandbox.8 $(MANDIR)/man8/ + + all: sandbox seunshare sandboxX.sh + +@@ -20,6 +20,9 @@ + 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) -+ -mkdir -p $(INITDIR) -+ install -m 755 sandbox.init $(INITDIR)/sandbox -+ -mkdir -p $(SYSCONFDIR) + -mkdir -p $(SBINDIR) + install -m 4755 seunshare $(SBINDIR)/ + -mkdir -p $(SHAREDIR) +@@ -27,7 +30,7 @@ + -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 -+ -+clean: -+ -rm -f seunshare *.o *~ -+ -+indent: -+ ../../scripts/Lindent $(wildcard *.[ch]) -+ -+relabel: -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox policycoreutils-2.0.82/sandbox/sandbox ---- nsapolicycoreutils/sandbox/sandbox 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/sandbox 2010-06-08 15:12:00.000000000 -0400 -@@ -0,0 +1,434 @@ -+#! /usr/bin/python -E -+# Authors: Dan Walsh + + test: + @python test_sandbox.py -v +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox policycoreutils-2.0.83/sandbox/sandbox +--- nsapolicycoreutils/sandbox/sandbox 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/sandbox 2010-07-13 13:31:35.000000000 -0400 +@@ -1,5 +1,6 @@ +-#! /usr/bin/python -E ++#! /usr/bin/python -Es + # Authors: Dan Walsh +# Authors: Thomas Liu -+# Authors: Josh Cogliati -+# -+# Copyright (C) 2009,2010 Red Hat -+# see file 'COPYING' for use and warranty information -+# -+# This program is free software; you can redistribute it and/or -+# modify it under the terms of the GNU General Public License as -+# published by the Free Software Foundation; version 2 only -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+# -+ + # Authors: Josh Cogliati + # + # Copyright (C) 2009,2010 Red Hat +@@ -19,11 +20,12 @@ + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # + +-import os, sys, socket, random, fcntl, shutil, re, subprocess +import os, stat, sys, socket, random, fcntl, shutil, re, subprocess -+import selinux -+import signal -+from tempfile import mkdtemp -+import pwd + import selinux + import signal + from tempfile import mkdtemp + import pwd +import commands -+ -+PROGNAME = "policycoreutils" -+HOMEDIR=pwd.getpwuid(os.getuid()).pw_dir -+ -+import gettext -+gettext.bindtextdomain(PROGNAME, "/usr/share/locale") -+gettext.textdomain(PROGNAME) -+ -+try: -+ gettext.install(PROGNAME, -+ localedir = "/usr/share/locale", -+ unicode=False, -+ codeset = 'utf-8') -+except IOError: -+ import __builtin__ -+ __builtin__.__dict__['_'] = unicode -+ -+DEFAULT_TYPE = "sandbox_t" -+DEFAULT_X_TYPE = "sandbox_x_t" -+SAVE_FILES = {} -+ -+random.seed(None) -+ -+def sighandler(signum, frame): -+ signal.signal(signum, signal.SIG_IGN) -+ os.kill(0, signum) -+ raise KeyboardInterrupt -+ -+def setup_sighandlers(): -+ signal.signal(signal.SIGHUP, sighandler) -+ signal.signal(signal.SIGQUIT, sighandler) -+ signal.signal(signal.SIGTERM, sighandler) -+ -+def error_exit(msg): -+ sys.stderr.write("%s: " % sys.argv[0]) -+ sys.stderr.write("%s\n" % msg) -+ sys.stderr.flush() -+ sys.exit(1) -+ -+def chcon(path, context, recursive=False): -+ """ Restore SELinux context on a given path """ -+ mode = os.lstat(path)[stat.ST_MODE] -+ selinux.lsetfilecon(path, context) -+ if recursive: -+ for root, dirs, files in os.walk(path): -+ for f in files: -+ chcon("%s/%s" % (root, f), context, False) -+ -+def copyfile(file, dir, dest): -+ import re -+ if file.startswith(dir): -+ dname = os.path.dirname(file) -+ bname = os.path.basename(file) -+ if dname == dir: -+ dest = dest + "/" + bname -+ else: -+ newdir = re.sub(dir, dest, dname) -+ if not os.path.exists(newdir): -+ os.makedirs(newdir) -+ dest = newdir + "/" + bname -+ -+ try: -+ if os.path.isdir(file): -+ shutil.copytree(file, dest) -+ else: -+ shutil.copy2(file, dest) -+ except shutil.Error, elist: -+ for e in elist: -+ sys.stderr.write(e[1]) -+ -+ SAVE_FILES[file] = (dest, os.path.getmtime(dest)) -+ -+def savefile(new, orig, X_ind): -+ copy = False -+ if(X_ind): -+ import gtk -+ dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, -+ gtk.BUTTONS_YES_NO, -+ _("Do you want to save changes to '%s' (Y/N): ") % orig) -+ dlg.set_title(_("Sandbox Message")) -+ dlg.set_position(gtk.WIN_POS_MOUSE) -+ dlg.show_all() -+ rc = dlg.run() -+ dlg.destroy() -+ if rc == gtk.RESPONSE_YES: -+ copy = True -+ else: -+ ans = raw_input(_("Do you want to save changes to '%s' (y/N): ") % orig) -+ if(re.match(_("[yY]"),ans)): -+ copy = True -+ if(copy): -+ shutil.copy2(new,orig) -+ -+def reserve(level): -+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) -+ sock.bind("\0%s" % level) -+ fcntl.fcntl(sock.fileno(), fcntl.F_SETFD, fcntl.FD_CLOEXEC) -+ -+def gen_mcs(): -+ while True: -+ i1 = random.randrange(0, 1024) -+ i2 = random.randrange(0, 1024) -+ if i1 == i2: -+ continue -+ if i1 > i2: -+ tmp = i1 -+ i1 = i2 -+ i2 = tmp -+ level = "s0:c%d,c%d" % (i1, i2) -+ try: -+ reserve(level) -+ except socket.error: -+ continue -+ break -+ return level -+ -+def fullpath(cmd): -+ for i in [ "/", "./", "../" ]: -+ if cmd.startswith(i): -+ return cmd -+ for i in os.environ["PATH"].split(':'): -+ f = "%s/%s" % (i, cmd) -+ if os.access(f, os.X_OK): -+ return f -+ return cmd -+ -+class Sandbox: -+ VERSION = "sandbox .1" -+ SYSLOG = "/var/log/messages" -+ -+ def __init__(self): -+ self.setype = DEFAULT_TYPE -+ self.__options = None -+ self.__cmds = None -+ self.__init_files = [] -+ self.__paths = [] -+ self.__mount = False -+ self.__level = None -+ self.__homedir = None -+ self.__tmpdir = None -+ -+ def __validate_mount(self): -+ if self.__options.level: -+ if not self.__options.homedir or not self.__options.tmpdir: -+ self.usage(_("Homedir and tempdir required for level mounts")) -+ -+ if not os.path.exists("/usr/sbin/seunshare"): -+ raise ValueError(_(""" -+/usr/sbin/seunshare is required for the action you want to perform. -+""")) -+ -+ def __mount_callback(self, option, opt, value, parser): -+ self.__mount = True -+ -+ def __x_callback(self, option, opt, value, parser): -+ self.__mount = True -+ setattr(parser.values, option.dest, True) -+ -+ def __validdir(self, option, opt, value, parser): -+ if not os.path.isdir(value): -+ raise IOError("Directory "+value+" not found") -+ setattr(parser.values, option.dest, value) -+ self.__mount = True -+ -+ def __include(self, option, opt, value, parser): -+ rp = os.path.realpath(os.path.expanduser(value)) -+ if not os.path.exists(rp): -+ raise IOError(value+" not found") -+ -+ if rp not in self.__init_files: -+ self.__init_files.append(rp) -+ -+ def __includefile(self, option, opt, value, parser): -+ fd = open(value, "r") -+ for i in fd.readlines(): -+ try: -+ self.__include(option, opt, i[:-1], parser) -+ except IOError, e: -+ sys.stderr.write(e) -+ fd.close() -+ -+ def __copyfiles(self): -+ files = self.__init_files + self.__paths -+ homedir=pwd.getpwuid(os.getuid()).pw_dir -+ for f in files: -+ copyfile(f, homedir, self.__homedir) -+ copyfile(f, "/tmp", self.__tmpdir) -+ -+ def __setup_sandboxrc(self, wm = "/usr/bin/matchbox-window-manager -use_titlebar no"): -+ execfile =self.__homedir + "/.sandboxrc" -+ fd = open(execfile, "w+") -+ if self.__options.session: -+ fd.write("""#!/bin/sh -+#TITLE: /etc/gdm/Xsession -+/etc/gdm/Xsession -+""") -+ else: -+ command = " ".join(self.__paths) -+ fd.write("""#! /bin/sh -+#TITLE: %s -+/usr/bin/test -r ~/.xmodmap && /usr/bin/xmodmap ~/.xmodmap -+%s & -+WM_PID=$! + + PROGNAME = "policycoreutils" + HOMEDIR=pwd.getpwuid(os.getuid()).pw_dir +@@ -218,7 +220,7 @@ + /usr/bin/test -r ~/.xmodmap && /usr/bin/xmodmap ~/.xmodmap + %s & + WM_PID=$! +-%s +dbus-launch %s -+kill -TERM $WM_PID 2> /dev/null -+""" % (command, wm, command)) -+ fd.close() -+ os.chmod(execfile, 0700) -+ -+ def usage(self, message = ""): -+ error_exit("%s\n%s" % (self.__parser.usage, message)) -+ -+ def __parse_options(self): -+ from optparse import OptionParser -+ usage = _(""" + kill -TERM $WM_PID 2> /dev/null + """ % (command, wm, command)) + fd.close() +@@ -230,9 +232,9 @@ + def __parse_options(self): + from optparse import OptionParser + usage = _(""" +-sandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] command +sandbox [-h] [-l level ] [-[X|M] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] command -+ + +-sandbox [-h] [-[X|M] [-l level ] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] -S +sandbox [-h] [-l level ] [-[X|M] [-H homedir] [-T tempdir]] [-I includefile ] [-W windowmanager ] [[-i file ] ...] [ -t type ] -S -+""") -+ -+ parser = OptionParser(version=self.VERSION, usage=usage) -+ parser.disable_interspersed_args() -+ parser.add_option("-i", "--include", -+ action="callback", callback=self.__include, -+ type="string", -+ help=_("include file in sandbox")) -+ parser.add_option("-I", "--includefile", action="callback", callback=self.__includefile, -+ type="string", -+ help=_("read list of files to include in sandbox from INCLUDEFILE")) -+ parser.add_option("-t", "--type", dest="setype", action="store", default=None, -+ help=_("run sandbox with SELinux type")) -+ parser.add_option("-M", "--mount", -+ action="callback", callback=self.__mount_callback, -+ help=_("mount new home and/or tmp directory")) -+ -+ parser.add_option("-S", "--session", action="store_true", dest="session", -+ default=False, help=_("run complete desktop session within sandbox")) -+ -+ parser.add_option("-X", dest="X_ind", -+ action="callback", callback=self.__x_callback, -+ default=False, help=_("run X application within a sandbox")) -+ -+ parser.add_option("-H", "--homedir", -+ action="callback", callback=self.__validdir, -+ type="string", -+ dest="homedir", -+ help=_("alternate home directory to use for mounting")) -+ -+ parser.add_option("-T", "--tmpdir", dest="tmpdir", -+ type="string", -+ action="callback", callback=self.__validdir, -+ help=_("alternate /tmp directory to use for mounting")) -+ -+ parser.add_option("-W", "--windowmanager", dest="wm", -+ type="string", -+ default="/usr/bin/matchbox-window-manager -use_titlebar no", -+ help=_("alternate window manager")) -+ -+ parser.add_option("-l", "--level", dest="level", -+ help=_("MCS/MLS level for the sandbox")) -+ + """) + + parser = OptionParser(version=self.VERSION, usage=usage) +@@ -276,6 +278,10 @@ + parser.add_option("-l", "--level", dest="level", + help=_("MCS/MLS level for the sandbox")) + + parser.add_option("-C", "--cgroups", + action="store_true", dest="usecgroup", default=False, + help="Use cgroups to limit this sandbox.") + -+ self.__parser=parser -+ -+ self.__options, cmds = parser.parse_args() -+ -+ if self.__options.X_ind: -+ self.setype = DEFAULT_X_TYPE -+ -+ if self.__options.setype: -+ self.setype = self.__options.setype -+ -+ if self.__mount: -+ self.__validate_mount() -+ -+ if self.__options.session: -+ if not self.__options.setype: -+ self.setype = selinux.getcon()[1].split(":")[2] -+ if not self.__options.homedir or not self.__options.tmpdir: -+ self.usage(_("You must specify a Homedir and tempdir when setting up a session sandbox")) -+ if len(cmds) > 0: -+ self.usage(_("Commands are not allowed in a session sandbox")) -+ self.__options.X_ind = True -+ self.__homedir = self.__options.homedir -+ self.__tmpdir = self.__options.tmpdir -+ else: -+ if len(cmds) == 0: -+ self.usage(_("Command required")) -+ cmds[0] = fullpath(cmds[0]) -+ if not os.access(cmds[0], os.X_OK): -+ self.usage(_("%s is not an executable") % cmds[0] ) -+ -+ self.__cmds = cmds -+ -+ for f in cmds: -+ rp = os.path.realpath(f) -+ if os.path.exists(rp): -+ self.__paths.append(rp) -+ else: -+ self.__paths.append(f) -+ -+ def __gen_context(self): -+ if self.__options.level: -+ level = self.__options.level -+ else: -+ level = gen_mcs() -+ -+ con = selinux.getcon()[1].split(":") -+ self.__execcon = "%s:%s:%s:%s" % (con[0], con[1], self.setype, level) -+ self.__filecon = "%s:%s:%s:%s" % (con[0], "object_r", -+ "%s_file_t" % self.setype[:-2], -+ level) -+ def __setup_dir(self): -+ if self.__options.level or self.__options.session: -+ return -+ sandboxdir = HOMEDIR + "/.sandbox" -+ if not os.path.exists(sandboxdir): -+ os.mkdir(sandboxdir) -+ -+ if self.__options.homedir: -+ chcon(self.__options.homedir, self.__filecon, True) -+ self.__homedir = self.__options.homedir -+ else: -+ selinux.setfscreatecon(self.__filecon) -+ self.__homedir = mkdtemp(dir=sandboxdir, prefix=".sandbox") -+ -+ if self.__options.tmpdir: -+ chcon(self.__options.tmpdir, self.__filecon, True) -+ self.__tmpdir = self.__options.tmpdir -+ else: -+ selinux.setfscreatecon(self.__filecon) -+ self.__tmpdir = mkdtemp(dir="/tmp", prefix=".sandbox") -+ selinux.setfscreatecon(None) -+ self.__copyfiles() -+ -+ def __execute(self): -+ try: + self.__parser=parser + + self.__options, cmds = parser.parse_args() +@@ -351,22 +357,24 @@ + + def __execute(self): + try: +- if self.__options.X_ind: +- xmodmapfile = self.__homedir + "/.xmodmap" +- xd = open(xmodmapfile,"w") +- subprocess.Popen(["/usr/bin/xmodmap","-pke"],stdout=xd).wait() +- xd.close() +- +- self.__setup_sandboxrc(self.__options.wm) +- +- cmds = [ '/usr/sbin/seunshare', "-t", self.__tmpdir, "-h", self.__homedir, "--", self.__execcon, "/usr/share/sandbox/sandboxX.sh" ] +- rc = subprocess.Popen(cmds).wait() +- return rc +- + cmds = [ '/usr/sbin/seunshare', "-Z", self.__execcon ] + if self.__options.usecgroup == True: + cmds.append('-c') -+ if self.__mount: + if self.__mount: +- cmds = [ '/usr/sbin/seunshare', "-t", self.__tmpdir, "-h", self.__homedir, "--", self.__execcon ] + self.__paths +- rc = subprocess.Popen(cmds).wait() +- return rc + cmds += [ "-t", self.__tmpdir, "-h", self.__homedir ] + + if self.__options.X_ind: @@ -1985,130 +1668,50 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + else: + cmds += [ "--" ] + self.__paths + return subprocess.Popen(cmds).wait() -+ -+ selinux.setexeccon(self.__execcon) -+ rc = subprocess.Popen(self.__cmds).wait() -+ selinux.setexeccon(None) -+ return rc -+ -+ finally: -+ for i in self.__paths: -+ if i not in SAVE_FILES: -+ continue -+ (dest, mtime) = SAVE_FILES[i] -+ if os.path.getmtime(dest) > mtime: -+ savefile(dest, i, self.__options.X_ind) -+ -+ if self.__homedir and not self.__options.homedir: -+ shutil.rmtree(self.__homedir) -+ if self.__tmpdir and not self.__options.tmpdir: -+ shutil.rmtree(self.__tmpdir) -+ def main(self): -+ try: -+ self.__parse_options() -+ self.__gen_context() -+ self.__setup_dir() -+ return self.__execute() -+ except KeyboardInterrupt: -+ sys.exit(0) -+ -+ -+if __name__ == '__main__': -+ setup_sighandlers() -+ if selinux.is_selinux_enabled() != 1: -+ error_exit("Requires an SELinux enabled system") -+ -+ try: -+ sandbox = Sandbox() -+ rc = sandbox.main() -+ except OSError, error: -+ error_exit(error.args[1]) -+ except ValueError, error: -+ error_exit(error.args[0]) -+ except KeyError, error: -+ error_exit(_("Invalid value %s") % error.args[0]) -+ except IOError, error: -+ error_exit(error) -+ except KeyboardInterrupt: -+ rc = 0 -+ -+ sys.exit(rc) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.8 policycoreutils-2.0.82/sandbox/sandbox.8 ---- nsapolicycoreutils/sandbox/sandbox.8 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/sandbox.8 2010-06-08 14:41:10.000000000 -0400 -@@ -0,0 +1,69 @@ + + selinux.setexeccon(self.__execcon) + rc = subprocess.Popen(self.__cmds).wait() +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.8 policycoreutils-2.0.83/sandbox/sandbox.8 +--- nsapolicycoreutils/sandbox/sandbox.8 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/sandbox.8 2010-06-16 08:22:37.000000000 -0400 +@@ -1,4 +1,4 @@ +-.TH SANDBOX "8" "May 2009" "chcat" "User Commands" +.TH SANDBOX "8" "May 2010" "sandbox" "User Commands" -+.SH NAME -+sandbox \- Run cmd under an SELinux sandbox -+.SH SYNOPSIS -+.B sandbox -+[-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [[-i file ]...] [ -t type ] cmd -+[-l level ] [[-M | -X] -H homedir -T tempdir ] [-I includefile ] [ -W windowmanager ] [[-i file ]...] [ -t type ] -S -+.br -+.SH DESCRIPTION -+.PP -+Run the -+.I cmd -+application within a tightly confined SELinux domain. The default sandbox domain only allows applications the ability to read and write stdin, stdout and any other file descriptors handed to it. It is not allowed to open any other files. The -M option will mount an alternate homedir and tmpdir to be used by the sandbox. -+ -+If you have the -+.I policycoreutils-sandbox -+package installed, you can use the -X option and the -M option. -+.B sandbox -X -+allows you to run X applications within a sandbox. These applications will start up their own X Server and create a temporary home directory and /tmp. The default SELinux policy does not allow any capabilities or network access. It also prevents all access to the users other processes and files. Files specified on the command that are in the home directory or /tmp will be copied into the sandbox directories. -+ -+If directories are specified with -H or -T the directory will have its context modified with chcon(1) unless a level is specified with -l. If the MLS/MCS security level is specified, the user is responsible to set the correct labels. -+.PP -+.TP -+\fB\-H\ homedir -+Use alternate homedir to mount over your home directory. Defaults to temporary. Requires -X or -M. -+.TP -+\fB\-i file\fR -+Copy this file into the appropriate temporary sandbox directory. Command can be repeated. -+.TP -+\fB\-I inputfile\fR Copy all files listed in inputfile into the -+appropriate temporary sandbox directories. -+.TP -+\fB\-l\fR -+Specify the MLS/MCS Security Level to run the sandbox with. Defaults to random. -+.TP -+\fB\-M\fR -+Create a Sandbox with temporary files for $HOME and /tmp. -+.TP -+\fB\-t type\fR -+Use alternate sandbox type, defaults to sandbox_t or sandbox_x_t for -X. -+.TP -+\fB\-T\ tmpdir -+Use alternate tempory directory to mount on /tmp. Defaults to tmpfs. Requires -X or -M. -+.TP + .SH NAME + sandbox \- Run cmd under an SELinux sandbox + .SH SYNOPSIS +@@ -42,6 +42,9 @@ + \fB\-T\ tmpdir + Use alternate tempory directory to mount on /tmp. Defaults to tmpfs. Requires -X or -M. + .TP +\fB\-S +Run a full desktop session, Requires level, and home and tmpdir. +.TP -+\fB\-W windowmanager\fR -+Select alternative window manager to run within -+.B sandbox -X. -+Default to /usr/bin/matchbox-window-manager. -+.TP -+\fB\-X\fR -+Create an X based Sandbox for gui apps, temporary files for -+$HOME and /tmp, secondary Xserver, defaults to sandbox_x_t + \fB\-W windowmanager\fR + Select alternative window manager to run within + .B sandbox -X. +@@ -50,8 +53,17 @@ + \fB\-X\fR + Create an X based Sandbox for gui apps, temporary files for + $HOME and /tmp, secondary Xserver, defaults to sandbox_x_t +.TP +\fB\-C\fR +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. -+.PP -+.SH "SEE ALSO" -+.TP + .PP + .SH "SEE ALSO" + .TP +-runcon(1) +runcon(1), seunshare(8), selinux(8) -+.PP + .PP + +.SH AUTHOR +This manual page was written by +.I Dan Walsh +and +.I Thomas Liu -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.conf policycoreutils-2.0.82/sandbox/sandbox.conf +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.conf policycoreutils-2.0.83/sandbox/sandbox.conf --- nsapolicycoreutils/sandbox/sandbox.conf 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/sandbox.conf 2010-06-08 14:41:59.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/sandbox.conf 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,7 @@ +# Space separate list of homedirs +HOMEDIRS="/home" @@ -2117,9 +1720,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +CPUAFFINITY=ALL +MEMUSAGE=80% +CPUUSAGE=80% -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.conf.5 policycoreutils-2.0.82/sandbox/sandbox.conf.5 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.conf.5 policycoreutils-2.0.83/sandbox/sandbox.conf.5 --- nsapolicycoreutils/sandbox/sandbox.conf.5 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/sandbox.conf.5 2010-06-08 14:41:19.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/sandbox.conf.5 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,40 @@ +.TH sandbox.conf "5" "June 2010" "sandbox.conf" "Linux System Administration" +.SH NAME @@ -2161,104 +1764,15 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +.SH AUTHOR +This manual page was written by +.I Thomas Liu -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.init policycoreutils-2.0.82/sandbox/sandbox.init ---- nsapolicycoreutils/sandbox/sandbox.init 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/sandbox.init 2010-06-03 17:11:59.000000000 -0400 -@@ -0,0 +1,72 @@ -+#!/bin/bash -+## BEGIN INIT INFO -+# Provides: sandbox -+# Default-Start: 3 4 5 -+# Default-Stop: 0 1 2 3 4 6 -+# Required-Start: -+# -+## END INIT INFO -+# sandbox: Set up / mountpoint to be shared, /var/tmp, /tmp, /home/sandbox unshared -+# -+# chkconfig: 345 1 99 -+# -+# Description: sandbox and other apps that want to use pam_namespace -+# on /var/tmp, /tmp and home directories, requires this script -+# to be run at boot time. -+# This script sets up the / mount point and all of its -+# subdirectories as shared. The script sets up -+# /tmp, /var/tmp, /home and any homedirs listed in -+# /etc/sysconfig/sandbox and all of their subdirectories -+# as unshared. -+# All processes that use pam_namespace will see -+# modifications to the global mountspace, except for the -+# unshared directories. -+# -+ -+# Source function library. -+. /etc/init.d/functions -+ -+HOMEDIRS="/home" -+ -+. /etc/sysconfig/sandbox -+ -+LOCKFILE=/var/lock/subsys/sandbox -+ -+base=${0##*/} -+ -+case "$1" in -+ restart | start) -+ [ -f "$LOCKFILE" ] && exit 0 -+ -+ touch $LOCKFILE -+ mount --make-rshared / -+ mount --rbind /tmp /tmp -+ mount --rbind /var/tmp /var/tmp -+ mount --make-private /tmp -+ mount --make-private /var/tmp -+ for h in $HOMEDIRS; do -+ mount --rbind $h $h -+ mount --make-private $h -+ done -+ -+ exit $? -+ ;; -+ -+ status) -+ if [ -f "$LOCKFILE" ]; then -+ echo "$base is running" -+ else -+ echo "$base is stopped" -+ fi -+ exit 0 -+ ;; -+ -+ stop) -+ rm -f $LOCKFILE -+ exit 0 -+ ;; -+ *) -+ echo $"Usage: $0 {start|stop|status|restart}" -+ exit 3 -+ ;; -+esac -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandboxX.sh policycoreutils-2.0.82/sandbox/sandboxX.sh ---- nsapolicycoreutils/sandbox/sandboxX.sh 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/sandboxX.sh 2010-05-19 15:36:19.000000000 -0400 -@@ -0,0 +1,15 @@ -+#!/bin/bash -+context=`id -Z | secon -t -l -P` -+export TITLE="Sandbox $context -- `grep ^#TITLE: ~/.sandboxrc | /usr/bin/cut -b8-80`" -+export SCREENSIZE="1000x700" -+#export SCREENSIZE=`xdpyinfo | awk '/dimensions/ { print $2 }'` -+trap "exit 0" HUP -+ -+(/usr/bin/Xephyr -title "$TITLE" -terminate -screen $SCREENSIZE -displayfd 5 5>&1 2>/dev/null) | while read D; do -+ export DISPLAY=:$D -+ python -c 'import gtk, os, commands; commands.getstatusoutput("%s/.sandboxrc" % os.environ["HOME"])' -+ export EXITCODE=$? -+ kill -HUP 0 -+ break -+done -+exit 0 -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/seunshare.8 policycoreutils-2.0.82/sandbox/seunshare.8 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/sandbox.config policycoreutils-2.0.83/sandbox/sandbox.config +--- nsapolicycoreutils/sandbox/sandbox.config 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/sandbox.config 1969-12-31 19:00:00.000000000 -0500 +@@ -1,2 +0,0 @@ +-# Space separate list of homedirs +-HOMEDIRS="/home" +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/seunshare.8 policycoreutils-2.0.83/sandbox/seunshare.8 --- nsapolicycoreutils/sandbox/seunshare.8 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/seunshare.8 2010-06-08 14:41:19.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/seunshare.8 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,34 @@ +.TH SEUNSHARE "8" "May 2010" "seunshare" "User Commands" +.SH NAME @@ -2294,167 +1808,56 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +.I Dan Walsh +and +.I Thomas Liu -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/seunshare.c policycoreutils-2.0.82/sandbox/seunshare.c ---- nsapolicycoreutils/sandbox/seunshare.c 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/seunshare.c 2010-06-08 14:56:09.000000000 -0400 -@@ -0,0 +1,522 @@ +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/seunshare.c policycoreutils-2.0.83/sandbox/seunshare.c +--- nsapolicycoreutils/sandbox/seunshare.c 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/sandbox/seunshare.c 2010-06-16 08:32:38.000000000 -0400 +@@ -1,13 +1,20 @@ +/* + * Authors: Dan Walsh + * Authors: Thomas Liu + */ + +#define _GNU_SOURCE -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include + #include + #include + #include + #include + #include + #include +-#define _GNU_SOURCE + #include +#include -+#include -+#include + #include + #include +#include -+#include -+#include -+#include /* for getopt_long() form of getopt() */ -+#include -+#include -+#include -+ -+#include -+#include /* for context-mangling functions */ -+ -+#include -+#include -+ -+#ifdef USE_NLS -+#include /* for setlocale() */ -+#include /* for gettext() */ -+#define _(msgid) gettext (msgid) -+#else -+#define _(msgid) (msgid) -+#endif + #include + #include + #include +@@ -21,7 +28,6 @@ + + #include + #include +-#include + + #ifdef USE_NLS + #include /* for setlocale() */ +@@ -39,6 +45,12 @@ + #define MS_PRIVATE 1<<18 + #endif + +#ifndef PACKAGE +#define PACKAGE "policycoreutils" /* the name of this package lang translation */ +#endif + +#define BUF_SIZE 1024 + -+/** -+ * This function will drop all capabilities -+ * Returns zero on success, non-zero otherwise -+ */ -+static int drop_capabilities(uid_t uid) -+{ -+ capng_clear(CAPNG_SELECT_BOTH); -+ -+ if (capng_lock() < 0) -+ return -1; -+ /* Change uid */ -+ if (setresuid(uid, uid, uid)) { -+ fprintf(stderr, _("Error changing uid, aborting.\n")); -+ return -1; -+ } -+ return capng_apply(CAPNG_SELECT_BOTH); -+} -+ -+#define DEFAULT_PATH "/usr/bin:/bin" -+static int verbose = 0; -+ -+/** -+ * Take care of any signal setup -+ */ -+static int set_signal_handles(void) -+{ -+ sigset_t empty; -+ -+ /* Empty the signal mask in case someone is blocking a signal */ -+ if (sigemptyset(&empty)) { -+ fprintf(stderr, "Unable to obtain empty signal set\n"); -+ return -1; -+ } -+ -+ (void)sigprocmask(SIG_SETMASK, &empty, NULL); -+ -+ /* Terminate on SIGHUP. */ -+ if (signal(SIGHUP, SIG_DFL) == SIG_ERR) { -+ perror("Unable to set SIGHUP handler"); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+/** -+ * This function makes sure the mounted directory is owned by the user executing -+ * seunshare. -+ * If so, it returns 0. If it can not figure this out or they are different, it returns -1. -+ */ -+static int verify_mount(const char *mntdir, struct passwd *pwd) { -+ struct stat sb; -+ if (stat(mntdir, &sb) == -1) { -+ fprintf(stderr, _("Invalid mount point %s: %s\n"), mntdir, strerror(errno)); -+ return -1; -+ } -+ if (sb.st_uid != pwd->pw_uid) { -+ errno = EPERM; -+ syslog(LOG_AUTHPRIV | LOG_ALERT, "%s attempted to mount an invalid directory, %s", pwd->pw_name, mntdir); -+ perror(_("Invalid mount point, reporting to administrator")); -+ return -1; -+ } -+ return 0; -+} -+ -+/** -+ * This function checks to see if the shell is known in /etc/shells. -+ * If so, it returns 0. On error or illegal shell, it returns -1. -+ */ -+static int verify_shell(const char *shell_name) -+{ -+ int rc = -1; -+ const char *buf; -+ -+ if (!(shell_name && shell_name[0])) -+ return rc; -+ -+ while ((buf = getusershell()) != NULL) { -+ /* ignore comments */ -+ if (*buf == '#') -+ continue; -+ -+ /* check the shell skipping newline char */ -+ if (!strcmp(shell_name, buf)) { -+ rc = 1; -+ break; -+ } -+ } -+ endusershell(); -+ return rc; -+} -+ -+static int seunshare_mount(const char *src, const char *dst, struct passwd *pwd) { -+ if (verbose) -+ printf("Mount %s on %s\n", src, dst); -+ -+ if (mount(dst, dst, NULL, MS_BIND, NULL) < 0) { -+ fprintf(stderr, _("Failed to mount %s on %s: %s\n"), dst, dst, strerror(errno)); -+ return -1; -+ } -+ -+ if (mount(dst, dst, NULL, MS_PRIVATE, NULL) < 0) { -+ fprintf(stderr, _("Failed to make %s private: %s\n"), dst, strerror(errno)); -+ return -1; -+ } -+ -+ if (mount(src, dst, NULL, MS_BIND, NULL) < 0) { -+ fprintf(stderr, _("Failed to mount %s on %s: %s\n"), src, dst, strerror(errno)); -+ return -1; -+ } -+ -+ if (verify_mount(dst, pwd) < 0) -+ return -1; + /** + * This function will drop all capabilities + * Returns zero on success, non-zero otherwise +@@ -151,25 +163,57 @@ + + if (verify_mount(dst, pwd) < 0) + return -1; + + return 0; +} @@ -2466,8 +1869,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + syslog(LOG_AUTHPRIV | LOG_ALERT, string); + exit(-1); + -+} -+ + } + +-#define USAGE_STRING _("USAGE: seunshare [ -v ] [ -t tmpdir ] [ -h homedir ] -- CONTEXT executable [args] ") + +int match(const char *string, char *pattern) { + int status; @@ -2487,96 +1891,104 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + fprintf(stderr, "Error parsing config file."); + exit(-1); +} -+ -+int main(int argc, char **argv) { -+ int rc; -+ int status = -1; -+ + + int main(int argc, char **argv) { + int rc; + int status = -1; + +- security_context_t scontext; + security_context_t scontext = NULL; -+ -+ int flag_index; /* flag index in argv[] */ -+ int clflag; /* holds codes for command line flags */ -+ char *tmpdir_s = NULL; /* tmpdir spec'd by user in argv[] */ -+ char *homedir_s = NULL; /* homedir spec'd by user in argv[] */ + + int flag_index; /* flag index in argv[] */ + int clflag; /* holds codes for command line flags */ + char *tmpdir_s = NULL; /* tmpdir spec'd by user in argv[] */ + char *homedir_s = NULL; /* homedir spec'd by user in argv[] */ + int usecgroups = 0; -+ -+ const struct option long_options[] = { -+ {"homedir", 1, 0, 'h'}, -+ {"tmpdir", 1, 0, 't'}, -+ {"verbose", 1, 0, 'v'}, + + const struct option long_options[] = { + {"homedir", 1, 0, 'h'}, + {"tmpdir", 1, 0, 't'}, + {"verbose", 1, 0, 'v'}, + {"cgroups", 1, 0, 'c'}, + {"context", 1, 0, 'Z'}, -+ {NULL, 0, 0, 0} -+ }; -+ -+ uid_t uid = getuid(); -+ -+ if (!uid) { -+ fprintf(stderr, _("Must not be root")); -+ return -1; -+ } -+ + {NULL, 0, 0, 0} + }; + +@@ -180,6 +224,12 @@ + return -1; + } + +#ifdef USE_NLS + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); +#endif + -+ struct passwd *pwd=getpwuid(uid); -+ if (!pwd) { -+ perror(_("getpwduid failed")); -+ return -1; -+ } -+ -+ if (verify_shell(pwd->pw_shell) < 0) { -+ fprintf(stderr, _("Error! Shell is not valid.\n")); -+ return -1; -+ } -+ -+ while (1) { + struct passwd *pwd=getpwuid(uid); + if (!pwd) { + perror(_("getpwduid failed")); +@@ -192,30 +242,30 @@ + } + + while (1) { +- clflag = getopt_long(argc, argv, "h:t:", long_options, + clflag = getopt_long(argc, argv, "cvh:t:c:m:p:Z:", long_options, -+ &flag_index); -+ if (clflag == -1) -+ break; -+ -+ switch (clflag) { -+ case 't': + &flag_index); + if (clflag == -1) + break; + + switch (clflag) { + case 't': +- if (!(tmpdir_s = realpath(optarg, NULL))) { +- fprintf(stderr, _("Invalid mount point %s: %s\n"), optarg, strerror(errno)); +- return -1; +- } + tmpdir_s = optarg; -+ if (verify_mount(tmpdir_s, pwd) < 0) return -1; -+ break; -+ case 'h': + if (verify_mount(tmpdir_s, pwd) < 0) return -1; + break; + case 'h': +- if (!(homedir_s = realpath(optarg, NULL))) { +- fprintf(stderr, _("Invalid mount point %s: %s\n"), optarg, strerror(errno)); +- return -1; +- } + homedir_s = optarg; -+ if (verify_mount(homedir_s, pwd) < 0) return -1; -+ if (verify_mount(pwd->pw_dir, pwd) < 0) return -1; -+ break; -+ case 'v': -+ verbose = 1; -+ break; + if (verify_mount(homedir_s, pwd) < 0) return -1; + if (verify_mount(pwd->pw_dir, pwd) < 0) return -1; + break; + case 'v': + verbose = 1; + break; + case 'c': + usecgroups = 1; + break; + case 'Z': + scontext = strdup(optarg); + break; -+ default: -+ fprintf(stderr, "%s\n", USAGE_STRING); -+ return -1; -+ } -+ } -+ -+ if (! homedir_s && ! tmpdir_s) { + default: + fprintf(stderr, "%s\n", USAGE_STRING); + return -1; +@@ -223,21 +273,179 @@ + } + + if (! homedir_s && ! tmpdir_s) { +- fprintf(stderr, _("Error: tmpdir and/or homedir required \n"), +- "%s\n", USAGE_STRING); + fprintf(stderr, _("Error: tmpdir and/or homedir required \n %s\n"),USAGE_STRING); -+ return -1; -+ } -+ + return -1; + } + +- if (argc - optind < 2) { +- fprintf(stderr, _("Error: context and executable required \n"), +- "%s\n", USAGE_STRING); + if (argc - optind < 1) { + fprintf(stderr, _("Error: executable required \n %s \n"), USAGE_STRING); -+ return -1; -+ } -+ -+ -+ if (set_signal_handles()) -+ return -1; + return -1; + } + +- scontext = argv[optind++]; + + if (set_signal_handles()) + return -1; + if (usecgroups) { + char *cpus = NULL; /* which CPUs to use */ + char *cgroupname = NULL;/* name for the cgroup */ @@ -2738,54 +2150,18 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + cgroup_attach_task(sandbox_group); + + } -+ -+ if (unshare(CLONE_NEWNS) < 0) { -+ perror(_("Failed to unshare")); -+ return -1; -+ } -+ -+ if (homedir_s && tmpdir_s && (strncmp(pwd->pw_dir, tmpdir_s, strlen(pwd->pw_dir)) == 0)) { -+ if (seunshare_mount(tmpdir_s, "/tmp", pwd) < 0) -+ return -1; -+ if (seunshare_mount(homedir_s, pwd->pw_dir, pwd) < 0) -+ return -1; -+ } else { -+ if (homedir_s && seunshare_mount(homedir_s, pwd->pw_dir, pwd) < 0) -+ return -1; -+ -+ if (tmpdir_s && seunshare_mount(tmpdir_s, "/tmp", pwd) < 0) -+ return -1; -+ } -+ -+ if (drop_capabilities(uid)) { -+ perror(_("Failed to drop all capabilities")); -+ return -1; -+ } -+ -+ int child = fork(); -+ if (child == -1) { -+ perror(_("Unable to fork")); -+ return -1; -+ } -+ -+ if (!child) { -+ char *display=NULL; -+ /* Construct a new environment */ -+ char *d = getenv("DISPLAY"); -+ if (d) { -+ display = strdup(d); -+ if (!display) { -+ perror(_("Out of memory")); -+ exit(-1); -+ } -+ } -+ -+ if ((rc = clearenv())) { -+ perror(_("Unable to clear environment")); -+ free(display); -+ exit(-1); -+ } -+ + + if (unshare(CLONE_NEWNS) < 0) { + perror(_("Failed to unshare")); +@@ -286,11 +494,13 @@ + exit(-1); + } + +- if (setexeccon(scontext)) { +- fprintf(stderr, _("Could not set exec context to %s.\n"), +- scontext); +- free(display); +- exit(-1); + if (scontext) { + if (setexeccon(scontext)) { + fprintf(stderr, _("Could not set exec context to %s.\n"), @@ -2793,143 +2169,29 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + free(display); + exit(-1); + } -+ } -+ -+ if (display) -+ rc |= setenv("DISPLAY", display, 1); -+ rc |= setenv("HOME", pwd->pw_dir, 1); -+ rc |= setenv("SHELL", pwd->pw_shell, 1); -+ rc |= setenv("USER", pwd->pw_name, 1); -+ rc |= setenv("LOGNAME", pwd->pw_name, 1); -+ rc |= setenv("PATH", DEFAULT_PATH, 1); -+ -+ if (chdir(pwd->pw_dir)) { -+ perror(_("Failed to change dir to homedir")); -+ exit(-1); -+ } -+ setsid(); -+ -+ execv(argv[optind], argv + optind); -+ free(display); + } + + if (display) +@@ -308,6 +518,7 @@ + setsid(); + execv(argv[optind], argv + optind); + free(display); + freecon(scontext); -+ perror("execv"); -+ exit(-1); -+ } else { -+ waitpid(child, &status, 0); -+ } -+ -+ return status; -+} -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/test_sandbox.py policycoreutils-2.0.82/sandbox/test_sandbox.py ---- nsapolicycoreutils/sandbox/test_sandbox.py 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/test_sandbox.py 2010-04-28 17:12:19.000000000 -0400 -@@ -0,0 +1,98 @@ -+import unittest, os, shutil -+from tempfile import mkdtemp -+from subprocess import Popen, PIPE -+ -+class SandboxTests(unittest.TestCase): -+ def assertDenied(self, err): -+ self.assert_('Permission denied' in err, -+ '"Permission denied" not found in %r' % err) -+ def assertNotFound(self, err): -+ self.assert_('not found' in err, -+ '"not found" not found in %r' % err) -+ -+ def assertFailure(self, status): -+ self.assert_(status != 0, -+ '"Succeeded when it should have failed') -+ -+ def assertSuccess(self, status, err): -+ self.assert_(status == 0, -+ '"Sandbox should have succeeded for this test %r' % err) -+ -+ def test_simple_success(self): -+ "Verify that we can read file descriptors handed to sandbox" -+ p1 = Popen(['cat', '/etc/passwd'], stdout = PIPE) -+ p2 = Popen(['sandbox', 'grep', 'root'], stdin = p1.stdout, stdout=PIPE) -+ out, err = p2.communicate() -+ self.assert_('root' in out) -+ -+ def test_cant_kill(self): -+ "Verify that we cannot send kill signal in the sandbox" -+ pid = os.getpid() -+ p = Popen(['sandbox', 'kill', '-HUP', str(pid)], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertDenied(err) -+ -+ def test_cant_ping(self): -+ "Verify that we can't ping within the sandbox" -+ p = Popen(['sandbox', 'ping', '-c 1 ', '127.0.0.1'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertDenied(err) -+ -+ def test_cant_mkdir(self): -+ "Verify that we can't mkdir within the sandbox" -+ p = Popen(['sandbox', 'mkdir', '~/test'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertFailure(p.returncode) -+ -+ def test_cant_list_homedir(self): -+ "Verify that we can't list homedir within the sandbox" -+ p = Popen(['sandbox', 'ls', '~'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertFailure(p.returncode) -+ -+ def test_cant_send_mail(self): -+ "Verify that we can't send mail within the sandbox" -+ p = Popen(['sandbox', 'mail'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertDenied(err) -+ -+ def test_cant_sudo(self): -+ "Verify that we can't run sudo within the sandbox" -+ p = Popen(['sandbox', 'sudo'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertFailure(p.returncode) -+ -+ def test_mount(self): -+ "Verify that we mount a file system" -+ p = Popen(['sandbox', '-M', 'id'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertSuccess(p.returncode, err) -+ -+ def test_set_level(self): -+ "Verify that we set level a file system" -+ p = Popen(['sandbox', '-l', 's0', 'id'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ self.assertSuccess(p.returncode, err) -+ -+ def test_homedir(self): -+ "Verify that we set homedir a file system" -+ homedir = mkdtemp(dir=".", prefix=".sandbox_test") -+ p = Popen(['sandbox', '-H', homedir, '-M', 'id'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ shutil.rmtree(homedir) -+ self.assertSuccess(p.returncode, err) -+ -+ def test_tmpdir(self): -+ "Verify that we set tmpdir a file system" -+ tmpdir = mkdtemp(dir="/tmp", prefix=".sandbox_test") -+ p = Popen(['sandbox', '-T', tmpdir, '-M', 'id'], stdout=PIPE, stderr=PIPE) -+ out, err = p.communicate() -+ shutil.rmtree(tmpdir) -+ self.assertSuccess(p.returncode, err) -+ -+if __name__ == "__main__": -+ import selinux -+ if selinux.security_getenforce() == 1: -+ unittest.main() -+ else: -+ print "SELinux must be in enforcing mode for this test" -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sandbox/test.txt policycoreutils-2.0.82/sandbox/test.txt ---- nsapolicycoreutils/sandbox/test.txt 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sandbox/test.txt 2010-04-28 17:12:19.000000000 -0400 -@@ -0,0 +1 @@ -+1 -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.82/scripts/fixfiles + perror("execv"); + exit(-1); + } else { +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/chcat policycoreutils-2.0.83/scripts/chcat +--- nsapolicycoreutils/scripts/chcat 2010-05-19 14:45:51.000000000 -0400 ++++ policycoreutils-2.0.83/scripts/chcat 2010-07-13 13:31:23.000000000 -0400 +@@ -1,4 +1,4 @@ +-#! /usr/bin/python -E ++#! /usr/bin/python -Es + # Copyright (C) 2005 Red Hat + # see file 'COPYING' for use and warranty information + # +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/fixfiles policycoreutils-2.0.83/scripts/fixfiles --- nsapolicycoreutils/scripts/fixfiles 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/scripts/fixfiles 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/scripts/fixfiles 2010-06-16 08:22:37.000000000 -0400 @@ -21,6 +21,17 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -3021,12 +2283,12 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po restore } -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/genhomedircon.8 policycoreutils-2.0.82/scripts/genhomedircon.8 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/genhomedircon.8 policycoreutils-2.0.83/scripts/genhomedircon.8 --- nsapolicycoreutils/scripts/genhomedircon.8 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/scripts/genhomedircon.8 2010-05-21 08:10:14.000000000 -0400 -@@ -0,0 +1,38 @@ ++++ policycoreutils-2.0.83/scripts/genhomedircon.8 2010-06-16 08:33:58.000000000 -0400 +@@ -0,0 +1,37 @@ +.\" Hey, Emacs! This is an -*- nroff -*- source file. -+.\" Copyright (c) 2005 Manoj Srivastava ++.\" Copyright (c) 2010 Dan Walsh +.\" +.\" This is free documentation; you can redistribute it and/or +.\" modify it under the terms of the GNU General Public License as @@ -3062,10 +2324,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +.SH AUTHOR +This manual page was written by +.I Dan Walsh -+ -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/Makefile policycoreutils-2.0.82/scripts/Makefile +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/scripts/Makefile policycoreutils-2.0.83/scripts/Makefile --- nsapolicycoreutils/scripts/Makefile 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/scripts/Makefile 2010-05-21 08:13:36.000000000 -0400 ++++ policycoreutils-2.0.83/scripts/Makefile 2010-06-16 08:22:37.000000000 -0400 @@ -14,6 +14,7 @@ install -m 755 genhomedircon $(SBINDIR) -mkdir -p $(MANDIR)/man8 @@ -3074,9 +2335,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po install -m 644 chcat.8 $(MANDIR)/man8/ clean: -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/default_encoding.c policycoreutils-2.0.82/semanage/default_encoding/default_encoding.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/default_encoding.c policycoreutils-2.0.83/semanage/default_encoding/default_encoding.c --- nsapolicycoreutils/semanage/default_encoding/default_encoding.c 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/semanage/default_encoding/default_encoding.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/default_encoding/default_encoding.c 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,59 @@ +/* + * Authors: @@ -3137,9 +2398,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + PyUnicode_SetDefaultEncoding("utf-8"); + m = Py_InitModule3("default_encoding_utf8", methods, "Forces the default encoding to utf-8"); +} -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/Makefile policycoreutils-2.0.82/semanage/default_encoding/Makefile +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/Makefile policycoreutils-2.0.83/semanage/default_encoding/Makefile --- nsapolicycoreutils/semanage/default_encoding/Makefile 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/semanage/default_encoding/Makefile 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/default_encoding/Makefile 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,8 @@ +all: + LDFLAGS="" python setup.py build @@ -3149,9 +2410,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + +clean: + rm -rf build *~ -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/policycoreutils/__init__.py policycoreutils-2.0.82/semanage/default_encoding/policycoreutils/__init__.py +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/policycoreutils/__init__.py policycoreutils-2.0.83/semanage/default_encoding/policycoreutils/__init__.py --- nsapolicycoreutils/semanage/default_encoding/policycoreutils/__init__.py 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/semanage/default_encoding/policycoreutils/__init__.py 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/default_encoding/policycoreutils/__init__.py 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,17 @@ +# +# Copyright (C) 2006,2007,2008, 2009 Red Hat, Inc. @@ -3170,9 +2431,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/setup.py policycoreutils-2.0.82/semanage/default_encoding/setup.py +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/default_encoding/setup.py policycoreutils-2.0.83/semanage/default_encoding/setup.py --- nsapolicycoreutils/semanage/default_encoding/setup.py 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/semanage/default_encoding/setup.py 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/default_encoding/setup.py 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,38 @@ +# Authors: +# John Dennis @@ -3212,9 +2473,15 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + ext_modules = [default_encoding_utf8], + packages=["policycoreutils"], +) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage policycoreutils-2.0.82/semanage/semanage +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage policycoreutils-2.0.83/semanage/semanage --- nsapolicycoreutils/semanage/semanage 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/semanage/semanage 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/semanage 2010-07-13 13:09:01.000000000 -0400 +@@ -1,4 +1,4 @@ +-#! /usr/bin/python -E ++#! /usr/bin/python -Es + # Copyright (C) 2005, 2006, 2007 Red Hat + # see file 'COPYING' for use and warranty information + # @@ -20,6 +20,7 @@ # 02111-1307 USA # @@ -3616,9 +2883,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po errorExit(error.args[1]) + except OSError, error: + errorExit(error.args[1]) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage.8 policycoreutils-2.0.82/semanage/semanage.8 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/semanage.8 policycoreutils-2.0.83/semanage/semanage.8 --- nsapolicycoreutils/semanage/semanage.8 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/semanage/semanage.8 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/semanage.8 2010-06-16 08:22:37.000000000 -0400 @@ -1,27 +1,58 @@ -.TH "semanage" "8" "2005111103" "" "" +.TH "semanage" "8" "20100223" "" "" @@ -3779,9 +3046,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +and Russell Coker . +.br Examples by Thomas Bleher . -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/seobject.py policycoreutils-2.0.82/semanage/seobject.py +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/semanage/seobject.py policycoreutils-2.0.83/semanage/seobject.py --- nsapolicycoreutils/semanage/seobject.py 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/semanage/seobject.py 2010-05-21 08:35:31.000000000 -0400 ++++ policycoreutils-2.0.83/semanage/seobject.py 2010-06-16 08:22:37.000000000 -0400 @@ -29,47 +29,12 @@ import gettext gettext.bindtextdomain(PROGNAME, "/usr/share/locale") @@ -4535,10 +3802,10 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po def list(self, heading = True, locallist = False, use_file = False): on_off = (_("off"), _("on")) if use_file: -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sepolgen-ifgen/Makefile policycoreutils-2.0.82/sepolgen-ifgen/Makefile +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sepolgen-ifgen/Makefile policycoreutils-2.0.83/sepolgen-ifgen/Makefile --- nsapolicycoreutils/sepolgen-ifgen/Makefile 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sepolgen-ifgen/Makefile 2010-04-28 17:12:19.000000000 -0400 -@@ -0,0 +1,26 @@ ++++ policycoreutils-2.0.83/sepolgen-ifgen/Makefile 2010-06-16 08:24:30.000000000 -0400 +@@ -0,0 +1,25 @@ +# Installation directories. +PREFIX ?= ${DESTDIR}/usr +BINDIR ?= $(PREFIX)/bin @@ -4555,7 +3822,6 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + +install: all + -mkdir -p $(BINDIR) -+ install -m 755 sepolgen-ifgen $(BINDIR) + install -m 755 sepolgen-ifgen-attr-helper $(BINDIR) + +clean: @@ -4565,144 +3831,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + ../../scripts/Lindent $(wildcard *.[ch]) + +relabel: ; -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sepolgen-ifgen/sepolgen-ifgen policycoreutils-2.0.82/sepolgen-ifgen/sepolgen-ifgen ---- nsapolicycoreutils/sepolgen-ifgen/sepolgen-ifgen 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sepolgen-ifgen/sepolgen-ifgen 2010-04-28 17:12:19.000000000 -0400 -@@ -0,0 +1,131 @@ -+#! /usr/bin/python -E -+# -+# Authors: Karl MacMillan -+# -+# Copyright (C) 2006 Red Hat -+# see file 'COPYING' for use and warranty information -+# -+# This program is free software; you can redistribute it and/or -+# modify it under the terms of the GNU General Public License as -+# published by the Free Software Foundation; version 2 only -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+# -+ -+# Parse interfaces and output extracted information about them -+# suitable for policy generation. By default writes the output -+# to the default location (obtained from sepolgen.defaults), but -+# will output to another file provided as an argument: -+# sepolgen-ifgen [headers] [output-filename] -+ -+ -+import sys -+import os -+import tempfile -+import subprocess -+ -+import selinux -+ -+import sepolgen.refparser as refparser -+import sepolgen.defaults as defaults -+import sepolgen.interfaces as interfaces -+ -+ -+VERSION = "%prog .1" -+ATTR_HELPER = "/usr/bin/sepolgen-ifgen-attr-helper" -+ -+def parse_options(): -+ from optparse import OptionParser -+ -+ parser = OptionParser(version=VERSION) -+ parser.add_option("-o", "--output", dest="output", default=defaults.interface_info(), -+ help="filename to store output") -+ parser.add_option("-i", "--interfaces", dest="headers", default=defaults.headers(), -+ help="location of the interface header files") -+ parser.add_option("-a", "--attribute_info", dest="attribute_info") -+ parser.add_option("-v", "--verbose", action="store_true", default=False, -+ help="print debuging output") -+ parser.add_option("-d", "--debug", action="store_true", default=False, -+ help="extra debugging output") -+ parser.add_option("--no_attrs", action="store_true", default=False, -+ help="do not retrieve attribute access from kernel policy") -+ options, args = parser.parse_args() -+ -+ return options -+ -+def get_attrs(): -+ try: -+ policy_path = selinux.selinux_binary_policy_path() + "." + str(selinux.security_policyvers()) -+ outfile = tempfile.NamedTemporaryFile() -+ except IOError, e: -+ sys.stderr.write("could not open attribute output file\n") -+ return None -+ except OSError: -+ # SELinux Disabled Machine -+ return None -+ -+ fd = open("/dev/null","w") -+ ret = subprocess.Popen([ATTR_HELPER, policy_path, outfile.name], stdout=fd).wait() -+ fd.close() -+ if ret != 0: -+ sys.stderr.write("could not run attribute helper") -+ return None -+ -+ attrs = interfaces.AttributeSet() -+ try: -+ attrs.from_file(outfile) -+ except: -+ print "error parsing attribute info" -+ return None -+ -+ return attrs -+ -+def main(): -+ options = parse_options() -+ -+ # Open the output first to generate errors before parsing -+ try: -+ f = open(options.output, "w") -+ except IOError, e: -+ sys.stderr.write("could not open output file [%s]\n" % options.output) -+ return 1 -+ -+ if options.verbose: -+ log = sys.stdout -+ else: -+ log = None -+ -+ # Get the attibutes from the binary -+ attrs = None -+ if not options.no_attrs: -+ attrs = get_attrs() -+ if attrs is None: -+ return 1 -+ -+ # Parse the headers -+ try: -+ headers = refparser.parse_headers(options.headers, output=log, debug=options.debug) -+ except ValueError, e: -+ print "error parsing headers" -+ print str(e) -+ return 1 -+ -+ if_set = interfaces.InterfaceSet(output=log) -+ if_set.add_headers(headers, attributes=attrs) -+ if_set.to_file(f) -+ f.close() -+ -+ if refparser.success: -+ return 0 -+ else: -+ return 1 -+ -+if __name__ == "__main__": -+ sys.exit(main()) -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c policycoreutils-2.0.82/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c policycoreutils-2.0.83/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c --- nsapolicycoreutils/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c 1969-12-31 19:00:00.000000000 -0500 -+++ policycoreutils-2.0.82/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c 2010-06-16 08:22:37.000000000 -0400 @@ -0,0 +1,230 @@ +/* Authors: Frank Mayer + * and Karl MacMillan @@ -4934,9 +4065,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + + return 0; +} -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/restore.c policycoreutils-2.0.82/setfiles/restore.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/restore.c policycoreutils-2.0.83/setfiles/restore.c --- nsapolicycoreutils/setfiles/restore.c 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/setfiles/restore.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/setfiles/restore.c 2010-06-16 08:22:37.000000000 -0400 @@ -1,4 +1,5 @@ #include "restore.h" +#include @@ -5118,9 +4249,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po + free(buf); +} -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/restorecon.8 policycoreutils-2.0.82/setfiles/restorecon.8 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/restorecon.8 policycoreutils-2.0.83/setfiles/restorecon.8 --- nsapolicycoreutils/setfiles/restorecon.8 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/setfiles/restorecon.8 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/setfiles/restorecon.8 2010-06-16 08:22:37.000000000 -0400 @@ -4,10 +4,10 @@ .SH "SYNOPSIS" @@ -5144,9 +4275,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po .TP .B \-v show changes in file labels. -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/restore.h policycoreutils-2.0.82/setfiles/restore.h +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/restore.h policycoreutils-2.0.83/setfiles/restore.h --- nsapolicycoreutils/setfiles/restore.h 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/setfiles/restore.h 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/setfiles/restore.h 2010-06-16 08:22:37.000000000 -0400 @@ -27,6 +27,7 @@ int hard_links; int verbose; @@ -5166,9 +4297,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po +void exclude_non_seclabel_mounts(); #endif -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/setfiles.8 policycoreutils-2.0.82/setfiles/setfiles.8 +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/setfiles.8 policycoreutils-2.0.83/setfiles/setfiles.8 --- nsapolicycoreutils/setfiles/setfiles.8 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/setfiles/setfiles.8 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/setfiles/setfiles.8 2010-06-16 08:22:37.000000000 -0400 @@ -31,6 +31,9 @@ .TP .B \-n @@ -5179,9 +4310,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po .TP .B \-q suppress non-error output. -diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/setfiles.c policycoreutils-2.0.82/setfiles/setfiles.c +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/setfiles/setfiles.c policycoreutils-2.0.83/setfiles/setfiles.c --- nsapolicycoreutils/setfiles/setfiles.c 2010-05-19 14:45:51.000000000 -0400 -+++ policycoreutils-2.0.82/setfiles/setfiles.c 2010-04-28 17:12:19.000000000 -0400 ++++ policycoreutils-2.0.83/setfiles/setfiles.c 2010-06-16 08:22:37.000000000 -0400 @@ -5,7 +5,6 @@ #include #include @@ -5321,3 +4452,9 @@ diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po } } +diff --exclude-from=exclude --exclude=sepolgen-1.0.23 --exclude=gui --exclude=po -N -u -r nsapolicycoreutils/VERSION policycoreutils-2.0.83/VERSION +--- nsapolicycoreutils/VERSION 2010-06-16 08:03:38.000000000 -0400 ++++ policycoreutils-2.0.83/VERSION 2010-06-16 08:22:37.000000000 -0400 +@@ -1 +1 @@ +-2.0.83 ++2.0.82 diff --git a/policycoreutils.spec b/policycoreutils.spec index b086f4e..8174d07 100644 --- a/policycoreutils.spec +++ b/policycoreutils.spec @@ -6,8 +6,8 @@ Summary: SELinux policy core utilities Name: policycoreutils -Version: 2.0.82 -Release: 30%{?dist} +Version: 2.0.83 +Release: 3%{?dist} License: GPLv2+ Group: System Environment/Base Source: http://www.nsa.gov/selinux/archives/policycoreutils-%{version}.tgz @@ -314,6 +314,18 @@ fi exit 0 %changelog +* Tue Jun 15 2010 Dan Walsh 2.0.83-3 +- Change python scripts to use -s flag +- Update po + +* Tue Jun 15 2010 Dan Walsh 2.0.83-1 +- Update to upstream + * Add sandbox support from Dan Walsh with modifications from Steve Lawrence. + +* Tue Jun 15 2010 Dan Walsh 2.0.82-31 +- Fix sepolgen code generation +Resolve: #603001 + * Tue Jun 8 2010 Dan Walsh 2.0.82-30 - Add cgroup support for sandbox