selinux/policycoreutils
Steve Lawrence 582fd00c7b Author: Steve Lawrence
Email: slawrence@tresys.com
Subject: Updated sandbox patch.
Date: Mon, 07 Jun 2010 17:53:41 -0400

On Thu, 2010-05-27 at 08:57 -0400, Daniel J Walsh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 05/26/2010 04:06 PM, Steve Lawrence wrote:
> > On Wed, 2010-05-19 at 15:59 -0400, Daniel J Walsh wrote:
> > Fixed patch that handles Spaces in homedir.
>
> > The following patch makes a few updates the the sandbox patch, though I
> > have a question:
>
> > Is the sandbox.init script needed anymore? It looks like seunshare was
> > changed to now bind mount and make private the necessary directories.
> > The only thing that seems missing is making root rshared. Also, if the
> > init script is obsolete, do the mounts also need the MS_REC flag for
> > recursive bind/private like they are mounted in the init script? e.g.
>
> The init script is needed for the xguest package/more specifically
> pam_namespace, but also needed for
> mount --make-rshared /
>
> Whether the init script belongs in policycoreutils is questionable though.
>
>
> > mount(dst, dst, NULL, (MS_BIND | MS_REC), NULL)
> > mount(dst, dst, NULL, (MS_PRIVATE | MS_REC), NULL)
>
> We probably should add these.  Although it is not likely.
>
> > Changes the following patch makes:
>
> > sandbox.py
> > - Removes unused 'import commands'
> > - Fixes the chcon function, and replaces the deprecated os.path.walk
> >   with os.walk. I think this way is a bit easier to read too.
>
> I think chcon should be added to libselinux python bindings and then
> leave the recursive flag.  (restorecon is currently in python bindings._
>
> > - Removes the 'yum install seunshare' message. This tool is not specific
> >   to RPM based distros.
>
> People are using seunshare without X now that I have added the -M flag.
>  So I will move it from the -gui package to the base package with
> sandbox and then this should not be necessary.
> > - Remove try/except around -I include to be consistent with the -i
> >   option. If we can't include a file, then this should bail, no matter
> >   if it's being included via -i or -I.
>
> Ok, I was thinking you could list a whole bunch of files in the -I case
> and if one does not exist, allow it to continue.  But I don't really care.
> > - Fix homedir/tmpdir typo in chcon call
>
> > sandbox.init (maybe obsoleted?)
> > - Fix restart so it stops and starts
> > - unmount the bind mounts when stopped
> I doubt this will work.  Two many locks in /tmp /home
> > - Abort with failure if any mounts fail
>
> > seunshare.c
> > - Define the mount flag MS_PRIVATE if it isn't already. The flag is only
> >   defined in the latest glibc but has been in the kernel since 2005.
> > - Simplify an if-statment. Also, I'm not sure the purpose of the
> >   strncmmp in that conditional, so maybe I've oversimplified.
> This is wrong.  The problem comes about when you mount within the same
> directory.
>
> seunshare -t /home/dwalsh/sanbox/tmp -h /home/dwalsh/sandbox/home   ...
>
> seunshare -t /tmp/sandbox/tmp -h /tmp/sandbox/home
>
> If you do not have the check one of the above will fail.
>
> In the first example if Homedir is mounted first,
> /home/dwalsh/sanbox/tmp will no longer exist when seunshare attempts to
> mount it on /tmp.
>
> Similarly, if /tmp is mounted first in the second example.
> /tmp/sandbox/home will no longer exist.
>
> You have to check to make sure one of the directories is not included in
> the other.
>
> It seems
> >   like maybe an error should be thrown if tmpdir_s == pw_dir or
> >   homedir_s == "/tmp", but maybe I'm missing something.
>
> See above.
>
> I was blowing up because I use
>
> ~/sandbox/tmp and ~/sandbox/home for my mountpoints.

<snip>

Below is an updated patch that makes a few changes the the latest
Sandbox Patch [1]. This requires the chcon patch [2].

Changes this patch makes:

sandbox.py
- Remove unused 'import commands'
- Uses new chcon method in libselinux [2]
- Removes the 'yum install seunshare' message
- Converts an IOError to a string for printing a warning if a file
  listed in -I does not exist

sandbox.init
- Print the standard Starting/Stoping messages with the appropriate
  OK/FAIL
- Abort with failure if any mounts fail

seunshare.c
- Add the MS_REC flag during mounts to perform recursive mounts
- Define the mount flags MS_PRIVATE and MS_REC if they aren't already.
  The flags are only defined in the latest glibc but have been in the
  kernel since 2005.
- Calls realpath(3) on tmpdir_s and homedir_s. If relative paths are
  used, it wouldn't correctly detect that tmpdir is inside homedir and
  change the mount order. This fixes that.

[1] http://marc.info/?l=selinux&m=127429948731841&w=2
[2] http://marc.info/?l=selinux&m=127594712200878&w=2

Signed-off-by: Chad Sellers <csellers@tresys.com>
2010-06-10 16:37:59 -04:00
..
audit2allow This patch allows audit2allow to look at all avc's since the last time the machine booted. 2010-03-18 16:36:22 -04:00
audit2why initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
load_policy Author: Daniel J Walsh 2009-11-18 15:33:00 -05:00
newrole Fix double free in newrole when it fails to exec. 2009-12-30 16:59:48 -05:00
po remove gui from po/Makefile and po/POTFILES and regenerate po files 2009-06-24 10:54:56 -04:00
restorecond Author: Daniel J Walsh 2009-04-10 19:17:47 -04:00
run_init Author: Manoj Srivastava 2009-09-16 11:16:19 -04:00
sandbox Author: Steve Lawrence 2010-06-10 16:37:59 -04:00
scripts This patch removes OUTPUT from fixfiles which was never used and was broken 2009-11-27 12:44:16 -05:00
secon initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
semanage Fix bug in semanage fcontext 2009-11-19 15:01:13 -05:00
semodule Last attempt at upstreaming semodule_disable patch. 2010-03-06 17:56:24 -05:00
semodule_deps initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
semodule_expand initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
semodule_link initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
semodule_package initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
sestatus initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
setfiles Author: Thomas Liu 2009-11-02 17:02:25 -05:00
setsebool initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
.gitignore Add subdirectory .gitignore files. 2009-10-20 21:25:55 -04:00
COPYING initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
ChangeLog bump sepolgen to 2.0.82 2010-03-24 15:40:05 -04:00
Makefile Author: Daniel J Walsh 2010-06-10 16:35:55 -04:00
VERSION bump sepolgen to 2.0.82 2010-03-24 15:40:05 -04:00