Commit Graph

101 Commits

Author SHA1 Message Date
bauen1 c233f661a0
kernel/corecommands: fix the label of xfce4 helpers (on debian) 2020-01-25 16:34:47 +01:00
bauen1 a1f20e749e
fix ifupdown2 executable mislabeled as lib_t 2019-12-10 20:18:00 +01:00
Chris PeBenito 9d80ada777 Merge pull request #78 from fishilico/debian-dynamic-motd 2019-09-03 19:44:13 -04:00
Nicolas Iooss 2da886dccf
corecommands: no longer use \d
In order to detect bugs like the one fixed by commit d938683bf4
("drbd: fix pattern for /usr/lib/ocf/resource.d/linbit/drbd"), forbid
the use of \d in the policy. This was actually only used to match

    /usr/share/apr-1/build/...

with

    /usr/share/apr(-\d)?/build/[^/]+\.sh --	gen_context(system_u:object_r:bin_t,s0)
    /usr/share/apr(-\d)?/build/libtool --	gen_context(system_u:object_r:bin_t,s0)

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-01 15:26:55 +02:00
Nicolas Iooss c021287125
Allow Debian to generate a dynamic motd when users log in
Debian's PAM configuration uses a patched pam_motd module that runs
files in /etc/update-motd.d/ in order to generate a dynamic Message Of
The Day (MOTD). By default, there is only one script:

    $ cat /etc/update-motd.d/10-uname
    #!/bin/sh
    uname -snrvm

According to https://wiki.debian.org/motd, the script is executed
through run-parts:

    if (!system("/usr/bin/env -i
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    run-parts --lsbsysinit /etc/update-motd.d >
    /run/motd.dynamic.new"))
        rename("/run/motd.dynamic.new", "/run/motd.dynamic");

This requires allowing pam_motd users to execute bin_t commands
(/usr/bin/env) and shells (/bin/sh), and to manage /run/motd.dynamic*
files.

Allow relevant accesses for Debian-based systems.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-01 13:44:28 +02:00
Nicolas Iooss f0cade07b2
Remove unescaped single dot from the policy
In a pattern, a dot can match any character, including slash. It makes
sense when it is combined with ?, + or *, but makes little sense when
left alone.

Most of the time, the label was for file containing dots, where the dot
was not escaped. A few times, the dot was really intended to match any
character. In such case, [^/] better suits the intent.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-08-27 23:38:09 +02:00
Russell Coker 044da0b8b9 more misc stuff
Here's the latest stuff, most of which is to make staff_t usable as a login
domain.  Please merge whatever you think is good and skip the rest.
2019-02-01 14:16:57 -05:00
Russell Coker 5125b8eb2d last misc stuff
More tiny patches.  Note that this and the other 2 patches I just sent are not
dependent on each other, please apply any that you like.
2019-01-05 13:54:38 -05:00
Luis Ressel e751959925 corecommands: Fix /usr/share/apr* fc
Both apr and apr-1 are possible
2018-09-28 15:14:43 -04:00
Jason Zaman ece7bdc282 corecommands: adjust gcc fcontext to also work on musl 2018-06-10 13:05:57 -04:00
Nicolas Iooss dbd8fbb01c corecommands: label systemd script directories bin_t
systemd defines in /usr/lib/systemd several directories which can
contain scripts or executable files:
- system-environment-generators/ and user-environment-generators/
  documented in
  https://www.freedesktop.org/software/systemd/man/systemd.environment-generator.html
- system-shutdown/ documented in
  https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
- system-sleep/ documented in
  https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html

Currently the content of these directories is labelled lib_t, which
causes the following AVC on Arch Linux:

    avc:  denied  { execute_no_trans } for  pid=10308 comm="systemd"
    path="/usr/lib/systemd/system-environment-generators/10-arch"
    dev="vda1" ino=543182 scontext=system_u:system_r:init_t
    tcontext=system_u:object_r:lib_t tclass=file permissive=1

For information /usr/lib/systemd/system-environment-generators/10-arch
only defines $PATH and its content is available on
https://git.archlinux.org/svntogit/packages.git/tree/trunk/env-generator?h=packages/filesystem
2017-12-17 15:28:37 -05:00
David Sugar d0c3be2617 RHEL 7.4 has moved the location of /usr/libexec/sesh to /usr/libexec/sudo/sesh
Update file context to include label for new location.
See https://bugzilla.redhat.com/show_bug.cgi?id=1480791

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2017-12-03 16:38:39 -05:00
David Sugar via refpolicy f3e0a751db label /etc/mcelog/mcelog.setup correctly (for RHEL)
I am seeing the following denials when mcelog.service is attempting to execute /etc/mcelog/mcelog.setup (on RHEL 7).  It should be labeled bin_t.

Sep 21 02:45:50 localhost audit: type=AVC msg=audit(1505961383.859:28): avc:  denied  { execute } for  pid=626 comm="(og.setup)" name="mcelog.setup" dev="dm-0" ino=718731 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:mcelog_etc_t:s0 tclass=file
Sep 21 02:45:50 localhost audit: type=AVC msg=audit(1505961383.859:28): avc:  denied  { read open } for  pid=626 comm="(og.setup)" path="/etc/mcelog/mcelog.setup" dev="dm-0" ino=718731 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:mcelog_etc_t:s0 tclass=file
Sep 21 02:45:50 localhost audit: type=AVC msg=audit(1505961383.859:28): avc:  denied  { execute_no_trans } for  pid=626 comm="(og.setup)" path="/etc/mcelog/mcelog.setup" dev="dm-0" ino=718731 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:mcelog_etc_t:s0 tclass=file
Sep 21 02:45:50 localhost audit: type=SYSCALL msg=audit(1505961383.859:28): arch=c000003e syscall=59 success=yes exit=0 a0=55a0ddd00260 a1=55a0ddcd1be0 a2=55a0ddd02e90 a3=3 items=3 ppid=1 pid=626 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="mcelog.setup" exe="/usr/bin/bash" subj=system_u:system_r:init_t:s0 key=(null)
Sep 21 02:45:50 localhost audit: type=EXECVE msg=audit(1505961383.859:28): argc=2 a0="/bin/sh" a1="/etc/mcelog/mcelog.setup"
Sep 21 02:45:50 localhost audit: type=PATH msg=audit(1505961383.859:28): item=0 name="/etc/mcelog/mcelog.setup" inode=718731 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:mcelog_etc_t:s0 objtype=NORMAL
Sep 21 02:45:50 localhost audit: type=AVC msg=audit(1505961383.862:29): avc:  denied  { ioctl } for  pid=626 comm="mcelog.setup" path="/etc/mcelog/mcelog.setup" dev="dm-0" ino=718731 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:mcelog_etc_t:s0 tclass=file
Sep 21 02:45:50 localhost audit: type=SYSCALL msg=audit(1505961383.862:29): arch=c000003e syscall=16 success=no exit=-25 a0=3 a1=5401 a2=7ffec57f28f0 a3=7ffec57f2690 items=0 ppid=1 pid=626 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="mcelog.setup" exe="/usr/bin/bash" subj=system_u:system_r:init_t:s0 key=(null)
Sep 21 02:45:50 localhost audit: type=AVC msg=audit(1505961383.867:30): avc:  denied  { getattr } for  pid=626 comm="mcelog.setup" path="/etc/mcelog/mcelog.setup" dev="dm-0" ino=718731 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:mcelog_etc_t:s0 tclass=file
Sep 21 02:45:50 localhost audit: type=SYSCALL msg=audit(1505961383.867:30): arch=c000003e syscall=5 success=yes exit=0 a0=ff a1=7ffec57f2890 a2=7ffec57f2890 a3=7ffec57f25a0 items=0 ppid=1 pid=626 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="mcelog.setup" exe="/usr/bin/bash" subj=system_u:system_r:init_t:s0 key=(null)

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2017-09-23 14:30:35 -04:00
Russell Coker 25a9bcb405 minor nspawn, dnsmasq, and mon patches
Label some shell scripts from bridge-utils correctly.  Maybe have ifdef
distro_debian around this, not sure what upstream is doing.

systemd_nspawn_t needs to manage the /etc/localtime symlink if you have a
labeled chroot.

Another dontaudit for mon_local_test_t to stop it spamming the logs.

Support a .d directory for dnsmasq config files.
2017-09-17 11:08:06 -04:00
Nicolas Iooss f23e6ee79c corecommands: label Arch Linux pacman's scripts as bin_t
On Arch Linux, the package manager uses hooks which execute scripts in
/usr/share/libalpm/scripts.
2017-09-08 11:42:08 -04:00
Nicolas Iooss 179e3217b0 Add "/usr/(.*/)?bin(/.*)?" pattern back
Commit 2e7553db63 ("Create / to /usr equivalence for bin, sbin, and
lib, from Russell Coker.") removed from corecommands.fc:

    /usr/(.*/)?bin(/.*)?    gen_context(system_u:object_r:bin_t,s0)

Consequently files like /usr/x86_64-w64-mingw32/bin/objdump get labeled
as usr_t:

    $ matchpathcon /usr/x86_64-w64-mingw32/bin/objdump
    /usr/x86_64-w64-mingw32/bin/objdump system_u:object_r:usr_t

Make such files labeled as bin_t again.
2017-08-19 12:01:56 -04:00
Nicolas Iooss 28ad98572b corecommands: label dhcpcd hook scripts bin_t
dhcpcd executes scripts in /usr/lib/dhcpcd/:

    avc:  denied  { execute_no_trans } for  pid=608 comm="dhcpcd"
    path="/usr/lib/dhcpcd/dhcpcd-run-hooks" dev="vda1" ino=406981
    scontext=system_u:system_r:dhcpc_t tcontext=system_u:object_r:lib_t
    tclass=file permissive=1
2017-08-13 19:51:19 -04:00
cgzones c6f76058dc chkrootkit: add interfaces and sysadm permit
v2:
 - add bin_t fc to corecommands
2017-06-12 18:41:56 -04:00
Jason Zaman aa1afa41aa corecommands: add consolekit fcontexts 2017-05-11 19:35:53 -04:00
Chris PeBenito 8ab6ff00f6 Merge branch 'usr_bin_fc' of git://github.com/fishilico/selinux-refpolicy-patched 2017-05-04 08:20:42 -04:00
Chris PeBenito 8527b86621 Further strict systemd fixes from Russell Coker. 2017-04-20 20:00:34 -04:00
Chris PeBenito bff3838916 corecommands: Add fc escaping for previous patch. 2017-04-18 21:51:52 -04:00
Guido Trentalancia c3dab0699b corecommands: new file contexts for Gnome applications
This patch adds three new file contexts for script executables
belonging to new Gnome applications (weather application and
sound recorder).

Signed-off-by: Guido Trentalancia <guido@trentalancia.net>
2017-04-18 21:46:24 -04:00
Nicolas Iooss 69c742f11b
Support systems with a single /usr/bin directory
On systems such as Arch Linux, all programs which are usually located in
/bin, /sbin, /usr/bin and /usr/sbin are present in /usr/bin and the
other locations are symbolic links to this directory.  With such a
configuration, the file contexts which define types for files in
/bin, /sbin and /usr/sbin need to be duplicated to provide definitions
for /usr/bin/...

As the "/bin vs. /usr/bin" part of the needed definitions has already
been done with the "usr merge" patches, the next step consists in
duplicating file contexts for /usr/sbin. This is what this patch does
for all modules which are not in contrib.

This is the second iteration of an idea I have previously posted on
http://oss.tresys.com/pipermail/refpolicy/2017-March/009176.html
2017-04-15 20:49:07 +02:00
Chris PeBenito b690079a93 Misc fc changes from Russell Coker. 2017-04-06 17:00:28 -04:00
cgzones da1ea093cb corecommands: label some binaries as bin_t 2017-02-16 17:05:26 +01:00
Russell Coker 5a6251efc6 tiny mon patch
When you merged the mon patch you removed the ability for mon_t to execute
lib_t files.

The following patch re-enables the ability to execute alert scripts.
2017-02-15 18:51:39 -05:00
Chris PeBenito 69da46ae18 usrmerge FC fixes from Russell Coker. 2017-02-07 18:51:58 -05:00
Chris PeBenito 2e7553db63 Create / to /usr equivalence for bin, sbin, and lib, from Russell Coker. 2017-02-04 15:19:35 -05:00
Nicolas Iooss 85d678bd2f
Add file contexts in /usr for /bin, /usr/sbin and /usr/lib
Some policy modules define file contexts in /bin, /sbin and /lib without
defining similar file contexts in the same directory under /usr.

Add these missing file contexts when there are outside ifdef blocks.
2016-12-27 17:06:54 +01:00
Garrett Holmstrom 58ac82612d corecmd: Remove fcontext for /etc/sysconfig/libvirtd
/etc/sysconfig/libvirtd does not have the executable bit set, so it does
not make sense for it to be labelled bin_t.  I can't seem to find the
reason it was set that way originally.

Signed-off-by: Garrett Holmstrom <gholms@devzero.com>
2016-06-30 20:34:49 -04:00
Laurent Bigonville af61f22e24 Add some labels for SELinux tools path in Debian 2016-03-25 22:35:17 +01:00
Nicolas Iooss e43b1e2ffc Do not label /usr/lib/gvfs/libgvfscommon.so as bin_t
On Arch Linux, /usr/lib/gvfs directory contains both executable files
(gvfsd, gvfs-udisks2-volume-monitor...) and libraries (libgvfscommon.so
and libgvfsdaemon.so).  As all executable files are prefixed with
"gfvs", so use this to distinguish them with the libraries.

This fixes the following AVC denials, reported from geoclue service
using a library wrongly labelled bin_t:

    avc:  denied  { read } for  pid=14872 comm="geoclue"
    name="libgvfscommon.so" dev="dm-0" ino=3152594
    scontext=system_u:system_r:geoclue_t
    tcontext=system_u:object_r:bin_t tclass=file permissive=1

    avc:  denied  { open } for  pid=14872 comm="geoclue"
    path="/usr/lib/gvfs/libgvfscommon.so" dev="dm-0" ino=3152594
    scontext=system_u:system_r:geoclue_t
    tcontext=system_u:object_r:bin_t tclass=file permissive=1

     avc:  denied  { execute } for  pid=14872 comm="geoclue"
     path="/usr/lib/gvfs/libgvfscommon.so" dev="dm-0" ino=3152594
     scontext=system_u:system_r:geoclue_t
     tcontext=system_u:object_r:bin_t tclass=file permissive=1
2016-03-19 10:39:17 +01:00
Nicolas Iooss 4b1cd5b369 Label some user session DBus services as bin_t 2016-03-19 10:39:17 +01:00
Nicolas Iooss 2cedfc0ada Label gedit plugins properly on Arch Linux 2016-03-19 10:39:17 +01:00
Nicolas Iooss 55f64a8112 Label system-config-printer applet properly on Arch Linux
It is used by system-config-printer, as shown by these AVC denials:

    avc:  denied  { execute } for  pid=1061 comm="system-config-p"
    name="applet.py" dev="dm-0" ino=9568316
    scontext=sysadm_u:sysadm_r:sysadm_t tcontext=system_u:object_r:usr_t
    tclass=file permissive=1

    avc:  denied  { execute_no_trans } for  pid=1061
    comm="system-config-p"
    path="/usr/share/system-config-printer/applet.py" dev="dm-0"
    ino=9568316 scontext=sysadm_u:sysadm_r:sysadm_t
    tcontext=system_u:object_r:usr_t tclass=file permissive=1
2016-03-19 10:39:17 +01:00
Nicolas Iooss 90599ef760 Label TexLive scripts bin_t
These scripts can be run by users.
2016-03-19 10:39:17 +01:00
Chris PeBenito 5922346539 Merge branch 'systemd-1' of git://github.com/bigon/refpolicy into bigon-systemd-1 2016-01-06 09:13:47 -05:00
Nicolas Iooss 3505a51d76 Label OpenSSH files correctly on Arch Linux
On Arch Linux, OpenSSH installs these binary files in /usr/lib/ssh:

* sftp-server (labeled with ssh_keysign_exec_t type in refpolicy)
* ssh-askpass (symlink to x11-ssh-askpass)
* ssh-keysign
* ssh-pkcs11-helper
* x11-ssh-askpass (from x11-ssh-askpass package)

Label all these files but sftp-server as bin_t.
2016-01-05 13:22:52 -05:00
Laurent Bigonville c0e95ed326 On Debian, systemd binaries are installed in / not /usr
On Debian, systemd binaries are installed in / not /usr, add an
equivalence for this.
2015-12-14 22:52:47 +01:00
Chris PeBenito 3639880cf6 Implement core systemd policy.
Significant contributions from the Tresys CLIP team.

Other changes from Laurent Bigonville.
2015-10-23 10:16:59 -04:00
Luis Ressel fd5e40b047 Mark APR build scripts as bin_t
I don't know why those are in /usr/share/build-1/ instead of
/usr/share/apr-0/build/ here, but it doesn't appear to be
Gentoo-specific.
2015-08-11 08:42:25 -04:00
Sven Vermeulen 29292968fe xfce4-notifyd is an executable 2014-12-02 09:16:05 -05:00
Nicolas Iooss 28658963c3 Label /usr/lib/networkmanager/ like /usr/lib/NetworkManager/
On ArchLinux the directory name of Network Manager in /usr/lib is
written in lowercase but not the files in /usr/bin, /var/lib, etc.

While at it, remove a useless backslash before a minus character.
2014-08-26 08:08:41 -04:00
Chris PeBenito a3a64ffced Move tumblerd fc entry 2014-06-30 15:28:51 -04:00
Jason Zaman 724eff0b5e File Context for tumbler
Tumbler is a D-Bus service for applications to request thumbnails

Signed-off-by: Jason Zaman <jason@perfinion.com>
2014-06-30 14:38:59 -04:00
Sven Vermeulen 622c11fae4 Enable rcs2log location for all distributions
Currently, the /usr/share/cvs/contrib/rcs2log is only labeled as bin_t
for redhat distributions. Moving this to the general one as it is also
in use on other distributions

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2014-06-02 11:08:17 -04:00
Nicolas Iooss 9427fc3ce1 Label /usr/lib/getconf as bin_t
On ArchLinux, glibc package installs /usr/bin/getconf as a hard link to a file
in /usr/lib/getconf/.  For example on a x86_64 machine:

    $ ls -i -l /usr/bin/getconf /usr/lib/getconf/XBS5_LP64_OFF64
    5900355 -rwxr-xr-x. 4 root root 22880 Feb 28 04:53 /usr/bin/getconf
    5900355 -rwxr-xr-x. 4 root root 22880 Feb 28 04:53 /usr/lib/getconf/XBS5_LP64_OFF64

Such configuration produces an instability when labeling the files with
"restorecon -Rv /":

    restorecon reset /usr/bin/getconf context unconfined_u:object_r:lib_t:s0->unconfined_u:object_r:bin_t:s0
    restorecon reset /usr/lib/getconf/XBS5_LP64_OFF64 context unconfined_u:object_r:bin_t:s0->unconfined_u:object_r:lib_t:s0

As /usr/lib/getconf directory only contains executable programs, this issue is
fixed by labeling this directory and its content "bin_t".
2014-04-21 10:15:51 -04:00
Laurent Bigonville 81570b1eb4 Properly label git-shell and other git commands for Debian 2014-03-14 11:14:43 -04:00
Nicolas Iooss f003497bcb Label /usr/lib/sudo/sesh as shell_exec_t 2014-02-08 09:50:09 -05:00