From 9b440f8a5cfa0214833196db7ea0639036eaec34 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 26 Feb 2018 17:14:11 -0500 Subject: [PATCH] Simplify tempfile fix for macOS. --- cups/tempfile.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cups/tempfile.c b/cups/tempfile.c index 97972bd82..dcd81736d 100644 --- a/cups/tempfile.c +++ b/cups/tempfile.c @@ -62,15 +62,15 @@ cupsTempFd(char *filename, /* I - Pointer to buffer */ /* * On macOS and iOS, the TMPDIR environment variable is not always the best * location to place temporary files due to sandboxing. Instead, the confstr - * function should be called when running as a normal process (not a child of - * cupsd) to get the proper per-user, per-process TMPDIR value. We know - * whether the process is running as a child of cupsd by the presence of the - * "SOFTWARE" environment variable that cupsd sets. + * function should be called to get the proper per-user, per-process TMPDIR + * value. Currently this only happens if TMPDIR is not set or is set to + * "/var/folders/...". */ - tmpdir = getenv("TMPDIR"); + if ((tmpdir = getenv("TMPDIR")) != NULL && !strncmp(tmpdir, "/var/folders/", 13)) + tmpdir = NULL; - if (!getenv("SOFTWARE") || !tmpdir) + if (!tmpdir) { if (confstr(_CS_DARWIN_USER_TEMP_DIR, tmppath, sizeof(tmppath))) tmpdir = tmppath; -- 2.39.2