Skip to content

Commit 89766d5

Browse files
committed
Rework shadow transitions and access
shadow access is tightly controlled, with separate types for the shadow files and the locks. This patch distinguishes the two by enumerating the backup filenames and lock file names in their associated file transition rules. Prior to this, the overbroad file transition rules would cause various shadow-manipulating tools to create lock files with the incorrect shadow_t label. Signed-off-by: Antonio Enrico Russo <[email protected]>
1 parent 5747626 commit 89766d5

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

policy/modules/admin/usermanage.te

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ auth_use_nsswitch(groupadd_t)
249249
# domtrans_chk_passwd() call.
250250
auth_manage_shadow(groupadd_t)
251251
auth_relabel_shadow(groupadd_t)
252-
auth_etc_filetrans_shadow(groupadd_t)
253252

254253
seutil_read_config(groupadd_t)
255254
seutil_read_file_contexts(groupadd_t)
@@ -349,7 +348,6 @@ auth_run_chk_passwd(passwd_t, passwd_roles)
349348
auth_run_upd_passwd(passwd_t, passwd_roles)
350349
auth_manage_shadow(passwd_t)
351350
auth_relabel_shadow(passwd_t)
352-
auth_etc_filetrans_shadow(passwd_t)
353351
auth_use_nsswitch(passwd_t)
354352

355353
# allow checking if a shell is executable
@@ -438,7 +436,6 @@ term_use_all_ptys(sysadm_passwd_t)
438436

439437
auth_manage_shadow(sysadm_passwd_t)
440438
auth_relabel_shadow(sysadm_passwd_t)
441-
auth_etc_filetrans_shadow(sysadm_passwd_t)
442439
auth_use_nsswitch(sysadm_passwd_t)
443440

444441
# allow vipw to exec the editor
@@ -534,7 +531,6 @@ auth_use_nsswitch(useradd_t)
534531
# domtrans_chk_passwd() call.
535532
auth_manage_shadow(useradd_t)
536533
auth_relabel_shadow(useradd_t)
537-
auth_etc_filetrans_shadow(useradd_t)
538534

539535
init_use_fds(useradd_t)
540536
init_rw_utmp(useradd_t)

policy/modules/system/authlogin.if

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,8 @@ interface(`auth_manage_shadow',`
719719
auth_manage_shadow_history($1)
720720
auth_rw_shadow_lock($1)
721721
allow $1 shadow_t:file manage_file_perms;
722+
auth_etc_filetrans_shadow($1, "shadow-")
723+
auth_etc_filetrans_shadow($1, "gshadow-")
722724
typeattribute $1 can_read_shadow_passwords, can_write_shadow_passwords;
723725
')
724726

@@ -859,9 +861,13 @@ interface(`auth_relabel_shadow',`
859861
interface(`auth_rw_shadow_lock',`
860862
gen_require(`
861863
type shadow_lock_t;
864+
type etc_t;
862865
')
863866

864-
rw_files_pattern($1, shadow_lock_t, shadow_lock_t)
867+
files_etc_filetrans($1, shadow_lock_t, file, ".pwd.lock")
868+
files_etc_filetrans($1, shadow_lock_t, file, "passwd.lock")
869+
files_etc_filetrans($1, shadow_lock_t, file, "group.lock")
870+
rw_files_pattern($1, etc_t, shadow_lock_t)
865871
')
866872

867873
########################################

policy/modules/system/systemd.te

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,6 @@ kernel_read_kernel_sysctls(systemd_sysusers_t)
18931893
selinux_use_status_page(systemd_sysusers_t)
18941894

18951895
auth_manage_shadow(systemd_sysusers_t)
1896-
auth_etc_filetrans_shadow(systemd_sysusers_t)
18971896
auth_use_nsswitch(systemd_sysusers_t)
18981897

18991898
seutil_libselinux_linked(systemd_sysusers_t)

0 commit comments

Comments
 (0)