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=emacs-27.2#n1393> `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/<USER_ID>` arbitrarily. But `/run/user/0` doesn't exist because it should be created by `/etc/profile` in a login shell. And `sudo` doesn't spawn a new login shell. # Reproduction 1. Install `emacs` and `emcas-nox` from zypper, and don't install `emacs-x11`. 1. Restart your computer and don't login as root in any tty, but login as a regular user. 1. `sudo emacs` 1. Quit emacs. 1. You will see the prompt. # Versions openSUSE Leap 15.4 Emacs 27.2 Sudo 1.9.9