Sample Header Ad - 728x90

TMPDIR is not set in a new shell when using su

0 votes
0 answers
87 views
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 sued 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 sudoing 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