From: msweet Date: Fri, 14 Feb 2014 16:07:13 +0000 (+0000) Subject: Support new launch_activate_socket API on OS X () X-Git-Tag: v2.2b1~759 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02f3db8a515647960cda4e85bbc5cd52764a0625;p=thirdparty%2Fcups.git Support new launch_activate_socket API on OS X () 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 --- diff --git a/config-scripts/cups-launchd.m4 b/config-scripts/cups-launchd.m4 index 8db35d43d1..63b9ade853 100644 --- a/config-scripts/cups-launchd.m4 +++ b/config-scripts/cups-launchd.m4 @@ -1,16 +1,16 @@ 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 @@ -21,6 +21,9 @@ LAUNCHDLIBS="" 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 diff --git a/config.h.in b/config.h.in index 863c667574..7c96248f86 100644 --- a/config.h.in +++ b/config.h.in @@ -3,7 +3,7 @@ * * 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 @@ -454,6 +454,7 @@ #undef HAVE_LAUNCH_H #undef HAVE_LAUNCHD +#undef HAVE_LAUNCH_ACTIVATE_SOCKET /* diff --git a/cups/encode.c b/cups/encode.c index 9e9e19aab5..f31c05ac32 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -68,17 +68,6 @@ static const ipp_op_t ipp_all_print[] = 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, @@ -87,18 +76,6 @@ static const ipp_op_t ipp_set_printer[] = 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, diff --git a/scheduler/main.c b/scheduler/main.c index 74ee9137e8..934f2d6f40 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -28,6 +28,10 @@ # include # 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) @@ -1288,6 +1292,86 @@ cupsdSetStringf(char **s, /* O - New string */ 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 */ @@ -1420,16 +1504,17 @@ launchd_checkin(void) 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 */ } diff --git a/xcode/CUPS.xcodeproj/project.pbxproj b/xcode/CUPS.xcodeproj/project.pbxproj index ef3689cc13..c2ee2fec93 100644 --- a/xcode/CUPS.xcodeproj/project.pbxproj +++ b/xcode/CUPS.xcodeproj/project.pbxproj @@ -1300,6 +1300,9 @@ 72220FB313330BCE00FCA411 /* mime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mime.c; path = ../scheduler/mime.c; sourceTree = ""; }; 72220FB413330BCE00FCA411 /* mime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mime.h; path = ../scheduler/mime.h; sourceTree = ""; }; 72220FB513330BCE00FCA411 /* type.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = type.c; path = ../scheduler/type.c; sourceTree = ""; }; + 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 = ""; }; 7234F41F1378A16F00D3E9C9 /* array-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "array-private.h"; path = "../cups/array-private.h"; sourceTree = ""; }; 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 = ""; }; @@ -1860,6 +1863,7 @@ 72220F461333060C00FCA411 /* Private Headers */ = { isa = PBXGroup; children = ( + 7226369D18AE73BB004ED309 /* config.h.in */, 72220F471333063D00FCA411 /* config.h */, 7234F41F1378A16F00D3E9C9 /* array-private.h */, 72220EC01333056300FCA411 /* cups-private.h */, @@ -1883,6 +1887,8 @@ 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 */, @@ -2726,7 +2732,7 @@ 72BF96371333042100B1EAD7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0500; + LastUpgradeCheck = 0600; ORGANIZATIONNAME = "Apple Inc."; }; buildConfigurationList = 72BF963A1333042100B1EAD7 /* Build configuration list for PBXProject "CUPS" */; @@ -3621,6 +3627,7 @@ 274FF5F0133330C800317ECB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups; @@ -3632,6 +3639,7 @@ 274FF5F1133330C800317ECB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups; @@ -3707,6 +3715,7 @@ 274FF6DE1333B1C400317ECB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_EXTENSION = a; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/local/lib; @@ -3720,6 +3729,7 @@ 274FF6DF1333B1C400317ECB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_EXTENSION = a; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/local/lib; @@ -3891,6 +3901,7 @@ 72220EB01333047D00FCA411 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups; @@ -3902,6 +3913,7 @@ 72220EB11333047D00FCA411 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/cups; @@ -3929,6 +3941,7 @@ 72220FAE13330B2300FCA411 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3938,6 +3951,7 @@ 72220FAF13330B2300FCA411 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4155,6 +4169,7 @@ 72F75A631336F9A3004BB496 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -4164,6 +4179,7 @@ 72F75A641336F9A3004BB496 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; EXECUTABLE_PREFIX = ""; INSTALL_PATH = /usr/lib; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/xcode/config.h b/xcode/config.h index 00b3691418..94a6f5d853 100644 --- a/xcode/config.h +++ b/xcode/config.h @@ -454,6 +454,7 @@ #define HAVE_LAUNCH_H 1 #define HAVE_LAUNCHD 1 +#undef HAVE_LAUNCH_ACTIVATE_SOCKET /*