Bug 1174408 - zsh should honour $TMPDIR or XDG_RUNTIME_DIR by default
Summary: zsh should honour $TMPDIR or XDG_RUNTIME_DIR by default
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: Ismail Dönmez
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-22 17:50 UTC by Cristian Rodríguez
Modified: 2020-07-23 13:41 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cristian Rodríguez 2020-07-22 17:50:11 UTC
By default /tmp is going to live on tmpfs but it might not be volatile by users 's choice. 

zsh creates temporary/runtime files according to DEFAULT_TMPPREFIX build time constant, that can be overriden at runtime setting the TMPPREFIX variable.

In my opinion:

a) at the bare minimum if only minimal changes respect to upstream are desired:

DEFAULT_TMPPREFIX build time definition that is set to hardcoded string "/tmp/zsh" should instead try to use standard-defined TMPDIR envirnoment variable so for example pam modules or other parts of the OS can override at will.

Unfortunately this does not solve the problem of temporary files on abnormal program termination, so I believe you should go one step forward and 

TMPPREFIX be set to:

first and foremost to $XDG_RUNTIME_DIR/zsh if $XDG_RUNTIME_DIR is set.
if that is not the case, to a tmpfs-backed directory /run/zsh  (mode 1777) created by tmpfiles.d snippet.
since this is a shell and must work in all cases if the above fails fallback to $TMPDIR/zsh

Im happy if you do this on the global zsh configuration, but it must apply to every shell invocation, interactive or non-interactive alike.
Comment 1 Cristian Rodríguez 2020-07-23 13:41:42 UTC
I also have some patches that make zsh use O_TMPFILE on most cases, like =(echo "foo") but Im not sure at all if that will break some assumptions or special case. Needs test.

Using O_TMPFILE is the only really safe way, since the fd is closed in all kinds of program termination and the "file" is not visible to anyone other than the calling process.