Commit graph

162 commits

Author SHA1 Message Date
Richard Haines
16a37c9f94 libselinux - correct selabel invalid context logging
When selabel_lookup found an invalid context with validation enabled, it
always stated it was 'file_contexts' whether media, x, db or file.
The fix is to store the spec file name in the selabel_lookup_rec on
selabel_open and use this as output for logs. Also a minor fix if key is
NULL to stop seg faults.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-21 12:35:05 -05:00
Eric Paris
d65c02f066 bump version and changelog 2011-12-05 16:20:45 -05:00
Eric Paris
85cfd2fe2e libselinux: use -W and -Werror in utils
Add the flags and fix the one build break.

Signed-off-by: Eric Paris <eparis@redhat.com>
2011-12-05 16:14:17 -05:00
Richard Haines
426d624723 libselinux: Add man/man5 man pages
Add service_seusers(5) - those in the ./logins directory, seusers(5),
user_contexts(5) - those in the ./contexts/users directory,
virtual_domain_context(5) and virtual_image_context(5) man pages.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-12-05 16:11:22 -05:00
Richard Haines
accf6a433f libselinux: Add man/man5 man pages
Add failsafe_context(5), local.users(5), removable_contexts(5) and
securetty_types(5) man pages.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-12-05 16:11:22 -05:00
Richard Haines
cc9e7e5865 libselinux: Add man/man5 man pages
Add booleans(5), customizable_types(5), default_contexts(5) and
default_type(5) man pages.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-12-05 16:11:22 -05:00
Richard Haines
af9608245a libselinux: Updated selabel_x(5) man page
Updated selabel_x(5) with X-Windows context configuration file format and
added x_contexts(5) man page that links to it.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:11:22 -05:00
Richard Haines
a566af7974 libselinux: Updated selabel_media(5) man page
Updated selabel_media(5) with media context configuration file format and
added media(5) man page that links to it.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:11:22 -05:00
Richard Haines
30bd4567cf libselinux: Updated selabel_db(5) man page
Updated selabel_db(5) with RDBMS context configuration file format and added sepgsql_contexts(5) man page that links to it.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:11:21 -05:00
Richard Haines
5f2e362d25 libselinux: Updated selabel_file(5) man page
Updated selabel_file(5) with file context configuration file format and
added file_contexts(5) man page that links to it. selabel_file(5) also
describes the .local, .homedirs, .subs and .subs_dist configuration file
formats.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:11:21 -05:00
Richard Haines
aed37210a3 libselinux: return EINVAL if invalid role selected
For get_default_context_with_role(3) and get_default_context_with_rolelevel(3),
return errno = EINVAL if invalid role.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:10:38 -05:00
Richard Haines
83161f73ea libselinux: get_default_type now sets EINVAL if no entry.
get_default_type(3) now returns with errno set to EINVAL if the entry does not
exist.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:10:38 -05:00
Richard Haines
d0a8d81882 libselinux: Mapped compute functions now obey deny_unknown flag
If selinux_set_mapping(3) is used to map classes, and an invalid class is used
to compute a decision (tclass = 0), the result did not obey the status of the
deny_unknown flag.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:10:38 -05:00
Richard Haines
98234cf543 libselinux: Remove assert in security_get_boolean_names(3)
Remove assert in security_get_boolean_names(3) if the len invalid and stop seg
fault if names is null. Set EINVAL instead and return error.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:10:38 -05:00
Dan Walsh
7e81db0eb8 libselinux: selinuxswig_python.i: don't make syscall if it won't change anything
Add a check to restorecon, to not change a context if the context on disk matches

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-12-05 16:10:38 -05:00
Eric Paris
14e4b70b93 Bump Version and Changelog for commit 2011-11-03 15:26:36 -04:00
Eric Paris
d4a39ca15b policycoreutils: label_file: style changes to make Eric happy.
Sometimes sticking to 80 characters sucks a lot.  I don't care.  Buy a
wider monitor so I can read the code.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 16:22:06 -04:00
Eric Paris
2b06f47400 libselinux: rename and export symlink_realpath
symlink_realpath is used by both libselinux and policycoreutils.
Instead of coding it twice, export the libselinux version under a new
name that makes it sound more generic.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:11 -04:00
Dan Walsh
74a9a52966 libselinux: audit2why: close fd on enomem
Potential file descriptor leak on this code path, need to close file
descriptor if out of memory.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:11 -04:00
Dan Walsh
dd563b35e1 libselinux: seusers: fix to handle large sets of groups
If a user was in too many groups the check_group function might not pass
a large enough buffer to getgrnam_r to handle things.  This could return
ERANGE which we then aborted.  Instead we should make the buffer larger and
try again.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Dan Walsh
3b5e45f004 libselinux: Don't reinitialize avc_init if it has been called previously
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Dan Walsh
9c46a0a315 libselinux: simple interface for access checks
Some programs, like passwd, need to do simeple one time access checks.
Rather than set up a full avc cache and use that infrastructure they
were directly using security_compute_av.  A problem with this approach
is the lack of audit on denials.  This patch creates a new interface
that is simple to use and which will still listen to things like
permissive and output audit messages on denials.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Eric Paris
023c9c1fde libselinux: label: cosmetic cleanups
Return early to save an indent.  Clean up all memory on ENOMEM
conditions.  Use '\0' instead of 0 for nul terminiator.  Style changes
to make Eric happy.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Eric Paris
c81a43c753 libselinux: libsemanage: libsepol: regenerate .pc on VERSION change
The makefile which generated the package config files did not have the
VERSION file as a dependancy.  Thus if you updated a tree you have
previously build the .pc file wouldn't be rebuilt and the old version
would be reinstalled.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Eric Paris
b3b19fdce5 libselinux: load_policy: handle selinux=0 and /sys/fs/selinux not exist
Handle situation where selinux=0 passed to the kernel and both /selinux and
/sys/fs/selinux directories do not exist.  We used to handle selinux=0
(or kernel compile without selinux) by getting ENODEV when we tried to
mount selinuxfs on /selinux.  Now selinux=0 means that /sys/fs/selinux
won't exist and we never create the real directory /selinux at all. So
we get ENOENT instead of ENODEV.  The solution is to check to see if the
mount failure was for ENODEV and if not to check if selinuxfs exists in
/proc/filesystems at all.  If it doesn't exist, that's equivalent to
ENODEV.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:10 -04:00
Eric Paris
468bff0952 tree: Makefiles: syntax, convert all ${VAR} to $(VAR)
This is purely personal preference.  Most of the Makefiles use $() for
Makefile variables, but a couple of places use ${}.  Since this obscured
some later Makefile changes I figured I'd just make them all the same up
front.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-11-02 15:37:08 -04:00
Eric Paris
418dbc70e8 Bump version and changelog for all components. 2011-09-16 15:34:36 -04:00
Guido Trentalancia
eb695e5a56 whole tree: default make target to all not install
Change the default "make" target for the libraries from "install" to
"all" in the makefiles.

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-09-16 11:54:04 -04:00
Eric Paris
e172b87a30 libselinux: put libselinux.so.1 in /lib not /usr/lib
Commit 874bac80bb incorrectly changed the default install location
of libselinux.so.1 from /lib to /usr/lib.  This patch fixes that problem
by reverting that portion of the change.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-09-16 11:54:04 -04:00
Eric Paris
7bfaa63839 libselinux: src: matchpathcon: make sure resolved path starts with /
Resolving paths from relative to absolute didn't always start with a /.
Make sure they start with a /.

