selinux-policy/fix_ntp.patch
Johannes Segitz c4556003bf Accepting request 1061575 from home:jsegitz:branches:security:SELinux
- Update to version 20230125. Refreshed:
  * distro_suse_to_distro_redhat.patch
  * fix_dnsmasq.patch
  * fix_init.patch
  * fix_ipsec.patch
  * fix_kernel_sysctl.patch
  * fix_logging.patch
  * fix_rpm.patch
  * fix_selinuxutil.patch
  * fix_systemd_watch.patch
  * fix_userdomain.patch
- More flexible lib(exec) matching in fix_fwupd.patch
- Removed sys_admin for systemd_gpt_generator_t in fix_systemd.patch
- Dropped fix_container.patch, is now upstream
- Added fix_entropyd.patch
  * Added new interface entropyd_semaphore_filetrans to properly transfer
    semaphore created during early boot. That doesn't work yet, so work
    around with next item
  * Allow reading tempfs files
- Added fix_kernel.patch. Added modutils_execute_kmod_tmpfs_files interace
  to allow kmod_tmpfs_t files to be executed. Necessary for firewalld
- Added fix_rtkit.patch to fix labeling of binary
- Modified fix_ntp.patch:
  * Proper labeling for start-ntpd
  * Fixed label rules for chroot path
  * Temporarily allow dac_override for ntpd_t (bsc#1207577)
  * Add interface ntp_manage_pid_files to allow management of pid
    files
- Updated fix_networkmanager.patch to allow managing ntp pid files

OBS-URL: https://build.opensuse.org/request/show/1061575
OBS-URL: https://build.opensuse.org/package/show/security:SELinux/selinux-policy?expand=0&rev=171
2023-01-27 14:51:33 +00:00

100 lines
5.1 KiB
Diff

Index: fedora-policy-20230125/policy/modules/contrib/ntp.fc
===================================================================
--- fedora-policy-20230125.orig/policy/modules/contrib/ntp.fc
+++ fedora-policy-20230125/policy/modules/contrib/ntp.fc
@@ -9,6 +9,7 @@
/etc/rc\.d/init\.d/ntpd -- gen_context(system_u:object_r:ntpd_initrc_exec_t,s0)
+/usr/sbin/start-ntpd -- gen_context(system_u:object_r:ntpd_exec_t,s0)
/usr/sbin/ntpd -- gen_context(system_u:object_r:ntpd_exec_t,s0)
/usr/sbin/ntpdate -- gen_context(system_u:object_r:ntpdate_exec_t,s0)
/usr/libexec/ntpdate-wrapper -- gen_context(system_u:object_r:ntpdate_exec_t,s0)
@@ -16,7 +17,6 @@
/usr/lib/systemd/system/ntpd.* -- gen_context(system_u:object_r:ntpd_unit_file_t,s0)
-/var/lib/ntp(/.*)? gen_context(system_u:object_r:ntp_drift_t,s0)
/var/lib/sntp(/.*)? gen_context(system_u:object_r:ntp_drift_t,s0)
/var/lib/sntp-kod(/.*)? gen_context(system_u:object_r:ntp_drift_t,s0)
@@ -25,3 +25,26 @@
/var/log/xntpd.* -- gen_context(system_u:object_r:ntpd_log_t,s0)
/var/run/ntpd\.pid -- gen_context(system_u:object_r:ntpd_var_run_t,s0)
+
+/var/lib/ntp gen_context(system_u:object_r:root_t,s0)
+/var/lib/ntp/kod gen_context(system_u:object_r:etc_runtime_t,s0)
+/var/lib/ntp/dev gen_context(system_u:object_r:device_t,s0)
+/var/lib/ntp/etc gen_context(system_u:object_r:etc_t,s0)
+/var/lib/ntp/etc/ntpd.*\.conf.* -- gen_context(system_u:object_r:ntp_conf_t,s0)
+/var/lib/ntp/etc/ntp/crypto(/.*)? -- gen_context(system_u:object_r:ntpd_key_t,s0)
+/var/lib/ntp/etc/ntp/data(/.*)? -- gen_context(system_u:object_r:ntp_drift_t,s0)
+/var/lib/ntp/etc/ntp/keys -- gen_context(system_u:object_r:ntpd_key_t,s0)
+/var/lib/ntp/etc/ntp/step-tickers.* -- gen_context(system_u:object_r:ntp_conf_t,s0)
+/var/lib/ntp/etc/ntp.conf.iburst -- gen_context(system_u:object_r:ntp_conf_t,s0)
+/var/lib/ntp/var(/.*)? gen_context(system_u:object_r:var_t,s0)
+/var/lib/ntp/var/lib(/.*)? gen_context(system_u:object_r:var_lib_t,s0)
+/var/lib/ntp/var/run(/.*)? gen_context(system_u:object_r:var_run_t,s0)
+/var/lib/ntp/var/run/ntp(/.*)? gen_context(system_u:object_r:ntpd_var_run_t,s0)
+/var/lib/ntp/var/lib/ntp(/.*)? gen_context(system_u:object_r:ntp_drift_t,s0)
+/var/lib/ntp/var/lib/sntp(/.*)? gen_context(system_u:object_r:ntp_drift_t,s0)
+/var/lib/ntp/var/lib/sntp-kod(/.*)? gen_context(system_u:object_r:ntp_drift_t,s0)
+/var/lib/ntp/drift gen_context(system_u:object_r:ntp_drift_t,s0)
+/var/lib/ntp/drift/ntp.drift -- gen_context(system_u:object_r:ntp_drift_t,s0)
+/var/lib/ntp/var/log/ntp.* -- gen_context(system_u:object_r:ntpd_log_t,s0)
+/var/lib/ntp/var/log/ntpstats(/.*)? gen_context(system_u:object_r:ntpd_log_t,s0)
+/var/lib/ntp/var/log/xntpd.* -- gen_context(system_u:object_r:ntpd_log_t,s0)
Index: fedora-policy-20230125/policy/modules/contrib/ntp.te
===================================================================
--- fedora-policy-20230125.orig/policy/modules/contrib/ntp.te
+++ fedora-policy-20230125/policy/modules/contrib/ntp.te
@@ -49,6 +49,9 @@ init_system_domain(ntpd_t, ntpdate_exec_
allow ntpd_t self:capability { chown dac_read_search kill setgid setuid sys_time ipc_lock ipc_owner sys_chroot sys_nice sys_resource };
dontaudit ntpd_t self:capability { net_admin sys_tty_config fsetid sys_nice };
+# remove once 1207577 is done
+allow ntpd_t self:capability dac_override;
+
allow ntpd_t self:process { signal_perms getcap setcap setsched setrlimit };
allow ntpd_t self:fifo_file rw_fifo_file_perms;
allow ntpd_t self:shm create_shm_perms;
@@ -78,7 +81,8 @@ manage_files_pattern(ntpd_t, ntpd_tmpfs_
fs_tmpfs_filetrans(ntpd_t, ntpd_tmpfs_t, { dir file })
manage_files_pattern(ntpd_t, ntpd_var_run_t, ntpd_var_run_t)
-files_pid_filetrans(ntpd_t, ntpd_var_run_t, file)
+manage_lnk_files_pattern(ntpd_t, ntpd_var_run_t, ntpd_var_run_t)
+files_pid_filetrans(ntpd_t, ntpd_var_run_t, { file dir lnk_file })
can_exec(ntpd_t, ntpd_exec_t)
can_exec(ntpd_t, ntpdate_exec_t)
Index: fedora-policy-20230125/policy/modules/contrib/ntp.if
===================================================================
--- fedora-policy-20230125.orig/policy/modules/contrib/ntp.if
+++ fedora-policy-20230125/policy/modules/contrib/ntp.if
@@ -339,3 +339,23 @@ interface(`ntp_manage_log',`
manage_lnk_files_pattern($1, ntpd_log_t, ntpd_log_t)
')
+########################################
+## <summary>
+## Create, read, write, and delete
+## ntp pid (lnk) files.
+## </summary>
+## <param name="domain">
+## <summary>
+## Domain allowed access.
+## </summary>
+## </param>
+#
+interface(`ntp_manage_pid_files',`
+ gen_require(`
+ type ntpd_var_run_t;
+ ')
+
+ files_search_pids($1)
+ manage_files_pattern($1, ntpd_var_run_t, ntpd_var_run_t)
+ manage_lnk_files_pattern($1, ntpd_var_run_t, ntpd_var_run_t)
+')