Score:1

selinux - why can't stuff_u with sysadm_r run postsuper?

vn flag

I am trying to understand how selinux confined users really work, but there are a few behaviours that I still can not understand. According to redhat

SELinux User Capabilities

stuff_u users should be able to run sudo, but not su. So I have created the user someuser and mapped it to staff_u

[someuser@testserver ~]$ id -Z
staff_u:staff_r:staff_t:s0-s0:c0.c1023

Now if I add full permissions using sudo, but not setting the role/type on sudoers I will not be able to do much( as expected ).

[someuser@testserver ~]$ sudo -l
Matching Defaults entries for someuser on testserver:
    !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE",
    env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
    secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User someuser may run the following commands on testserver:
    (ALL) NOPASSWD: ALL

[someuser@testserver ~]$ sudo ls -la /var/log/audit/audit.log 
ls: cannot access '/var/log/audit/audit.log': Permission denied

[someuser@testserver ~]$ sudo ausearch -m avc -ts recent
Error opening config file (Permission denied)
NOTE - using built-in logs: /var/log/audit/audit.log
Error opening /var/log/audit/audit.log (Permission denied)
[someuser@testserver ~]$ 

If I change the sudoers to make the transitioning to sysadm_r and sysadm_t I was expecting to get basically permission to do anything, but it is not exactly what I am getting.

I can do lots of things:

[someuser@testserver ~]$ sudo -l
Matching Defaults entries for someuser on testserver:
    !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE",
    env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
    secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User someuser may run the following commands on testserver:
    (ALL) ROLE=sysadm_r TYPE=sysadm_t NOPASSWD: ALL
[someuser@testserver ~]$ sudo ausearch -m avc -ts recent | wc -l
66
[someuser@testserver ~]$ sudo ls -la /var/log/audit/audit.log 
-rw-------. 1 root root 1996980 Jul 30 12:55 /var/log/audit/audit.log
[someuser@testserver ~]$ sudo cat /var/log/audit/audit.log  | wc -l
8172
[someuser@testserver ~]$ 


But some commands are still blocked, for example postsuper from the postfix package.

[someuser@testserver ~]$ sudo postsuper
sesh: unable to execute /sbin/postsuper: Permission denied
[someuser@testserver ~]$ file /sbin/postsuper
/sbin/postsuper: cannot open `/sbin/postsuper' (Permission denied)
[someuser@testserver ~]$ sudo file /sbin/postsuper
/sbin/postsuper: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=aa0157870508c475195fe5fb1dafe5a9b3898a61, stripped
[someuser@testserver ~]$ 

Can anyone please explain to me the reason of that ? the strangest thing is that I do not see any denial on /var/log/audit/audit.log for the postsuper command. But it must be related to SELINUX because if I change the user back to the unconfined_u everything works.

Michael Hampton avatar
cz flag
I see what's going on now. I can reproduce the problem on an up to date RHEL 7 system. What I don't see are any logs or useful information to describe why this is failing, even with dontaudit disabled. Hmm. If you have a RHEL subscription it would be worth opening a case with Red Hat.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.