Bug 425253 - systemd related commit breaks exporting env vars
Summary: systemd related commit breaks exporting env vars
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: master
Platform: Other Linux
: VHI normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-08-12 12:41 UTC by Ahmad Samir
Modified: 2020-08-25 14:11 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
output of env (2.27 KB, text/plain)
2020-08-14 12:02 UTC, Ahmad Samir
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmad Samir 2020-08-12 12:41:57 UTC
With commit 57438d6dfe4ecb1ae022775401f5c7bcbf2a93da[1], if I login, with SDDM Plasma X11, some environment variables aren't exported for some reason, e.g.:

XDG_SESSION_DESKTOP=KDE
XDG_CURRENT_DESKTOP=KDE
KDE_SESSION_UID=1000
KDE_SESSION_VERSION=5
KDE_FULL_SESSION=true

also some stuff that I have in ~/.profile; that means the session is broken for me since Qt sets the hidpi scaling stuff.

As a temporary hack, making SystemdProcessRunner::isAvailable() always return false fixes the issue for me.

[1] https://invent.kde.org/frameworks/kio/-/commit/57438d6dfe4ecb1ae022775401f5c7bcbf2a93da
Comment 1 David Edmundson 2020-08-12 12:50:37 UTC
What's happening is we're now relying on systemd to the launching which should fix some other bugs, but that relies on systemd having the right environment.

A quite major bug means that calling dbus-update-activation-environment --all --systemd

Fails if any one var contains the symbol \033

This should be worked around with:
https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/198
Comment 2 Ahmad Samir 2020-08-12 12:57:36 UTC
OK, I'll test that and report back. (And systemd... is just weird).

Thanks :)
Comment 3 Nate Graham 2020-08-12 14:23:08 UTC
Can confirm. For example this broke GDK_* env vars which causes GTK-based software to be tiny on high DPI setups.
Comment 4 Ahmad Samir 2020-08-12 15:24:10 UTC
I built plasma-workspace from git master, with the change from MR 198 included, and still hit this issue. (The hack I mentioned in the OP still works though).

Note that, AFAICS, the issue doesn't happen when I log in to "plasma (full wayland)" session.
Comment 5 David Edmundson 2020-08-12 15:29:02 UTC
Can I see the output of:

qdbus org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.Environment


dbus-update-activation-environment --all --systemd

from a terminal to make sure we're talking the same bug?
Comment 6 Ahmad Samir 2020-08-12 17:08:21 UTC
$ qdbus-qt5 org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.Environment
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
HOME=/home/ahmad
LANG=en_US.UTF-8
LOGNAME=ahmad
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/bin/bash
USER=ahmad
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/ahmad/.gtkrc-2.0:/home/ahmad/.config/gtkrc-2.0
GTK_RC_FILES=/etc/gtk/gtkrc:/home/ahmad/.gtkrc:/home/ahmad/.config/gtkrc
XAUTHORITY=/run/user/1000/xauth_FbfOei
XCURSOR_SIZE=36
XCURSOR_THEME=breeze_cursors


