another first systemd patch
PATCH 1/1 another first systemd patch
Here's another first patch for systemd support. I split out the misc patch and parts of what became the dpkg patch as well as a heap of other stuff that will be in a later patch.
This patch has all the interfaces needed to build and no excess interfaces.
It starts with allowing a dynamic transition from kernel_t which is something that systemd likes to do. It has lots of changes for init_t which are needed by systemd which does a lot more than the old SysV init.
It probably also has some init_t and initrc_t changes that aren't specific to systemd. As I only use systemd I don't know exactly what is required without it nowadays.
The file contexts have a few non-systemd changes that were in the same patch, while I'm aiming to just have systemd stuff sometimes it seems easier to put a few little things in than to split them out.
There are significant changes to syslogd_t because we have systemd-journald running in that domain and it does a lot more.
There are some changes to userdomain policy to interact with systemd. The way systemd manages logins requires a lot more interaction with various daemons.
There's a minor change to the lvm related policy due to having a systemd process using that domain. lvm_t isn't an ideal name any more, but that's an issue to discuss later.
For the main systemd policy I only added some extra type definitions and the policy for systemd_backlight_t. I added policy for systemd_backlight_t instead of any of the other systemd domains because I have the policy file in alphabetical order and I didn't want to make a huge patch. There is more to come in future patches. ;)
policy/modules/system/udev.if +20 -0
@@ -282,6 +282,26 @@ interface(`udev_manage_pid_dirs',` ######################################## ## <summary> +## Allow process to relabelto udev database +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`udev_relabelto_db',` + gen_require(` + type udev_var_run_t; + ') + + files_search_pids($1) + allow $1 udev_var_run_t:file relabelto_file_perms; + allow $1 udev_var_run_t:lnk_file relabelto_file_perms; +') + +######################################## +## <summary> ## Read udev pid files. ## </summary> ## <param name="domain">
policy/modules/kernel/devices.te +3 -0
@@ -21,6 +21,9 @@ files_mountpoint(device_t) files_associate_tmp(device_t) fs_xattr_type(device_t) fs_use_trans devtmpfs gen_context(system_u:object_r:device_t,s0); +optional_policy(` + systemd_tmpfiles_manage_object(device_t, fifo_file) +') # # Type for /dev/agpgart
policy/modules/kernel/files.te +4 -0
@@ -174,6 +174,10 @@ type var_run_t; files_pid_file(var_run_t) files_mountpoint(var_run_t) +optional_policy(` + systemd_tmpfiles_manage_object(var_run_t, lnk_file) +') + # # var_spool_t is the type of /var/spool #
policy/modules/kernel/kernel.te +2 -0
@@ -361,6 +361,8 @@ optional_policy(` optional_policy(` init_sigchld(kernel_t) + init_dyntrans(kernel_t) + domain_dyntrans_type(kernel_t) ') optional_policy(`
policy/modules/system/authlogin.te +6 -0
@@ -30,6 +30,9 @@ role system_r types chkpwd_t; type faillog_t; logging_log_file(faillog_t) +optional_policy(` + systemd_tmpfiles_manage_object(faillog_t, file) +') type lastlog_t; logging_log_file(lastlog_t)
@@ -81,6 +84,9 @@ application_domain(utempter_t, utempter_ # type var_auth_t; files_type(var_auth_t) +optional_policy(` + systemd_tmpfiles_manage_object(var_auth_t, dir) +') type wtmp_t; logging_log_file(wtmp_t)
policy/modules/system/init.fc +2 -0
@@ -57,6 +57,8 @@ ifdef(`distro_gentoo', ` /run/runlevel\.dir gen_context(system_u:object_r:initrc_var_run_t,s0) /run/random-seed -- gen_context(system_u:object_r:initrc_var_run_t,s0) /run/setmixer_flag -- gen_context(system_u:object_r:initrc_var_run_t,s0) +/run/wd_keepalive\.pid -- gen_context(system_u:object_r:initrc_var_run_t,s0) +/run/sm-notify\.pid -- gen_context(system_u:object_r:initrc_var_run_t,s0) /run/systemd(/.*)? gen_context(system_u:object_r:init_var_run_t,s0) ifdef(`distro_debian',`
policy/modules/system/init.if +138 -14
308 lines not on this page · raw message
policy/modules/system/init.te +432 -12
729 lines not on this page · raw message
policy/modules/system/logging.fc +8 -0
@@ -1,4 +1,5 @@ /dev/log -s gen_context(system_u:object_r:devlog_t,mls_systemhigh) +/var/run/systemd/journal/stdout -s gen_context(system_u:object_r:devlog_t,mls_systemhigh) /etc/rsyslog.conf gen_context(system_u:object_r:syslog_conf_t,s0) /etc/syslog.conf gen_context(system_u:object_r:syslog_conf_t,s0)
@@ -80,3 +81,10 @@ ifdef(`distro_redhat',` /var/spool/rsyslog(/.*)? gen_context(system_u:object_r:var_log_t,s0) /var/tinydns/log/main(/.*)? gen_context(system_u:object_r:var_log_t,s0) + +/opt/zimbra/log(/.*)? gen_context(system_u:object_r:var_log_t,s0) +/opt/Symantec/scspagent/IDS/system(/.*)? gen_context(system_u:object_r:var_log_t,s0) + +/usr/lib/systemd/systemd-kmsg-syslogd -- gen_context(system_u:object_r:syslogd_exec_t,s0) + +/usr/local/centreon/log(/.*)? gen_context(system_u:object_r:var_log_t,s0)
policy/modules/system/miscfiles.te +3 -0
@@ -40,6 +40,9 @@ files_type(locale_t) # type man_t alias catman_t; files_type(man_t) +optional_policy(` + systemd_tmpfiles_manage_object(man_t, dir) +') type man_cache_t; files_type(man_cache_t)
policy/modules/system/logging.te +27 -0
@@ -94,6 +94,26 @@ ifdef(`enable_mls',` init_ranged_daemon_domain(syslogd_t, syslogd_exec_t, mls_systemhigh) ') +ifdef(`init_systemd', ` + dev_read_kmsg(syslogd_t) + dev_write_kmsg(syslogd_t) + allow syslogd_t self:capability sys_ptrace; + init_read_pipes(syslogd_t) + init_read_state(syslogd_t) + allow syslogd_t init_var_run_t:file { read write create open }; + allow syslogd_t var_run_t:dir create; + init_create_pid_dirs(syslogd_t) + kernel_read_ring_buffer(syslogd_t) + dev_read_urand(syslogd_t) + domain_read_all_domains_state(syslogd_t) + systemd_manage_journal_files(syslogd_t) + + # for systemd-journal + allow syslogd_t self:netlink_audit_socket connected_socket_perms; + allow syslogd_t self:capability2 audit_read; + rename_unlink_init_var_run(syslogd_t) +') + ######################################## # # Auditctl local policy
@@ -230,6 +250,9 @@ optional_policy(` udev_read_db(auditd_t) ') +# for systemd but can not be conditional +filetrans_pattern(syslogd_t, var_run_t, syslogd_tmp_t, dir, "log") + ######################################## # # audit dispatcher local policy
@@ -396,6 +419,9 @@ allow syslogd_t syslog_conf_t:file read_ # Create and bind to /dev/log or /var/run/log. allow syslogd_t devlog_t:sock_file manage_sock_file_perms; files_pid_filetrans(syslogd_t, devlog_t, sock_file) +init_pid_filetrans(syslogd_t, devlog_t, sock_file, "dev-log") + +seutil_read_config(syslogd_t) # create/append log files. manage_files_pattern(syslogd_t, var_log_t, var_log_t)
@@ -416,6 +442,7 @@ files_search_var_lib(syslogd_t) # manage pid file manage_files_pattern(syslogd_t, syslogd_var_run_t, syslogd_var_run_t) files_pid_filetrans(syslogd_t, syslogd_var_run_t, file) +allow syslogd_t syslogd_var_run_t:dir create_dir_perms; kernel_read_system_state(syslogd_t) kernel_read_network_state(syslogd_t)
policy/modules/kernel/devices.if +37 -0
@@ -154,6 +154,25 @@ interface(`dev_relabel_all_dev_nodes',` ######################################## ## <summary> +## Allow full relabeling (to and from) of all device files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +## <rolecap/> +# +interface(`dev_relabel_all_dev_files',` + gen_require(` + type device_t; + ') + + relabel_files_pattern($1, device_t, device_t) +') + +######################################## +## <summary> ## List all of the device nodes in a device directory. ## </summary> ## <param name="domain">
@@ -4225,6 +4244,24 @@ interface(`dev_relabel_all_sysfs',` ') ######################################## +## <summary> +## Relabel hardware state directories. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_relabel_sysfs_dirs',` + gen_require(` + type sysfs_t; + ') + + relabel_dirs_pattern($1, sysfs_t, sysfs_t) +') + +######################################## ## <summary> ## Read and write the TPM device. ## </summary>
policy/modules/system/logging.if +18 -0
@@ -822,6 +822,24 @@ interface(`logging_append_all_logs',` ######################################## ## <summary> +## Append to all log files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`logging_inherit_append_all_logs',` + gen_require(` + attribute logfile; + ') + + allow $1 logfile:file { getattr append ioctl lock }; +') + +######################################## +## <summary> ## Read all log files. ## </summary> ## <param name="domain">
policy/modules/system/userdomain.if +71 -0
86 lines not on this page · raw message
policy/modules/system/authlogin.if +9 -0
@@ -155,9 +155,18 @@ interface(`auth_login_pgm_domain',` seutil_read_config($1) seutil_read_default_contexts($1) + userdom_search_user_runtime($1) + userdom_read_user_tmpfs_files($1) + tunable_policy(`allow_polyinstantiation',` files_polyinstantiate_all($1) ') + + optional_policy(` + systemd_read_logind_state($1) + systemd_write_inherited_logind_sessions_pipes($1) + systemd_passwd_agent_inherits_fd($1) + ') ') ########################################
policy/modules/kernel/terminal.if +18 -0
@@ -500,6 +500,24 @@ interface(`term_list_ptys',` ######################################## ## <summary> +## Relabel the /dev/pts directory +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`term_relabel_ptys_dirs',` + gen_require(` + type devpts_t; + ') + + allow $1 devpts_t:dir relabel_dir_perms; +') + +######################################## +## <summary> ## Do not audit attempts to read the ## /dev/pts directory. ## </summary>
policy/modules/system/lvm.if +18 -0
@@ -187,3 +187,21 @@ interface(`lvm_admin',` files_search_tmp($1) admin_pattern($1, lvm_tmp_t) ') + +######################################## +## <summary> +## Read and write a lvm unnamed pipe. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`lvm_rw_pipes',` + gen_require(` + type lvm_var_run_t; + ') + + allow $1 lvm_var_run_t:fifo_file rw_inherited_fifo_file_perms; +')
policy/modules/kernel/files.if +152 -0
167 lines not on this page · raw message
policy/modules/system/systemd.if +123 -1
151 lines not on this page · raw message
policy/modules/system/systemd.te +47 -7
115 lines not on this page · raw message
policy/modules/system/systemd.fc +9 -2
@@ -7,6 +7,7 @@ /usr/bin/systemd-stdio-bridge -- gen_context(system_u:object_r:systemd_stdio_bridge_exec_t,s0) /usr/bin/systemd-tmpfiles -- gen_context(system_u:object_r:systemd_tmpfiles_exec_t,s0) /usr/bin/systemd-tty-ask-password-agent -- gen_context(system_u:object_r:systemd_passwd_agent_exec_t,s0) +/usr/bin/systemd-notify -- gen_context(system_u:object_r:systemd_notify_exec_t,s0) /usr/lib/systemd/systemd-activate -- gen_context(system_u:object_r:systemd_activate_exec_t,s0) /usr/lib/systemd/systemd-backlight -- gen_context(system_u:object_r:systemd_backlight_exec_t,s0)
@@ -32,14 +33,20 @@ /usr/lib/systemd/system/systemd-binfmt.* -- gen_context(system_u:object_r:systemd_binfmt_unit_t,s0) /var/lib/systemd/backlight(/.*)? gen_context(system_u:object_r:systemd_backlight_var_lib_t,s0) +/var/lib/systemd/coredump(/.*)? gen_context(system_u:object_r:systemd_coredump_var_lib_t,s0) /var/lib/systemd/linger(/.*)? gen_context(system_u:object_r:systemd_logind_var_lib_t,s0) /run/\.nologin[^/]* -- gen_context(system_u:object_r:systemd_sessions_var_run_t,s0) /run/nologin -- gen_context(system_u:object_r:systemd_sessions_var_run_t,s0) /run/systemd/resolve(/.*)? gen_context(system_u:object_r:systemd_resolved_var_run_t,s0) -/run/systemd/seats(/.*)? gen_context(system_u:object_r:systemd_logind_var_run_t,s0) -/run/systemd/sessions(/.*)? gen_context(system_u:object_r:systemd_logind_var_run_t,s0) +/run/systemd/seats(/.*)? gen_context(system_u:object_r:systemd_sessions_var_run_t,s0) +/run/systemd/sessions(/.*)? gen_context(system_u:object_r:systemd_sessions_var_run_t,s0) /run/systemd/users(/.*)? gen_context(system_u:object_r:systemd_logind_var_run_t,s0) /run/systemd/inhibit(/.*)? gen_context(system_u:object_r:systemd_logind_var_run_t,s0) +/var/run/systemd/nspawn(/.*)? gen_context(system_u:object_r:systemd_nspawn_var_run_t,s0) +/var/run/systemd/machines(/.*)? gen_context(system_u:object_r:systemd_machined_var_run_t,s0) /run/tmpfiles\.d/kmod.conf gen_context(system_u:object_r:systemd_kmod_conf_t,s0) + +/var/log/journal(/.*)? gen_context(system_u:object_r:systemd_journal_t,s0) +/var/run/log/journal(/.*)? gen_context(system_u:object_r:systemd_journal_t,s0)
policy/modules/system/unconfined.if +19 -0
@@ -604,3 +604,22 @@ interface(`unconfined_dbus_connect',` allow $1 unconfined_t:dbus acquire_svc; ') + +######################################## +## <summary> +## Do not audit attempts to read and write +## unconfined domain stream. +## </summary> +## <param name="domain"> +## <summary> +## Domain to not audit. +## </summary> +## </param> +# +interface(`unconfined_dontaudit_rw_stream',` + gen_require(` + type unconfined_t; + ') + + dontaudit $1 unconfined_t:unix_stream_socket rw_socket_perms; +')
policy/modules/contrib/cron.if +19 -0
@@ -891,3 +891,22 @@ interface(`cron_admin',` files_search_spool($1) admin_pattern($1, cron_spool_type) ') + +######################################## +## <summary> +## Search the directory containing user cron tables. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`cron_manage_system_spool',` + gen_require(` + type cron_system_spool_t; + ') + + files_search_spool($1) + manage_files_pattern($1, cron_system_spool_t, cron_system_spool_t) +')
PATCH 1/1 another first systemd patch
Quoted 88 lines · Russell Coker via refpolicy
Here's another first patch for systemd support. I split out the misc patch and parts of what became the dpkg patch as well as a heap of other stuff that
will be in a later patch.This patch has all the interfaces needed to build and no excess interfaces.
It starts with allowing a dynamic transition from
kernel_twhich is something
that systemd likes to do. It has lots of changes forinit_twhich are needed
by systemd which does a lot more than the old SysV init.It probably also has some
init_tandinitrc_tchanges that aren't specific to
systemd. As I only use systemd I don't know exactly what is required without
it nowadays.The file contexts have a few non-systemd changes that were in the same patch,
while I'm aiming to just have systemd stuff sometimes it seems easier to put
a few little things in than to split them out.There are significant changes to
syslogd_tbecause we have systemd-journald running in that domain and it does a lot more.There are some changes to userdomain policy to interact with systemd. The way systemd manages logins requires a lot more interaction with various daemons.
There's a minor change to the lvm related policy due to having a systemd process using that domain.
lvm_tisn't an ideal name any more, but that's an
issue to discuss later.For the main systemd policy I only added some extra type definitions and the
policy forsystemd_backlight_t. I added policy forsystemd_backlight_tinstead of any of the other systemd domains because I have the policy file in alphabetical order and I didn't want to make a huge patch. There is more to come in future patches. ;)[...]
policy/modules/system/systemd.te +9
-7@@ -140,29 +176,33 @@ dontaudit systemd_log_parse_env_type sel kernel_read_system_state(systemd_log_parse_env_type) dev_write_kmsg(systemd_log_parse_env_type) - -term_use_console(systemd_log_parse_env_type) - init_read_state(systemd_log_parse_env_type) - logging_send_syslog_msg(systemd_log_parse_env_type) +term_use_console(systemd_log_parse_env_type) ###################################### # # Backlight local policy # +allow systemd_backlight_t self:unix_dgram_socket { connect connected_socket_perms }; + allow systemd_backlight_t systemd_backlight_var_lib_t:dir manage_dir_perms; -init_var_lib_filetrans(systemd_backlight_t, systemd_backlight_var_lib_t, dir) manage_files_pattern(systemd_backlight_t, systemd_backlight_var_lib_t, systemd_backlight_var_lib_t) - systemd_log_parse_environment(systemd_backlight_t) +kernel_read_system_state(systemd_backlight_t) + # Allow systemd-backlight to write to /sys/class/backlight/*/brightness dev_rw_sysfs(systemd_backlight_t) - +dev_write_kmsg(systemd_backlight_t) +# for udev.conf files_read_etc_files(systemd_backlight_t) +init_read_state(systemd_backlight_t) +init_var_lib_filetrans(systemd_backlight_t, systemd_backlight_var_lib_t,dir)
policy/modules/system/systemd.te dontaudit systemd_log_parse_env_type sel · line 206
Quoted 3 lines
policy/modules/system/systemd.te +2
-0+logging_send_syslog_msg(systemd_backlight_t) +# for /run/udev/data/+backlight* udev_read_pid_files(systemd_backlight_t)
Why are init_read_state(systemd_backlight_t), logging_send_syslog_msg(systemd_backlight_t)...
needed with systemd_log_parse_environment(systemd_backlight_t)? The accesses these calls provide should already be handled by attribute systemd_log_parse_env_type, right above in systemd.te.
Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.tresys.com/pipermail/refpolicy/attachments/20170219/e1421379/attachment-0001.html
PATCH 1/1 another first systemd patch
Quoted 5 lines · Nicolas Iooss
Why are
init_read_state(systemd_backlight_t),logging_send_syslog_msg(systemd_backlight_t)...
needed withsystemd_log_parse_environment(systemd_backlight_t)? The accesses these calls provide should already be handled by attributesystemd_log_parse_env_type, right above in systemd.te.
Maybe they predate systemd_log_parse_environment().
Thanks for pointing this out, I've removed those and a couple of other instances. I'll send a new patch shortly.
Signature · 2 lines
My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/