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

$XDG_RUNTIME_DIR is created with invalid permissions (755, should be 700) #10896

Open
1 of 2 tasks
velle opened this issue Dec 10, 2023 · 8 comments
Open
1 of 2 tasks

Comments

@velle
Copy link

velle commented Dec 10, 2023

Windows Version

Microsoft Windows [Version 10.0.19045.3693]

WSL Version

2.0.9.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.133.1-1

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

I created a container from the default WSL image of Ubuntu 22.04, and logged in.

Check the file permissions for $XDG_RUNTIME_DIR:

$ stat -c '%A %a %n' $XDG_RUNTIME_DIR
drwxr-xr-x 755 /run/user/1000/

Use Qt's QStandardPaths

Run a piece of software or a script that depends on Qt's QStandardPath, e.g. this minimal Python script:

#!/usr/bin/env python3
from PyQt6.QtCore import QStandardPaths
QStandardPaths.standardLocations(QStandardPaths.StandardLocation.RuntimeLocation)

Expected Behavior

Expected file permissions:

According to the XDG Base Directory Specification it should always have permissions 700, ie:

$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...) should be stored. The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.

Expected output:

$ stat -c '%A %a %n' $XDG_RUNTIME_DIR
drwxr-xr-x 700 /run/user/1000/

Expected Qt behavior

No warnings or errors.

Actual Behavior

Actual file permissions:

$ stat -c '%A %a %n' $XDG_RUNTIME_DIR
drwxr-xr-x 755 /run/user/1000/

Actual Qt behavior

QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700

Diagnostic Logs

No response

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 15, 2023

@velle: Do you have systemd enabled ? If so systemd actually creates this folder. You can validate that by running:

journalctl | grep -iF /run/user

@velle
Copy link
Author

velle commented Dec 16, 2023

Yes, I have systemd enabled. Here is the output:

$ journalctl -b | grep -iF /run/user
Dec 14 15:20:48 ELCON45223 systemd[1]: Starting User Runtime Directory /run/user/1000...
Dec 14 15:20:48 ELCON45223 systemd[1]: Finished User Runtime Directory /run/user/1000.

Before posting this issue, I wrote the systemd-devel mailing list: https://lists.freedesktop.org/archives/systemd-devel/2023-November/049679.html. If I understand correctly, they believe that something in WSL creates those folders before systemd tries to, and therefore systemd does not touch those folders.

From https://lists.freedesktop.org/archives/systemd-devel/2023-November/049691.html:

So logind invokes [email protected], but it sees the
existing directory and does nothing. I would suggest asking this
question on WSL support channels.

@ashemedai
Copy link

With 2.0.14.0 and Debian 12 with systemd enabled I cannot reproduce this:
image

@drphrozen
Copy link

I have the same issue (trying to run imhex):

$ imhex
terminate called after throwing an instance of 'xdg::BaseDirectoryException'
  what():  $XDG_RUNTIME_DIR must have 0700 as permissions
[1]    12114 IOT instruction  imhex
$ stat -c '%A %a %n' $XDG_RUNTIME_DIR
drwxr-xr-x 755 /run/user/1000/
PS C:\> wsl --version
WSL-version: 2.0.9.0
Kerneversion: 5.15.133.1-1
WSLg-version: 1.0.59
MSRDC-version: 1.2.4677
Direct3D-version: 1.611.1-81528511
DXCore-version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows-version: 10.0.22631.3007

@shoffmeister
Copy link

The impact of this cannot be under-estimated:

With systemd enabled, none of the tools mentioned above will start. I.e. anything using the Qt UI toolkit will simply fail to start.

Symptoms are a Real Crash (imhex, see above, reproduced), or anything from the KDE ecosystem, such as konsole, filelight, kate, all of which start with a black/blank/transparent screen.

And it's always

❯ filelight
QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700
QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700
QStandardPaths: wrong permissions on runtime directory /run/user/1000/, 0755 instead of 0700

@ASadMuon-6671011
Copy link

@shoffmeister yes exactly, the impact is way more than it seems, did you figure out a way to fix this? i've been breaking my head over it the past whole day

@shoffmeister
Copy link

I have not looked into this in detail, but simply redefining XDG_RUNTIME_DIR to some other location, with the correct privileges, should suffice.

Following https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html, something as simple as

export XDG_RUNTIME_DIR=/tmp/my-xdg-runtime-dir
mkdir -p $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR

filelight&

could work.

@BrentHuang
Copy link

me too.
QStandardPaths: wrong permissions on runtime directory /var/run/user/1000, 0755 instead of 0700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants