Commit graph

1897 commits

Author SHA1 Message Date
Jason Zaman
c094ca9662 restorecond: Add gitignore
Signed-off-by: Jason Zaman <jason@perfinion.com>
2016-11-16 11:20:05 -05:00
Jason Zaman
62cb9fc165 mcstrans: Add utils gitignore
Signed-off-by: Jason Zaman <jason@perfinion.com>
2016-11-16 11:20:05 -05:00
Jason Zaman
9123b38cae Add stub make test targets to new subdirs
Signed-off-by: Jason Zaman <jason@perfinion.com>
2016-11-16 11:20:05 -05:00
Jason Zaman
089000ad1c mcstrans: take LIBDIR from args, dont guess
All the other makefiles just have LIBDIR optionally set so it can be
overridden. These makefiles were autodetecting incorrectly. uname -i
returns "GenuineIntel" so should have been uname -m.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2016-11-16 11:20:05 -05:00
Jason Zaman
30cbe52c5b mcstrans: Fix Werror=shadow errors
gcc -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror -I../include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o mcstrans.o mcstrans.c
mcstrans.c: In function ‘violates_constraints’:
mcstrans.c:551:14: error: declaration of ‘common’ shadows a previous local [-Werror=shadow]
    ebitmap_t common;
              ^
mcstrans.c:545:13: error: shadowed declaration is here [-Werror=shadow]
   ebitmap_t common;
             ^
mcstrans.c: In function ‘build_regexps’:
mcstrans.c:1048:7: error: declaration of ‘i’ shadows a previous local [-Werror=shadow]
   int i=0;
       ^
mcstrans.c:993:15: error: shadowed declaration is here [-Werror=shadow]
  size_t n_el, i;
               ^
mcstrans.c: In function ‘compute_raw_from_trans’:
mcstrans.c:1166:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1174:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1189:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c: In function ‘compute_trans_from_raw’:
mcstrans.c:1328:14: error: declaration of ‘unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
              ^
mcstrans.c:1291:49: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                 ^
mcstrans.c:1328:25: error: declaration of ‘orig_unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
                         ^
mcstrans.c:1291:60: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                            ^
mcstrans.c:1360:15: error: declaration of ‘handled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
               ^
mcstrans.c:1291:28: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                            ^
mcstrans.c:1360:24: error: declaration of ‘nothandled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
                        ^
mcstrans.c:1291:37: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                     ^
mcstrans.c:1377:17: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
       ebitmap_t temp;
                 ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1378:17: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
       ebitmap_t bit_diff;
                 ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1403:16: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
      ebitmap_t bit_diff;
                ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1407:16: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
      ebitmap_t temp;
                ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1434:19: error: declaration of ‘g’ shadows a previous local [-Werror=shadow]
     word_group_t *g;
                   ^
mcstrans.c:1335:18: error: shadowed declaration is here [-Werror=shadow]
    word_group_t *g;
                  ^
cc1: all warnings being treated as errors
Makefile:35: recipe for target 'mcstrans.o' failed
make[2]: *** [mcstrans.o] Error 1

Signed-off-by: Jason Zaman <jason@perfinion.com>
2016-11-16 11:20:05 -05:00
Stephen Smalley
618a64aea3 semodule-utils: Drop -lselinux from Makefiles.
These programs do not depend on libselinux.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
25c167a6ea Add COPYING files for new subdirs.
Copied from policycoreutils/COPYING, from which these originated.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
f0e61d336f Fix release script
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
4480129412 restorecond: break source dependency on policycoreutils/setfiles
Now that restorecond is separated from policycoreutils, we should not
retain a build dependency on the policycoreutils/setfiles source files.
Fork the restore.[ch] files for restorecond.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
65f5868c23 Move policycoreutils/semodule_package to semodule-utils.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
6bd0b55380 Add VERSION files for new components
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
f0cc95435f Fix release script for packages that need prefixes.
We need prefixes for dbus, gui, python at least, and
we'll include sandbox too.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
1c8505dac2 Update release script for the new structure.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
6e4bb702af mcstrans: fix clang warnings
Fix the following warnings from clang.