Signed-off-by: Eric Paris <eparis@redhat.com>
2011-09-16 11:54:03 -04:00
Eric Paris
09b635fa20 libselinux: src: matchpathcon: use myprintf not fprintf
Use the myprintf helper rather than fprintf directly.

Signed-off-by: Eric Paris <eparis@redhat.com>
2011-09-16 11:54:03 -04:00
Eric Paris
bedd2a8dc4 libselinux: utils: matchpathcon: remove duplicate declaration
We declare rc both for a function and inside a stanze.  We only need it in the
stanze so remove the declaration for the whole function.

Signed-off-by: Eric Paris <eparis@redhat.com>
2011-09-16 11:54:03 -04:00
Eric Paris
1f8cf403be update changelog and versions for 2011-08-26 2011-08-26 15:11:58 -04:00
Richard Haines
bc1a8e2a4a libselinux: selinux_file_context_verify function returns wrong value.
selinux_file_context_verify(3) should now return the correct codes and
matchpathcon(8) has been modified to handle them.

The selinux_file_context_verify(3)and selinux_file_context_cmp(3) man pages
have also been updated (re-written really) to correct return codes.

I found that selabel_open left errno set to ENOENT because a
file_contexts.subs file did not exist on my system, but left selabel_open
alone and set errno = 0 before calling selinux_filecontext_cmp.

