Skip to content

Commit

Permalink
Add policy for systemd-homed
Browse files Browse the repository at this point in the history
  • Loading branch information
richiedaze committed Sep 22, 2024
1 parent fe8833a commit 830966c
Show file tree
Hide file tree
Showing 15 changed files with 440 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dist/targeted/modules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3077,3 +3077,10 @@ afterburn = module
# sap
#
sap = module

# Layer: system
# Module: systemd-homed
#
# Policy for systemd-homed
#
systemd-homed = module
1 change: 1 addition & 0 deletions policy/modules/contrib/colord.te
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ domain_use_interactive_fds(colord_t)
files_list_mnt(colord_t)
files_watch_usr_dirs(colord_t)
files_map_var_lib_files(colord_t)
files_mmap_isid_files(colord_t)
files_read_var_lib_files(colord_t)

fs_getattr_all_fs(colord_t)
Expand Down
1 change: 1 addition & 0 deletions policy/modules/contrib/dbus.te
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ optional_policy(`
')

optional_policy(`
systemd_homed_write_pipes(system_dbusd_t)
systemd_status_systemd_services(system_dbusd_t)
systemd_use_fds_logind(system_dbusd_t)
systemd_write_inherited_logind_sessions_pipes(system_dbusd_t)
Expand Down
4 changes: 4 additions & 0 deletions policy/modules/contrib/policykit.te
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ optional_policy(`
devicekit_dbus_chat(policykit_t)
')

optional_policy(`
systemd_homed_dbus_chat(policykit_t)
')

optional_policy(`
rhsmcertd_dbus_chat(policykit_t)
')
Expand Down
1 change: 1 addition & 0 deletions policy/modules/contrib/virt.te
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,7 @@ optional_policy(`

optional_policy(`
systemd_dbus_chat_machined(virtqemud_t)
systemd_homed_stream_connect(virtqemud_t)
')

optional_policy(`
Expand Down
37 changes: 37 additions & 0 deletions policy/modules/kernel/files.if
Original file line number Diff line number Diff line change
Expand Up @@ -4848,6 +4848,25 @@ interface(`files_manage_isid_type_dirs',`
allow $1 unlabeled_t:dir manage_dir_perms;
')

########################################
## <summary>
## Map files on new filesystems
## that have not yet been labeled.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`files_mmap_isid_files',`
gen_require(`
type unlabeled_t;
')

allow $1 unlabeled_t:file { getattr map };
')

########################################
## <summary>
## Mount a filesystem on a directory on new filesystems
Expand Down Expand Up @@ -5249,6 +5268,24 @@ interface(`files_create_home_dir',`
create_dirs_pattern($1, home_root_t, home_root_t)
')

########################################
## <summary>
## Delete /home directories
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access
## </summary>
## </param>
#
interface(`files_delete_home_dir',`
gen_require(`
type home_root_t;
')

delete_dirs_pattern($1, home_root_t, home_root_t)
')

########################################
## <summary>
## Search home directories root (/home).
Expand Down
6 changes: 6 additions & 0 deletions policy/modules/services/xserver.te
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,12 @@ optional_policy(`
sssd_read_pid_files(xdm_t)
')

optional_policy(`
systemd_homed_write_pid_sock_files(xdm_t)
systemd_homed_write_pipes(xdm_t)
systemd_homed_dbus_chat(xdm_t)
')

optional_policy(`
telepathy_exec(xdm_t)
')
Expand Down
1 change: 1 addition & 0 deletions policy/modules/system/authlogin.te
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ optional_policy(`
')

optional_policy(`
systemd_homed_stream_connect(nsswitch_domain)
systemd_userdbd_stream_connect(nsswitch_domain)
systemd_machined_stream_connect(nsswitch_domain)
')
Expand Down
18 changes: 18 additions & 0 deletions policy/modules/system/fstools.if
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ interface(`fstools_domtrans',`
domtrans_pattern($1, fsadm_exec_t, fsadm_t)
')

########################################
## <summary>
## NNP Transition to fstools.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`fstools_nnp_domtrans',`
gen_require(`
type fsadm_t;
')
allow $1 fsadm_t:process2 nnp_transition;

')

########################################
## <summary>
## Execute fs tools in the fstools domain, and
Expand Down
6 changes: 6 additions & 0 deletions policy/modules/system/init.te
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ optional_policy(`
optional_policy(`
devicekit_dbus_chat_power(init_t)
')

')

optional_policy(`
Expand Down Expand Up @@ -877,6 +878,11 @@ optional_policy(`
stratisd_data_read_lnk_files(init_t)
')

optional_policy(`
systemd_homed_dbus_chat(init_t)
systemd_homed_write_pipes(init_t)
')

optional_policy(`
systemd_filetrans_named_content(init_t)
systemd_write_inhibit_pipes(init_t)
Expand Down
22 changes: 22 additions & 0 deletions policy/modules/system/systemd-homed.fc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# homed file context
#

/run/systemd/home/(.+)\.dont-suspend -p gen_context(system_u:object_r:systemd_homed_runtime_pipe_t,s0)
/run/systemd/home/notify -s gen_context(system_u:object_r:systemd_homed_runtime_socket_t,s0)
/run/systemd/home -d gen_context(system_u:object_r:systemd_homed_runtime_dir_t,s0)
/run/systemd/user-home-mount -d gen_context(system_u:object_r:systemd_homed_runtime_work_dir_t,s0)

/usr/lib/systemd/systemd-homed -- gen_context(system_u:object_r:systemd_homed_exec_t,s0)
/usr/lib/systemd/systemd-homework -- gen_context(system_u:object_r:systemd_homework_exec_t,s0)
/usr/lib/systemd/system/systemd-homed-activate\.service -- gen_context(system_u:object_r:systemd_homed_unit_file_t,s0)
/usr/lib/systemd/system/systemd-homed\.service -- gen_context(system_u:object_r:systemd_homed_unit_file_t,s0)

/var/lib/systemd/home/(.+)\.identity -- gen_context(system_u:object_r:systemd_homed_record_t,s0)
/var/lib/systemd/home/local\.private -- gen_context(system_u:object_r:systemd_homed_record_t,s0)
/var/lib/systemd/home/(.+)\.public -- gen_context(system_u:object_r:systemd_homed_record_t,s0)
/var/lib/systemd/home/local\.public -- gen_context(system_u:object_r:systemd_homed_record_t,s0)
/var/lib/systemd/home -d gen_context(system_u:object_r:systemd_homed_library_dir_t,s0)

HOME_DIR/\.identity -- gen_context(system_u:object_r:systemd_homed_record_t,s0)
HOME_ROOT/(.+)\.home -- gen_context(system_u:object_r:systemd_homed_crypto_luks_t,s0)
80 changes: 80 additions & 0 deletions policy/modules/system/systemd-homed.if
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
## <summary>SELinux policy for systemd-homed components</summary>

########################################
## <summary>
## Send and receive messages from
## systemd homed over dbus.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`systemd_homed_dbus_chat',`
gen_require(`
type systemd_homed_t;
class dbus send_msg;
')

allow $1 systemd_homed_t:dbus send_msg;
allow systemd_homed_t $1:dbus send_msg;
')

########################################
## <summary>
## Allow the specified domain to connect to
## systemd homed with a unix socket.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`systemd_homed_stream_connect',`
gen_require(`
type systemd_homed_t;
')

allow $1 systemd_homed_t:unix_stream_socket connectto;
')

#######################################
## <summary>
## Write to systemd_homed PID socket files.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`systemd_homed_write_pid_sock_files',`
gen_require(`
type systemd_homed_runtime_dir_t;
type systemd_homed_runtime_socket_t;
')

write_sock_files_pattern($1, systemd_homed_runtime_dir_t, systemd_homed_runtime_socket_t)
')

######################################
## <summary>
## Write systemd homed pipes.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`systemd_homed_write_pipes',`
gen_require(`
type systemd_homed_runtime_dir_t;
type systemd_homed_runtime_pipe_t;
')

write_fifo_files_pattern($1, systemd_homed_runtime_dir_t, systemd_homed_runtime_pipe_t)
')

Loading

0 comments on commit 830966c

Please sign in to comment.