Skip to content

Commit

Permalink
screensaver: Look at $PKEXEC_UID not $USERHELPER_UID
Browse files Browse the repository at this point in the history
Since commit 919be1d anaconda has
been using pkexec instead of consolehelper to get root privileges
on the live image.

This caused a regression on the KDE live image, because anaconda
was trying to inhibit the screensaver as the $USERHELPER_UID user
which no longer gets set.

This commit changes the code to use $PKEXEC_UID which is the polkit
equivalent.
  • Loading branch information
halfline committed Aug 22, 2023
1 parent aa741a5 commit a260c76
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyanaconda/screensaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@
inhibit_id = None


class SetEuidFromConsolehelper():
class SetEuidFromPkexec():
"""Context manager to temporarily set euid from env. variable set by consolehelper.
Live installs use consolehelper to run as root, which sets the original UID in $USERHELPER_UID.
Live installs use pkexec to run as root, which sets the original UID in $PKEXEC_UID.
"""
def __init__(self):
self.old_euid = None

def __enter__(self):
if "USERHELPER_UID" in os.environ:
if "PKEXEC_UID" in os.environ:
self.old_euid = os.geteuid()
new_euid = int(os.environ["USERHELPER_UID"])
new_euid = int(os.environ["PKEXEC_UID"])
os.seteuid(new_euid)
return self

Expand All @@ -87,7 +87,7 @@ def inhibit_screensaver():
global session_proxy
global inhibit_id
try:
with SetEuidFromConsolehelper():
with SetEuidFromPkexec():
SCREENSAVER = DBusServiceIdentifier(
namespace=("org", "freedesktop", "ScreenSaver"),
message_bus=SessionMessageBus()
Expand All @@ -104,7 +104,7 @@ def uninhibit_screensaver():
return
log.info("Un-inhibiting screensaver.")
try:
with SetEuidFromConsolehelper():
with SetEuidFromPkexec():
session_proxy.UnInhibit(inhibit_id)
except (DBusError, KeyError) as e:
log.warning("Unable to uninhibit the screensaver: %s", e)

4 comments on commit a260c76

@X3MBoy
Copy link

@X3MBoy X3MBoy commented on a260c76 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also causing a regression on Fedora i3 39 Beta

@VladimirSlavik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you open a bug, please?

@X3MBoy
Copy link

@X3MBoy X3MBoy commented on a260c76 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Should I open it here?

@VladimirSlavik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, no, on Fedora bugzilla, anaconda component. Please include details on how anaconda runs in this spin.

Please sign in to comment.