$ dbus-update-activation-environment --all --systemd --verbose
dbus-update-activation-environment: setting SHELL=/bin/bash
dbus-update-activation-environment: setting WINDOWID=83886087
dbus-update-activation-environment: setting COLORTERM=truecolor
dbus-update-activation-environment: setting LANGUAGE=
dbus-update-activation-environment: setting SHELL_SESSION_ID=bfa26dfc07b24a3aa600ba5435046206
dbus-update-activation-environment: setting GTK_RC_FILES=/etc/gtk/gtkrc:/home/ahmad/.gtkrc:/home/ahmad/.config/gtkrc
dbus-update-activation-environment: setting XCURSOR_SIZE=36
dbus-update-activation-environment: setting GPG_TTY=/dev/pts/1
dbus-update-activation-environment: setting PWD=/home/ahmad
dbus-update-activation-environment: setting LOGNAME=ahmad
dbus-update-activation-environment: setting XAUTHORITY=/run/user/1000/xauth_FbfOei
dbus-update-activation-environment: setting LS_OPTIONS=-N --color=tty -T 0
dbus-update-activation-environment: setting GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/ahmad/.gtkrc-2.0:/home/ahmad/.config/gtkrc-2.0
dbus-update-activation-environment: setting HOME=/home/ahmad
dbus-update-activation-environment: setting LANG=en_US.UTF-8
dbus-update-activation-environment: setting KONSOLE_DBUS_SERVICE=:1.90
dbus-update-activation-environment: setting KONSOLE_DBUS_SESSION=/Sessions/1
dbus-update-activation-environment: setting PROFILEHOME=
dbus-update-activation-environment: setting INVOCATION_ID=445e69f49d394213958a6722dc3c5d13
dbus-update-activation-environment: setting KONSOLE_VERSION=200403
dbus-update-activation-environment: setting MANAGERPID=3763
dbus-update-activation-environment: setting TERM=xterm-256color
dbus-update-activation-environment: setting USER=ahmad
dbus-update-activation-environment: setting COLORFGBG=15;0
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting SHLVL=1
dbus-update-activation-environment: setting XDG_RUNTIME_DIR=/run/user/1000
dbus-update-activation-environment: setting JOURNAL_STREAM=8:76101
dbus-update-activation-environment: setting XCURSOR_THEME=breeze_cursors
dbus-update-activation-environment: setting PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting KONSOLE_DBUS_WINDOW=/Windows/1
dbus-update-activation-environment: setting _=/usr/bin/dbus-update-activation-environment
Comment 7 Ahmad Samir 2020-08-12 17:13:30 UTC
That ^ was when stuff are broken. Now with the isAvailable() hack from the OP, and stuff working properly:
$ qdbus-qt5 org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager.Environment
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
HOME=/home/ahmad
LANG=en_US.UTF-8
LOGNAME=ahmad
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/bin/bash
USER=ahmad
XDG_RUNTIME_DIR=/run/user/1000
COLORFGBG=15;0
COLORTERM=truecolor
DISPLAY=:0
GPG_TTY=/dev/pts/1
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/ahmad/.gtkrc-2.0:/home/ahmad/.config/gtkrc-2.0
GTK_RC_FILES=/etc/gtk/gtkrc:/home/ahmad/.gtkrc:/home/ahmad/.config/gtkrc
KONSOLE_DBUS_SERVICE=:1.90
KONSOLE_DBUS_SESSION=/Sessions/1
KONSOLE_DBUS_WINDOW=/Windows/1
KONSOLE_VERSION=200403
LANGUAGE=
LS_OPTIONS=-N --color=tty -T 0
PROFILEHOME=
PWD=/home/ahmad
SHELL_SESSION_ID=bfa26dfc07b24a3aa600ba5435046206
SHLVL=1
TERM=xterm-256color
WINDOWID=83886087
XAUTHORITY=/run/user/1000/xauth_mWfKbR
XCURSOR_SIZE=36
XCURSOR_THEME=breeze_cursors
_=/usr/bin/dbus-update-activation-environment


