From: Michael R Sweet Date: Tue, 27 Feb 2018 22:03:19 +0000 (-0500) Subject: Use a writability test for TMPDIR on macOS... X-Git-Tag: v2.3b4~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18dfe3cbe7fc6730921365d424685c674fba9513;p=thirdparty%2Fcups.git Use a writability test for TMPDIR on macOS... --- 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)