Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix selinux check for ReloadUnit #2493

Merged
merged 4 commits into from
Feb 1, 2016

Conversation

evverx
Copy link
Member

@evverx evverx commented Jan 31, 2016

Fixes:

-bash-4.3# echo 1 >/sys/fs/selinux/enforce
-bash-4.3# runcon -t systemd_test_start_t systemctl start hola

-bash-4.3# sesearch --allow -s systemd_test_reload_t -c service
Found 1 semantic av rules:
   allow systemd_test_reload_t systemd_unit_file_t : service reload ;

-bash-4.3# runcon -t systemd_test_reload_t systemctl reload hola
Failed to reload hola.service: Access denied
See system logs and 'systemctl status hola.service' for details.

-bash-4.3# journalctl -b | grep -i user_avc | grep reload
USER_AVC pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
msg='
avc:  denied  { start } for auid=0 uid=0 gid=0 path="/etc/systemd/system/hola.service" cmdline="systemctl reload hola"
scontext=unconfined_u:unconfined_r:systemd_test_reload_t:s0-s0:c0.c1023
tcontext=system_u:object_r:systemd_unit_file_t:s0
tclass=service

See
https://fedoraproject.org/wiki/Features/SELinuxSystemdAccessControl#Documentation
ReloadUnit maps to reload (not start)

Fixes:
-bash-4.3# echo 1 >/sys/fs/selinux/enforce
-bash-4.3# runcon -t systemd_test_start_t systemctl start hola

-bash-4.3# sesearch --allow -s systemd_test_reload_t -c service
Found 1 semantic av rules:
   allow systemd_test_reload_t systemd_unit_file_t : service reload ;

-bash-4.3# runcon -t systemd_test_reload_t systemctl reload hola
Failed to reload hola.service: Access denied
See system logs and 'systemctl status hola.service' for details.

-bash-4.3# journalctl -b | grep -i user_avc | grep reload
USER_AVC pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
msg='
avc:  denied  { start } for auid=0 uid=0 gid=0 path="/etc/systemd/system/hola.service" cmdline="systemctl reload hola"
scontext=unconfined_u:unconfined_r:systemd_test_reload_t:s0-s0:c0.c1023
tcontext=system_u:object_r:systemd_unit_file_t:s0
tclass=service

See
https://fedoraproject.org/wiki/Features/SELinuxSystemdAccessControl#Documentation
@evverx evverx changed the title Fix selinux checks Fix selinux check for ReloadUnitFile Jan 31, 2016
@evverx evverx changed the title Fix selinux check for ReloadUnitFile Fix selinux check for ReloadUnit Jan 31, 2016
@evverx
Copy link
Member Author

evverx commented Jan 31, 2016

You can create systemd_test_reload_t for testing:

$ cd test/TEST-06-SELINUX

$ sudo make -f /usr/share/selinux/devel/Makefile load

$ sudo semanage module -l | grep systemd_test
systemd_test              400       pp

$ sesearch --allow -s 'systemd_test_*' -c service -R
Found 4 semantic av rules:
   allow systemd_test_status_t systemd_unit_file_t : service status ;
   allow systemd_test_start_t systemd_unit_file_t : service start ;
   allow systemd_test_stop_t systemd_unit_file_t : service stop ;
   allow systemd_test_reload_t systemd_unit_file_t : service reload ;

@poettering
Copy link
Member

OK, only found a nitpick... Looks excellent will merge. The switch() suggestions doesn't really matter I figure...

poettering added a commit that referenced this pull request Feb 1, 2016
Fix selinux check for ReloadUnit
@poettering poettering merged commit da21f87 into systemd:master Feb 1, 2016
@evverx evverx deleted the fix-selinux-checks branch February 2, 2016 02:53
evverx added a commit to evverx/systemd that referenced this pull request Feb 11, 2016
evverx added a commit to evverx/systemd that referenced this pull request Feb 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants