Commit graph

340 commits

Author SHA1 Message Date
Sven Vermeulen
6068fcb361 Mount sys before trying to mount selinuxfs
If /sys is not present, the attempt to mount selinuxfs will of course
fail. So we try to mount /sys first (and only if that fails fall back to
the /selinux mount point) and then try to mount selinuxfs.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-24 13:58:41 -04:00
Dan Walsh
874a976470 Fix handling of temporary file in sefcontext_compile.c
This way if something goes wrong regex file will not be corrupt.
2013-10-24 13:58:38 -04:00
Dan Walsh
c32da69e01 Fixes for procattr calls to handle cache properly.
We were asked not to link to libpthread but to use gcc internals.
We were not handling properly the fact that a cache was UNSET, and this
patch fixes this.
2013-10-24 13:58:38 -04:00
Dan Walsh
9639f5d9a8 Add decent constants for python for return of getenforce call. 2013-10-24 13:58:38 -04:00
Dan Walsh
22671378f1 Fix label substituion to work with the equiv path of "/"
Software collections are setting up equiv directories to the root directory.
2013-10-24 13:58:38 -04:00
Dan Walsh
7eec00a5be Add selinux_current_policy_path, which returns the a pointer to the loaded policy
Also change audit2why to look at the loaded policy rather then searching on disk for
the policy file.  It is more likely that you are examining the running policy.
2013-10-24 13:58:38 -04:00
Dan Walsh
403f2cfeb8 Change get_context_list to return an error rather then guess at a match.
In the past pam_selinux would return a bogus login context if the login program
was running with the wrong context.  If you ran sshd as unconfined_t
you might get the login user loggin in as pam_oddjob_mkhomedir_t or some other bogus
type.  This change fixes the code to return an error if it can not return a good
match.
2013-10-24 13:58:38 -04:00
Dan Walsh
f1598dff7e Support udev-197 and higher
The errno value was not set, causing wrong return notifications and
failing to have udev label things correctly.

See https://bugzilla.redhat.com/show_bug.cgi?id=909826#c24 and
see https://bugs.gentoo.org/show_bug.cgi?id=462626

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-24 13:58:37 -04:00
Dan Walsh
fd56c5230c Separate out the calling of local subs and dist subs in selabel_sub
We want to allow users to setup their substitions to run fist and then run
the distro subs second.  This fixes the problem where a user defines
a sub like /usr/local/foobar and we ignore it.  We need this for
software collections which is setting up local subs of /opt/src/foobar/root /
2013-10-24 13:58:37 -04:00
Dan Walsh
51d9a078c2 Patch to change *setfilecon to not return ENOSUP if context matches.
Tools like cp -A try to maintain the context of a program and call *setfilecon,
currently if the file system does not support XAttrs we return ENOSUPP.  We have
been requested to check if the context that is being set is the same to not return this
error.  So if I try to set the label on an nfs share to system_u:object_r:nfs_t:s0 and I get
ENOSUPP, it will not return an error.
2013-10-24 13:58:37 -04:00
Dan Walsh
756013edc5 This patch fixes python parsing.
Eliminates a potential memory leaks.
2013-10-24 13:58:37 -04:00
Dan Walsh
851266c180 define SELINUX_TRANS_DIR in selinux.h
I wanted to separate this directory out in order for a new patch to mcstransd to watch
this directory for newly created files, which it could then translate.

The idea is libvirt would write to /var/run/setrans/c0:c1,c2 with the contents of vm1, then
setrans could translate the processes to show system_u:system_r:svirt_t:vm1
2013-10-24 13:58:37 -04:00
Dan Walsh
ce2a8848ad Add selinux_systemd_contexts_path
systemd has some internal contexts like generated systemd unit files
that we want to allow it to check against processes trying to manage them.
2013-10-24 13:58:37 -04:00
Dan Walsh
7fe6036ca5 Add selinux_set_policy_root sets an alternate policy root directory path
This allows us to specify under which the compiled policy file and context configuration
files exist. We can use this with matchpathcon to check the labels under alternate policies,
and we can use it for sepolicy manpage to build manpages during policy build.
2013-10-24 13:58:37 -04:00
Dan Walsh
2af252621b Add missing man page for sefcontext_compile 2013-10-24 13:58:37 -04:00
Dan Walsh
2540b20096 Laurent Bigonville patch to fix various minor manpage issues and correct section numbering. 2013-10-24 13:58:37 -04:00
Dan Walsh
a8b3340288 Laurent Bigonville patch to allow overriding PATH Definitions in Makefiles 2013-10-24 13:58:37 -04:00
Dan Walsh
56b49ab711 Richard Haines patch that allows us discover constraint violation information
Basically we need this information to allow audit2allow/audit2why to better
describe which constraint is being broken.
2013-10-24 13:58:37 -04:00
Stephen Smalley
39b5a40295 Fix relabel target.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2013-10-23 12:44:30 -04:00
Joe MacDonald
fceca652c1 libselinux: avoid shadowing 'stat' in load_mmap
label_file.c: In function ‘load_mmap’:
   label_file.c:238:81: error: declaration of ‘stat’ shadows a global declaration [-Werror=shadow]
   cc1: all warnings being treated as errors

