[Bug 1205169] New: With sudo the XDG variables point to SUDO_UID aka calling user instead of 0 aka root
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1205169
Bug ID: 1205169
Summary: With sudo the XDG variables point to SUDO_UID aka
calling user instead of 0 aka root
Classification: openSUSE
Product: openSUSE Tumbleweed
Version: Current
Hardware: All
OS: openSUSE Leap 15.4
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Basesystem
Assignee: screening-team-bugs@suse.de
Reporter: werner@suse.com
QA Contact: qa-bugs@suse.de
CC: zimtsui@gmail.com
Depends on: 1205109
Found By: ---
Blocker: ---
Note that the description below is not fully correct:
/suse/werner> sudo printenv | grep XDG
XDG_CONFIG_DIRS=/etc/xdg:/usr/local/etc/xdg:/usr/etc/xdg
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session11
XDG_MENU_PREFIX=fvwm-
XDG_CONFIG_HOME=/suse/werner/.config
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=
XDG_SESSION_TYPE=x11
XDG_CURRENT_DESKTOP=FVWM
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_CACHE_HOME=/suse/werner/.cache/noether:0
XDG_SESSION_CLASS=user
XDG_DESKTOP_DIR=/suse/werner/Desktop
XDG_SESSION_COOKIE=noether
XDG_VTNR=7
XDG_SESSION_ID=733
XDG_RUNTIME_DIR=/run/user/223
XDG_DATA_DIRS=/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
that is sudo does *not* remove the XDG variables from the ennvirnment nor does
the pam_systemd module set the correct XDG variables.
+++ This bug was initially created as a clone of Bug #1205109 +++
# Description
Emacs checks whether environment variable `XDG_RUNTIME_DIR` exists to determine
where a certain socket file should be placed. If `XDG_RUNTIME_DIR` doesn't
exist, emacs will fallback to some other location. See
https://git.savannah.gnu.org/cgit/emacs.git/tree/lib-src/emacsclient.c?h=ema...
`sudo` defaults to unset all environment variables and set some certain ones.
So any program run by `sudo` should miss `XDG_RUNTIME_DIR` in its environment.
If I run `sudo emacs-nox`, everything goes expectedly. But if I run `sudo
emacs`, emacs prompts `Unable to set up transient service directory:
XDG_RUNTIME_DIR "/run/user/0" not available: No such file or directory`.
# Possible reason
The binary `/usr/bin/emacs` is not built from emacs source, but made by the
SUSE package maintainer. The binary checks whether it's run in terminal or X to
determine whether it should exec `emacs-nox` or `emacs-x11`.
The `/usr/bin/emacs` binary defines an environment variable `XDG_RUNTIME_DIR`
as `/run/user/
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1205169 Bug 1205169 depends on bug 1205109, which changed state. Bug 1205109 Summary: emacs cannot reach XDG_RUNTIME_DIR http://bugzilla.opensuse.org/show_bug.cgi?id=1205109 What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are on the CC list for the bug.
![](https://seccdn.libravatar.org/avatar/a895f78a81a109471893519443e4d933.jpg?s=120&d=mm&r=g)
http://bugzilla.opensuse.org/show_bug.cgi?id=1205169
http://bugzilla.opensuse.org/show_bug.cgi?id=1205169#c3
Dr. Werner Fink
participants (1)
-
bugzilla_noreply@suse.com