You are not logged in.
It seems Arch makes a file ~/.local/share/systemd/user even if XDG variables point elsewhere. (This box has no ~/.local folder.)
The system creates this file "user" as a broken symlink to nonexistent ~/.config/systemd/user. There is not even a ~/.config/systemd folder on this box. Arch or systemd makes the nested folders and then the broken symlink, if I am following.
So I am trying to determine how/where/when this symlink happens. It reappears with each reboot. Is it an Arch issue or systemd behavior? What config files will alter it, if not the XDG variables?
Thanks
Offline
It seems like standard systemd behavior, have a look at http://cgit.freedesktop.org/systemd/sys … h-lookup.c around line 100 and down.
Offline
Thank you very much, qinohe. That was good sleuthing.
I think the code there intends a different result than I see. I suspect a C syntax bug or even a compiler bug. The goto statement has been massively deprecated in C for donkey's years. It may not get all the unit testing that it should. I'm surprised to see it in systemd at all.
Anyway I asked the experts.
Offline
Is XDG_DATA_HOME supposed to be set? It's empty here - and systemd also links to the non-existent destination - I just never noticed before.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
Thank you very much, qinohe. That was good sleuthing.
I think the code there intends a different result than I see. I suspect a C syntax bug or even a compiler bug. The goto statement has been massively deprecated in C for donkey's years. It may not get all the unit testing that it should. I'm surprised to see it in systemd at all.
Anyway I asked the experts.
You're welcome,, well mind you that I don't speak 'C' yet, I'm on lesson 7 on CS, that's in the beginning, however, that code I referred to seamed very clear to me.
I didn't know 'goto' was deprecated, for instance
Is XDG_DATA_HOME supposed to be set? It's empty here - and systemd also links to the non-existent destination - I just never noticed before.
The code says
We look in both the config and the data dirs because we
want to encourage that distributors ship their unit files
as data, and allow overriding as configuration.
Maybe this base dir.specs shed some light http://standards.freedesktop.org/basedi … c-0.6.html
Offline
@OP
As pointed in one of the mails, the user@ service is started without XDG_DATA_HOME set. That's why it uses the default values ($HOME/.config and $HOME/.local/share).
Assuming you set your $XDG_DATA_HOME in $HOME/.profile, here is a possible solution:
$ cat /etc/systemd/system/user@.service
.include /usr/lib/systemd/system/user@.service
[Service]
Environment=SHELL=%s
Environment=XDG_RUNTIME_DIR=/run/user/%I
ExecStart=
ExecStart=/etc/systemd/systemd-user-env
$ cat /etc/systemd/systemd-user-env
#!/bin/sh
if [ -r /etc/profile ]; then
. /etc/profile
fi
if [ -r "$HOME/.profile" ]; then
. "$HOME/.profile"
fi
exec /usr/lib/systemd/systemd --user
$ stat -c %A /etc/systemd/systemd-user-env
-rwxr-xr-x
(This will also fix the "/bin/false" error).
About goto: it is used very widely e.g. in the kernel, and can produce more readable code *if used correctly*. It's not a matter of "eliminate all gotos", it's "use goto only where it makes sense"; use Google for examples and reasoning. So no, it is by no means deprecated.
Offline
@falconindy & @ msthev, I thank you both.
msthev, thanks for explaining it.
Offline
I don't set XDG_DATA_HOME at all:
$ printenv | grep XDG
XDG_VTNR=7
XDG_SESSION_ID=1
XDG_SEAT=seat0
XDG_DATA_DIRS=/usr/share:/usr/share:/usr/local/share
XDG_RUNTIME_DIR=/run/user/1000
XDG_CURRENT_DESKTOP=KDE
I feel like I'm missing something here - that I somehow missed a step when I installed or updated Arch or something.
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
You didn't miss anything — these variables are not required. If they are not set, programs will (or at least should) just use default values. If you want to use paths other than default ones, then you can set those — it's good to just set/change 3 variables and be done.
Offline
So the three would be
XDG_DATA_HOME # defaults to ${HOME}/.local/share
XDG_CONFIG_HOME # defaults to ${HOME}/.config
XDG_CACHE_HOME # defaults to ${HOME}/.cache
But then also:
XDG_RUNTIME_DIR # defaults to /run/user/<user's id>
XDG_DATA_DIRS # defaults to /usr/share:/usr/share:/usr/local/share on my system, I think
XDG_CONFIG_DIRS # defaults to /etc/xdg
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
As pointed in one of the mails, the user@ service is started without XDG_DATA_HOME set. That's why it uses the default values ($HOME/.config and $HOME/.local/share).
Thank you so much for this clarification! I already had my XDG_*_HOME variables set in /etc/profile.d/custom.sh, but ~/.local was still being created. Using the info you provided, plus some research, I was able to come up with an alternate solution that works well for me.
mkdir -p /etc/systemd/system/user@.service.d
cat >> /etc/systemd/system/user@.service.d/env.conf << EOF
[Service]
Environment=XDG_CONFIG_HOME=%h/.xdg/config
Environment=XDG_CACHE_HOME=%h/.xdg/cache
Environment=XDG_DATA_HOME=%h/.xdg/data
EOF
Works like a charm. I was finally able to delete ~/.local and keep it that way.
Offline
The ideas here look good. A different way is adding lines in /etc/security/pam_env.conf
XDG_CACHE_HOME DEFAULT=/tmp/XDG_CACHE_HOME_@{PAM_USER}
XDG_DATA_HOME DEFAULT=/tmp/XDG_DATA_HOME_@{PAM_USER}
GOTO debates never die but deprecation is common knowledge in CS departments and industry at large as far as I can tell.
Everyone has used the odd GOTO, me too. They are no surprise in a kernel. They're legacy from assembly and C was conceived as "portable assembly." Kernels run the metal so one expects quasi-asm style. If you're writing kernels, help yourself, but avoid Linus's awful monolithic design. Remember too that many eyeballs worldwide test/debug Linux, so GOTO risk is heavily mitigated.
Google the recent "goto fail" bug in Apple's phone and desktop OSes. Here you have full-time paid staff goofing royally with GOTO. It's 2014 and we're partying like it's 1979.
Offline