Signed-off-by: Joe MacDonald <joe@deserted.net>
2013-10-22 14:22:42 -04:00
Joe MacDonald
2864f757dd libselinux: support building on older PCRE libs
Versions of PCRE prior to 8.20 did not have pcre_free_study().  In its
absence, use pcre_free() instead.

Signed-off-by: Joe MacDonald <joe@deserted.net>
2013-10-22 14:22:22 -04:00
Laurent Bigonville
ead1e1d8e2 libselinux: Fix various minor manpage issues and correct section numbering. 2013-10-16 15:10:34 -04:00
Laurent Bigonville
50b1654c1d libselinux: Do not use LDFLAGS to set -lpcre and -lpthread
This is breaking build if LDFLAGS is redefined.

This is the case on Debian where hardening flags are passed
automatically by the build system.
2013-10-16 15:10:14 -04:00
Laurent Bigonville
c45f797b28 libselinux: Allow overriding LIBBASE in src/Makefile 2013-10-16 15:09:26 -04:00
Sven Vermeulen
32e76a314e Current stable policycoreutils requires selinux_current_policy_path
Without this fix, stolen from Fedora's patchset, recent policycoreutils
just fails.

See http://marc.info/?t=136926404600001&r=1&w=2 and
see http://marc.info/?l=selinux&m=136692033821285&w=2

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-16 14:57:02 -04:00
Sven Vermeulen
a15451b523 Support udev-197 and higher
The errno value was not set, causing wrong return notifications and
failing to have udev label things correctly.

See https://bugzilla.redhat.com/show_bug.cgi?id=909826#c24 and
see https://bugs.gentoo.org/show_bug.cgi?id=462626

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-16 14:56:48 -04:00
Sven Vermeulen
e4cee831af Make RANLIB variable overridable
If the RANLIB variable is defined by the user, use that value instead of
the /usr/bin/ranlib binary.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-16 14:55:58 -04:00
Sven Vermeulen
1310e36026 Update pkgconfig definition
Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-16 14:55:48 -04:00
Sven Vermeulen
ef3e072f58 Mount sys before trying to mount selinuxfs
If /sys is not present, the attempt to mount selinuxfs will of course
fail. So we try to mount /sys first (and only if that fails fall back to
the /selinux mount point) and then try to mount selinuxfs.

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2013-10-16 14:55:40 -04:00
Eric Paris
e9410c9b06 VERSION BUMP FOR UPSTREAM PUSH 2013-02-05 20:22:02 -05:00
Eric Paris
ce39302fd0 libselinux: sefcontext_compile: do not leak fd on error
We open the file which is to be used to write the binary format of file
contexts.  If we hit an error actually writing things out, we return,
but never close the fd.  Do not leak.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:21:52 -05:00
Eric Paris
4e5eaacc59 libselinux: matchmediacon: do not leak fd
Every time matchmediacon is called we open the
selinux_media_context_path().  But we never close the file.  Close the
file when we are finished with it.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:21:52 -05:00
Eric Paris
1e8f102e8c libselinux: src/label_android_property: do not leak fd on error
We were opening the path, but if the fstat failed or it was not a
regular file we would return without closing the fd.  Fix my using the
common error exit path rather than just returning.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:21:52 -05:00
Eric Paris
0834ff3022 libselinux: do not leak file contexts with mmap'd backend
We use strdup to store the intended context when we have an mmap'd
file backend.  We, however, skipped freeing those contexts.

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:14:48 -05:00
Eric Paris
efb6347dd3 libselinux: unmap file contexts on selabel_close()
We were leaking all of the file context db because we didn't unmap them
on selabel_close()

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:14:48 -05:00
Dan Walsh
9c83b206e1 libselinux: pkg-config do not specifc ruby version
pkg-config do not work if you specifiy the version of ruby in Fedora 19

