summaryrefslogtreecommitdiff
path: root/modules/pam_wheel/pam_wheel.c
diff options
context:
space:
mode:
authorikerexxe <ipedrosa@redhat.com>2020-08-27 09:16:15 +0200
committerTomáš Mráz <tmraz@redhat.com>2020-09-10 09:06:31 +0200
commit9091ea1d81e85f49a221b0325d27b22ce69e444a (patch)
treea86bfe0ac58f06f01db7860260c337efc7526255 /modules/pam_wheel/pam_wheel.c
parent6bf9b454eb971083f0cce49faa2aa1cde329ff5d (diff)
pam_wheel: if getlogin fails fallback to PAM_RUSER
modules/pam_wheel/pam_wheel.c: if getlogin fails to obtain the real user ID, then try with PAM_RUSER. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1866866
Diffstat (limited to 'modules/pam_wheel/pam_wheel.c')
-rw-r--r--modules/pam_wheel/pam_wheel.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/pam_wheel/pam_wheel.c b/modules/pam_wheel/pam_wheel.c
index 94cb7d89..7fa3cfa9 100644
--- a/modules/pam_wheel/pam_wheel.c
+++ b/modules/pam_wheel/pam_wheel.c
@@ -141,6 +141,16 @@ perform_check (pam_handle_t *pamh, int ctrl, const char *use_group)
} else {
fromsu = pam_modutil_getlogin(pamh);
+ /* if getlogin fails try a fallback to PAM_RUSER */
+ if (fromsu == NULL) {
+ const char *rhostname;
+
+ retval = pam_get_item(pamh, PAM_RHOST, (const void **)&rhostname);
+ if (retval != PAM_SUCCESS || rhostname == NULL) {
+ retval = pam_get_item(pamh, PAM_RUSER, (const void **)&fromsu);
+ }
+ }
+
if (fromsu != NULL) {
tpwd = pam_modutil_getpwnam (pamh, fromsu);
}