]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Support new launch_activate_socket API on OS X (<rdar://problem/16069952>)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 14 Feb 2014 16:07:13 +0000 (16:07 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Fri, 14 Feb 2014 16:07:13 +0000 (16:07 +0000)
Check for new function at configure time.

Define prototype pending public API header.

Use it to get the list of Listeners sockets in launchd_checkin.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11591 a1ca3aef-8c08-0410-bb20-df032aa958be

config-scripts/cups-launchd.m4
config.h.in
cups/encode.c
scheduler/main.c
xcode/CUPS.xcodeproj/project.pbxproj
xcode/config.h

index 8db35d43d18f59aaf6c9c956ac3ffa905ac9c9ee..63b9ade853ccf4ff3954c692905be3c7d25f0f20 100644 (file)
@@ -1,16 +1,16 @@
 dnl
 dnl "$Id$"
 dnl
 dnl
 dnl "$Id$"
 dnl
-dnl   launchd stuff for CUPS.
+dnl launchd stuff for CUPS.
 dnl
 dnl
-dnl   Copyright 2007-2010 by Apple Inc.
-dnl   Copyright 1997-2005 by Easy Software Products, all rights reserved.
+dnl Copyright 2007-2014 by Apple Inc.
+dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
 dnl
 dnl
-dnl   These coded instructions, statements, and computer programs are the
-dnl   property of Apple Inc. and are protected by Federal copyright
-dnl   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
-dnl   which should have been included with this file.  If this file is
-dnl   file is missing or damaged, see the license at "http://www.cups.org/".
+dnl These coded instructions, statements, and computer programs are the
+dnl property of Apple Inc. and are protected by Federal copyright
+dnl law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+dnl which should have been included with this file.  If this file is
+dnl file is missing or damaged, see the license at "http://www.cups.org/".
 dnl
 
 
 dnl
 
 
@@ -21,6 +21,9 @@ LAUNCHDLIBS=""
 
 if test x$enable_launchd != xno; then
        AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD))
 
 if test x$enable_launchd != xno; then
        AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD))
+       AC_CHECK_FUNC(launch_activate_socket, [
+               AC_DEFINE(HAVE_LAUNCHD)
+               AC_DEFINE(HAVE_LAUNCH_ACTIVATE_SOCKET)])
        AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
 
        case "$uname" in
        AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
 
        case "$uname" in
index 863c667574b03390c50c223eb0ca0c06e499dfac..7c96248f862b3164fb7dd5b01d6a021a8112f94d 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Configuration file for CUPS.
  *
  *
  * Configuration file for CUPS.
  *
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
  * Copyright 1997-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
  * Copyright 1997-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
 
 #undef HAVE_LAUNCH_H
 #undef HAVE_LAUNCHD
 
 #undef HAVE_LAUNCH_H
 #undef HAVE_LAUNCHD
