hplip/hplip-check-userperms.patch
DistroBaker 7e89c8f2d8 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/hplip.git#2015e140a3fde37fed190f5e80df683de35b5d8f
2020-11-22 17:31:54 +00:00

34 lines
1019 B
Diff

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