mcstrans.c:1309:6: warning: variable 'groups' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (violates_constraints(l)) {
            ^~~~~~~~~~~~~~~~~~~~~~~
mcstrans.c:1491:9: note: uninitialized use occurs here
        while (groups)
               ^~~~~~
mcstrans.c:1309:2: note: remove the 'if' if its condition is always false
        if (violates_constraints(l)) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mcstrans.c:1303:6: warning: variable 'groups' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (!l)
            ^~
mcstrans.c:1491:9: note: uninitialized use occurs here
        while (groups)
               ^~~~~~
mcstrans.c:1303:2: note: remove the 'if' if its condition is always false
        if (!l)
        ^~~~~~~
mcstrans.c:1299:6: warning: variable 'groups' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (!level)
            ^~~~~~
mcstrans.c:1491:9: note: uninitialized use occurs here
        while (groups)
               ^~~~~~
mcstrans.c:1299:2: note: remove the 'if' if its condition is always false
        if (!level)
        ^~~~~~~~~~~
mcstrans.c:1316:2: note: variable 'groups' is declared here
        word_group_t *groups = NULL;
        ^
3 warnings generated.
mcscolor.c:334:24: warning: size argument in 'strncat' call appears to be size of the source [-Wstrncat-size]
                strncat(result, buf, sizeof(buf));

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
b97d959a6a Move policycoreutils/sepolgen-ifgen into python/audit2allow.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
50be5fcca4 Move sepolicy desktop and png files to gui.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
eeba5952df mcstrans: Add a relabel target.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:51 -05:00
Stephen Smalley
233fe333f8 mcstrans: Add .gitignore file
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
fe74095490 Build mcstrans.
We should build it by default or else it will bitrot.
But you can still omit it by overriding OPT_SUBDIRS.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
3dcdc46378 Make it easy to omit optional components.
Split optional components into their own overridable OPT_SUBDIRS
definition.  Then you can build without them via make OPT_SUBDIRS=
or specify a subset of them in that manner.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
c9c97d6e8b Move policycoreutils/semodule_{deps,expand,link} to semodule-utils.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
48dc232627 Move policycoreutils/{sepolicy,audit2allow,semanage,scripts/chcat*} and sepolgen to python.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
63e6dba9ca Move policycoreutils/sepolicy dbus service files to dbus.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
97bf196c89 Move policycoreutils/sandbox to sandbox.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
00be13634a Move policycoreutils/restorecond to restorecond.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
4cc808671a Move policycoreutils/mcstrans to mcstrans.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
2e4d0bc862 Move policycoreutils/gui to gui.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 11:19:50 -05:00
Stephen Smalley
d4387cd75f Updated libsepol ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 09:14:13 -05:00
Nicolas Iooss
02a7d77ef2 libsepol: make parsing symbol table headers more robust
When hll/pp loads a policy file which has been modified so that the
nprim field of one of its non-empty symbol table was changed to zero, it
crashes with a segmentation fault. A quick analysis leads to
"p->sym_val_to_name[i] = (char **)alloc(p->symtab[i].nprim, sizeof(char
*));" in policydb_index_others(), which is not executed when
p->symtab[i].nprim is zero even though there are items in
p->symtab[i].table.

Detect such an oddity in the policy file early to exit with a clean
error message.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-16 09:07:10 -05:00
Nicolas Iooss
0a32f3b169 libsepol: test for ebitmap_read() negative return value
While fuzzing hll/pp, the fuzzer (AFL) crafted a policy which triggered
the following message without making the policy loading fail (the
program crashed with a segmentation fault later):

    security: ebitmap: map size 192 does not match my size 64 (high bit
    was 0)

This is because ebitmap_read() returned -EINVAL and this value was
handled as a successful return value by scope_index_read() because it
was not -1.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-16 09:05:18 -05:00
Nicolas Iooss
784b43b2ae libsepol: replace an assert with an error message
When fuzzing hll/pp inputs, a policy module where the value of
scope->decl_ids_len has been modified to zero makes the program abort
(when it has been compiled without -DNDEBUG).

Change the behavior to report an error message instead. This eases
fuzzing functions like policydb_read().

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-16 09:03:45 -05:00
Stephen Smalley
a96184bcbb Updated libsepol ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-16 08:53:27 -05:00
William Roberts
be96f05182 libsepol: fix checkpolicy dontaudit compiler bug
The combining logic for dontaudit rules was wrong, causing
a dontaudit A B:C *; rule to be clobbered by a dontaudit A B:C p;
rule.

This is a reimplementation of:
commit 6201bb5e25 ("libsepol:
fix checkpolicy dontaudit compiler bug")
that avoids the cumbersome pointer assignments on alloced.

Reported-by: Nick Kralevich <nnk@google.com>
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-11-16 08:50:03 -05:00
William Roberts
5862ac5dfe Revert "libsepol: fix checkpolicy dontaudit compiler bug"
This reverts commit 6201bb5e25.
2016-11-16 08:46:21 -05:00
Stephen Smalley
d0c82f8fb9 Updated libsemanage ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 17:28:49 -05:00
Nicolas Iooss
398266f95f libsemanage: use a macro prefixed with SEMANAGE to protect dso.h
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 17:28:12 -05:00
Stephen Smalley
f60519edf6 Updated libsepol ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 17:25:14 -05:00
Stephen Smalley
7a4db1566a libsepol: cil_lexer: make warnings non-fatal for building
The flex skeleton often triggers compiler warnings; make these
non-fatal for building.  We already do likewise for checkpolicy.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 17:19:18 -05:00
Stephen Smalley
2ceadad8a3 Updated libselinux and libsemanage ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 11:14:24 -05:00
Nicolas Iooss
79db6da87f libselinux, libsemanage: swig: use SWIG_fail when an error occurs
Using SWIG_fail in the Python SWIG wrappers makes the wrapping function
destroy/free the memory which could have been dynamically allocated
before calling the wrapped function. This thus prevents possible memory
leaks in the wrappers of set*con(), set*con_raw(), security_compute_*(),
etc.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:11:25 -05:00
Nicolas Iooss
db17f12273 libselinux,libsemanage: fall back to gcc in exception.sh
clang does not support -aux-info option. When exception.sh is run with
CC=clang, use gcc to build selinuxswig_python_exception.i and
semanageswig_python_exception.i.

This does not solve the issue of building libselinux and libsemanage
Python wrappers on a system without gcc. However parsing the result of
"gcc -aux-info" is easier than parsing the header files so stay with
this command at least for now.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:10:57 -05:00
Stephen Smalley
f1db7b75e0 Updated secilc ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 11:10:21 -05:00
Nicolas Iooss
672f96f012 secilc: do not build secilc man page if it is up to date
When running "make all" several times in the root directory of the
project, the following lines always appear (and the command takes some
seconds to complete on my system with a slow hard drive):

    xmlto man secilc.8.xml
    Note: Writing secilc.8

This is because "make man" always builds secilc.8 even though
secilc.8.xml has not been modified. Introduce an intermediate target to
avoid this behavior.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:08:50 -05:00
Stephen Smalley
2c1ae0f029 Updated libselinux and libsemanage ChangeLogs
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 11:07:20 -05:00
Nicolas Iooss
bb98da0948 libselinux,libsemanage: link Python wrapper with Python
When linking with -Wl,-no-undefined in LDFLAGS (in order to find
possible link-time errors), the Python wrapper module needs to be
linked with the right libpython.so. This library is found using
pkg-config in a new PYLIBS variable.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:04:00 -05:00
Nicolas Iooss
ad3aa7f52f libsemanage: query for python site-packages dir directly
Use the python interpreter to find the install directory, like commit
8162f10e67 ("libselinux: query for python site-packages dir directly")
did for libselinux.

While at it, do not install semanage.py (generated by SWIG) with
executable permission bits.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:04:00 -05:00
Nicolas Iooss
f5b9bc2a06 libselinux,libsemanage: link Ruby wrapper with -lruby
When linking with -Wl,-no-undefined in LDFLAGS (in order to find
possible link-time errors), the Ruby wrapper module needs to be linked
with the libruby.so which is used by $(RUBY). Introduce a new RUBYLIBS
variable to find this library.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:04:00 -05:00
Nicolas Iooss
22e3ad6633 libselinux,libsemanage: use Ruby to define RUBYINC
This makes building libselinux and libsemanage  more robust on systems
with several versions of Ruby installed: when building, only RUBY needs
to be set, without wondering about PKG_CONFIG_PATH or other environment
variables.

Using RbConfig::CONFIG["rubyarchhdrdir"] only works with Ruby >= 2.0 but
since previous Ruby versions are retired since 2015-02-23 this should
not have any impact
(https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/).

While at it, in libsemanage, use RbConfig::CONFIG["vendorarchdir"] to
install the Ruby extension, like commit 1cd80faa53 ("libselinux:
versioned ruby pkg-config and query vendorarchdir properly") did for
libselinux.

My main motivation with this patch is to make the build configuration
easier to define on Travis-CI or other continuous integration platforms.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2016-11-15 11:04:00 -05:00
Stephen Smalley
df3ba03b9f Updated policycoreutils ChangeLog
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2016-11-15 10:56:24 -05:00
Laurent Bigonville
917f398d7c policycoreutils: Use GObject introspection binding instead of python-gobject in selinux_server.py
Signed-off-by: Laurent Bigonville <bigon@bigon.be>
2016-11-15 10:54:18 -05:00