Skip to content

Conversation

@dramforever
Copy link
Contributor

@dramforever dramforever commented Oct 25, 2025

Using tempfile::Builder::tempdir() defaults to creating this directory in /tmp, which is shared with the host and often somewhat persistent. This causes one extra directory to be created in the host /tmp every time muvm runs.

Since we mount /run as a tmpfs now in the guest now, just create $XDG_RUNTIME_DIR in /run/user/{uid}, a common default. Specifically:

  • Create /run/user as 0o755 (rwxr-xr-x) owned by root:root
  • Create /run/user/{uid} as 0o700 (rwx------) owned by uid:gid

@dramforever
Copy link
Contributor Author

I couldn't find a justification for using /tmp. This seems to have been there since the C krun's initial commit and might have just been missed, or maybe it was implemented before /run was properly handled.

@dramforever dramforever force-pushed the xdg-runtime-dir-in-run branch from 5199214 to ce4086e Compare October 25, 2025 18:44
@teohhanhui
Copy link
Collaborator

teohhanhui commented Oct 25, 2025

I think it should be changed, yeah, but some other existing assumptions might need to be fixed, e.g.

// Must succeed since /run/ was just mounted and is now an empty tmpfs.

The other thing I could think of is, maybe this (XDG_RUNTIME_DIR in /tmp) was done this way to ease debugging? /cc @slp

@dramforever
Copy link
Contributor Author

AIUI the part where I changed is in the user initialization part, which happens after FEX init, so guest/mount.rs shouldn't be affected.

@teohhanhui
Copy link
Collaborator

teohhanhui commented Oct 25, 2025

Hmm... Actually, if we're changing this, why are we not just using the typical /run/user/{uid}?


Anyway, relevant part from the spec:

$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 they MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.

@dramforever
Copy link
Contributor Author

Oh, good idea. I'll change it to /run/user/{uid}

@dramforever dramforever marked this pull request as draft October 26, 2025 04:01
@dramforever dramforever force-pushed the xdg-runtime-dir-in-run branch from ce4086e to 183f414 Compare October 26, 2025 05:08
@dramforever dramforever changed the title Create $XDG_RUNTIME_DIR in /run instead Create $XDG_RUNTIME_DIR in /run/user/{uid} Oct 26, 2025
@dramforever
Copy link
Contributor Author

The directory and permissions now looks like this

$ namei -l $XDG_RUNTIME_DIR 
f: /run/user/1000
drwxr-xr-x root root  /
drwxrwxrwt root root  run
drwxr-xr-x root root  user
drwx------ dram users 1000

@dramforever dramforever marked this pull request as ready for review October 26, 2025 05:10
@dramforever dramforever force-pushed the xdg-runtime-dir-in-run branch 2 times, most recently from 6c2e2ee to c7a6520 Compare October 26, 2025 15:27
@slp
Copy link
Collaborator

slp commented Oct 31, 2025

The other thing I could think of is, maybe this (XDG_RUNTIME_DIR in /tmp) was done this way to ease debugging? /cc @slp

IIRC it's in /tmp to avoid polluting the host's /run since originally we weren't mounting a tmpfs on it. I like the idea of switching to it now that we do the tmpfs mount.

@slp
Copy link
Collaborator

slp commented Oct 31, 2025

Please fix the clippy issue. Otherwise LGTM, thanks!

Using tempfile::Builder::tempdir() defaults to creating this directory
in /tmp, which is shared with the host and often somewhat persistent.
This causes one extra directory to be created in the host /tmp every
time muvm runs.

Since we mount /run as a tmpfs now in the guest now, just create
$XDG_RUNTIME_DIR in /run/user/{uid}, a common default. Specifically:

- Create /run/user as 0o755 (rwxr-xr-x) owned by root:root
- Create /run/user/{uid} as 0o700 (rwx------) owned by uid:gid

Signed-off-by: Vivian Wang <dramforever@live.com>
@dramforever dramforever force-pushed the xdg-runtime-dir-in-run branch from c7a6520 to c421925 Compare October 31, 2025 11:09
@dramforever
Copy link
Contributor Author

Clippy should be happy now

@slp slp merged commit 51c3960 into AsahiLinux:main Nov 14, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants