Skip to content

Commit

Permalink
Merge pull request SELinuxProject#371 from pebenito/systemd-StandardI…
Browse files Browse the repository at this point in the history
…nputText
  • Loading branch information
pebenito committed May 11, 2021
2 parents 07dc9a3 + 2d0cb88 commit 61bc896
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@
/policy/modules/kernel/corenetwork.te
/tmp/

.vagrant/

# monolithic generated files
/file_contexts
/homedir_template
/policy.conf
/.vagrant/
/.vscode/
16 changes: 16 additions & 0 deletions policy/modules/system/init.if
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,17 @@ interface(`init_domain',`
allow init_t $1:process rlimitinh;

ifdef(`init_systemd',`
gen_require(`
type init_tmpfs_t;
')

allow $1 init_t:unix_stream_socket { getattr read write ioctl };

allow init_t $1:process2 { nnp_transition nosuid_transition };

# StandardInputText uses a memfd rw shm segment.
# Cannot deny writes or it breaks.
allow $1 init_tmpfs_t:file rw_inherited_file_perms;
')
')

Expand Down Expand Up @@ -270,9 +278,17 @@ interface(`init_spec_daemon_domain',`
allow init_t $1:process rlimitinh;

ifdef(`init_systemd',`
gen_require(`
type init_tmpfs_t;
')

allow $1 init_t:unix_stream_socket { getattr read write ioctl };

allow init_t $1:process2 { nnp_transition nosuid_transition };

# StandardInputText uses a memfd rw shm segment.
# Cannot deny writes or it breaks.
allow $1 init_tmpfs_t:file rw_inherited_file_perms;
')

# daemons started from init will
Expand Down
8 changes: 6 additions & 2 deletions policy/modules/system/init.te
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ files_type(initrc_state_t)
type initrc_tmp_t;
files_tmp_file(initrc_tmp_t)

type init_tmpfs_t;
files_tmpfs_file(init_tmpfs_t)

type initrc_var_log_t;
logging_log_file(initrc_var_log_t)

Expand Down Expand Up @@ -170,6 +173,9 @@ files_runtime_filetrans(init_t, initctl_t, fifo_file)
# Modify utmp.
allow init_t initrc_runtime_t:file { rw_file_perms setattr };

allow init_t init_tmpfs_t:file manage_file_perms;
fs_tmpfs_filetrans(init_t, init_tmpfs_t, file)

kernel_read_system_state(init_t)
kernel_share_state(init_t)
kernel_dontaudit_search_unlabeled(init_t)
Expand Down Expand Up @@ -292,8 +298,6 @@ ifdef(`init_systemd',`
manage_lnk_files_pattern(init_t, init_runtime_t, init_runtime_t)
manage_sock_files_pattern(init_t, init_runtime_t, init_runtime_t)
manage_dirs_pattern(init_t, init_runtime_t, init_runtime_t)
# /memfd:systemd-state
fs_tmpfs_filetrans(init_t, init_runtime_t, file)

# mounton is required for systemd-timesyncd
allow init_t init_var_lib_t:dir { manage_dir_perms mounton };
Expand Down

0 comments on commit 61bc896

Please sign in to comment.