Skip to content

Commit 5ad8ee0

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 7d4aa74 commit 5ad8ee0

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

policy/modules/admin/usermanage.te

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ auth_use_nsswitch(groupadd_t)
246246
# domtrans_chk_passwd() call.
247247
auth_manage_shadow(groupadd_t)
248248
auth_relabel_shadow(groupadd_t)
249-
auth_etc_filetrans_shadow(groupadd_t)
249+
auth_filetrans_shadow(groupadd_t)
250250

251251
seutil_read_config(groupadd_t)
252252
seutil_read_file_contexts(groupadd_t)
@@ -346,7 +346,7 @@ auth_run_chk_passwd(passwd_t, passwd_roles)
346346
auth_run_upd_passwd(passwd_t, passwd_roles)
347347
auth_manage_shadow(passwd_t)
348348
auth_relabel_shadow(passwd_t)
349-
auth_etc_filetrans_shadow(passwd_t)
349+
auth_filetrans_shadow(passwd_t)
350350
auth_use_nsswitch(passwd_t)
351351

352352
# allow checking if a shell is executable
@@ -435,7 +435,7 @@ term_use_all_ptys(sysadm_passwd_t)
435435

436436
auth_manage_shadow(sysadm_passwd_t)
437437
auth_relabel_shadow(sysadm_passwd_t)
438-
auth_etc_filetrans_shadow(sysadm_passwd_t)
438+
auth_filetrans_shadow(sysadm_passwd_t)
439439
auth_use_nsswitch(sysadm_passwd_t)
440440

441441
# allow vipw to exec the editor
@@ -531,7 +531,7 @@ auth_use_nsswitch(useradd_t)
531531
# domtrans_chk_passwd() call.
532532
auth_manage_shadow(useradd_t)
533533
auth_relabel_shadow(useradd_t)
534-
auth_etc_filetrans_shadow(useradd_t)
534+
auth_filetrans_shadow(useradd_t)
535535

536536
init_use_fds(useradd_t)
537537
init_rw_utmp(useradd_t)

policy/modules/services/nis.te

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ selinux_get_fs_mount(yppasswdd_t)
199199

200200
auth_manage_shadow(yppasswdd_t)
201201
auth_relabel_shadow(yppasswdd_t)
202-
auth_etc_filetrans_shadow(yppasswdd_t)
202+
auth_filetrans_shadow(yppasswdd_t)
203203

204204
logging_send_syslog_msg(yppasswdd_t)
205205

policy/modules/system/authlogin.if

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,23 @@ interface(`auth_relabel_shadow',`
847847
typeattribute $1 can_relabelto_shadow_passwords;
848848
')
849849

850+
########################################
851+
## <summary>
852+
## File transitions for shadow files.
853+
## </summary>
854+
## <param name="domain">
855+
## <summary>
856+
## Domain with file transition.
857+
## </summary>
858+
## </param>
859+
#
860+
interface(`auth_filetrans_shadow',`
861+
auth_etc_filetrans_shadow($1, "shadow")
862+
auth_etc_filetrans_shadow($1, "gshadow")
863+
auth_etc_filetrans_shadow($1, "shadow-")
864+
auth_etc_filetrans_shadow($1, "gshadow-")
865+
')
866+
850867
########################################
851868
## <summary>
852869
## Read/Write shadow lock files.
@@ -860,9 +877,18 @@ interface(`auth_relabel_shadow',`
860877
interface(`auth_rw_shadow_lock',`
861878
gen_require(`
862879
type shadow_lock_t;
880+
type shadow_t;
863881
')
864882

865883
allow $1 shadow_lock_t:file rw_file_perms;
884+
ifelse(`$2',`',`
885+
files_etc_filetrans($1, shadow_lock_t, file, ".pwd.lock")
886+
files_etc_filetrans($1, shadow_lock_t, file, "passwd.lock")
887+
files_etc_filetrans($1, shadow_lock_t, file, "group.lock")
888+
',`
889+
refpolicywarn(`$0($*) second parameter is deprecated.')
890+
files_etc_filetrans($1, shadow_t, file, $2)
891+
')
866892
')
867893

868894
########################################

policy/modules/system/authlogin.te

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ term_dontaudit_use_console(updpwd_t)
412412
term_dontaudit_use_unallocated_ttys(updpwd_t)
413413

414414
auth_manage_shadow(updpwd_t)
415+
auth_filetrans_shadow(updpwd_t)
415416
auth_use_nsswitch(updpwd_t)
416417

417418
logging_send_syslog_msg(updpwd_t)

policy/modules/system/systemd.te

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ kernel_read_kernel_sysctls(systemd_sysusers_t)
20772077
selinux_use_status_page(systemd_sysusers_t)
20782078

20792079
auth_manage_shadow(systemd_sysusers_t)
2080-
auth_etc_filetrans_shadow(systemd_sysusers_t)
2080+
auth_filetrans_shadow(systemd_sysusers_t)
20812081
auth_use_nsswitch(systemd_sysusers_t)
20822082

20832083
seutil_libselinux_linked(systemd_sysusers_t)

0 commit comments

Comments
 (0)