Blame SOURCES/pam-1.3.1-wheel-pam_ruser-fallback.patch

387ec0
From 6bf9b454eb971083f0cce49faa2aa1cde329ff5d Mon Sep 17 00:00:00 2001
387ec0
From: ikerexxe <ipedrosa@redhat.com>
387ec0
Date: Wed, 26 Aug 2020 14:44:23 +0200
387ec0
Subject: [PATCH 1/3] pam_wheel: improve coding style
387ec0
387ec0
modules/pam_wheel/pam_wheel.c: improve indentation and explicitly state
387ec0
condition statements
387ec0
---
387ec0
 modules/pam_wheel/pam_wheel.c | 36 ++++++++++++++++++-----------------
387ec0
 1 file changed, 19 insertions(+), 17 deletions(-)
387ec0
387ec0
diff --git a/modules/pam_wheel/pam_wheel.c b/modules/pam_wheel/pam_wheel.c
387ec0
index a025ebaf..94cb7d89 100644
387ec0
--- a/modules/pam_wheel/pam_wheel.c
387ec0
+++ b/modules/pam_wheel/pam_wheel.c
387ec0
@@ -130,25 +130,27 @@ perform_check (pam_handle_t *pamh, int ctrl, const char *use_group)
387ec0
     }
387ec0
 
387ec0
     if (ctrl & PAM_USE_UID_ARG) {
387ec0
-	tpwd = pam_modutil_getpwuid (pamh, getuid());
387ec0
-	if (!tpwd) {
387ec0
-	    if (ctrl & PAM_DEBUG_ARG) {
387ec0
+        tpwd = pam_modutil_getpwuid (pamh, getuid());
387ec0
+        if (tpwd == NULL) {
387ec0
+            if (ctrl & PAM_DEBUG_ARG) {
387ec0
                 pam_syslog(pamh, LOG_NOTICE, "who is running me ?!");
387ec0
-	    }
387ec0
-	    return PAM_SERVICE_ERR;
387ec0
-	}
387ec0
-	fromsu = tpwd->pw_name;
387ec0
+            }
387ec0
+            return PAM_SERVICE_ERR;
387ec0
+        }
387ec0
+        fromsu = tpwd->pw_name;
387ec0
     } else {
387ec0
-	fromsu = pam_modutil_getlogin(pamh);
387ec0
-	if (fromsu) {
387ec0
-	    tpwd = pam_modutil_getpwnam (pamh, fromsu);
387ec0
-	}
387ec0
-	if (!fromsu || !tpwd) {
387ec0
-	    if (ctrl & PAM_DEBUG_ARG) {
387ec0
-		pam_syslog(pamh, LOG_NOTICE, "who is running me ?!");
387ec0
-	    }
387ec0
-	    return PAM_SERVICE_ERR;
387ec0
-	}
387ec0
+        fromsu = pam_modutil_getlogin(pamh);
387ec0
+
387ec0
+        if (fromsu != NULL) {
387ec0
+            tpwd = pam_modutil_getpwnam (pamh, fromsu);
387ec0
+        }
387ec0
+
387ec0
+        if (fromsu == NULL || tpwd == NULL) {
387ec0
+            if (ctrl & PAM_DEBUG_ARG) {
387ec0
+                pam_syslog(pamh, LOG_NOTICE, "who is running me ?!");
387ec0
+            }
387ec0
+            return PAM_SERVICE_ERR;
387ec0
+        }
387ec0
     }
387ec0
 
387ec0
     /*
387ec0
-- 
387ec0
2.26.2
387ec0
387ec0
387ec0
From 9091ea1d81e85f49a221b0325d27b22ce69e444a Mon Sep 17 00:00:00 2001
387ec0
From: ikerexxe <ipedrosa@redhat.com>
387ec0
Date: Thu, 27 Aug 2020 09:16:15 +0200
387ec0
Subject: [PATCH 2/3] pam_wheel: if getlogin fails fallback to PAM_RUSER
387ec0
387ec0
modules/pam_wheel/pam_wheel.c: if getlogin fails to obtain the real user
387ec0
ID, then try with PAM_RUSER.
387ec0
387ec0
Resolves:
387ec0
https://bugzilla.redhat.com/show_bug.cgi?id=1866866
387ec0
---
387ec0
 modules/pam_wheel/pam_wheel.c | 10 ++++++++++
387ec0
 1 file changed, 10 insertions(+)
387ec0
387ec0
diff --git a/modules/pam_wheel/pam_wheel.c b/modules/pam_wheel/pam_wheel.c
387ec0
index 94cb7d89..7fa3cfa9 100644
387ec0
--- a/modules/pam_wheel/pam_wheel.c
387ec0
+++ b/modules/pam_wheel/pam_wheel.c
387ec0
@@ -141,6 +141,16 @@ perform_check (pam_handle_t *pamh, int ctrl, const char *use_group)
387ec0
     } else {
387ec0
         fromsu = pam_modutil_getlogin(pamh);
387ec0
 
387ec0
+        /* if getlogin fails try a fallback to PAM_RUSER */
387ec0
+        if (fromsu == NULL) {
387ec0
+            const char *rhostname;
387ec0
+
387ec0
+            retval = pam_get_item(pamh, PAM_RHOST, (const void **)&rhostname);
387ec0
+            if (retval != PAM_SUCCESS || rhostname == NULL) {
387ec0
+                retval = pam_get_item(pamh, PAM_RUSER, (const void **)&fromsu);
387ec0
+            }
387ec0
+        }
387ec0
+
387ec0
         if (fromsu != NULL) {
387ec0
             tpwd = pam_modutil_getpwnam (pamh, fromsu);
387ec0
         }
387ec0
-- 
387ec0
2.26.2
387ec0
387ec0
387ec0
From a3a5cbf86083c43026b558e2023f597530626267 Mon Sep 17 00:00:00 2001
387ec0
From: ikerexxe <ipedrosa@redhat.com>
387ec0
Date: Wed, 9 Sep 2020 10:32:03 +0200
387ec0
Subject: [PATCH 3/3] pam_wheel: clarify use_uid option in man page
387ec0
387ec0
modules/pam_wheel/pam_wheel.8.xml: indicate that use_uid option uses the
387ec0
real uid of the calling process.
387ec0
---
387ec0
 modules/pam_wheel/pam_wheel.8.xml | 6 +++---
387ec0
 1 file changed, 3 insertions(+), 3 deletions(-)
387ec0
387ec0
diff --git a/modules/pam_wheel/pam_wheel.8.xml b/modules/pam_wheel/pam_wheel.8.xml
387ec0
index b32f5e2b..ee8c7d26 100644
387ec0
--- a/modules/pam_wheel/pam_wheel.8.xml
387ec0
+++ b/modules/pam_wheel/pam_wheel.8.xml
387ec0
@@ -122,9 +122,9 @@
387ec0
         </term>
387ec0
         <listitem>
387ec0
           <para>
387ec0
-            The check for wheel membership will be done against
387ec0
-            the current uid instead of the original one (useful when
387ec0
-            jumping with su from one account to another for example).
387ec0
+            The check will be done against the real uid of the calling process,
387ec0
+            instead of trying to obtain the user from the login session
387ec0
+            associated with the terminal in use.
387ec0
           </para>
387ec0
         </listitem>
387ec0
       </varlistentry>
387ec0
-- 
387ec0
2.26.2
387ec0