dnl
dnl "$Id$"
dnl
-dnl launchd stuff for CUPS.
+dnl launchd stuff for CUPS.
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 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
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
*
* 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
#undef HAVE_LAUNCH_H
#undef HAVE_LAUNCHD
+#undef HAVE_LAUNCH_ACTIVATE_SOCKET
/*
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,
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,
# 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)
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 */
lis->fd = fd;
-# ifdef HAVE_SSL
+# ifdef HAVE_SSL
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);
+# endif /* HAVE_LAUNCH_ACTIVATE_SOCKET */
}
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>"; };
72220F461333060C00FCA411 /* Private Headers */ = {
isa = PBXGroup;
children = (
+ 7226369D18AE73BB004ED309 /* config.h.in */,
72220F471333063D00FCA411 /* config.h */,
7234F41F1378A16F00D3E9C9 /* array-private.h */,
72220EC01333056300FCA411 /* cups-private.h */,
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 */,
72BF96371333042100B1EAD7 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0500;
+ LastUpgradeCheck = 0600;
ORGANIZATIONNAME = "Apple Inc.";
};
buildConfigurationList = 72BF963A1333042100B1EAD7 /* Build configuration list for PBXProject "CUPS" */;
274FF5F0133330C800317ECB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
274FF5F1133330C800317ECB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
274FF6DE1333B1C400317ECB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_EXTENSION = a;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/local/lib;
274FF6DF1333B1C400317ECB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_EXTENSION = a;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/local/lib;
72220EB01333047D00FCA411 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
72220EB11333047D00FCA411 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups;
72220FAE13330B2300FCA411 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRODUCT_NAME = "$(TARGET_NAME)";
72220FAF13330B2300FCA411 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRODUCT_NAME = "$(TARGET_NAME)";
72F75A631336F9A3004BB496 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRODUCT_NAME = "$(TARGET_NAME)";
72F75A641336F9A3004BB496 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
EXECUTABLE_PREFIX = "";
INSTALL_PATH = /usr/lib;
PRODUCT_NAME = "$(TARGET_NAME)";
#define HAVE_LAUNCH_H 1
#define HAVE_LAUNCHD 1
+#undef HAVE_LAUNCH_ACTIVATE_SOCKET
/*