From 5180a04ce8365f7f3e6156fe7389367aee1de9b7 Mon Sep 17 00:00:00 2001 From: msweet Date: Tue, 30 Mar 2010 23:24:27 +0000 Subject: [PATCH] Merge changes from CUPS 1.5svn-r9062. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@2016 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.4.txt | 2 + Makefile | 4 +- config-scripts/cups-directories.m4 | 2 +- cups/Makefile | 4 +- cups/cups-private.h | 11 +- cups/getdevices.c | 52 ++++- cups/globals.c | 46 ++++- cups/http-private.h | 1 + cups/libcups2.def | 312 +++++++++++++++++++++++++++++ cups/libcups_s.exp | 24 ++- scheduler/cups-lpd.c | 103 +--------- scheduler/job.c | 5 +- scheduler/main.c | 2 + test/ipptest.c | 1 + vcnet/config.h | 12 +- vcnet/libcups2.vcproj | 198 +++++++++--------- 16 files changed, 550 insertions(+), 229 deletions(-) create mode 100644 cups/libcups2.def diff --git a/CHANGES-1.4.txt b/CHANGES-1.4.txt index fb9b605f1..c6eb7dd59 100644 --- a/CHANGES-1.4.txt +++ b/CHANGES-1.4.txt @@ -41,6 +41,8 @@ CHANGES IN CUPS V1.4.3 - SECURITY: The scheduler could try responding on a closed client connection, leading to a crash (STR #3200) + - SECURITY: The lppasswd program allowed the localization files to be + overridden when running in setuid mode (STR #3482) - Localization updates (STR #3352, STR #3409, STR #3422, STR #3452, STR #3473, STR #3502) - Documentation updates (STR #3451, STR #3504) diff --git a/Makefile b/Makefile index d215c47f4..2c3e7e9ff 100644 --- a/Makefile +++ b/Makefile @@ -190,8 +190,8 @@ install-headers: done if test "x$(privateinclude)" != x; then \ echo Installing config.h into $(PRIVATEINCLUDE)...; \ - $(INSTALLDIR) -m 755 $(PRIVATEINCLUDE); \ - $(INSTALL_DATA) config.h $(PRIVATEINCLUDE); \ + $(INSTALL_DIR) -m 755 $(PRIVATEINCLUDE); \ + $(INSTALL_DATA) config.h $(PRIVATEINCLUDE)/config.h; \ fi diff --git a/config-scripts/cups-directories.m4 b/config-scripts/cups-directories.m4 index 0d492f381..c46afec78 100644 --- a/config-scripts/cups-directories.m4 +++ b/config-scripts/cups-directories.m4 @@ -119,7 +119,7 @@ if test "$libdir" = "\${exec_prefix}/lib"; then fi dnl Setup private include directory... -AC_ARG_WITH(privateinclude, [ --with-privateinclude set path for private include files, default=none],privatedir="$withval",privatedir="") +AC_ARG_WITH(privateinclude, [ --with-privateinclude set path for private include files, default=none],privateinclude="$withval",privateinclude="") if test "x$privateinclude" != x -a "x$privateinclude" != xnone; then PRIVATEINCLUDE="$privateinclude/cups" else diff --git a/cups/Makefile b/cups/Makefile index dba1ce60e..b565c436a 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -230,9 +230,9 @@ install-headers: done if test "x$(privateinclude)" != x; then \ echo Installing private header files into $(PRIVATEINCLUDE)...; \ - $(INSTALLDIR) -m 755 $(PRIVATEINCLUDE); \ + $(INSTALL_DIR) -m 755 $(PRIVATEINCLUDE); \ for file in $(HEADERSPRIV); do \ - $(INSTALL_DATA) $$file $(PRIVATEINCLUDE); \ + $(INSTALL_DATA) $$file $(PRIVATEINCLUDE)/$$file; \ done; \ fi diff --git a/cups/cups-private.h b/cups/cups-private.h index c23803399..5fa1a242c 100644 --- a/cups/cups-private.h +++ b/cups/cups-private.h @@ -111,6 +111,12 @@ typedef struct _cups_globals_s /**** CUPS global state data ****/ _pwg_media_t pwg_media; /* PWG media data for custom size */ char pwg_name[65]; /* PWG media name for custom size */ + /* request.c */ + http_t *http; /* Current server connection */ + ipp_status_t last_error; /* Last IPP error */ + char *last_status_message; + /* Last IPP status-message */ + /* snmp.c */ char snmp_community[255]; /* Default SNMP community name */ @@ -128,11 +134,6 @@ typedef struct _cups_globals_s /**** CUPS global state data ****/ void *password_data; /* Password user data */ /* util.c */ - http_t *http; /* Current server connection */ - ipp_status_t last_error; /* Last IPP error */ - char *last_status_message; - /* Last IPP status-message */ - char def_printer[256]; /* Default printer */ char ppd_filename[HTTP_MAX_URI]; diff --git a/cups/getdevices.c b/cups/getdevices.c index 23d2af36f..a74a593c7 100644 --- a/cups/getdevices.c +++ b/cups/getdevices.c @@ -106,15 +106,55 @@ cupsGetDevices( } /* - * Send the request... + * Send the request and do any necessary authentication... */ - DEBUG_puts("2cupsGetDevices: Sending request..."); - status = cupsSendRequest(http, request, "/", ippLength(request)); + do + { + DEBUG_puts("2cupsGetDevices: Sending request..."); + status = cupsSendRequest(http, request, "/", ippLength(request)); + + DEBUG_puts("2cupsGetDevices: Waiting for response status..."); + while (status == HTTP_CONTINUE) + status = httpUpdate(http); + + if (status != HTTP_OK) + { + httpFlush(http); + + if (status == HTTP_UNAUTHORIZED) + { + /* + * See if we can do authentication... + */ + + DEBUG_puts("2cupsGetDevices: Need authorization..."); + + if (!cupsDoAuthentication(http, "POST", "/")) + httpReconnect(http); + else + { + status = HTTP_AUTHORIZATION_CANCELED; + break; + } + } + +#ifdef HAVE_SSL + else if (status == HTTP_UPGRADE_REQUIRED) + { + /* + * Force a reconnect with encryption... + */ + + DEBUG_puts("2cupsGetDevices: Need encryption..."); - DEBUG_puts("2cupsGetDevices: Waiting for response status..."); - while (status == HTTP_CONTINUE) - status = httpUpdate(http); + if (!httpReconnect(http)) + httpEncryption(http, HTTP_ENCRYPT_REQUIRED); + } +#endif /* HAVE_SSL */ + } + } + while (status == HTTP_UNAUTHORIZED || status == HTTP_UPGRADE_REQUIRED); DEBUG_printf(("2cupsGetDevices: status=%d", status)); diff --git a/cups/globals.c b/cups/globals.c index 3353604d3..b21924a41 100644 --- a/cups/globals.c +++ b/cups/globals.c @@ -81,20 +81,44 @@ cups_env_init(_cups_globals_t *g) /* I - Global data */ g->localedir = localedir; #else - if ((g->cups_datadir = getenv("CUPS_DATADIR")) == NULL) - g->cups_datadir = CUPS_DATADIR; - - if ((g->cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL) - g->cups_serverbin = CUPS_SERVERBIN; +# ifdef HAVE_GETEUID + if ((geteuid() != getuid() && getuid()) || getegid() != getgid()) +# else + if (!getuid()) +# endif /* HAVE_GETEUID */ + { + /* + * When running setuid/setgid, don't allow environment variables to override + * the directories... + */ - if ((g->cups_serverroot = getenv("CUPS_SERVERROOT")) == NULL) + g->cups_datadir = CUPS_DATADIR; + g->cups_serverbin = CUPS_SERVERBIN; g->cups_serverroot = CUPS_SERVERROOT; + g->cups_statedir = CUPS_STATEDIR; + g->localedir = CUPS_LOCALEDIR; + } + else + { + /* + * Allow directories to be overridden by environment variables. + */ - if ((g->cups_statedir = getenv("CUPS_STATEDIR")) == NULL) - g->cups_statedir = CUPS_STATEDIR; + if ((g->cups_datadir = getenv("CUPS_DATADIR")) == NULL) + g->cups_datadir = CUPS_DATADIR; - if ((g->localedir = getenv("LOCALEDIR")) == NULL) - g->localedir = CUPS_LOCALEDIR; + if ((g->cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL) + g->cups_serverbin = CUPS_SERVERBIN; + + if ((g->cups_serverroot = getenv("CUPS_SERVERROOT")) == NULL) + g->cups_serverroot = CUPS_SERVERROOT; + + if ((g->cups_statedir = getenv("CUPS_STATEDIR")) == NULL) + g->cups_statedir = CUPS_STATEDIR; + + if ((g->localedir = getenv("LOCALEDIR")) == NULL) + g->localedir = CUPS_LOCALEDIR; + } #endif /* WIN32 */ } @@ -132,7 +156,7 @@ _cupsGlobals(void) _cups_globals_t *globals; /* Pointer to global data */ - /* + /* * Initialize the global data exactly once... */ diff --git a/cups/http-private.h b/cups/http-private.h index c0e4814cf..4a08eb9e3 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -23,6 +23,7 @@ */ # include "config.h" +# include # include # ifdef __sun diff --git a/cups/libcups2.def b/cups/libcups2.def new file mode 100644 index 000000000..83d33f382 --- /dev/null +++ b/cups/libcups2.def @@ -0,0 +1,312 @@ +LIBRARY libcups2 +VERSION 2.8 +EXPORTS +_cupsCharmapFlush +_cupsCharmapFree +_cupsCharmapGet +_cupsEncodingName +_cupsGetPassword +_cupsGlobals +_cupsLangPrintf +_cupsLangPuts +_cupsLangString +_cupsMD5Append +_cupsMD5Finish +_cupsMD5Init +_cupsMessageFree +_cupsMessageLoad +_cupsMessageLookup +_cupsSetError +_cupsSetLocale +_cupsStrAlloc +_cupsStrFlush +_cupsStrFormatd +_cupsStrFree +_cupsStrScand +_cupsStrStatistics +_cups_strcpy +_cups_strlcat +_cups_strlcpy +_httpResolveURI +_ippAddAttr +_ippFindOption +_ippFreeAttr +_ppdFreeLanguages +_ppdGetEncoding +_ppdGetLanguages +_ppdHashName +_pwgCreateWithFile +_pwgDestroy +_pwgWriteFile +_pwgGenerateSize +_pwgInitSize +_pwgMediaForLegacy +_pwgMediaForPPD +_pwgMediaForPWG +_pwgMediaForSize +_pwgCreateWithPPD +_pwgGetInputSlot +_pwgGetMediaType +_pwgGetPageSize +_pwgGetSize +_pwgGetSource +_pwgGetType +_pwgInputSlotForSource +_pwgMediaTypeForType +_pwgPageSizeForMedia +cupsAddDest +cupsAddOption +cupsAdminCreateWindowsPPD +cupsAdminExportSamba +cupsArrayAdd +cupsArrayClear +cupsArrayCount +cupsArrayCurrent +cupsArrayDelete +cupsArrayDup +cupsArrayFind +cupsArrayFirst +cupsArrayIndex +cupsArrayInsert +cupsArrayLast +cupsArrayNew +cupsArrayNext +cupsArrayPrev +cupsArrayRemove +cupsArrayRestore +cupsArraySave +cupsArrayUserData +cupsCancelJob +cupsCharsetToUTF8 +cupsDirClose +cupsDirOpen +cupsDirRead +cupsDirRewind +cupsDoAuthentication +cupsDoFileRequest +cupsDoIORequest +cupsDoRequest +cupsEncodeOptions +cupsEncodeOptions2 +cupsEncryption +cupsFileClose +cupsFileCompression +cupsFileEOF +cupsFileFind +cupsFileFlush +cupsFileGetChar +cupsFileGetConf +cupsFileGetLine +cupsFileGets +cupsFileLock +cupsFileNumber +cupsFileOpen +cupsFileOpenFd +cupsFilePeekChar +cupsFilePrintf +cupsFilePutChar +cupsFilePuts +cupsFileRead +cupsFileRewind +cupsFileSeek +cupsFileStderr +cupsFileStdin +cupsFileStdout +cupsFileTell +cupsFileUnlock +cupsFileWrite +cupsFreeDests +cupsFreeJobs +cupsFreeOptions +cupsGetClasses +cupsGetDefault +cupsGetDefault2 +cupsGetDest +cupsGetDests +cupsGetDests2 +cupsGetFd +cupsGetFile +cupsGetJobs +cupsGetJobs2 +cupsGetOption +cupsGetPPD +cupsGetPPD2 +cupsGetPassword +cupsGetPrinters +cupsGetResponse +cupsLangDefault +cupsLangEncoding +cupsLangFlush +cupsLangFree +cupsLangGet +cupsLastError +cupsLastErrorString +cupsMarkOptions +cupsNotifySubject +cupsNotifyText +cupsParseOptions +cupsPrintFile +cupsPrintFile2 +cupsPrintFiles +cupsPrintFiles2 +cupsPutFd +cupsPutFile +cupsRemoveOption +cupsResolveConflicts +cupsSendRequest +cupsServer +cupsSetDests +cupsSetDests2 +cupsSetEncryption +cupsSetPasswordCB +cupsSetServer +cupsSetUser +cupsTempFd +cupsTempFile +cupsTempFile2 +cupsUTF32ToUTF8 +cupsUTF8ToCharset +cupsUTF8ToUTF32 +cupsUser +cupsWriteRequestData +httpAddrAny +httpAddrConnect +httpAddrEqual +httpAddrFreeList +httpAddrGetList +httpAddrLength +httpAddrLocalhost +httpAddrLookup +httpAddrString +httpAssembleURI +httpAssembleURIf +httpBlocking +httpCheck +httpClearCookie +httpClearFields +httpClose +httpConnect +httpConnectEncrypt +httpDecode64 +httpDecode64_2 +httpDelete +httpEncode64 +httpEncode64_2 +httpEncryption +httpError +httpFlush +httpFlushWrite +httpGet +httpGetBlocking +httpGetCookie +httpGetDateString +httpGetDateString2 +httpGetDateTime +httpGetFd +httpGetField +httpGetHostByName +httpGetHostname +httpGetLength +httpGetLength2 +httpGetStatus +httpGetSubField +httpGetSubField2 +httpGets +httpHead +httpInitialize +httpMD5 +httpMD5Final +httpMD5String +httpOptions +httpPost +httpPrintf +httpPut +httpRead +httpRead2 +httpReconnect +httpSeparate +httpSeparate2 +httpSeparateURI +httpSetCookie +httpSetExpect +httpSetField +httpSetLength +httpStatus +httpTrace +httpUpdate +httpWait +httpWrite +httpWrite2 +ippAddBoolean +ippAddBooleans +ippAddCollection +ippAddCollections +ippAddDate +ippAddInteger +ippAddIntegers +ippAddOctetString +ippAddRange +ippAddRanges +ippAddResolution +ippAddResolutions +ippAddSeparator +ippAddString +ippAddStrings +ippDateToTime +ippDelete +ippDeleteAttribute +ippErrorString +ippErrorValue +ippFindAttribute +ippFindNextAttribute +ippLength +ippNew +ippNewRequest +ippOpString +ippOpValue +ippPort +ippRead +ippReadFile +ippReadIO +ippSetPort +ippTagString +ippTagValue +ippTimeToDate +ippWrite +ippWriteFile +ippWriteIO +ppdClose +ppdCollect +ppdCollect2 +ppdConflicts +ppdEmit +ppdEmitAfterOrder +ppdEmitFd +ppdEmitJCL +ppdEmitJCLEnd +ppdEmitString +ppdErrorString +ppdFindAttr +ppdFindChoice +ppdFindCustomOption +ppdFindCustomParam +ppdFindMarkedChoice +ppdFindNextAttr +ppdFindOption +ppdFirstCustomParam +ppdFirstOption +ppdIsMarked +ppdLastError +ppdLocalize +ppdMarkDefaults +ppdMarkOption +ppdNextCustomParam +ppdNextOption +ppdOpen +ppdOpen2 +ppdOpenFd +ppdOpenFile +ppdPageLength +ppdPageSize +ppdPageWidth +ppdSetConformance diff --git a/cups/libcups_s.exp b/cups/libcups_s.exp index 30b8a9f01..79564a6c3 100644 --- a/cups/libcups_s.exp +++ b/cups/libcups_s.exp @@ -15,9 +15,6 @@ _cupsMD5Init _cupsMessageFree _cupsMessageLoad _cupsMessageLookup -_cupsPWGMediaByName -_cupsPWGMediaByLegacy -_cupsPWGMediaBySize _cupsSetError _cupsSetLocale _cupsSNMPClose @@ -57,4 +54,23 @@ _ppdGetLanguages _ppdHashName _ppdLocalizedAttr _ppdNormalizeMakeAndModel -_ppdParseOptions \ No newline at end of file +_ppdParseOptions +_pwgCreateWithFile +_pwgDestroy +_pwgWriteFile +_pwgGenerateSize +_pwgInitSize +_pwgMediaForLegacy +_pwgMediaForPPD +_pwgMediaForPWG +_pwgMediaForSize +_pwgCreateWithPPD +_pwgGetInputSlot +_pwgGetMediaType +_pwgGetPageSize +_pwgGetSize +_pwgGetSource +_pwgGetType +_pwgInputSlotForSource +_pwgMediaTypeForType +_pwgPageSizeForMedia diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index 4aa320e72..d1b03e1b8 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -41,13 +41,6 @@ # include #endif /* HAVE_INTTYPES_H */ -#ifdef HAVE_COREFOUNDATION_H -# include -#endif /* HAVE_COREFOUNDATION_H */ -#ifdef HAVE_CFPRIV_H -# include -#endif /* HAVE_CFPRIV_H */ - /* * LPD "mini-daemon" for CUPS. This program must be used in conjunction @@ -363,7 +356,7 @@ create_job(http_t *http, /* I - HTTP connection */ NULL, title); if (docname[0]) - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name", + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "document-name", NULL, docname); cupsEncodeOptions(request, num_options, options); @@ -655,100 +648,6 @@ get_printer(http_t *http, /* I - HTTP connection */ ippDelete(response); } - /* - * Override shared value for LPD using system-specific APIs... - */ - -#ifdef HAVE_CFPRIV_H /* MacOS X */ - if (shared && *shared) - { - CFURLRef prefsurl; /* URL for preferences file */ - CFDataRef xmldata; /* XML data from preferences file */ - CFPropertyListRef plist; /* Property list from XML data */ - CFStringRef queueid; /* CFString of destination name */ - CFArrayRef lprqarray; /* Array of shared "LPR" printers */ - CFBooleanRef serverflag; /* State of the print service */ - static const char printerprefsfile[] = - "/Library/Preferences/com.apple.printservice.plist"; - /* Preferences file */ - - - /* - * See if we are running on MacOS X Server... - */ - - CFDictionaryRef versdict = _CFCopyServerVersionDictionary(); - - if (versdict) - { - /* - * Yes, use the LPR sharing preference... - */ - - CFRelease(versdict); - - *shared = 0; - - prefsurl = CFURLCreateFromFileSystemRepresentation( - kCFAllocatorDefault, - (const UInt8 *)printerprefsfile, - (CFIndex)strlen(printerprefsfile), - false); - if (prefsurl) - { - if (CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, - prefsurl, &xmldata, NULL, - NULL, NULL)) - { - plist = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, xmldata, - kCFPropertyListImmutable, - NULL); - if (plist) - { - serverflag = (CFBooleanRef)CFDictionaryGetValue( - (CFDictionaryRef)plist, - CFSTR("serviceState")); - - if (serverflag && CFBooleanGetValue(serverflag)) - { - lprqarray = (CFArrayRef)CFDictionaryGetValue( - (CFDictionaryRef)plist, - CFSTR("lprSharedQueues")); - - if (lprqarray) - { - queueid = CFStringCreateWithCString(CFAllocatorGetDefault(), - dest, - kCFStringEncodingUTF8); - - if (queueid) - { - *shared = CFArrayContainsValue(lprqarray, - CFRangeMake(0, - CFArrayGetCount(lprqarray)), - queueid); - - CFRelease(queueid); - } - } - } - - CFRelease(plist); - } - - CFRelease(xmldata); - } - - CFRelease(prefsurl); - } - - if (!shared) - syslog(LOG_ERR, "Warning - Print Service sharing disabled for LPD " - "on queue: %s", name); - } - } -#endif /* HAVE_CFPRIV_H */ - /* * Next look for the printer in the lpoptions file... */ diff --git a/scheduler/job.c b/scheduler/job.c index cbdb0e29a..d5a47756f 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -4249,7 +4249,8 @@ update_job(cupsd_job_t *job) /* I - Job to check */ cupsdLogJob(job, loglevel, "%s", ptr); - if (loglevel < CUPSD_LOG_DEBUG) + if (loglevel < CUPSD_LOG_DEBUG && + strcmp(job->printer->state_message, ptr)) { strlcpy(job->printer->state_message, ptr, sizeof(job->printer->state_message)); @@ -4284,7 +4285,7 @@ update_job(cupsd_job_t *job) /* I - Job to check */ if (event & CUPSD_EVENT_JOB_PROGRESS) cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job, "%s", job->printer->state_message); - else if (event & CUPSD_EVENT_PRINTER_STATE) + if (event & CUPSD_EVENT_PRINTER_STATE) cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, job->printer, NULL, (job->printer->type & CUPS_PRINTER_CLASS) ? "Class \"%s\" state changed." : diff --git a/scheduler/main.c b/scheduler/main.c index cc05af694..0eaeca455 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1447,7 +1447,9 @@ launchd_checkin(void) { size_t i, /* Looping var */ count; /* Number of listeners */ +# ifdef HAVE_SSL int portnum; /* Port number */ +# endif /* HAVE_SSL */ launch_data_t ld_msg, /* Launch data message */ ld_resp, /* Launch data response */ ld_array, /* Launch data array */ diff --git a/test/ipptest.c b/test/ipptest.c index f2f4f414f..9f49a71d3 100644 --- a/test/ipptest.c +++ b/test/ipptest.c @@ -43,6 +43,7 @@ */ #include +#include #include #ifndef O_BINARY diff --git a/vcnet/config.h b/vcnet/config.h index ab2d920e9..272724c04 100644 --- a/vcnet/config.h +++ b/vcnet/config.h @@ -1,9 +1,9 @@ /* * "$Id: config.h 6649 2007-07-11 21:46:42Z mike $" * - * Configuration file for the Common UNIX Printing System (CUPS). + * Configuration file for CUPS. * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -51,6 +51,14 @@ #define write _write +/* + * Map the POSIX sleep() and usleep() functions to the Win32 Sleep() function... + */ + +#define sleep(X) Sleep(1000 * (X)) +#define usleep(X) Sleep((X)/1000) + + /* * Compiler stuff... */ diff --git a/vcnet/libcups2.vcproj b/vcnet/libcups2.vcproj index 983e7da2a..13fa19872 100644 --- a/vcnet/libcups2.vcproj +++ b/vcnet/libcups2.vcproj @@ -101,7 +101,7 @@ /> - - + + + + + + @@ -1509,6 +1515,10 @@ RelativePath="..\cups\dir.h" > + + @@ -1557,6 +1567,10 @@ RelativePath="..\cups\ppd.h" > + + -- 2.39.5