+#undef HAVE_LAUNCH_ACTIVATE_SOCKET
 
 
 /*
 
 
 /*
index 9e9e19aab5552ecf20f3415da4977d4773020529..f31c05ac3256761434ed113eb5340bb921d49b08 100644 (file)
@@ -68,17 +68,6 @@ static const ipp_op_t ipp_all_print[] =
   IPP_OP_CUPS_NONE
 };
 
   IPP_OP_CUPS_NONE
 };
 
-static const ipp_op_t ipp_all_limit[] =
-{
-  IPP_OP_GET_JOBS,
-  IPP_OP_GET_PRINTER_ATTRIBUTES,
-  IPP_OP_CUPS_GET_PRINTERS,
-  IPP_OP_CUPS_GET_CLASSES,
-  IPP_OP_CUPS_GET_DEVICES,
-  IPP_OP_CUPS_GET_PPDS,
-  IPP_OP_CUPS_NONE
-};
-
 static const ipp_op_t ipp_set_printer[] =
 {
   IPP_OP_SET_PRINTER_ATTRIBUTES,
 static const ipp_op_t ipp_set_printer[] =
 {
   IPP_OP_SET_PRINTER_ATTRIBUTES,
@@ -87,18 +76,6 @@ static const ipp_op_t ipp_set_printer[] =
   IPP_OP_CUPS_NONE
 };
 
   IPP_OP_CUPS_NONE
 };
 
-static const ipp_op_t cups_am_class[] =
-{
-  IPP_OP_CUPS_ADD_MODIFY_CLASS,
-  IPP_OP_CUPS_NONE
-};
-
-static const ipp_op_t cups_am_printer[] =
-{
-  IPP_OP_CUPS_ADD_MODIFY_PRINTER,
-  IPP_OP_CUPS_NONE
-};
-
 static const ipp_op_t cups_schemes[] =
 {
   IPP_OP_CUPS_GET_DEVICES,
 static const ipp_op_t cups_schemes[] =
 {
   IPP_OP_CUPS_GET_DEVICES,
index 74ee9137e8a9873ee99b61de5232212c51bc53c1..934f2d6f405eebae897d879d7079de9c77e94780 100644 (file)
 #  include <libgen.h>
 #  define CUPS_KEEPALIVE CUPS_CACHEDIR "/org.cups.cupsd"
                                        /* Name of the launchd KeepAlive file */
 #  include <libgen.h>
 #  define CUPS_KEEPALIVE CUPS_CACHEDIR "/org.cups.cupsd"
                                        /* Name of the launchd KeepAlive file */
+#  ifdef HAVE_LAUNCH_ACTIVATE_SOCKET
+/* Update when we have a public header we can include */
+extern int launch_activate_socket(const char *name, int **fds, size_t *cnt);
+#  endif /* HAVE_LAUNCH_ACTIVATE_SOCKET */
 #endif /* HAVE_LAUNCH_H */
 
 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
 #endif /* HAVE_LAUNCH_H */
 
 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
@@ -1288,6 +1292,86 @@ cupsdSetStringf(char       **s,          /* O - New string */
 static void
 launchd_checkin(void)
 {
 static void
 launchd_checkin(void)
 {
+#  ifdef HAVE_LAUNCH_ACTIVATE_SOCKET
+  int                  error;          /* Check-in error, if any */
+  size_t               i,              /* Looping var */
+                       count;          /* Number of listeners */
+  int                  *ld_sockets;    /* Listener sockets */
+  cupsd_listener_t     *lis;           /* Listeners array */
+  http_addr_t          addr;           /* Address variable */
+  socklen_t            addrlen;        /* Length of address */
+  char                 s[256];         /* String addresss */
+
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: pid=%d", (int)getpid());
+
+ /*
+  * Check-in with launchd...
+  */
+
+  if ((error = launch_activate_socket("Listeners", &ld_sockets, &count)) != 0)
+  {
+    cupsdLogMessage(CUPSD_LOG_ERROR, "launchd_checkin: Unable to get listener sockets: %s", strerror(error));
+    exit(EXIT_FAILURE);
+    return; /* anti-compiler-warning */
+  }
+
+ /*
+  * Try to match the launchd sockets to the cupsd listeners...
+  */
+
+  for (i = 0; i < count; i ++)
+  {
+   /*
+    * Get the launchd socket address...
+    */
+
+    addrlen = sizeof(addr);
+
+    if (getsockname(ld_sockets[i], (struct sockaddr *)&addr, &addrlen))
+    {
+      cupsdLogMessage(CUPSD_LOG_ERROR, "launchd_checkin: Unable to get local address for listener #%d: %s", (int)i + 1, strerror(errno));
+      continue;
+    }
+
+    for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
+        lis;
+        lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
+      if (httpAddrEqual(&lis->address, &addr))
+       break;
+
+   /*
+    * Add a new listener if there's no match...
+    */
+
+    if (lis)
+    {
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: Matched existing listener #%d to %s.", (int)i + 1, httpAddrString(&(lis->address), s, sizeof(s)));
+    }
+    else
+    {
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: Adding new listener #%d for %s.", (int)i + 1, httpAddrString(&addr, s, sizeof(s)));
+
+      if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
+      {
+       cupsdLogMessage(CUPSD_LOG_ERROR, "launchd_checkin: Unable to allocate listener: %s", strerror(errno));
+       exit(EXIT_FAILURE);
+      }
+
+      cupsArrayAdd(Listeners, lis);
+
+      memcpy(&lis->address, &addr, sizeof(lis->address));
+    }
+
+    lis->fd = ld_sockets[i];
+
+#    ifdef HAVE_SSL
+    if (httpAddrPort(&(lis->address)) == 443)
+      lis->encryption = HTTP_ENCRYPT_ALWAYS;
+#    endif /* HAVE_SSL */
+  }
+
+#  else
   size_t               i,              /* Looping var */
                        count;          /* Number of listeners */
   launch_data_t                ld_msg,         /* Launch data message */
   size_t               i,              /* Looping var */
                        count;          /* Number of listeners */
   launch_data_t                ld_msg,         /* Launch data message */
@@ -1420,16 +1504,17 @@ launchd_checkin(void)
 
        lis->fd = fd;
 
 
        lis->fd = fd;
 
-#  ifdef HAVE_SSL
+#    ifdef HAVE_SSL
        if (httpAddrPort(&(lis->address)) == 443)
          lis->encryption = HTTP_ENCRYPT_ALWAYS;
        if (httpAddrPort(&(lis->address)) == 443)
          lis->encryption = HTTP_ENCRYPT_ALWAYS;
-#  endif /* HAVE_SSL */
+#    endif /* HAVE_SSL */
       }
     }
   }
 
   launch_data_free(ld_msg);
   launch_data_free(ld_resp);
       }
     }
   }
 
   launch_data_free(ld_msg);
   launch_data_free(ld_resp);
