From 5f7f494d190bb69c4097a7d57692e7d86b0c22a3 Mon Sep 17 00:00:00 2001 From: Yi Zhao Date: Sun, 30 Jun 2024 22:24:57 +0800 Subject: [PATCH] userdomain: allow administrative user to get attributes of shadow history file Before the patch: root@qemux86-64:~# ls -lZ /etc/security/opasswd -?????????? ? ? ? ? ? ? /etc/security/opasswd After the patch: root@qemux86-64:~# ls -lZ /etc/security/opasswd -rw-------. 1 root root user_u:object_r:shadow_history_t 237 Jun 30 12:03 /etc/security/opasswd Signed-off-by: Yi Zhao --- policy/modules/system/authlogin.if | 19 +++++++++++++++++++ policy/modules/system/userdomain.if | 1 + 2 files changed, 20 insertions(+) diff --git a/policy/modules/system/authlogin.if b/policy/modules/system/authlogin.if index fca13171e..51ed1a081 100644 --- a/policy/modules/system/authlogin.if +++ b/policy/modules/system/authlogin.if @@ -745,6 +745,25 @@ interface(`auth_etc_filetrans_shadow',` files_etc_filetrans($1, shadow_t, file, $2) ') +######################################## +## +## Get the attributes of the shadow history file. +## +## +## +## Domain allowed access. +## +## +# +interface(`auth_getattr_shadow_history',` + gen_require(` + type shadow_history_t; + ') + + files_search_etc($1) + allow $1 shadow_history_t:file getattr; +') + ######################################## ## ## Read the shadow history file. diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if index a2a96e263..73bb7c410 100644 --- a/policy/modules/system/userdomain.if +++ b/policy/modules/system/userdomain.if @@ -1428,6 +1428,7 @@ template(`userdom_admin_user_template',` term_use_all_terms($1_t) auth_getattr_shadow($1_t) + auth_getattr_shadow_history($1_t) # Manage almost all files files_manage_non_auth_files($1_t) files_map_non_auth_files($1_t)