Skip to content

Commit

Permalink
newrole: allow newrole to search faillock runtime directory
Browse files Browse the repository at this point in the history
Allow newrole to search the /run/faillock directory, otherwise the
faillock mechanism will not work for neworle.

Before the patch (pam faillock deny=3):
root@intel-x86-64:~# newrole -r sysadm_r
Password:
newrole: incorrect password for root
root@intel-x86-64:~# newrole -r sysadm_r
Password:
newrole: incorrect password for root
root@intel-x86-64:~# newrole -r sysadm_r
Password:
newrole: incorrect password for root
root@intel-x86-64:~# newrole -r sysadm_r
Password:
newrole: incorrect password for root

After the patch (pam faillock deny=3):
root@intel-x86-64:~# newrole  -r sysadm_r
Password:
newrole: incorrect password for root
root@intel-x86-64:~# newrole -r sysadm_r
Password:
newrole: incorrect password for root
root@intel-x86-64:~# newrole -r sysadm_r
Password:
newrole: incorrect password for root
root@intel-x86-64:~# newrole -r sysadm_r
The account is locked due to 3 failed logins.
(1 minute left to unlock)
Password:

Fixes:
avc: denied { search } for pid=508 comm="newrole" name="faillock"
dev="tmpfs" ino=582 scontext=root:sysadm_r:newrole_t:s0-s15:c0.c1023
tcontext=system_u:object_r:faillog_t:s0 tclass=dir permissive=0

Signed-off-by: Yi Zhao <[email protected]>
  • Loading branch information
yizhao1 committed Jun 4, 2024
1 parent 54dfe1e commit 65a4c64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions policy/modules/system/authlogin.if
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,24 @@ interface(`auth_setattr_faillog_files',`
setattr_files_pattern($1, faillog_t, faillog_t)
')

########################################
## <summary>
## Search faillock dirs (/run/faillock).
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
#
interface(`auth_search_faillog_dirs',`
gen_require(`
type faillog_t;
')

allow $1 faillog_t:dir search_dir_perms;
')

#######################################
## <summary>
## Read the last logins log.
Expand Down
1 change: 1 addition & 0 deletions policy/modules/system/selinuxutil.te
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ auth_use_nsswitch(newrole_t)
auth_run_chk_passwd(newrole_t, newrole_roles)
auth_run_upd_passwd(newrole_t, newrole_roles)
auth_rw_faillog(newrole_t)
auth_search_faillog_dirs(newrole_t)

# Write to utmp.
init_rw_utmp(newrole_t)
Expand Down

0 comments on commit 65a4c64

Please sign in to comment.