Blame SOURCES/hplip-check-userperms.patch

7a2b19
diff --git a/base/password.py b/base/password.py
7a2b19
index bd68f2a..bff9f80 100644
7a2b19
--- a/base/password.py
7a2b19
+++ b/base/password.py
7a2b19
@@ -157,6 +157,28 @@ class Password(object):
7a2b19
                 log.warn("%s distro is not found in AUTH_TYPES" % distro_name)
7a2b19
                 self.__authType = 'su'
7a2b19
 
7a2b19
+        # check if caller is in wheel group - use 'su' if he isnt -
7a2b19
+        # or if the caller is root (just for showing 'root' username)
7a2b19
+        # in the prompt
7a2b19
+        import os
7a2b19
+        from grp import getgrnam
7a2b19
+
7a2b19
+        user = os.getenv('USER')
7a2b19
+
7a2b19
+        try:
7a2b19
+            members = getgrnam('wheel').gr_mem
7a2b19
+        except KeyError:
7a2b19
+            try:
7a2b19
+                members = getgrnam('sudo').gr_mem
7a2b19
+            except:
7a2b19
+                return
7a2b19
+
7a2b19
+        if user in members:
7a2b19
+            self.__authType = 'sudo'
7a2b19
+        else:
7a2b19
+            self.__authType = 'su'
7a2b19
+
7a2b19
+
7a2b19
     def __getPasswordDisplayString(self):
7a2b19
         if self.__authType == "su":
7a2b19
             return "Please enter the root/superuser password: "