$ dbus-update-activation-environment --all --systemd --verbose
dbus-update-activation-environment: setting SHELL=/bin/bash
dbus-update-activation-environment: setting SESSION_MANAGER=local/homeBox:@/tmp/.ICE-unix/21388,unix/homeBox:/tmp/.ICE-unix/21388
dbus-update-activation-environment: setting WINDOWID=37748743
dbus-update-activation-environment: setting QT_SCREEN_SCALE_FACTORS=DP1=1;HDMI1=1;HDMI2=1;HDMI3=1;VGA1=1;VIRTUAL1=1;
dbus-update-activation-environment: setting COLORTERM=truecolor
dbus-update-activation-environment: setting XDG_CONFIG_DIRS=/etc/xdg
dbus-update-activation-environment: setting LESS=-RMicJj.2
dbus-update-activation-environment: setting XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session11
dbus-update-activation-environment: setting HISTCONTROL=ignoredups:erasedups:ignorespace
dbus-update-activation-environment: setting GTK_IM_MODULE=cedilla
dbus-update-activation-environment: setting MACHTYPE=x86_64-suse-linux
dbus-update-activation-environment: setting G_BROKEN_FILENAMES=1
dbus-update-activation-environment: setting HOSTNAME=homeBox
dbus-update-activation-environment: setting HISTSIZE=50000
dbus-update-activation-environment: setting LANGUAGE=en_US:en_GB
dbus-update-activation-environment: setting FROM_HEADER=
dbus-update-activation-environment: setting MINICOM=-c on
dbus-update-activation-environment: setting FREETYPE_PROPERTIES=truetype:interpreter-version=35
dbus-update-activation-environment: setting KDE_DEBUG=1
dbus-update-activation-environment: setting JAVA_ROOT=/usr/lib64/jvm/jre-openjdk
dbus-update-activation-environment: setting JAVA_HOME=/usr/lib64/jvm/jre-openjdk
dbus-update-activation-environment: setting AUDIODRIVER=pulseaudio
dbus-update-activation-environment: setting USE_CCACHE=0
dbus-update-activation-environment: setting JRE_HOME=/usr/lib64/jvm/java-11-openjdk-11
dbus-update-activation-environment: setting INPUT_METHOD=none
dbus-update-activation-environment: setting CPU=x86_64
dbus-update-activation-environment: setting SHELL_SESSION_ID=28d2573e1a444b81a606f6e3908b63d1
dbus-update-activation-environment: setting JAVA_BINDIR=/usr/lib64/jvm/jre-openjdk/bin
dbus-update-activation-environment: setting MAN_POSIXLY_CORRECT=1
dbus-update-activation-environment: setting XMODIFIERS=@im=local
dbus-update-activation-environment: setting DESKTOP_SESSION=/usr/share/xsessions/plasma5
dbus-update-activation-environment: setting LC_MONETARY=C
dbus-update-activation-environment: setting GTK_RC_FILES=/etc/gtk/gtkrc:/home/ahmad/.gtkrc:/home/ahmad/.config/gtkrc
dbus-update-activation-environment: setting XCURSOR_SIZE=36
dbus-update-activation-environment: setting GPG_TTY=/dev/pts/0
dbus-update-activation-environment: setting EDITOR=vim
dbus-update-activation-environment: setting XDG_SEAT=seat0
dbus-update-activation-environment: setting PWD=/home/ahmad
dbus-update-activation-environment: setting QEMU_AUDIO_DRV=pa
dbus-update-activation-environment: setting XDG_SESSION_DESKTOP=KDE
dbus-update-activation-environment: setting LOGNAME=ahmad
dbus-update-activation-environment: setting XDG_SESSION_TYPE=x11
dbus-update-activation-environment: setting MANOPT=--nj
dbus-update-activation-environment: setting MANPATH=/usr/local/man:/usr/local/share/man:/usr/share/man
dbus-update-activation-environment: setting XAUTHORITY=/run/user/1000/xauth_mWfKbR
dbus-update-activation-environment: setting LS_OPTIONS=-N --color=tty -T 0
dbus-update-activation-environment: setting XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
dbus-update-activation-environment: setting GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/ahmad/.gtkrc-2.0:/home/ahmad/.config/gtkrc-2.0
dbus-update-activation-environment: setting XNLSPATH=/usr/X11R6/lib/X11/nls
dbus-update-activation-environment: setting HOME=/home/ahmad
dbus-update-activation-environment: setting LANG=en_GB.UTF-8
dbus-update-activation-environment: setting XDG_CURRENT_DESKTOP=KDE
dbus-update-activation-environment: setting KONSOLE_DBUS_SERVICE=:1.118
dbus-update-activation-environment: setting KONSOLE_DBUS_SESSION=/Sessions/1
dbus-update-activation-environment: setting PROFILEHOME=
dbus-update-activation-environment: setting OSTYPE=linux
dbus-update-activation-environment: setting XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
dbus-update-activation-environment: setting QT_IM_SWITCHER=imsw-multi
dbus-update-activation-environment: setting LESS_ADVANCED_PREPROCESSOR=no
dbus-update-activation-environment: setting KONSOLE_VERSION=200403
dbus-update-activation-environment: setting QML_DISABLE_DISTANCEFIELD=1
dbus-update-activation-environment: setting XSESSION_IS_UP=yes
dbus-update-activation-environment: setting KDE_SESSION_UID=1000
dbus-update-activation-environment: setting GEM_HOME=/home/ahmad/Blog/gems
dbus-update-activation-environment: setting PKGSYSTEM_ENABLE_FSYNC=0
dbus-update-activation-environment: setting LESSCLOSE=
dbus-update-activation-environment: setting XDG_SESSION_CLASS=user
dbus-update-activation-environment: setting TERM=xterm-256color
dbus-update-activation-environment: setting G_FILENAME_ENCODING=@locale,UTF-8,ISO-8859-15,CP1252
dbus-update-activation-environment: setting HOST=homeBox
dbus-update-activation-environment: setting LESSOPEN=
dbus-update-activation-environment: setting USER=ahmad
dbus-update-activation-environment: setting SDL_AUDIODRIVER=pulse
dbus-update-activation-environment: setting COLORFGBG=15;0
dbus-update-activation-environment: setting KDE_SESSION_VERSION=5
dbus-update-activation-environment: setting MORE=-sl
dbus-update-activation-environment: setting CSHEDIT=emacs
dbus-update-activation-environment: setting DISPLAY=:0
dbus-update-activation-environment: setting SHLVL=1
dbus-update-activation-environment: setting WINDOWMANAGER=/usr/bin/startplasma-x11
dbus-update-activation-environment: setting PAGER=less
dbus-update-activation-environment: setting QT_IM_MODULE=xim
dbus-update-activation-environment: setting SYSTEMD_PAGER=less
dbus-update-activation-environment: setting LC_MEASUREMENT=C
dbus-update-activation-environment: setting XDG_VTNR=7
dbus-update-activation-environment: setting XDG_SESSION_ID=11
dbus-update-activation-environment: setting SYSTEMD_LESS=RMiaj5c+X
dbus-update-activation-environment: setting XDG_RUNTIME_DIR=/run/user/1000
dbus-update-activation-environment: setting LC_TIME=en_GB.UTF-8
dbus-update-activation-environment: setting QT_AUTO_SCREEN_SCALE_FACTOR=0
dbus-update-activation-environment: setting LC_COLLATE=en_GB.UTF-8
dbus-update-activation-environment: setting XCURSOR_THEME=breeze_cursors
dbus-update-activation-environment: setting XDG_DATA_DIRS=/usr/local/share:/usr/share
dbus-update-activation-environment: setting KDE_FULL_SESSION=true
dbus-update-activation-environment: setting PATH=/home/ahmad/.bin:/home/ahmad/Blog/gems/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/bin
dbus-update-activation-environment: setting QT_ENABLE_HIGHDPI_SCALING=0
dbus-update-activation-environment: setting HISTFILESIZE=50000
dbus-update-activation-environment: setting DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
dbus-update-activation-environment: setting PROFILEREAD=true
dbus-update-activation-environment: setting KDE_APPLICATIONS_AS_SCOPE=1
dbus-update-activation-environment: setting MAIL=/var/spool/mail/ahmad
dbus-update-activation-environment: setting HOSTTYPE=x86_64
dbus-update-activation-environment: setting LESSKEY=/home/ahmad/.lesskey.bin
dbus-update-activation-environment: setting LC_NUMERIC=C
dbus-update-activation-environment: setting KONSOLE_DBUS_WINDOW=/Windows/1
dbus-update-activation-environment: setting BASH_FUNC_mc%%=() {  . /usr/share/mc/mc-wrapper.sh
}
dbus-update-activation-environment: setting _=/usr/bin/dbus-update-activation-environment
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.InvalidArgs: Invalid environment assignments
Comment 8 David Edmundson 2020-08-13 15:19:38 UTC
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.InvalidArgs: Invalid environment assignments

