On a Mac running macOS 13.5,
$TMPDIR
is not set in a new shell. This is a multi-user machine, and it is unset for all users that are su
ed to, causing multiple issues since libraries may default to /tmp
, which is not writable by everyone.
The Mac with the problem is accessed via SSH through one account, and when I change to another account using:
sudo su - otheruser
I get an environment without TMPDIR
. Now, I understand that sudo su
discards environment variables; this is fine! I don't want the sudo
ing user's temporary directory, but the one of the user being accessed.
How can I accomplish that?
Note that it works when I SSH into the target user directly.
Asked by slhck
(2274 rep)
Nov 16, 2023, 07:11 PM