Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

screensaver: Look at $PKEXEC_UID not $USERHELPER_UID #5068

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/liveinst/liveinst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ if [ "$(id -u)" -ne 0 ]; then
exec pkexec "$0" "$@"
fi

# pkexec clears DBUS_SESSION_BUS_ADDRESS from environment
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${PKEXEC_UID}/bus
fi
Comment on lines +29 to +32
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how many of these issues could impact us. Anyway, let's go one by one :)


# Allow running another command in the place of anaconda, but in this same
# environment. This allows storage testing to make use of all the module
# loading and lvm control in this file, too.
Expand Down
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)