Commit graph

166 commits

Author SHA1 Message Date
Eric Paris
74bb5c01d6 policycoreutils: sandbox: check for paths up front
When launching a sandbox x environment we should check up front to make
sure that the seunshare and sandboxsh files exist and bail politely if
they do not exist.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:28:09 -04:00
Eric Paris
1701e786ea policycoreutils: sandbox: use defined values for paths rather than open coding
Rather than putting pathnames all throughout the file define them as
variables and reuse these variables where needed.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:28:07 -04:00
Eric Paris
406ae12e31 policycoreutils: sandbox: move seunshare globals to the top
Just coding style, globals go at the top of .c files, not randomly
throughout.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:28:05 -04:00
Eric Paris
89e3dd6c30 policycoreutils: sandbox: whitespace fix
couple of whitespace at the end of the line.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:28:03 -04:00
Dan Walsh
8fb9a4571d policycoreutils: semodule_package: Add semodule_unpackage executable
Much like semodule_package this utility will unpack!

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:28:02 -04:00
Eric Paris
242a98cd21 policycoreutils: setfiles: get rid of some stupid globals
We have some useless globals in setfiles that don't need to be.  Stop
it.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:28:00 -04:00
Eric Paris
5ffa296798 policycoreutils: setfiles: move exclude_non_seclabel_mounts to a generic location
move exclude_non_seclabel_mounts from setfiles.c to restore.c so it can
be used by other functions later.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:27:59 -04:00
Eric Paris
6b6b475dcf update changelog and VERSION for latest changes 2011-08-17 11:17:28 -04:00
Guido Trentalancia
3ed7221bf7 policycoreutils: run_init: clarification of the usage in the manual page
It's a very minor thing really, but I believe (on the basis of an
off-list question) that the manual page for policycoreutils/run_init can
be improved by the following short patch which aims to further clarify
the intended usage of such tool and mention that it caters for one
(somewhat hidden) compile-time option.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:24 -04:00
Dan Walsh
d761cc9849 policycoreutils: semanage: fix usage header around booleans
Fix header to not display all of the options and fix Booleans to only list
supported options

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:24 -04:00
Eric Paris
f97e508567 policycoreutils: semanage: remove useless empty lines
This patch just removes some blank lines that we don't need.  Makes it
all purdy.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
1654b964bc policycoreutils: semanage: update man page with new examples
semanage rocks, so make the man page rock!

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
e883871de2 policycoreutils: semanage: update usage text
Add -D and -l and -n in the usage text where they belong.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
d01c33c90e policycoreutils: semanage: introduce file context equivalencies
This adds a new -e options to semanage fcontext which allows one to
specify filesystem equivalancies.  An example would be if an admin were
to run out of space and to start putting home directories in /home1.
They can use the equivalencies to specify that /home1 is labeled exactly
like /home.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
f78aa2f81b policycoreutils: semanage: enable and disable modules
Add tools to store the state of modules and to enable and disable those
modules.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
e25ea71a5b policycoreutils: semanage: output all local modifications
Introduce a new -o option which will output all local modifications in a
method which can be 're-inputted' on another host.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
f3fbc5d6de policycoreutils: semanage: introduce extraction of local configuration
Add a new option -E which will extract the local configuration changes
made for the given record type.  This will be used by a further output
option to be able to dump local configuration in a form which can be
imported later.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
2c3e6f6115 policycoreutils: semanage: cleanup error on invalid operation
Before you would get:
$ semanage fcontext toys
/usr/sbin/semanage Invalid command fcontext toys

