https://refspecs.linuxfoundation.org/FH ... index.html says every linux system must have a /tmp directory ...Goverp wrote:Where to put it?
If your question is: How to be sure my script uses a tmpfile in RAM ?Goverp wrote:$TMPDIR uses /tmp and may or may not be on tmpfs; default is on the rootfs, so a real filesystem.
Code: Select all
init=/sbin/openrc-init
-systemd -logind -elogind seatdI am NaN! I am a man!

Code: Select all
mktemp --tmpdirCode: Select all
dir="/run/user/$(id -u)"
mkdir -p "$dir"
tempfile="$(mktemp -p $dir)"Code: Select all
init=/sbin/openrc-init
-systemd -logind -elogind seatdI am NaN! I am a man!

That's by design:Goverp wrote:It turns out that for a logged in user or root, $XDG_RUNTIME_DIR is set, and points to /run/user/<uid>.
For a user reached by "su -", $XDG_RUNTIME_DIR is unset, and the /run/user/<uid> directory may or may not exist, depending on whether the user is logged-in elsewhere.
XDG Base Directory Specification wrote:$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 lifetime of the directory MUST be bound to the user being logged in. It MUST be created when the user first logs in and if the user fully logs out the directory MUST be removed. If the user logs in more than once he should get pointed to the same directory, and it is mandatory that the directory continues to exist from his first login to his last logout on the system, and not removed in between. Files in the directory MUST not survive reboot or a full logout/login cycle.
According to this, the XDG Base Directory Specification specifies "how desktops should locate files, such as config files or application data files.". Processes that change effective user probably aren't typical for desktops, I guess.Goverp wrote:For a user reached by "su" (no hyphen), $XDG_RUNTIME_DIR is inherited and may be unwritable! Great!
Yup, thinking some more about it, an awful lot of things can break; I ought to get out of the habit of using it just to avoid changing working directory !Hu wrote:Generally, su without -l leaves many bits of the parent environment unchanged, so $XDG_RUNTIME_DIR leaking through is not surprising.