Skip to content

Commit

Permalink
Confine systemd system-ssh-generator
Browse files Browse the repository at this point in the history
Resolves: RHEL-72549
  • Loading branch information
zpytela committed Jan 8, 2025
1 parent 4a4e5a6 commit 941e159
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
19 changes: 19 additions & 0 deletions policy/modules/services/ssh.if
Original file line number Diff line number Diff line change
Expand Up @@ -1147,3 +1147,22 @@ interface(`ssh_read_state',`

read_files_pattern($1, ssh_t, ssh_t)
')

########################################
## <summary>
## Get attributes of sshd unit files
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`ssh_getattr_unit_file',`
gen_require(`
type sshd_unit_file_t;
')

systemd_search_unit_dirs($1)
allow $1 sshd_unit_file_t:file getattr_file_perms;
')
1 change: 1 addition & 0 deletions policy/modules/system/systemd.fc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ HOME_DIR/\.config/systemd/user(/.*)? gen_context(system_u:object_r:systemd_unit
/usr/lib/systemd/system-generators/systemd-fstab-generator -- gen_context(system_u:object_r:systemd_fstab_generator_exec_t,s0)
/usr/lib/systemd/system-generators/systemd-gpt-auto-generator -- gen_context(system_u:object_r:systemd_gpt_generator_exec_t,s0)
/usr/lib/systemd/system-generators/systemd-rc-local-generator -- gen_context(system_u:object_r:systemd_rc_local_generator_exec_t,s0)
/usr/lib/systemd/system-generators/systemd-ssh-generator -- gen_context(system_u:object_r:systemd_ssh_generator_exec_t,s0)
/usr/lib/systemd/system-generators/systemd-sysv-generator -- gen_context(system_u:object_r:systemd_sysv_generator_exec_t,s0)
/usr/lib/systemd/systemd-resolve(d|-host) gen_context(system_u:object_r:systemd_resolved_exec_t,s0)
/usr/lib/systemd/systemd-importd -- gen_context(system_u:object_r:systemd_importd_exec_t,s0)
Expand Down
15 changes: 15 additions & 0 deletions policy/modules/system/systemd.te
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ systemd_generator_template(systemd_fstab_generator)

#domain for rc-local-generator
systemd_generator_template(systemd_rc_local_generator)
# ssh-generator
systemd_generator_template(systemd_ssh_generator)

#domain for sysv-generator
systemd_generator_template(systemd_sysv_generator)
Expand Down Expand Up @@ -1288,6 +1290,19 @@ systemd_manage_all_unit_files(systemd_fstab_generator_t)

init_exec_script_files(systemd_rc_local_generator_t)

### ssh generator
allow systemd_ssh_generator_t self:vsock_socket create;
allow systemd_ssh_generator_t vsock_device_t:chr_file { read_chr_file_perms };

kernel_read_sysctl(systemd_ssh_generator_t)

dev_read_sysfs(systemd_ssh_generator_t)

optional_policy(`
ssh_domtrans(systemd_ssh_generator_t)
ssh_getattr_unit_file(systemd_ssh_generator_t)
')

#######################################
#
# systemd_sysv_generator_t
Expand Down

0 comments on commit 941e159

Please sign in to comment.