Blame SOURCES/hplip-check-userperms.patch

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