Skip to content

Commit 2e1dc55

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 <aerusso@aerusso.net>
1 parent d81aace commit 2e1dc55

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

policy/modules/admin/dpkg.te

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ term_use_all_terms(dpkg_script_t)
286286

287287
files_manage_non_auth_files(dpkg_script_t)
288288

289-
auth_etc_filetrans_shadow(dpkg_script_t, "shadow.upwd-write")
289+
auth_etc_filetrans_shadow(dpkg_script_t)
290290
auth_manage_shadow(dpkg_script_t)
291291

292292
init_all_labeled_script_domtrans(dpkg_script_t)

policy/modules/system/authlogin.if

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,18 +732,22 @@ interface(`auth_manage_shadow',`
732732
## Domain allowed access.
733733
## </summary>
734734
## </param>
735-
## <param name="name" optional="true">
736-
## <summary>
737-
## The name of the object being created.
738-
## </summary>
739-
## </param>
740735
#
741736
interface(`auth_etc_filetrans_shadow',`
742737
gen_require(`
743738
type shadow_t;
744739
')
745740

746-
files_etc_filetrans($1, shadow_t, file, $2)
741+
ifelse(`$2',`',`
742+
files_etc_filetrans($1, shadow_t, file, "shadow")
743+
files_etc_filetrans($1, shadow_t, file, "shadow-")
744+
files_etc_filetrans($1, shadow_t, file, "shadow.upwd-write")
745+
files_etc_filetrans($1, shadow_t, file, "gshadow")
746+
files_etc_filetrans($1, shadow_t, file, "gshadow-")
747+
',`
748+
refpolicywarn(`$0($*) second parameter is deprecated.')
749+
files_etc_filetrans($1, shadow_t, file, $2)
750+
')
747751
')
748752

749753
########################################
@@ -863,6 +867,9 @@ interface(`auth_rw_shadow_lock',`
863867
')
864868

865869
allow $1 shadow_lock_t:file rw_file_perms;
870+
files_etc_filetrans($1, shadow_lock_t, file, ".pwd.lock")
871+
files_etc_filetrans($1, shadow_lock_t, file, "passwd.lock")
872+
files_etc_filetrans($1, shadow_lock_t, file, "group.lock")
866873
')
867874

868875
########################################

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_etc_filetrans_shadow(updpwd_t)
415416
auth_use_nsswitch(updpwd_t)
416417

417418
logging_send_syslog_msg(updpwd_t)

0 commit comments

Comments
 (0)