Signed-off-by: Eric Paris <eparis@redhat.com>
2013-02-05 20:14:48 -05:00
Eric Paris
1d403326ae libselinux: optimize set*con functions
Set*con now caches the security context and only re-sets it if it changes.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:47 -05:00
Dan Walsh
e9759ea7af libselinux: Change boooleans.subs to booleans.subs_dist.
Currently we ship other subs files with the _dist to indicate they come with
the distribution as opposed to being modified by the user.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:46 -05:00
Eric Paris
aa62cd60f7 libselinux: Fix errors found by coverity
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:45 -05:00
Eric Paris
c89deab09a libselinux: selinux_status_open: do not leak statusfd on exec
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:44 -05:00
Eric Paris
761881c947 libselinux: selinux_status_open: handle error from sysconf
We didn't handle sysconf(_SC_PAGESIZE) returning an error.  It should be
very rare, obviously, be we should handle it.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:44 -05:00
Pádraig Brady
2f624c94c7 libselinux: man: context_new(3): fix the return value description
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:44 -05:00
Guillem Jover
be2d728599 libselinux: Use ENOTSUP instead of EOPNOTSUPP for getfilecon functions
EOPNOTSUPP means "operation not supoorted on socket", and ENOTSUP means
"not supported", although per POSIX they can be alised to the same
value and on Linux they do, ENOTSUP seems the more correct error code.
In addition these function are documented as returning ENOTSUP, and
given that they are implemented in means of getxattr(2) which does
return ENOTSUP too, this just consolidates their behaviour.

Signed-off-by: Guillem Jover <guillem@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:44 -05:00
Guillem Jover
9acdd37989 libselinux: man: Add references and man page links to _raw function variants
Signed-off-by: Guillem Jover <guillem@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:43 -05:00
Guillem Jover
4f289b50ac libselinux: man: Fix typo in man page
Signed-off-by: Guillem Jover <guillem@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:43 -05:00
Guillem Jover
6ef13eeda7 libselinux: man: Fix man pages formatting
- Add man page sections '(N)' to external references, and '()' on
  functions described in the same man page.
- Escape minus signs when those are expected to be used on the command
  line or files.
- Mark files and variables in italic; Note headings, function names,
  constants, program options and man page references in bold.
- Do not justify and hyphenate SEE ALSO section, and avoid hyphenation
  on symbol names by prepending them with \%.
- Remove trailing dot from NAME section description.
- Split sections with a no-op command '.', to visually distinguish them
  but to avoid introducing spurious vertical space in the formatted
  output.
- Add explicit .sp commands in the SYNOPSIS section between function
  prototypes, and fix space placement in function protoypes.
- Split header includes with .br (instead of the explicit or implicit
  .sp) so that they are vertically contiguous.
- Add missing {} around SELINUXTYPE and POLICYTYPE variable text in
  paths.
- Remove unneeded formatting commands.
- Remove spurious blank lines.

Signed-off-by: Guillem Jover <guillem@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:43 -05:00
Guillem Jover
8cc79bcd98 libselinux: man: Fix program synopsis and function prototypes in man pages
Fix typos, or wrong function prototypes.

