From 18dfe3cbe7fc6730921365d424685c674fba9513 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 27 Feb 2018 17:03:19 -0500 Subject: [PATCH] Use a writability test for TMPDIR on macOS... --- cups/ppd-util.c | 5 ++--- cups/tempfile.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cups/ppd-util.c b/cups/ppd-util.c index 07d91d4631..5641c79a9a 100644 --- a/cups/ppd-util.c +++ b/cups/ppd-util.c @@ -222,13 +222,12 @@ cupsGetPPD3(http_t *http, /* I - HTTP connection or @code CUPS_HTTP_DEFAUL * 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 to get the proper per-user, per-process TMPDIR - * value. Currently this only happens if TMPDIR is not set or is set to - * "/Users/...". + * value. */ char tmppath[1024]; /* Temporary directory */ - if ((tmpdir = getenv("TMPDIR")) != NULL && !strncmp(tmpdir, "/Users/", 7)) + if ((tmpdir = getenv("TMPDIR")) != NULL && access(tmpdir, W_OK)) tmpdir = NULL; if (!tmpdir) diff --git a/cups/tempfile.c b/cups/tempfile.c index 6226146968..bf26a08e8f 100644 --- a/cups/tempfile.c +++ b/cups/tempfile.c @@ -63,11 +63,10 @@ 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 to get the proper per-user, per-process TMPDIR - * value. Currently this only happens if TMPDIR is not set or is set to - * "/Users/...". + * value. */ - if ((tmpdir = getenv("TMPDIR")) != NULL && !strncmp(tmpdir, "/Users/", 7)) + if ((tmpdir = getenv("TMPDIR")) != NULL && access(tmpdir, W_OK)) tmpdir = NULL; if (!tmpdir) -- 2.47.2