[fix uninitialize init variable in matchpathcon.c::main - eparis]
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:27:51 -04:00
Eric Paris
7df397d3d9 libselinux: move realpath helper to matchpathcon library
Instead of only doing path simplification and symlink following for the
matchpathcon helper instead do it in the library potion.  This was an
issue when in python some called selinux.matchpatchcon("//lib64", 0) and
got the wrong answer (because the // wasn't being dealt with)

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:27:37 -04:00
Dan Walsh
57c6012f86 libselinux: python wrapper makefile changes
Allow Change libselinux Makefile to be able to build by default and to build
if you change the version of Python

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-26 14:27:34 -04:00
Eric Paris
6b6b475dcf update changelog and VERSION for latest changes 2011-08-17 11:17:28 -04:00
Richard Haines
34d9c258da libselinux: mapping fix for invalid class/perms after selinux_set_mapping call
Please find another libselinux patch. I've tested quite extensively with the compute_av and string functions with and without mapping and seems okay.

The patch covers:
When selinux_set_mapping(3) is used to set the class and permissions allowed by an object manager, then an invalid class and/or permissions are selected (e.g. using security_class_to_string), then mapping.c in libselinux forces an assert. This patch removes the asserts and allows the functions to return a class/perm of 0 (unknown) with errno set to EINVAL. A minor patch to set EINVAL in security_av_perm_to_string_compat is also included. All the functions to convert perms & classes to strings and back should now return the correct errno with or without mapping enabled.

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
8faf23de0b libselinux: audit2why: work around python bug not defining SIZEOF_SOCKET_T
A at least one broken python headers didn't define SIZEOF_SOCKET_T.
Define it if we happen upon one of those.

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
4ad1896954 libselinux: resolv symlinks and dot directories before matching paths
matchpathcon cannot handle ./ or ../ in pathnames and doesn't do well
with symlinks.  This patch uses the glibc function realpath() to try to
determine a real path with resolved symlinks and dot directories.  For
example before this pach we would see:

$ matchpathcon /tmp/../eric
/tmp/../eric	<<none>>
$ matchpathcon /eric
/eric	system_u:object_r:default_t:s0

Whereas after the path we get the same results.  The one quirk with the
patch is that we need special code to make sure that realpath() does not
follow a symlink if it is the final component.  aka if we have a symlink
from /eric to /tmp/eric we do not want to resolv to /tmp/eric.  We want
to just resolv to the actual symlink /eric.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-11 23:35:48 -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
802369fbe2 audit2allow: do not print statistics
I believe this is just to stop flooding the screen with libsepol
statistics every time you run audit2allow or any other libsepol command.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:32 -04:00
Eric Paris
c7ed95f449 libselinux: make python bindings for restorecon work on relative path
This patch just makes python bindings for restorecon work on relative
paths.

$ cd /etc
$ python
> import selinux
> selinux.restorecon("resolv.conf")

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:28 -04:00
Eric Paris
2ea80c28a5 libselinux: fix python audit2why binding error
There is a missing error check in audit2why.c.  Check for error and
return NULL if we can't initialize instead of just pretending it worked.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:19 -04:00
Eric Paris
63df0f7ef1 libselinux: support new python3 functions
python3 does not have PyString_FromString use PyBytes_FromString
instead. The same for PyString_Check->PyBytes_Check and for
PyString_AsString->PyBytes_AsString

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:14 -04:00
Eric Paris
4f621a1686 libselinux: do not check fcontext duplicates on use
Tools like restorecon or systemd, which load the fcontext database to
make labeling decisions do not need to check for duplicate rules.  Only
the first rule will be used.  Instead we should only check for
duplicates when new rules are added to the database.  And fail the
transaction if we find one.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:02:07 -04:00
Daniel J Walsh
874bac80bb Patch for python3 for libselinux
Allow the specification of python3 in the swig creation

This patch adds the new option PYPREFIX which causes the swig created
libraries to have a prefix.  This allows one to build both the python2
and python3 libraries in the same source tree.  The install will then
later strip this prefix back off when it drops the files into the python
approriate site package directory.

This patch also needs to update the PYINC definition as newer python
patckages on fedora exist in /usr/include/python3.2mu instead of
/usr/include/python3.2 as the other method of detemrining PYINC would
have found.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-03 18:01:58 -04:00
Eric Paris
78b4b56857 Made updates to checkpolicy libselinux and policycoreutils so update
version and changelogs

Signed-off-by: Eric Paris <eparis@redhat.com>
2011-08-02 14:10:39 -04:00
Eric Paris
84ea17b5f3 libselinux: move .gitignore into utils
There is a .gitignore at the head of the directory but only contains
entries for the utils directory.  Move to the utils directory.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-02 13:33:52 -04:00
Eric Paris
5ef65fd784 libselinux: new setexecon utility
This utility will tell what context a new task will have after exec
based on the pathname and the context of the launching task.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2011-08-02 13:33:35 -04:00