Signed-off-by: Guillem Jover <guillem@debian.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:43 -05:00
Dan Walsh
7504bbd873 libselinux: audit2why: Cleanup audit2why analysys function
Tee-tiny cleanup to remove needless {}

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:42 -05:00
rhatdan
13b599d7b8 libselinux: mode_to_security_class: interface to translate a mode_t in to a security class
coreutils needs to be able to take a statbuf and ask permissions
questions.  This gives us the interface to translate that statbuf mode_t
into a security class which can be used.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:40 -05:00
Eric Paris
d09bcb75f5 libselinux: audit2why: do not leak on multiple init() calls
If init() was already called then avc will be set.  If avc is set just
return.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:40 -05:00
rhatdan
019e6fd6d4 libselinux: audit2why: Fix segfault if finish() called twice
If audit2why.finish is called more than once the global avc variable
will be NULL, and thus dereferencing it will obviously cause problems.
Thus just bail if avc is NULL and we know cleanup is done.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:39 -05:00
rhatdan
2677b72191 libselinux: man: make selinux.8 mention service man pages
We were listing a number of service man pages (like httpd_selinux) in
the see also section of selinux.8.  As that number of pages explodes it
does not make sense to try to list them all.  Instead tell people to use
man -k selinux to find them.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-05 20:14:39 -05:00
rhatdan
44cba24ba6 libselinux: sefcontontext_compile: Add error handling to help debug problems in libsemanage.
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-01 12:08:57 -05:00
Eric Paris
a293048a59 libselinux: do not leak mmapfd
On failure, common if .bin is older than the text version, we will leak
the mmapfd.  Don't do that.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-01 12:08:57 -05:00
Eric Paris
9ebd779353 libselinux: label_file: use precompiled filecontext when possible
When loading the filecontext database, check to see if there is a newer
binary version.  If so, mmap that file, is used to populate the regex db
instead of reading from the text representation and compiling regex's as
needed.  If the text file is newer it will use the text version and
ignore the binary version.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-01 12:08:57 -05:00
Eric Paris
dac8b32c17 libselinux: utils: new file context regex compiler
This is a new 'compiler' which tranforms the file context database into
a binary format.  This binary format may be mmap'd in later removing the
need to compile the regular expression at run time.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-01 12:08:56 -05:00
Eric Paris
933840af6c libselinux: audit2why: make sure path is nul terminated
We use strncpy which could leave a non-nul terminated string if the
source is longer than PATH_MAX.  Add that nul.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2013-02-01 12:08:56 -05:00
Eric Paris
8638197342 Version bumps for upstream push 2012-09-13 10:33:58 -04:00
Guido Trentalancia
45658fc6d5 libselinux: improve the file_contexts.5 manual page
Manual page improvements for the file_contexts and related policy
configuration files (section 5):

- create links to selabel_file.5 not only for file_contexts.5 but
  also for the other optional policy configuration files (including
  the so-called file contexts "substitution" files);
- clarify the above mentioned manual page(s), in particular relatively
  to the action performed by the so-called file contexts "substitution"
  policy configuration files (aliasing/equivalence versus substitution);
- improve the explanation of the form that the "substitution" files
  shall have.

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 21:14:43 -04:00
Dan Walsh
1c8a7c194d libselinux: Ensure that we only close the selinux netlink socket once.
Taken from our Android libselinux tree.  From Stephen Smalley.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 21:06:55 -04:00
Eric Paris
4d04f4c443 libselinux: label_file: only run array once when sorting
Instead of running the array two times, sorting the 'hasMeta' the first
time and the !hasMeta the second, run the array once putting hasMeta in
the front and !hasMeta in the back.  Then ONLY run the !hasMeta section
a second time reversing its order so its sorted as it should be.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:51 -04:00
Eric Paris
36ab97dadc libselinux: label_file: struct reorg
Use char instead of int, reorder to put the chars together.  Just litle
things.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:51 -04:00
Eric Paris
de5bc062ca libselinux: label_file: break up find_stem_from_spec
Right now find_stem_from_spec does a number of things:
- calculate the length of th stem
- look for that stem
- duplicate the stem
- add the stem to the array

break those things up a bit because the mmap version isn't going to need
to do some of those things.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:50 -04:00
Eric Paris
16b578895e libselinux: label_file: new process_file function
We currently duplicate code 3 times for the main file, the homedirs, and
the local file.  Just put that stuff in its own function so we don't
have to deal with it multiple times.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:50 -04:00
Eric Paris
79b6a8d78f libselinux: label_file: only run regex files one time
We currectly run all of the regex files 2 times.  The first time counts
the lines and does the simple validatation.  We then allocate an array
of exactly the right size to hold the entries and run them a second time
doing stronger validation, regex compile, etc.

