Skip to content

Commit fda76f0

Browse files
committed
fix: ignore '$TMPDIR' when it is an unusable directory
A recent audit of Ubuntu’s Rust utilities¹ led me to learn that `$TMPDIR` is only intended to be used when the directory it points to is accessible:² If applications are written to use temporary or intermediate files, they should use the _TMPDIR_ environment variable, if it is set and represents an accessible directory, to select the location of temporary files. The effect of this change is that `vimcat --help` with an unusable `$TMPDIR` set will now fall back to using /tmp instead of trying (and failing) to use this `$TMPDIR`. ¹ https://discourse.ubuntu.com/t/an-update-on-rust-coreutils/80773 ² https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap01.html
1 parent 7417839 commit fda76f0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

vimcat/help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int help(void) {
4141

4242
// find temporary storage space
4343
const char *TMPDIR = getenv("TMPDIR");
44-
if (TMPDIR == NULL)
44+
if (TMPDIR == NULL || access(TMPDIR, R_OK | W_OK | X_OK) != 0)
4545
TMPDIR = "/tmp";
4646

4747
// create a temporary path

0 commit comments

Comments
 (0)