Skip to content

Commit 4d2484f

Browse files
committed
Allow the helper binary to be run as root.
This is needed if e.g. SELinux prevents access to file storing the hashed user password. Signed-off-by: Björn Esser <[email protected]>
1 parent b6ce07b commit 4d2484f

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@
9999
* tcb.spec: Remove -DENABLE_SETFSUGID.
100100
* ci/run-build-and-tests.sh: Likewise.
101101

102+
2021-10-12 Björn Esser <besser82 at fedoraproject.org>
103+
104+
pam_tcb: Allow for authentication if a system policy requires the
105+
root user to acquire special capabilities.
106+
* pam_tcb/support.c (unix_verify_password_plain): Allow the helper
107+
binary to be run as root if e.g. SELinux prevents access to file
108+
storing the hashed user password.
109+
* progs/tcb_chkpwd.c (unix_verify_password): Likewise.
110+
102111
2021-09-30 Björn Esser <besser82 at fedoraproject.org>
103112

104113
pam_tcb: Fix "-Wpedantic".

pam_tcb/support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ static int unix_verify_password_plain(pam_handle_t *pamh,
475475
if (!salt) {
476476
/* we're not faking, we have an existing user, so... */
477477
uid_t uid = getuid();
478-
if (uid == geteuid() && uid == pw->pw_uid && uid != 0) {
479-
/* We are not root perhaps this is the reason? */
478+
if (uid == geteuid() && (uid == pw->pw_uid || uid == 0)) {
479+
/* We are not privileged enough perhaps this is the reason? */
480480
D(("running helper binary"));
481481
retval = unix_run_helper_binary(user, pass);
482482
} else {

progs/tcb_chkpwd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ static int unix_verify_password(const char *user, const char *pass, int nullok)
4343

4444
stored_hash = NULL;
4545
if (pw) {
46-
if (getuid() != pw->pw_uid)
46+
uid_t uid = getuid();
47+
if (uid != pw->pw_uid && uid != 0)
4748
return AUTH_FAILED;
4849

4950
if (!strcmp(pw->pw_passwd, "x")) {

0 commit comments

Comments
 (0)