This is dumb.  Just run them one time and use realloc to grow the size
of the array as needed.  At the end the array will get sized perfectly
to fit by the sorting function, so even if we accidentally allocated
entra memory we'll get it back.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:49 -04:00
Eric Paris
ee88185aff libselinux: label_file: add accessors for the pcre extra data
When we use an mmap backed version of data we need to declare the pcre
extra data since we are only given a point to the data->buffer.  Since
sometimes the spec will hold a pointer to the extra data and sometimes
we want to declare it on the stack I introduce and use an accessor for
the extra data instead of using it directly.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:49 -04:00
Eric Paris
247759031a libselinux: label_file: move regex sorting to the header
We want to do the same thing in the compiler and as we do in in the code
which reads regexes in from the text file.  Move that sorting into the header.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:48 -04:00
Eric Paris
dd61029c54 libselinux: label_file: fix potential read past buffer in spec_hasMetaChars
An illegal regex may end with a single \ followed by nul.  This could
cause us to search past the end of the character array.  The loop
formation looks like so:

        c = regex_str;
        len = strlen(c);
        end = c + len;

        while (c != end) {
		switch (*c) {
		...
                case '\\':      /* skip the next character */
                        c++;
                        break;
		...
                }
                c++;
	}

If the \ is the last character then we will increment c and break from
the switch.  The while loop will then increment c.  So now c == end+1.
This means we will keep running into infinity and beyond!  Easy fix.
Make the loop check (c < end).  Thus even if we jump past end, we still
exit the loop.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:48 -04:00
Eric Paris
48682e2853 libselinux: label_file: move spec_hasMetaChars to header
So we can use it in the new compile utility, move the
spec_hasMetaChars() function, which looks for things like .*?+^$ in
regular expressions into the internal header file.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:47 -04:00
Eric Paris
fcc895661d libselinux: label_file: drop useless ncomp field from label_file data
The libselinux label_file backend counted the number of regexes which
had been compiled.  We didn't use it and it wasn't useful information.
Stop doing it.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:47 -04:00
Eric Paris
9937685cbe libselinux: label_file: move stem/spec handling to header
We want to be able to find the stem and the spec from our new utility.
So move those functions to the header file.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:51:47 -04:00
Eric Paris
b9482941ce libselinux: label_file: move error reporting back into caller
If we want to use these functions in utilities we shouldn't call such
libselinux internal functions.  Move the error reporting up to the
caller.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:50:17 -04:00
Eric Paris
f744f239fb libselinux: label_file: do string to mode_t conversion in a helper function
So the string to mode_t conversion in a helper function so it can be
used later by a regex compilation program.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:50:17 -04:00
Eric Paris
c27101a583 libselinux: label_file: move definitions to include file
We want to use some label_file internals in a utility to compile
fcontext files into binary data for fast use.  So start pushing
structures and such into a header file.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:50:16 -04:00
Eric Paris
dc1db39e28 libselinux: label_file: remove all typedefs
I hate them.  They just indirectly you needlessly.  Just use the struct
definitions.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:49:33 -04:00
Eric Paris
091eb526dd libselinux: label_file: use PCRE instead of glibc regex functions
The PCRE functions are about x10 faster than the glibc functions.  So
use the external library.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:49:32 -04:00
Eric Paris
ac5f5645b6 libselinux: stop messages when SELinux disabled
If SELinux is disabled we should send any messages.  We shouldn't do
anything.  Just return.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:42:29 -04:00
Eric Paris
b2d86f8219 libselinux: booleans: initialize pointer to silence coveriety
The coveriety scanner is too stupid to realize that the strtok_r()
function initializes the saveptr variable.  Since we are passing a
variable location without initializing it coveriety gets angry.  Just
shut up the scanner, but nothing was wrong to start with.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:30:22 -04:00
Dan Walsh
bd8ea2eb6c libselinux: seusers: Check for strchr failure
If we have a malformed seusers entry we may not find the : proceeding
the level and would thus get a NULL.  This can blow up.  Check for this
error and bail gracefully.  Found by coverity

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:30:21 -04:00
Dan Walsh
fa7a9a604e libselinux: utils: avcstat: clear sa_mask set
We were leaving random stack garbage in sa.sa_mask.  Clear it the way
one should.  (spotted by coveriety)

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:30:21 -04:00
Eric Paris
1db01640ee libselinux: matchpathcon: add -m option to force file type check
We may want to force matchpathcon to respond if the path is question is
a dir, sockfile, chr, blk, etc.  Add an option so you can force it to
hit the right rule types.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 14:23:22 -04:00
Dan Walsh
ee6901618c libselinux: expose selinux_boolean_sub
Make selinux_boolean_sub a public method so getsebool can use it, as well as
potentially used within libsemanage.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 13:15:00 -04:00
Dan Walsh
179ee6c187 libselinux: Add man page for new selinux_boolean_sub function.
Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 13:14:29 -04:00
Dan Walsh
bac96c8c70 libselinux: getsebool: support boolean name substitution
Use selinux_boolean_sub to translate the boolean name handed in by the user.
Report back the correct name of the boolean.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 13:14:29 -04:00
Eric Paris
88c3524153 libselinux: boolean name equivalency
Add support for booleans.subs file. Basically this allows us to finally change
badly named booleans to some standard name.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-09-12 13:14:25 -04:00
Eric Paris
1024ea34c6 libselinux: libsemanage: remove PYTHONLIBDIR and ruby equivalent
We generate pkg-config --libs and use that to build the libselinux
python so file.  We do not use it to build the libsemanage versions.  We
also never use the ruby equivalent.  So stop calling pkg-config
uselessly.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 12:16:19 -04:00
Eric Paris
b2523dc167 libselinux: libsemanage: do not set soname needlessly
We explicitly set the soname of the python and ruby files.  We don't
need this.  We are using the -o name as the soname, so just let the
toolchain do its thing.  It just makes the Makefile nicer to read.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-09-12 12:16:18 -04:00
Eric Paris
056f23c4bf libselinux: utils: add service to getdefaultcon
Add a -s option to getdefaultcon which allows one to specify the
service in question.  This exposes all of the abilities of getseuser
instead of only the abilities of getseuserbyname.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-09-12 12:16:18 -04:00
Dan Walsh
c802d4a6d5 libselinux: Add support for lxc_contexts_path
In order for lxc to look up its process and file labels we add new
libselinux support.  This is what we do for everything else, like
libvirt, seposgresql, etc.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-09-12 12:16:09 -04:00
Eric Paris
f05a71b92d Version bumps for upstream push 2012-06-28 14:02:29 -04:00
Eric Paris
824df4b60b libselinux: additional makefile support for rubywrap
SELinux ruby bindings didn't build from the top level
the swig generated .c file wasn't gitignored
use pkg-config for ruby info like we do for python

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
30900902b1 libselinux: label_android_property whitespace cleanups
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
rpcraig
cfc492cf11 libselinux: New Android property labeling backend
This is already in the android repo.  This is here to prevent potential
conflicts of the selabel indices, and possibly with an eye toward an eventual
reunification of the two libselinuxes down the road.

Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
5e3171f658 libselinux: seusers: getseuser: gracefully handle NULL service
getseuser() would unconditionally check strlen on the service variable
even though it could be NULL.  Whoops.  If service is NULL we should
only match on *: entries.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
5b344c112a libselinux: seusers: remove unused lineno
The lineno variable was being incremented, but nothing was being done
with it.  Remove it.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
12e2a0f9fc libselinux: matchpathcon: bad handling of symlinks in /
The realpath_not_final() function did not properly handle symlinks in
the / directory.  The reason is because when it determined the symlink
was in the root directory it would set the resolved portion of the path
to /, it would then add a / to the end of the resolved portion, and then
append the symlink name.  The fix is to instead set the resolved portion
to "".  Thus when the '/' at the end of the resolved portion is added it
will be correct.

While I am at it, strip extraneous leading / so that //tmp returns /tmp.

Signed-off-by: Eric Paris <eparis@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
5d19b70723 libselinux: libsemanage: remove build warning when build swig c files
swig creates C files with warnings.  Turn off the warnings so the build
is clean.  We can't help the code it produces anyway...

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Eric Paris
9b3055ada5 libselinux: audit2why: silence -Wmissing-prototypes warning
The init functions are non-static but did not have a prototype
declaration.  They are called magically from python, so just declare the
prototype to silence the warning.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Dan Walsh
378dfe4d6a libselinux: avc_netlink_recieve handle EINTR
should continue to poll if it receinves an EINTR rather then exiting with an error.

This was a major bug within dbus that was causing dbus to crash it was
discussed at the time whether this is a dbus bug or an libselinux bug,
it was decided that we should fix it within libselinux.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00
Dan Walsh
2ca19f3f67 libselinux: asprintf return code must be checked
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
2012-06-28 11:21:16 -04:00