Skip to content

Commit

Permalink
Label /run/systemd/default-hostname with hostname_etc_t
Browse files Browse the repository at this point in the history
The /run/systemd/default-hostname file is created by systemd
during boot time and can be removed later by systemd-hostnamed.
Accordingly, the file transition is defined for systemd and
systemd-hostnamed is allowed to delete pid dir entries.

Resolves: rhbz#1953060
  • Loading branch information
zpytela committed May 24, 2021
1 parent e1dfbd3 commit 517e50b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions policy/modules/system/init.if
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,24 @@ interface(`init_create_pid_dirs',`
create_dirs_pattern($1, init_var_run_t, init_var_run_t)
')

#######################################
## <summary>
## Remove entries from the /run/systemd directory.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`init_delete_pid_dir_entry',`
gen_require(`
type init_var_run_t;
')

allow $1 init_var_run_t:dir del_entry_dir_perms;
')

#######################################
## <summary>
## Create objects in /run/systemd directory
Expand Down
1 change: 1 addition & 0 deletions policy/modules/system/systemd.fc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ HOME_DIR/\.config/systemd/user(/.*)? gen_context(system_u:object_r:systemd_unit
/usr/lib/dracut/modules.d/.*\.service gen_context(system_u:object_r:systemd_unit_file_t,s0)
/usr/lib/systemd/system(/.*)? gen_context(system_u:object_r:systemd_unit_file_t,s0)
/usr/lib/systemd/user(/.*)? gen_context(system_u:object_r:systemd_unit_file_t,s0)
/run/systemd/default-hostname -- gen_context(system_u:object_r:hostname_etc_t,s0)
/run/systemd/transient(/.*)? gen_context(system_u:object_r:systemd_unit_file_t,s0)
/run/systemd/units(/.*)? gen_context(system_u:object_r:systemd_unit_file_t,s0)
/usr/lib/systemd/system/systemd-machined\.service -- gen_context(system_u:object_r:systemd_machined_unit_file_t,s0)
Expand Down
1 change: 1 addition & 0 deletions policy/modules/system/systemd.if
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,7 @@ interface(`systemd_filetrans_named_content',`

files_pid_filetrans($1, systemd_logind_var_run_t, file, "nologin")
files_pid_filetrans($1, systemd_logind_var_run_t, file, "shutdown")
init_named_pid_filetrans($1, hostname_etc_t, file, "default-hostname")
init_named_pid_filetrans($1, systemd_passwd_var_run_t, dir, "ask-password-block")
init_named_pid_filetrans($1, systemd_passwd_var_run_t, dir, "ask-password")
files_etc_filetrans($1, hostname_etc_t, file, "hostname" )
Expand Down
1 change: 1 addition & 0 deletions policy/modules/system/systemd.te
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ dev_read_sysfs(systemd_hostnamed_t)

fs_read_xenfs_files(systemd_hostnamed_t)

init_delete_pid_dir_entry(systemd_hostnamed_t)
init_status(systemd_hostnamed_t)
init_stream_connect(systemd_hostnamed_t)

Expand Down

0 comments on commit 517e50b

Please sign in to comment.