If we can't make polkit provide the desired information without real authentication attempts, and since this is a GUI issue and not a security issue, maybe a gsettings key could be a sufficient solution to this bug.
try:
gsettings_value = subprocess.check_output(
['gsettings', 'get', 'com.ubuntu.language-selector', 'no-greyed-out-admin-buttons']).decode().rstrip()
except subprocess.CalledProcessError:
gsettings_value = 'false'
if gsettings_value == 'true':
self.is_admin = True
else:
# find out if user has admin privileges via unix groups
try: in_grp_admin = grp.getgrnam("admin")[2] in os.getgroups()
except KeyError: in_grp_admin = False
try:
in_grp_sudo = grp.getgrnam("sudo")[2] in os.getgroups()
except KeyError:
in_grp_sudo = False
self.is_admin = (os.getuid() == 0 or in_grp_sudo or in_grp_admin)
Then, when giving a user admin privileges without using the "sudo" or "admin" unix group, changing the value of the gsettings key for that user would prevent the buttons in question from being greyed out.
If we can't make polkit provide the desired information without real authentication attempts, and since this is a GUI issue and not a security issue, maybe a gsettings key could be a sufficient solution to this bug.
try: check_output( language- selector' ,
'no-greyed- out-admin- buttons' ]).decode( ).rstrip( ) CalledProcessEr ror:
in_grp_ admin = grp.getgrnam( "admin" )[2] in os.getgroups()
in_grp_ admin = False "sudo") [2] in os.getgroups()
gsettings_value = subprocess.
['gsettings', 'get', 'com.ubuntu.
except subprocess.
gsettings_value = 'false'
if gsettings_value == 'true':
self.is_admin = True
else:
# find out if user has admin privileges via unix groups
try:
except KeyError:
try:
in_grp_sudo = grp.getgrnam(
except KeyError:
in_grp_sudo = False
self.is_admin = (os.getuid() == 0 or in_grp_sudo or in_grp_admin)
Then, when giving a user admin privileges without using the "sudo" or "admin" unix group, changing the value of the gsettings key for that user would prevent the buttons in question from being greyed out.