+#  endif /* HAVE_LAUNCH_ACTIVATE_SOCKET */
 }
 
 
 }
 
 
index ef3689cc13a1431a8e0d09d83f6270d7b925e3be..c2ee2fec936cf20905d68151ab485c88c9153470 100644 (file)
                72220FB313330BCE00FCA411 /* mime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mime.c; path = ../scheduler/mime.c; sourceTree = "<group>"; };
                72220FB413330BCE00FCA411 /* mime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mime.h; path = ../scheduler/mime.h; sourceTree = "<group>"; };
                72220FB513330BCE00FCA411 /* type.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = type.c; path = ../scheduler/type.c; sourceTree = "<group>"; };
                72220FB313330BCE00FCA411 /* mime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mime.c; path = ../scheduler/mime.c; sourceTree = "<group>"; };
                72220FB413330BCE00FCA411 /* mime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mime.h; path = ../scheduler/mime.h; sourceTree = "<group>"; };
                72220FB513330BCE00FCA411 /* type.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = type.c; path = ../scheduler/type.c; sourceTree = "<group>"; };
+               7226369B18AE6D19004ED309 /* org.cups.cups-lpd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "org.cups.cups-lpd.plist"; path = "../scheduler/org.cups.cups-lpd.plist"; sourceTree = SOURCE_ROOT; };
+               7226369C18AE6D19004ED309 /* org.cups.cupsd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = org.cups.cupsd.plist; path = ../scheduler/org.cups.cupsd.plist; sourceTree = SOURCE_ROOT; };
+               7226369D18AE73BB004ED309 /* config.h.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = config.h.in; path = ../config.h.in; sourceTree = "<group>"; };
                7234F41F1378A16F00D3E9C9 /* array-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "array-private.h"; path = "../cups/array-private.h"; sourceTree = "<group>"; };
                724378FD1333E43E009631B9 /* ipp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ipp; sourceTree = BUILT_PRODUCTS_DIR; };
                724379091333E4E3009631B9 /* backend-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "backend-private.h"; path = "../backend/backend-private.h"; sourceTree = "<group>"; };
                7234F41F1378A16F00D3E9C9 /* array-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "array-private.h"; path = "../cups/array-private.h"; sourceTree = "<group>"; };
                724378FD1333E43E009631B9 /* ipp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ipp; sourceTree = BUILT_PRODUCTS_DIR; };
                724379091333E4E3009631B9 /* backend-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "backend-private.h"; path = "../backend/backend-private.h"; sourceTree = "<group>"; };
                72220F461333060C00FCA411 /* Private Headers */ = {
                        isa = PBXGroup;
                        children = (
                72220F461333060C00FCA411 /* Private Headers */ = {
                        isa = PBXGroup;
                        children = (
+                               7226369D18AE73BB004ED309 /* config.h.in */,
                                72220F471333063D00FCA411 /* config.h */,
                                7234F41F1378A16F00D3E9C9 /* array-private.h */,
                                72220EC01333056300FCA411 /* cups-private.h */,
                                72220F471333063D00FCA411 /* config.h */,
                                7234F41F1378A16F00D3E9C9 /* array-private.h */,
                                72220EC01333056300FCA411 /* cups-private.h */,
                72220F5D13330A5A00FCA411 /* cupsd */ = {
                        isa = PBXGroup;
                        children = (
                72220F5D13330A5A00FCA411 /* cupsd */ = {
                        isa = PBXGroup;
                        children = (
+                               7226369B18AE6D19004ED309 /* org.cups.cups-lpd.plist */,
+                               7226369C18AE6D19004ED309 /* org.cups.cupsd.plist */,
                                72D53A3615B4929D003F877F /* colorman.c */,
                                72D53A3715B4929D003F877F /* colorman.h */,
                                72220F6913330B0C00FCA411 /* auth.c */,
                                72D53A3615B4929D003F877F /* colorman.c */,
                                72D53A3715B4929D003F877F /* colorman.h */,
                                72220F6913330B0C00FCA411 /* auth.c */,
                72BF96371333042100B1EAD7 /* Project object */ = {
                        isa = PBXProject;
                        attributes = {
                72BF96371333042100B1EAD7 /* Project object */ = {
                        isa = PBXProject;
                        attributes = {
-                               LastUpgradeCheck = 0500;
+                               LastUpgradeCheck = 0600;
                                ORGANIZATIONNAME = "Apple Inc.";
                        };
                        buildConfigurationList = 72BF963A1333042100B1EAD7 /* Build configuration list for PBXProject "CUPS" */;
                                ORGANIZATIONNAME = "Apple Inc.";
                        };
                        buildConfigurationList = 72BF963A1333042100B1EAD7 /* Build configuration list for PBXProject "CUPS" */;
                274FF5F0133330C800317ECB /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                274FF5F0133330C800317ECB /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                274FF5F1133330C800317ECB /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                274FF5F1133330C800317ECB /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                274FF6DE1333B1C400317ECB /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                274FF6DE1333B1C400317ECB /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_EXTENSION = a;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/local/lib;
                                EXECUTABLE_EXTENSION = a;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/local/lib;
                274FF6DF1333B1C400317ECB /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                274FF6DF1333B1C400317ECB /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_EXTENSION = a;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/local/lib;
                                EXECUTABLE_EXTENSION = a;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/local/lib;
                72220EB01333047D00FCA411 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72220EB01333047D00FCA411 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                72220EB11333047D00FCA411 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72220EB11333047D00FCA411 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
                72220FAE13330B2300FCA411 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72220FAE13330B2300FCA411 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                72220FAF13330B2300FCA411 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72220FAF13330B2300FCA411 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                72F75A631336F9A3004BB496 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72F75A631336F9A3004BB496 /* Debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                72F75A641336F9A3004BB496 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                72F75A641336F9A3004BB496 /* Release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
+                               COMBINE_HIDPI_IMAGES = YES;
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
                                EXECUTABLE_PREFIX = "";
                                INSTALL_PATH = /usr/lib;
                                PRODUCT_NAME = "$(TARGET_NAME)";
index 00b369141872d217a1f45a867ec9459c1d2dfb9f..94a6f5d8534c4e08c16615a213836f5fd690816b 100644 (file)
 
 #define HAVE_LAUNCH_H 1
 #define HAVE_LAUNCHD 1
 
 #define HAVE_LAUNCH_H 1
 #define HAVE_LAUNCHD 1
+#undef HAVE_LAUNCH_ACTIVATE_SOCKET
 
 
 /*
 
 
 /*