From: Evan Miller Date: Mon, 30 Aug 2021 13:35:19 +0000 (-0400) Subject: Workaround for tempfiles on OS X 10.4 X-Git-Tag: v2.4b1~79^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=384329c1ef74576f1657b34e1e26180dcc9fa65e;p=thirdparty%2Fcups.git Workaround for tempfiles on OS X 10.4 _CS_DARWIN_USER_TEMP_DIR was introduced in the 10.5 SDK. Fall back to /private/tmp on earlier OS versions. --- diff --git a/cups/ppd-util.c b/cups/ppd-util.c index 5e43615eb7..99262aadbf 100644 --- a/cups/ppd-util.c +++ b/cups/ppd-util.c @@ -226,17 +226,21 @@ cupsGetPPD3(http_t *http, /* I - HTTP connection or @code CUPS_HTTP_DEFAUL * per-process TMPDIR value. */ +#ifdef _CS_DARWIN_USER_TEMP_DIR char tmppath[1024]; /* Temporary directory */ +#endif /* _CS_DARWIN_USER_TEMP_DIR */ if ((tmpdir = getenv("TMPDIR")) != NULL && access(tmpdir, W_OK)) tmpdir = NULL; if (!tmpdir) { +#ifdef _CS_DARWIN_USER_TEMP_DIR if (confstr(_CS_DARWIN_USER_TEMP_DIR, tmppath, sizeof(tmppath))) tmpdir = tmppath; else - tmpdir = "/private/tmp"; /* This should never happen */ +#endif /* _CS_DARWIN_USER_TEMP_DIR */ + tmpdir = "/private/tmp"; /* OS X 10.4 and earlier */ } #else /* diff --git a/cups/tempfile.c b/cups/tempfile.c index fb39802955..3b52a1547d 100644 --- a/cups/tempfile.c +++ b/cups/tempfile.c @@ -38,9 +38,9 @@ cupsTempFd(char *filename, /* I - Pointer to buffer */ int fd; /* File descriptor for temp file */ int tries; /* Number of tries */ const char *tmpdir; /* TMPDIR environment var */ -#if defined(__APPLE__) || defined(_WIN32) +#if (defined(__APPLE__) && defined(_CS_DARWIN_USER_TEMP_DIR)) || defined(_WIN32) char tmppath[1024]; /* Temporary directory */ -#endif /* __APPLE__ || _WIN32 */ +#endif /* (__APPLE__ && _CS_DARWIN_USER_TEMP_DIR) || _WIN32 */ #ifdef _WIN32 DWORD curtime; /* Current time */ #else @@ -72,10 +72,12 @@ cupsTempFd(char *filename, /* I - Pointer to buffer */ if (!tmpdir) { +#ifdef _CS_DARWIN_USER_TEMP_DIR if (confstr(_CS_DARWIN_USER_TEMP_DIR, tmppath, sizeof(tmppath))) tmpdir = tmppath; else - tmpdir = "/private/tmp"; /* This should never happen */ +#endif /* _CS_DARWIN_USER_TEMP_DIR */ + tmpdir = "/private/tmp"; /* OS X 10.4 and earlier */ } #else