]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/process.c
Add missing DNSSD.LIB functions.
[thirdparty/cups.git] / scheduler / process.c
index aa1fe96c97567926b0755c643a61433404216ff6..3c1c6ba4f9d49fcc3ebb82dd5e446f902ad2e636 100644 (file)
@@ -1,14 +1,10 @@
 /*
  * Process management routines for the CUPS scheduler.
  *
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file.  If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
  */
 
 /*
 #ifdef HAVE_POSIX_SPAWN
 #  include <spawn.h>
 extern char **environ;
-#endif /* HAVE_POSIX_SPAWN */
-#ifdef HAVE_POSIX_SPAWN
-#  if !defined(__OpenBSD__) || OpenBSD >= 201505
-#    define USE_POSIX_SPAWN 1
-#  else
+/* Don't use posix_spawn on systems with bugs in their implementations... */
+#  if defined(OpenBSD) && OpenBSD < 201505
 #    define USE_POSIX_SPAWN 0
-#  endif /* !__OpenBSD__ || */
+#  elif defined(__UCLIBC__) && __UCLIBC_MAJOR__ == 1 && __UCLIBC_MINOR__ == 0 && __UCLIBC_SUBLEVEL__ < 27
+#    define USE_POSIX_SPAWN 0
+#  elif defined(__UCLIBC__) && __UCLIBC_MAJOR__ < 1
+#    define USE_POSIX_SPAWN 0
+#  else /* All other platforms */
+#    define USE_POSIX_SPAWN 1
+#  endif /* ... */
 #else
 #  define USE_POSIX_SPAWN 0
 #endif /* HAVE_POSIX_SPAWN */
@@ -99,9 +98,13 @@ cupsdCreateProfile(int job_id,               /* I - Job ID or 0 for none */
 
   if ((fp = cupsTempFile2(profile, sizeof(profile))) == NULL)
   {
+   /*
+    * This should never happen, and is fatal when sandboxing is enabled.
+    */
+
     cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCreateProfile(job_id=%d, allow_networking=%d) = NULL", job_id, allow_networking);
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create security profile: %s",
-                    strerror(errno));
+    cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to create security profile: %s", strerror(errno));
+    kill(getpid(), SIGTERM);
     return (NULL);
   }
 
@@ -125,6 +128,7 @@ cupsdCreateProfile(int job_id,              /* I - Job ID or 0 for none */
   if (LogLevel >= CUPSD_LOG_DEBUG)
     cupsFilePuts(fp, "(debug deny)\n");
   cupsFilePuts(fp, "(import \"system.sb\")\n");
+  cupsFilePuts(fp, "(import \"com.apple.corefoundation.sb\")\n");
   cupsFilePuts(fp, "(system-network)\n");
   cupsFilePuts(fp, "(allow mach-per-user-lookup)\n");
   cupsFilePuts(fp, "(allow ipc-posix-sem)\n");
@@ -197,10 +201,8 @@ cupsdCreateProfile(int job_id,             /* I - Job ID or 0 for none */
                 " #\"^%s/\""           /* TempDir/... */
                 " #\"^%s$\""           /* CacheDir */
                 " #\"^%s/\""           /* CacheDir/... */
-                " #\"^%s$\""           /* StateDir */
-                " #\"^%s/\""           /* StateDir/... */
                 "))\n",
-                temp, temp, cache, cache, state, state);
+                temp, temp, cache, cache);
   /* Read common folders */
   cupsFilePrintf(fp,
                  "(allow file-read-data file-read-metadata\n"
@@ -242,8 +244,10 @@ cupsdCreateProfile(int job_id,             /* I - Job ID or 0 for none */
                 " #\"^%s/\""           /* ServerBin/... */
                 " #\"^%s$\""           /* ServerRoot */
                 " #\"^%s/\""           /* ServerRoot/... */
+                " #\"^%s$\""           /* StateDir */
+                " #\"^%s/\""           /* StateDir/... */
                 "))\n",
-                request, request, bin, bin, root, root);
+                request, request, bin, bin, root, root, state, state);
   if (Sandboxing == CUPSD_SANDBOXING_RELAXED)
   {
     /* Limited write access to /Library/Printers/... */
@@ -874,7 +878,7 @@ cupsd_requote(char       *dst,              /* I - Destination buffer */
     if (ch == '/' && !*src)
       break;                           /* Don't add trailing slash */
 
-    if (strchr(".?*()[]^$\\", ch))
+    if (strchr(".?*()[]^$\\\"", ch))
       *dstptr++ = '\\';
 
     *dstptr++ = (char)ch;