←back to thread

Against /Tmp

(dotat.at)
140 points todsacerdoti | 1 comments | | HN request time: 0.001s | source
Show context
Joker_vD ◴[] No.41913946[source]
> The fix, way back when, should have been for login(8) to create a per-user temporary directory in a sensible place before it drops privilege, and set $TMPDIR so the user’s shell and child processes can find it.

Something like

    tmpdir := "/tmp/${USERNAME}"
    loop:
        rmdir(tmpdir, recurse=true)
        while not mkdir(tmpdir, 0o700, must-create=true)
    chown(tmpdir, user=$USERNAME, group=$USERGROUP)
    export("TMPDIR", tmpdir)
with /tmp having root:root owner with 0o775 permissions on it? Yeah, would've been nice.
replies(3): >>41914009 #>>41914158 #>>41916846 #
nullindividual ◴[] No.41914009[source]
Why not both, like Windows?

$HOME/.tmp for user operations and /tmp for system operations?

EDIT: I see from other posters it can be done. Why the heck isn't this the default?!

replies(3): >>41914083 #>>41914609 #>>41915408 #
yxhuvud ◴[] No.41914083[source]
What system operations exist that need temp storage shouldn't have a separate user anyhow?
replies(1): >>41914134 #
nullindividual ◴[] No.41914134[source]
I see where you're going with your question, but like Windows' Services/scheduled tasks, most of those 'users' don't have a $HOME folder.

Not to say they couldn't have one!

replies(1): >>41915041 #
1. GoblinSlayer ◴[] No.41915041{3}[source]
Services on windows have home folder e.g. in \Windows\ServiceProfiles\LocalService