Now you get:
$ semanage fcontext toys
/usr/sbin/semanage: Invalid command: semanage fcontext toys

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
877447a9e7 policycoreutils: semanage: handle being called with no arguments
Return quickly instead of tring to parse arguments if there are
no arguments.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
a0d1dc8a01 policycoreutils: semanage: return sooner to save CPU time
Right now we do lots of needless string comparisons even though we know
we are finished doing work immediately after an operation.  So return
sooner.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
d2f0f42570 policycoreutils: semanage: surround getopt with try/except
One of the getopt parsers didn't have a try/except pair to show usage
when a user did it wrong.  Fix that.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
0c4d0788ab policycoreutils: semanage: use define/raise instead of lots of conditionals
Right now the validation code has lots of conditionals which check if we
are trying to add and delete or add and modify or something like that.
Instead make a single function which just sets if this operation is
trying to do an action and if it gets called twice will realize this is
invalid and will raise and exception.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
123559545f policycoreutils: semanage: some options are only valid for local changes
Some options like --locallist and --deleteall only effect local changes
not global things.  Split these validation options into their own bit of
code.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
cfddb3fa9a policycoreutils: semanage: introduce better deleteall support
The help text, man pages, and stuff didn't include everything about
deleteall rules.  Try to update them.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:23 -04:00
Eric Paris
643b9b703c policycoreutils: semanage: do not allow spaces in file context
The entire tool chain does not support file context with a space in the
regex.  If one of these gets into the file_context files, all sorts of stuff
goes nuts.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Eric Paris
4c96df7d77 policycoreutils: semanage: distinguish between builtin and local permissive types
This just distinguishes between permissive types that were definied in
policy and those that were set by the user using semanage.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Eric Paris
12e29ee1dd policycoreutils: semanage: centralized ip node handling
Right now we have very little in the way of IP address validation.  We
also do not properly support IPv6 netmasks.  This patch centralizes IP
address validation and fixes the netmask support.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Eric Paris
66564a67cf policycoreutils: setfiles: make the restore function exclude() non-static
Stuff wants to use it later.  Make it non-static.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Eric Paris
17c577ace7 policycoreutils: setfiles: use glob to handle ~ and . in filenames
Use the glob library to handle ~ and . in filenames passed from the
command line.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Dan Walsh
5bd734dd73 policycoreutils: fixfiles: do not hard code types
We had a number of places where fixfiles would search for or set hard
coded types.  If policy used something other than tmp_t var_t file_t or
unlabeled_t we would go wrong.  This patch does 2 things.  It uses the
kernel provided selinuxfs interfaces to determine the label on unlabeled
and unknown files and it uses the --reference option with chcon to set
new labels.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Eric Paris
35f4e6a870 policycoreutils: fixfiles: stop trying to be smart about filesystems
The type of a filesystem (ext*, btrfs, etc) really doesn't matter when
it comes to the ability to set labels.  Stop trying to be smart and just
call restorecon.  It will either work or it won't and out heuristic
isn't helping.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:22 -04:00
Eric Paris
1da72eea26 policycoreutils: fixfiles: use new kernel seclabel option
The kernel now outputs a mount option called 'seclabel' which indicates
if the filesystem supposed security labeling.  Use that instead of
having to update some hard coded list of acceptable filesystems (that
may or may not be acceptable depending on if they were compiled with
security xattrs)

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-15 11:25:20 -04:00
Eric Paris
e2769ff670 policycoreutils: fixfiles: pipe everything to cat before sending to LOGFILE
We do this so we can eliminate foolish avcs about restorecon trying to
write to a random directory.  We allow apps to communicate with fds
globably.  So this allows the access no AVC's I am happy

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-11 23:35:52 -04:00
Eric Paris
275560b2a3 policycoreutils: fixfiles: introduce /etc/selinux/fixfiles_exclude_dirs
Introduce a new file /etc/selinux/fixfiles_exclude_dirs which contains a
list of directories which should not be relabeled.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-11 23:35:52 -04:00
Eric Paris
5e096d9ceb policycoreutils: semodule: support for alternative root paths
Add a -p option to semodule which will allow it to operate on the
specified semanaged root instead of the default.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-11 23:35:52 -04:00
Eric Paris
4749940426 update repo for 2011-08-03 with version and changelog updates 2011-08-03 18:09:02 -04:00
Eric Paris
2ac99a505e policycoreutils: semanage: fix indention
Part of the if clause used tabs, part spaces.  Be consistent.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:38 -04:00
Eric Paris
e1ae7b43f1 policycoreutils: semodule_package: fix man page typo
Just drop an extra bit of cruft from the man page.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:38 -04:00
Eric Paris
c52ff76180 policycoreutils: semodule_expand: update man page with -a
Update the man page to include -a.  Passing -a causes semodule_expand to
not check assertions.  Include this in the man info.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:38 -04:00
Eric Paris
f2a74f4f87 policycoreutils: semanage: handle os errors
Rather than traceback, handle os errors and exit cleanly.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:38 -04:00
Eric Paris
b5c0a182ef policycoreutils: semanage: fix traceback with bad options
$ semanage fcontext add delete
Traceback (most recent call last):
  File "/usr/sbin/semanage", line 565, in <module>
    process_args(sys.argv[1:])
  File "/usr/sbin/semanage", line 396, in process_args
    raise ValueError(_("%s bad option") % o)
UnboundLocalError: local variable 'o' referenced before assignment

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
b1820fcca6 policycoreutils: semanage: show usage on -h or --help
Raise a more sensicle useage rather than value error on help request
from user.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
72a83a110d policycoreutils: semanage: introduce more deleteall options
Some semanage objects have a deleteall function, some don't.  This adds
them to login seluser node and interface.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
849e7d5be7 policycoreutils: semanage: verify ports < 65536
We could currently create a rule with a port number of one million.
This doesn't make sense.  Bounds test it.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
c3226ebac9 policycoreutils: transaction into semanageRecords
In order to allow semanage to perform a transaction on several seobjects
at the same time, the transaction lock has to be at the class level
versus being in each object.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
3fd3a927e2 policycoreutils: make get_handle a method of semanageRecords
Right now it is needlessly global.  Make it a method of semanageRecords.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
7e00948bdb policycoreutils: remove a needless blank line
Yeah, that's really it.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
5763e720d8 policycoreutils: make process_one error if not initialized correctly
Rather than blow up in horible ways, error out if we detect
initialization wasn't done properly.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
2b4d32dc4b policycoreutils: fixfiles: correct usage for r_opts.rootpath
The error usable displays r_opts.rootpath, but r_opts is supposed to be
an internal code thing, not something users care about.  When printing
the error message just call it 'rootpath'

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00
Eric Paris
89ca0c2e29 policycoreutils: put -p in help for restorecon and fixfiles
restorecon and fixfiles both have the -p option to display a * every
10000 files.  Put it in the usage and man pages.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:37 -04:00