Skip to content

Commit 78edaa1

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 db2b934 commit 78edaa1

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
@@ -23,6 +23,15 @@
2323
* tcb.spec: Remove -DENABLE_SETFSUGID.
2424
* ci/run-build-and-tests.sh: Likewise.
2525

26+
2021-10-12 Björn Esser <besser82 at fedoraproject.org>
27+
28+
pam_tcb: Allow for authentication if a system policy requires the
29+
root user to acquire special capabilities.
30+
* pam_tcb/support.c (unix_verify_password_plain): Allow the helper
31+
binary to be run as root if e.g. SELinux prevents access to file
32+
storing the hashed user password.
33+
* progs/tcb_chkpwd.c (unix_verify_password): Likewise.
34+
2635
2021-09-30 Björn Esser <besser82 at fedoraproject.org>
2736

2837
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)