Ok, same root bug - which is good.

But if you've applied my patches, potentially it's a different non-printable character messing it up? Maybe I should change my validation to be a whitelist instead of a blacklist.

Can I have the output of env > someFile to try and find which one it is.
Comment 9 Ahmad Samir 2020-08-14 11:45:32 UTC
Your post gave me an idea, so I ran a for loop and unset the env vars one by one and checked dbus-update-activation-environment output, it turns out un-setting XDG_RUNTIME_DIR makes the dbus command not give the warning. Looking closer it seems that deleting /run/user/<user id>/systemd/ makes dbus-update-activation-environment work.

The contest of the "systemd" dir are:
$ file *
notify:  socket
private: socket
units:   directory

$ file units/*
units/invocation:at-spi-dbus-bus.service: broken symbolic link to c2ba627c3ca748859356659127411e20
units/invocation:dbus.service:            broken symbolic link to 4e21c9c301ad4becbde8b93d23f5e868
units/invocation:dbus.socket:             broken symbolic link to 2560e237ecd44211b10f2513018b98e7
units/invocation:pulseaudio.service:      broken symbolic link to 25547a4bbe8b488ebb37ed535438c3a3
Comment 10 David Edmundson 2020-08-14 11:47:46 UTC
I suspect (if it's the same bug) that XDG_RUNTIME_DIR contains some unprintable character in the bye string

Could I still have "env > someFile" so I can open it in a hex editor?
Comment 11 Ahmad Samir 2020-08-14 12:02:05 UTC
Created attachment 130865 [details]
output of env

This is from a new user account, to rule out any custom stuff I have in my regular account (have had for too many years, with some many changes, some of which I've even forgotten I'd had).
Comment 12 David Edmundson 2020-08-14 13:23:00 UTC
Just to confirm that file is from a setup which hit the error when doing dbus-update-activation-environment --all --systemd?
Comment 13 Ahmad Samir 2020-08-14 13:46:03 UTC
(In reply to David Edmundson from comment #12)
> Just to confirm that file is from a setup which hit the error when doing
> dbus-update-activation-environment --all --systemd?

Yeah, same system, different user, same error.
Comment 14 David Edmundson 2020-08-14 13:47:24 UTC
Ok. I can't see it in my hex editor.

I'm going to change our validation check regardless, then ask you to retest it.
Comment 15 David Edmundson 2020-08-14 23:04:36 UTC
Can you cherry-pick this:

https://invent.kde.org/plasma/plasma-workspace/commit/ee1b939e19de2895ff04816661dc9d02492f880c

and report back. Then I'll make an official MR
Comment 16 Ahmad Samir 2020-08-14 23:38:03 UTC
Yeah! that works, dbus-update-activation-environment --all --systemd --verbose now doesn't print that warning/error, and all env vars are exported :)

Thanks! (you saved me from spending more time trying to get qdbus to call "an array of strings" aka type="as" from the CLI, which I don't know the magic incantation of :)).
Comment 17 Ahmad Samir 2020-08-19 18:07:20 UTC
Friendly ping.
Comment 18 Bug Janitor Service 2020-08-21 12:33:20 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/224