From 3e7fe0ca760ad0054cf5c9ec7c90ca415cf6eb06 Mon Sep 17 00:00:00 2001 From: msweet Date: Thu, 16 Feb 2012 22:03:53 +0000 Subject: [PATCH] Merge changes from CUPS 1.6svn-r10310. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@3683 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.5.txt | 5 +- CHANGES.txt | 15 +- backend/dnssd.c | 4 +- backend/ipp.c | 78 +++--- backend/lpd.c | 22 +- backend/snmp-supplies.c | 2 +- backend/testbackend.c | 8 +- cgi-bin/ipp-var.c | 4 +- config-scripts/cups-common.m4 | 36 +-- config-scripts/cups-dnssd.m4 | 20 +- config.h.in | 16 +- cups/auth.c | 20 +- cups/dest-options.c | 2 +- cups/emit.c | 24 +- cups/encode.c | 5 +- cups/http-support.c | 55 ++-- cups/http.c | 89 ++++--- cups/ipp-support.c | 6 +- cups/ipp.c | 6 +- cups/ppd-cache.c | 21 ++ cups/ppd-private.h | 3 +- cups/testipp.c | 4 +- cups/usersys.c | 105 ++++---- doc/help/api-cups.html | 284 ++++++++++++++++++-- doc/help/api-httpipp.html | 159 +++++++++++- doc/help/options.html | 116 +-------- doc/help/policies.html | 29 ++- doc/help/ppd-compiler.html | 8 +- doc/help/ref-client-conf.html | 15 ++ doc/help/ref-cupsd-conf.html.in | 15 ++ doc/help/spec-ipp.html | 14 +- doc/help/spec-ppd.html | 23 ++ filter/ppd-compiler.header | 8 +- filter/pstops.c | 56 ++-- filter/spec-ppd.shtml | 22 ++ man/client.conf.man.in | 10 +- man/cupsd.conf.man.in | 9 +- man/ppdc.man | 9 +- scheduler/Makefile | 4 +- scheduler/auth.c | 12 +- scheduler/avahi.c | 441 ++++++++++++++++++++++++++++++++ scheduler/avahi.h | 69 +++++ scheduler/client.h | 6 +- scheduler/conf.c | 4 +- scheduler/cups-driverd.cxx | 10 +- scheduler/cupsd.h | 28 ++ scheduler/ipp.c | 194 +------------- scheduler/job.c | 13 +- scheduler/job.h | 2 + scheduler/main.c | 33 ++- scheduler/printers.c | 4 +- scheduler/testsub.c | 4 +- scheduler/timeout.c | 249 ++++++++++++++++++ test/get-completed-jobs.test | 4 +- test/get-jobs.test | 4 +- test/ipptool.c | 30 ++- 56 files changed, 1813 insertions(+), 625 deletions(-) create mode 100644 scheduler/avahi.c create mode 100644 scheduler/avahi.h create mode 100644 scheduler/timeout.c diff --git a/CHANGES-1.5.txt b/CHANGES-1.5.txt index f97e843e3..3250d60aa 100644 --- a/CHANGES-1.5.txt +++ b/CHANGES-1.5.txt @@ -3,11 +3,12 @@ CHANGES-1.5.txt CHANGES IN CUPS V1.5.3 + - The cups-driverd program could temporarily "forget" a PPD file if it + was updated in place. + - The dnssd backend now prefers IPPS over IPP. - The USB backend now uses and requires LIBUSB 1.0 or later (STR #3477) - The LIBUSB-based USB backend now supports the back-channel (STR #2890) - Changed how timeouts are implemented in the LPD backend (STR #4013) - - The IPP backend no longer specifies the document-format for auto- - detect unless required (STR #3986) - Added more supported color names for SNMP supplies (STR #3981) - The default InputSlot setting was never used (STR #3957) - POSIX ACLs are now set properly on certificate files (STR #3970) diff --git a/CHANGES.txt b/CHANGES.txt index 454e98dc9..0528f3c3d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,8 +1,21 @@ -CHANGES.txt - 1.6b1 - 2012-01-30 +CHANGES.txt - 1.6b1 - 2012-02-15 -------------------------------- CHANGES IN CUPS V1.6b1 + - Documentation updates (STR #3927, STR #3980, STR #4010) + - CUPS now supports a User directive in client.conf and the CUPS_USER + environment variable for overriding the default username (STR #3114) + - Now set the PJL USERNAME variable as needed (STR #3100) + - Added support for usernames and passwords longer than 32 characters + (STR #2856) + - Added a new MaxHoldTime directive to automatically cancel jobs that + have been held indefinitely after a specific number of seconds + (STR #2291) + - The LPD backend now uses the originating host name when it is not the + local system (STR #2053) + - CUPS now prefers the suffix "dpcm" when reporting resolution in dots- + per-centimeter (STR #4006) - The configure script and build system no longer support building of separate 32-bit and 64-bit libraries. - The "brightness", "columns", "fitplot", "gamma", "hue", diff --git a/backend/dnssd.c b/backend/dnssd.c index fd86e0814..12571b15c 100644 --- a/backend/dnssd.c +++ b/backend/dnssd.c @@ -3,7 +3,7 @@ * * DNS-SD discovery backend for CUPS. * - * Copyright 2008-2011 by Apple Inc. + * Copyright 2008-2012 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -43,8 +43,8 @@ typedef enum { CUPS_DEVICE_PRINTER = 0, /* lpd://... */ - CUPS_DEVICE_IPP, /* ipp://... */ CUPS_DEVICE_IPPS, /* ipps://... */ + CUPS_DEVICE_IPP, /* ipp://... */ CUPS_DEVICE_FAX_IPP, /* ipp://... */ CUPS_DEVICE_PDL_DATASTREAM, /* socket://... */ CUPS_DEVICE_RIOUSBPRINT /* riousbprint://... */ diff --git a/backend/ipp.c b/backend/ipp.c index 68c05e954..20391f8a2 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -90,7 +90,9 @@ static const char * const jattrs[] = /* Job attributes we want */ }; static int job_canceled = 0; /* Job cancelled? */ -static char *password = NULL; +static char username[256] = "", + /* Username for device URI */ + *password = NULL; /* Password for device URI */ static int password_tries = 0; /* Password tries */ @@ -98,7 +100,6 @@ static const char * const pattrs[] = /* Printer attributes we want */ { "copies-supported", "cups-version", - "document-format-default", "document-format-supported", "marker-colors", "marker-high-levels", @@ -190,7 +191,6 @@ main(int argc, /* I - Number of command-line args */ const char *device_uri; /* Device URI */ char scheme[255], /* Scheme in URI */ hostname[1024], /* Hostname */ - username[255], /* Username info */ resource[1024], /* Resource info (printer name) */ addrname[256], /* Address name */ *optptr, /* Pointer to URI options */ @@ -230,7 +230,6 @@ main(int argc, /* I - Number of command-line args */ ipp_attribute_t *job_state; /* job-state */ ipp_attribute_t *copies_sup; /* copies-supported */ ipp_attribute_t *cups_version; /* cups-version */ - ipp_attribute_t *format_dflt; /* document-format-default */ ipp_attribute_t *format_sup; /* document-format-supported */ ipp_attribute_t *media_col_sup; /* media-col-supported */ ipp_attribute_t *operations_sup; /* operations-supported */ @@ -612,7 +611,10 @@ main(int argc, /* I - Number of command-line args */ const char *ptr = getenv("AUTH_USERNAME"); if (ptr) + { + strlcpy(username, ptr, sizeof(username)); cupsSetUser(ptr); + } password = getenv("AUTH_PASSWORD"); } @@ -841,7 +843,9 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n", ippErrorString(ipp_status), cupsLastErrorString()); - if (ipp_status > IPP_OK_CONFLICT) + if (ipp_status <= IPP_OK_CONFLICT) + password_tries = 0; + else { fprintf(stderr, "DEBUG: Get-Printer-Attributes returned %s.\n", ippErrorString(ipp_status)); @@ -898,7 +902,8 @@ main(int argc, /* I - Number of command-line args */ return (CUPS_BACKEND_STOP); } - else if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN) + else if (ipp_status == IPP_FORBIDDEN || + ipp_status == IPP_AUTHENTICATION_CANCELED) { const char *www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE); /* WWW-Authenticate field value */ @@ -911,7 +916,7 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required); return (CUPS_BACKEND_AUTH_REQUIRED); } - else + else if (ipp_status != IPP_NOT_AUTHORIZED) { _cupsLangPrintFilter(stderr, "ERROR", _("Unable to get printer status.")); @@ -997,16 +1002,6 @@ main(int argc, /* I - Number of command-line args */ cups_version = ippFindAttribute(supported, "cups-version", IPP_TAG_TEXT); - if ((format_dflt = ippFindAttribute(supported, "document-format-default", - IPP_TAG_MIMETYPE)) != NULL) - { - fprintf(stderr, "DEBUG: document-format-default (%d values)\n", - format_dflt->num_values); - for (i = 0; i < format_dflt->num_values; i ++) - fprintf(stderr, "DEBUG: [%d] = \"%s\"\n", i, - format_dflt->values[i].string.text); - } - if ((format_sup = ippFindAttribute(supported, "document-format-supported", IPP_TAG_MIMETYPE)) != NULL) { @@ -1184,21 +1179,17 @@ main(int argc, /* I - Number of command-line args */ if (format_sup != NULL) { for (i = 0; i < format_sup->num_values; i ++) - if (!_cups_strcasecmp(final_content_type, - format_sup->values[i].string.text)) + if (!_cups_strcasecmp(final_content_type, format_sup->values[i].string.text)) { document_format = final_content_type; break; } - if (!document_format && - (!format_dflt || - _cups_strcasecmp(format_dflt->values[0].string.text, - "application/octet-stream"))) + if (!document_format) { for (i = 0; i < format_sup->num_values; i ++) if (!_cups_strcasecmp("application/octet-stream", - format_sup->values[i].string.text)) + format_sup->values[i].string.text)) { document_format = "application/octet-stream"; break; @@ -1303,7 +1294,7 @@ main(int argc, /* I - Number of command-line args */ _cupsLangPrintFilter(stderr, "INFO", _("The printer is busy.")); sleep(10); } - else if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN || + else if (ipp_status == IPP_FORBIDDEN || ipp_status == IPP_AUTHENTICATION_CANCELED) { const char *www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE); @@ -1463,6 +1454,8 @@ main(int argc, /* I - Number of command-line args */ } else if (ipp_status == IPP_ERROR_JOB_CANCELED) goto cleanup; + else if (ipp_status == IPP_NOT_AUTHORIZED) + continue; else { /* @@ -1472,11 +1465,12 @@ main(int argc, /* I - Number of command-line args */ _cupsLangPrintFilter(stderr, "ERROR", _("Print file was not accepted.")); - if (ipp_status == IPP_NOT_AUTHORIZED || ipp_status == IPP_FORBIDDEN) + if (ipp_status == IPP_FORBIDDEN || + ipp_status == IPP_AUTHENTICATION_CANCELED) { const char *www_auth = httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE); /* WWW-Authenticate field value */ - + if (!strncmp(www_auth, "Negotiate", 9)) auth_info_required = "negotiate"; else if (www_auth[0]) @@ -1515,6 +1509,7 @@ main(int argc, /* I - Number of command-line args */ } else { + password_tries = 0; monitor.job_id = job_id = job_id_attr->values[0].integer; _cupsLangPrintFilter(stderr, "INFO", _("Print file accepted - job ID %d."), job_id); @@ -1616,8 +1611,13 @@ main(int argc, /* I - Number of command-line args */ _("Unable to add document to print job.")); break; } - else if (num_files == 0 || fd < 0) - break; + else + { + password_tries = 0; + + if (num_files == 0 || fd < 0) + break; + } } } @@ -1705,7 +1705,9 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "DEBUG: Get-Job-Attributes: %s (%s)\n", ippErrorString(ipp_status), cupsLastErrorString()); - if (ipp_status > IPP_OK_CONFLICT) + if (ipp_status <= IPP_OK_CONFLICT) + password_tries = 0; + else { if (ipp_status != IPP_SERVICE_UNAVAILABLE && ipp_status != IPP_NOT_POSSIBLE && @@ -1966,6 +1968,9 @@ check_printer_state( fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n", ippErrorString(cupsLastError()), cupsLastErrorString()); + if (cupsLastError() <= IPP_OK_CONFLICT) + password_tries = 0; + /* * Return the printer-state value... */ @@ -2073,6 +2078,8 @@ monitor_printer( http = _httpCreate(monitor->hostname, monitor->port, NULL, monitor->encryption, AF_UNSPEC); httpSetTimeout(http, 30.0, timeout_cb, NULL); + if (username[0]) + cupsSetUser(username); cupsSetPasswordCB(password_cb); /* @@ -2130,6 +2137,9 @@ monitor_printer( fprintf(stderr, "DEBUG: %s: %s (%s)\n", ippOpString(job_op), ippErrorString(cupsLastError()), cupsLastErrorString()); + if (cupsLastError() <= IPP_OK_CONFLICT) + password_tries = 0; + if (job_op == IPP_GET_JOB_ATTRIBUTES) { if ((attr = ippFindAttribute(response, "job-state", @@ -2452,6 +2462,9 @@ new_request( "multiple-document-handling", NULL, collate_str); break; } + + if (i >= doc_handling_sup->num_values) + copies = 1; } /* @@ -2500,7 +2513,7 @@ new_request( cupsEncodeOptions(request, num_options, options); } - if (copies > 1) + if (copies > 1 && copies <= pc->max_copies) ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies", copies); } @@ -2515,6 +2528,9 @@ new_request( static const char * /* O - Password */ password_cb(const char *prompt) /* I - Prompt (not used) */ { + fprintf(stderr, "DEBUG: password_cb(prompt=\"%s\"), password=%p, " + "password_tries=%d\n", prompt, password, password_tries); + (void)prompt; /* diff --git a/backend/lpd.c b/backend/lpd.c index 0dabfd766..3e3cbfc90 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -92,7 +92,7 @@ static int lpd_queue(const char *hostname, http_addrlist_t *addrlist, int mode, const char *user, const char *title, int copies, int banner, int format, int order, int reserve, int manual_copies, int timeout, - int contimeout); + int contimeout, const char *orighost); static int lpd_write(int lpd_fd, char *buffer, int length); #ifndef HAVE_RRESVPORT_AF static int rresvport_af(int *port, int family); @@ -144,6 +144,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + int num_jobopts; /* Number of job options */ + cups_option_t *jobopts = NULL; /* Job options */ /* @@ -191,6 +193,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ return (CUPS_BACKEND_FAILED); } + num_jobopts = cupsParseOptions(argv[5], 0, &jobopts); + /* * Extract the hostname and printer name from the URI... */ @@ -525,7 +529,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode, username, title, copies, banner, format, order, reserve, - manual_copies, timeout, contimeout); + manual_copies, timeout, contimeout, + cupsGetOption("job-originating-host-name", num_jobopts, + jobopts)); if (!status) fprintf(stderr, "PAGE: 1 %d\n", atoi(argv[4])); @@ -533,7 +539,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ else status = lpd_queue(hostname, addrlist, resource + 1, fd, snmp_fd, mode, username, title, 1, banner, format, order, reserve, 1, - timeout, contimeout); + timeout, contimeout, + cupsGetOption("job-originating-host-name", num_jobopts, + jobopts)); /* * Remove the temporary file if necessary... @@ -638,7 +646,8 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ int reserve, /* I - Reserve ports? */ int manual_copies,/* I - Do copies by hand... */ int timeout, /* I - Timeout... */ - int contimeout) /* I - Connection timeout */ + int contimeout, /* I - Connection timeout */ + const char *orighost) /* I - job-originating-host-name */ { char localhost[255]; /* Local host name */ int error; /* Error number */ @@ -927,7 +936,10 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ return (CUPS_BACKEND_FAILED); } - httpGetHostname(NULL, localhost, sizeof(localhost)); + if (orighost) + strlcpy(localhost, orighost, sizeof(localhost)); + else + httpGetHostname(NULL, localhost, sizeof(localhost)); snprintf(control, sizeof(control), "H%.31s\n" /* RFC 1179, Section 7.2 - host name <= 31 chars */ diff --git a/backend/snmp-supplies.c b/backend/snmp-supplies.c index 601bc979d..0eaba065d 100644 --- a/backend/snmp-supplies.c +++ b/backend/snmp-supplies.c @@ -149,7 +149,7 @@ static const int prtMarkerSuppliesType[] = static const backend_state_t const printer_states[] = { - { CUPS_TC_lowPaper, "media-low-report" }, + /* { CUPS_TC_lowPaper, "media-low-report" }, */ { CUPS_TC_noPaper | CUPS_TC_inputTrayEmpty, "media-empty-warning" }, /* { CUPS_TC_lowToner, "toner-low-report" }, */ /* now use prtMarkerSupplies */ /* { CUPS_TC_noToner, "toner-empty-warning" }, */ /* now use prtMarkerSupplies */ diff --git a/backend/testbackend.c b/backend/testbackend.c index 6182471d1..a3a7d97e6 100644 --- a/backend/testbackend.c +++ b/backend/testbackend.c @@ -98,12 +98,18 @@ main(int argc, /* I - Number of command-line args */ (ptr = strrchr(libpath, '/')) != NULL && !strcmp(ptr, "/backend")) { strlcpy(ptr, "/cups", sizeof(libpath) - (ptr - libpath)); - if (access(libpath, 0)) + if (!access(libpath, 0)) + { #ifdef __APPLE__ + fprintf(stderr, "Setting DYLD_LIBRARY_PATH to \"%s\".\n", libpath); setenv("DYLD_LIBRARY_PATH", libpath, 1); #else + fprintf(stderr, "Setting LD_LIBRARY_PATH to \"%s\".\n", libpath); setenv("LD_LIBRARY_PATH", libpath, 1); #endif /* __APPLE__ */ + } + else + perror(libpath); } /* diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c index 31d34d7fd..6c432a9d6 100644 --- a/cgi-bin/ipp-var.c +++ b/cgi-bin/ipp-var.c @@ -3,7 +3,7 @@ * * CGI <-> IPP variable routines for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -1219,7 +1219,7 @@ cgiSetIPPObjectVars( "%dx%d%s", attr->values[i].resolution.xres, attr->values[i].resolution.yres, attr->values[i].resolution.units == IPP_RES_PER_INCH ? - "dpi" : "dpc"); + "dpi" : "dpcm"); break; case IPP_TAG_URI : diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index 04e700eb5..9b8ac80aa 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -225,24 +225,20 @@ AC_ARG_ENABLE(libusb, [ --enable-libusb use libusb for USB printing]) LIBUSB="" AC_SUBST(LIBUSB) -if test x$enable_libusb = xyes; then - check_libusb=yes -elif test x$enable_libusb != xno -a $uname != Darwin; then - check_libusb=yes -else - check_libusb=no -fi - -if test $check_libusb = yes -a "x$PKGCONFIG" != x; then - AC_MSG_CHECKING(for libusb-1.0) - if $PKGCONFIG --exists libusb-1.0; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_LIBUSB) - CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`" - LIBUSB="`$PKGCONFIG --libs libusb-1.0`" - else - AC_MSG_RESULT(no) +if test "x$PKGCONFIG" != x; then + if test x$enable_libusb = xyes -o $uname != Darwin; then + AC_MSG_CHECKING(for libusb-1.0) + if $PKGCONFIG --exists libusb-1.0; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_LIBUSB) + CFLAGS="$CFLAGS `$PKGCONFIG --cflags libusb-1.0`" + LIBUSB="`$PKGCONFIG --libs libusb-1.0`" + else + AC_MSG_RESULT(no) + fi fi +elif x$enable_libusb = xyes; then + AC_MSG_ERROR(Need pkg-config to enable libusb support.) fi dnl See if we have libwrap for TCP wrappers support... @@ -353,12 +349,6 @@ case $uname in dnl Check for dynamic store function... AC_CHECK_FUNCS(SCDynamicStoreCopyComputerName) - dnl Check for new ColorSync APIs... - SAVELIBS="$LIBS" - LIBS="$LIBS -framework ApplicationServices" - AC_CHECK_FUNCS(ColorSyncRegisterDevice) - LIBS="$SAVELIBS" - dnl Check for the new membership functions in MacOSX 10.4... AC_CHECK_HEADER(membership.h,AC_DEFINE(HAVE_MEMBERSHIP_H)) AC_CHECK_HEADER(membershipPriv.h,AC_DEFINE(HAVE_MEMBERSHIPPRIV_H)) diff --git a/config-scripts/cups-dnssd.m4 b/config-scripts/cups-dnssd.m4 index 1999be3ff..3ed91f79b 100644 --- a/config-scripts/cups-dnssd.m4 +++ b/config-scripts/cups-dnssd.m4 @@ -3,7 +3,7 @@ dnl "$Id: cups-dnssd.m4 7890 2008-08-29 22:19:39Z mike $" dnl dnl DNS Service Discovery (aka Bonjour) stuff for CUPS. dnl -dnl Copyright 2007-2011 by Apple Inc. +dnl Copyright 2007-2012 by Apple Inc. dnl dnl These coded instructions, statements, and computer programs are the dnl property of Apple Inc. and are protected by Federal copyright @@ -12,7 +12,8 @@ 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 -AC_ARG_ENABLE(dnssd, [ --disable-dnssd disable DNS Service Discovery support]) +AC_ARG_ENABLE(avahi, [ --disable-avahi disable DNS Service Discovery support using Avahi]) +AC_ARG_ENABLE(dnssd, [ --disable-dnssd disable DNS Service Discovery support using mDNSResponder]) AC_ARG_WITH(dnssd-libs, [ --with-dnssd-libs set directory for DNS Service Discovery library], LDFLAGS="-L$withval $LDFLAGS" DSOFLAGS="-L$withval $DSOFLAGS",) @@ -23,7 +24,20 @@ AC_ARG_WITH(dnssd-includes, [ --with-dnssd-includes set directory for DNS Ser DNSSDLIBS="" DNSSD_BACKEND="" -if test x$enable_dnssd != xno; then +if test "x$PKGCONFIG" != x -a x$enable_avahi != xno; then + AC_MSG_CHECKING(for Avahi) + if $PKGCONFIG --exists avahi-client; then + AC_MSG_RESULT(yes) + CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`" + DNSSDLIBS="`$PKGCONFIG --libs avahi-client`" + DNSSD_BACKEND="dnssd" + AC_DEFINE(HAVE_AVAHI) + else + AC_MSG_RESULT(no) + fi +fi + +if test "x$DNSSD_BACKEND" = x -a x$enable_dnssd != xno; then AC_CHECK_HEADER(dns_sd.h, [ case "$uname" in Darwin*) diff --git a/config.h.in b/config.h.in index e5f383e15..9c1faf9ab 100644 --- a/config.h.in +++ b/config.h.in @@ -379,12 +379,19 @@ /* - * Do we have DNS Service Discovery (aka Bonjour)? + * Do we have mDNSResponder for DNS Service Discovery (aka Bonjour)? */ #undef HAVE_DNSSD +/* + * Do we have Avahi for DNS Service Discovery (aka Bonjour)? + */ + +#undef HAVE_AVAHI + + /* * Do we have ? */ @@ -723,13 +730,6 @@ #undef CUPS_BUNDLEDIR -/* - * Do we have the ColorSyncRegisterDevice function? - */ - -#undef HAVE_COLORSYNCREGISTERDEVICE - - /* * Do we have XPC? */ diff --git a/cups/auth.c b/cups/auth.c index bea62b797..7e091bee0 100644 --- a/cups/auth.c +++ b/cups/auth.c @@ -124,7 +124,8 @@ cupsDoAuthentication( const char *method, /* I - Request method ("GET", "POST", "PUT") */ const char *resource) /* I - Resource path */ { - const char *password; /* Password string */ + const char *password, /* Password string */ + *www_auth; /* WWW-Authenticate header */ char prompt[1024], /* Prompt for user */ realm[HTTP_MAX_VALUE], /* realm="xyz" string */ nonce[HTTP_MAX_VALUE]; /* nonce="xyz" string */ @@ -179,9 +180,11 @@ cupsDoAuthentication( * Nope, see if we should retry the current username:password... */ + www_auth = http->fields[HTTP_FIELD_WWW_AUTHENTICATE]; + if ((http->digest_tries > 1 || !http->userpass[0]) && - (!strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Basic", 5) || - !strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Digest", 6))) + (!_cups_strncasecmp(www_auth, "Basic", 5) || + !_cups_strncasecmp(www_auth, "Digest", 6))) { /* * Nope - get a new password from the user... @@ -197,8 +200,7 @@ cupsDoAuthentication( cupsUser(), http->hostname[0] == '/' ? "localhost" : http->hostname); - http->digest_tries = _cups_strncasecmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], - "Digest", 5) != 0; + http->digest_tries = _cups_strncasecmp(www_auth, "Digest", 6) != 0; http->userpass[0] = '\0'; if ((password = cupsGetPassword2(prompt, http, method, resource)) == NULL) @@ -227,7 +229,7 @@ cupsDoAuthentication( */ #ifdef HAVE_GSSAPI - if (!strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Negotiate", 9)) + if (!_cups_strncasecmp(www_auth, "Negotiate", 9)) { /* * Kerberos authentication... @@ -241,7 +243,7 @@ cupsDoAuthentication( } else #endif /* HAVE_GSSAPI */ - if (!strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Basic", 5)) + if (!_cups_strncasecmp(www_auth, "Basic", 5)) { /* * Basic authentication... @@ -254,7 +256,7 @@ cupsDoAuthentication( (int)strlen(http->userpass)); httpSetAuthString(http, "Basic", encode); } - else if (!strncmp(http->fields[HTTP_FIELD_WWW_AUTHENTICATE], "Digest", 6)) + else if (!_cups_strncasecmp(www_auth, "Digest", 6)) { /* * Digest authentication... @@ -277,7 +279,7 @@ cupsDoAuthentication( else { DEBUG_printf(("1cupsDoAuthentication: Unknown auth type: \"%s\"", - http->fields[HTTP_FIELD_WWW_AUTHENTICATE])); + www_auth)); http->status = HTTP_AUTHORIZATION_CANCELED; return (-1); } diff --git a/cups/dest-options.c b/cups/dest-options.c index eff70dcb0..af5a26256 100644 --- a/cups/dest-options.c +++ b/cups/dest-options.c @@ -187,7 +187,7 @@ cupsCheckDestSupported( if (!strcmp(temp, "dpi")) units_value = IPP_RES_PER_INCH; - else if (!strcmp(temp, "dpc")) + else if (!strcmp(temp, "dpc") || !strcmp(temp, "dpcm")) units_value = IPP_RES_PER_CM; else return (0); diff --git a/cups/emit.c b/cups/emit.c index 23e0c2800..e322bfe1a 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -3,7 +3,7 @@ * * PPD code emission routines for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -519,15 +519,27 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */ */ if (display && strcmp(display->value, "job")) - { fprintf(fp, "@PJL JOB NAME = \"%s\"\n", temp); - - if (display && !strcmp(display->value, "rdymsg")) - fprintf(fp, "@PJL RDYMSG DISPLAY = \"%s\"\n", displaymsg); - } + else if (display && !strcmp(display->value, "rdymsg")) + fprintf(fp, "@PJL RDYMSG DISPLAY = \"%s\"\n", displaymsg); else fprintf(fp, "@PJL JOB NAME = \"%s\" DISPLAY = \"%s\"\n", temp, displaymsg); + + /* + * Replace double quotes with single quotes and UTF-8 characters with + * question marks so that the user does not cause a PJL syntax error. + */ + + strlcpy(temp, user, sizeof(temp)); + + for (ptr = temp; *ptr; ptr ++) + if (*ptr == '\"') + *ptr = '\''; + else if (!charset && (*ptr & 128)) + *ptr = '?'; + + fprintf(fp, "@PJL SET USERNAME = \"%s\"\n", temp); } else fputs(ppd->jcl_begin, fp); diff --git a/cups/encode.c b/cups/encode.c index 91a37ecd8..2226e1950 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -3,7 +3,7 @@ * * Option encoding routines for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -539,7 +539,8 @@ cupsEncodeOptions2( else attr->values[j].resolution.yres = attr->values[j].resolution.xres; - if (!_cups_strcasecmp(s, "dpc")) + if (!_cups_strcasecmp(s, "dpc") || + !_cups_strcasecmp(s, "dpcm")) attr->values[j].resolution.units = IPP_RES_PER_CM; else attr->values[j].resolution.units = IPP_RES_PER_INCH; diff --git a/cups/http-support.c b/cups/http-support.c index 0d1f2b211..b886515bd 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -757,10 +757,13 @@ httpGetDateString2(time_t t, /* I - UNIX time */ tdate = gmtime(&t); - snprintf(s, slen, "%s, %02d %s %d %02d:%02d:%02d GMT", - http_days[tdate->tm_wday], tdate->tm_mday, - http_months[tdate->tm_mon], tdate->tm_year + 1900, - tdate->tm_hour, tdate->tm_min, tdate->tm_sec); + if (tdate) + snprintf(s, slen, "%s, %02d %s %d %02d:%02d:%02d GMT", + http_days[tdate->tm_wday], tdate->tm_mday, + http_months[tdate->tm_mon], tdate->tm_year + 1900, + tdate->tm_hour, tdate->tm_min, tdate->tm_sec); + else + s[0] = '\0'; return (s); } @@ -1504,15 +1507,19 @@ _httpResolveURI( if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError) { localref = ref; - if (DNSServiceResolve(&localref, kDNSServiceFlagsShareConnection, 0, - hostname, regtype, "local.", http_resolve_cb, + if (DNSServiceResolve(&localref, + kDNSServiceFlagsShareConnection | + kDNSServiceFlagsTimeout, 0, hostname, regtype, + "local.", http_resolve_cb, &uribuf) == kDNSServiceErr_NoError) { int fds; /* Number of ready descriptors */ time_t timeout, /* Poll timeout */ - start_time = time(NULL);/* Start time */ + start_time = time(NULL),/* Start time */ + end_time = start_time + 90; + /* End time */ - for (;;) + while (time(NULL) < end_time) { if (options & _HTTP_RESOLVE_STDERR) _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer.")); @@ -1524,27 +1531,27 @@ _httpResolveURI( } /* - * For the first minute (or forever if we have a callback), wakeup - * every 2 seconds to emit a "looking for printer" message... + * Wakeup every 2 seconds to emit a "looking for printer" message... */ - timeout = (time(NULL) < (start_time + 60) || cb) ? 2000 : -1; + if ((timeout = end_time - time(NULL)) > 2) + timeout = 2; #ifdef HAVE_POLL polldata.fd = DNSServiceRefSockFD(ref); polldata.events = POLLIN; - fds = poll(&polldata, 1, timeout); + fds = poll(&polldata, 1, 1000 * timeout); #else /* select() */ FD_ZERO(&input_set); FD_SET(DNSServiceRefSockFD(ref), &input_set); - stimeout.tv_sec = ((int)timeout) / 1000; - stimeout.tv_usec = ((int)(timeout) * 1000) % 1000000; + stimeout.tv_sec = timeout; + stimeout.tv_usec = 0; fds = select(DNSServiceRefSockFD(ref)+1, &input_set, NULL, NULL, - timeout < 0.0 ? NULL : &stimeout); + &stimeout); #endif /* HAVE_POLL */ if (fds < 0) @@ -1562,7 +1569,7 @@ _httpResolveURI( * comes in, do an additional domain resolution... */ - if (domainsent == 0 && (domain && _cups_strcasecmp(domain, "local."))) + if (domainsent == 0 && domain && _cups_strcasecmp(domain, "local.")) { if (options & _HTTP_RESOLVE_STDERR) fprintf(stderr, @@ -1571,10 +1578,12 @@ _httpResolveURI( domain ? domain : ""); domainref = ref; - if (DNSServiceResolve(&domainref, kDNSServiceFlagsShareConnection, + if (DNSServiceResolve(&domainref, + kDNSServiceFlagsShareConnection | + kDNSServiceFlagsTimeout, 0, hostname, regtype, domain, - http_resolve_cb, &uribuf) - == kDNSServiceErr_NoError) + http_resolve_cb, + &uribuf) == kDNSServiceErr_NoError) domainsent = 1; } @@ -1612,11 +1621,15 @@ _httpResolveURI( if (options & _HTTP_RESOLVE_STDERR) { if (uri) + { fprintf(stderr, "DEBUG: Resolved as \"%s\"...\n", uri); + fputs("STATE: -connecting-to-device,offline-report\n", stderr); + } else + { fputs("DEBUG: Unable to resolve URI\n", stderr); - - fputs("STATE: -connecting-to-device,offline-report\n", stderr); + fputs("STATE: -connecting-to-device\n", stderr); + } } #else diff --git a/cups/http.c b/cups/http.c index 16351ef0d..1f2d826dd 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1668,6 +1668,8 @@ _httpPeek(http_t *http, /* I - Connection to server */ * Buffer small reads for better performance... */ + ssize_t buflen; /* Length of read for buffer */ + if (!http->blocking) { while (!httpWait(http, http->wait_value)) @@ -1680,48 +1682,69 @@ _httpPeek(http_t *http, /* I - Connection to server */ } if (http->data_remaining > sizeof(http->buffer)) - bytes = sizeof(http->buffer); + buflen = sizeof(http->buffer); else - bytes = http->data_remaining; + buflen = http->data_remaining; + + DEBUG_printf(("2_httpPeek: Reading %d bytes into buffer.", (int)buflen)); + do + { #ifdef HAVE_SSL - if (http->tls) - bytes = http_read_ssl(http, http->buffer, bytes); - else + if (http->tls) + bytes = http_read_ssl(http, http->buffer, buflen); + else #endif /* HAVE_SSL */ - { - DEBUG_printf(("2_httpPeek: reading %d bytes from socket into buffer...", - (int)bytes)); - - bytes = recv(http->fd, http->buffer, bytes, 0); - - DEBUG_printf(("2_httpPeek: read %d bytes from socket into buffer...", - (int)bytes)); - } + bytes = recv(http->fd, http->buffer, buflen, 0); - if (bytes > 0) - http->used = bytes; - else if (bytes < 0) - { -#ifdef WIN32 - if (WSAGetLastError() != WSAEINTR && WSAGetLastError() != WSAEWOULDBLOCK) + if (bytes < 0) { - http->error = WSAGetLastError(); - return (-1); - } +#ifdef WIN32 + if (WSAGetLastError() != WSAEINTR) + { + http->error = WSAGetLastError(); + return (-1); + } + else if (WSAGetLastError() == WSAEWOULDBLOCK) + { + if (!http->timeout_cb || + !(*http->timeout_cb)(http, http->timeout_data)) + { + http->error = WSAEWOULDBLOCK; + return (-1); + } + } #else - if (errno != EINTR && errno != EAGAIN) - { - http->error = errno; - return (-1); - } + if (errno == EWOULDBLOCK || errno == EAGAIN) + { + if (http->timeout_cb && !(*http->timeout_cb)(http, http->timeout_data)) + { + http->error = errno; + return (-1); + } + else if (!http->timeout_cb && errno != EAGAIN) + { + http->error = errno; + return (-1); + } + } + else if (errno != EINTR) + { + http->error = errno; + return (-1); + } #endif /* WIN32 */ + } } - else - { - http->error = EPIPE; - return (0); - } + while (bytes < 0); + + DEBUG_printf(("2_httpPeek: Read " CUPS_LLFMT " bytes into buffer.", + CUPS_LLCAST bytes)); +#ifdef DEBUG + http_debug_hex("_httpPeek", http->buffer, (int)bytes); +#endif /* DEBUG */ + + http->used = bytes; } if (http->used > 0) diff --git a/cups/ipp-support.c b/cups/ipp-support.c index ec4c2c998..362321a55 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -3,7 +3,7 @@ * * Internet Printing Protocol support functions for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -487,12 +487,12 @@ ippAttributeString( bufptr += snprintf(bufptr, bufend - bufptr + 1, "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? - "dpi" : "dpc"); + "dpi" : "dpcm"); else bufptr += snprintf(temp, sizeof(temp), "%dx%d%s", val->resolution.xres, val->resolution.yres, val->resolution.units == IPP_RES_PER_INCH ? - "dpi" : "dpc"); + "dpi" : "dpcm"); break; case IPP_TAG_DATE : diff --git a/cups/ipp.c b/cups/ipp.c index 96361abdc..6b88d71de 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -3673,7 +3673,11 @@ ippSetString(ipp_t *ipp, /* IO - IPP message */ * Range check input... */ - if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_INTEGER || + if (!ipp || !attr || !*attr || + ((*attr)->value_tag != IPP_TAG_TEXTLANG && + (*attr)->value_tag != IPP_TAG_NAMELANG && + ((*attr)->value_tag < IPP_TAG_TEXT || + (*attr)->value_tag > IPP_TAG_MIMETYPE)) || element < 0 || element > (*attr)->num_values || !strvalue) return (0); diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index c9ee6af2d..cf34a00bd 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -171,6 +171,8 @@ _ppdCacheCreateWithFile( goto create_error; } + pc->max_copies = 9999; + /* * Read the file... */ @@ -553,6 +555,8 @@ _ppdCacheCreateWithFile( cupsArrayAdd(pc->finishings, finishings); } + else if (!_cups_strcasecmp(line, "MaxCopies")) + pc->max_copies = atoi(value); else { DEBUG_printf(("_ppdCacheCreateWithFile: Unknown %s on line %d.", line, @@ -1348,6 +1352,17 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd) /* I - PPD file */ NULL)) != NULL); } + /* + * Max copies... + */ + + if ((ppd_attr = ppdFindAttr(ppd, "cupsMaxCopies", NULL)) != NULL) + pc->max_copies = atoi(ppd_attr->value); + else if (ppd->manual_copies) + pc->max_copies = 1; + else + pc->max_copies = 9999; + /* * Return the cache data... */ @@ -2333,6 +2348,12 @@ _ppdCacheWriteFile( cupsFilePutChar(fp, '\n'); } + /* + * Max copies... + */ + + cupsFilePrintf(fp, "MaxCopies %d\n", pc->max_copies); + /* * IPP attributes, if any... */ diff --git a/cups/ppd-private.h b/cups/ppd-private.h index bc6a0f8b9..426c74ff8 100644 --- a/cups/ppd-private.h +++ b/cups/ppd-private.h @@ -49,7 +49,7 @@ extern "C" { * Constants... */ -# define _PPD_CACHE_VERSION 2 /* Version number in cache file */ +# define _PPD_CACHE_VERSION 3 /* Version number in cache file */ /* @@ -141,6 +141,7 @@ struct _ppd_cache_s /**** PPD cache and PWG conversion data ****/ *prefilters; /* cupsPreFilter values */ int single_file; /* cupsSingleFile value */ cups_array_t *finishings; /* cupsIPPFinishings values */ + int max_copies; /* cupsMaxCopies value */ }; diff --git a/cups/testipp.c b/cups/testipp.c index 70c83bf4b..5655b6be2 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -3,7 +3,7 @@ * * IPP test program for CUPS. * - * Copyright 2007-2011 by Apple Inc. + * Copyright 2007-2012 by Apple Inc. * Copyright 1997-2005 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -901,7 +901,7 @@ print_attributes(ipp_t *ipp, /* I - IPP request */ case IPP_TAG_RESOLUTION : for (i = 0, val = attr->values; i < attr->num_values; i ++, val ++) printf(" %dx%d%s", val->resolution.xres, val->resolution.yres, - val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpc"); + val->resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm"); putchar('\n'); break; diff --git a/cups/usersys.c b/cups/usersys.c index dfd5cb21c..0fcd86e57 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -66,6 +66,7 @@ static void cups_read_client_conf(cups_file_t *fp, _cups_globals_t *cg, const char *cups_encryption, const char *cups_server, + const char *cups_user, #ifdef HAVE_GSSAPI const char *cups_gssservicename, #endif /* HAVE_GSSAPI */ @@ -435,55 +436,11 @@ cupsSetUser(const char *user) /* I - User name */ const char * /* O - User name */ cupsUser(void) { - const char *user; /* USER environment variable */ _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ if (!cg->user[0]) - { -#ifdef WIN32 - /* - * Get the current user name from the OS... - */ - - DWORD size; /* Size of string */ - - size = sizeof(cg->user); - if (!GetUserName(cg->user, &size)) -#else - /* - * Get the user name corresponding to the current UID... - */ - - struct passwd *pwd; /* User/password entry */ - - setpwent(); - if ((pwd = getpwuid(getuid())) != NULL) - { - /* - * Found a match! - */ - - strlcpy(cg->user, pwd->pw_name, sizeof(cg->user)); - } - else -#endif /* WIN32 */ - if ((user = getenv("USER")) != NULL) - { - /* - * Use the username from the "USER" environment variable... - */ - strlcpy(cg->user, user, sizeof(cg->user)); - } - else - { - /* - * Use the default "unknown" user name... - */ - - strcpy(cg->user, "unknown"); - } - } + _cupsSetDefaults(); return (cg->user); } @@ -791,6 +748,7 @@ _cupsSetDefaults(void) const char *home, /* Home directory of user */ *cups_encryption, /* CUPS_ENCRYPTION env var */ *cups_server, /* CUPS_SERVER env var */ + *cups_user, /* CUPS_USER/USER env var */ #ifdef HAVE_GSSAPI *cups_gssservicename, /* CUPS_GSSSERVICENAME env var */ #endif /* HAVE_GSSAPI */ @@ -816,13 +774,16 @@ _cupsSetDefaults(void) cups_expiredroot = getenv("CUPS_EXPIREDROOT"); cups_expiredcerts = getenv("CUPS_EXPIREDCERTS"); + if ((cups_user = getenv("CUPS_USER")) == NULL) + cups_user = getenv("USER"); + /* * Then, if needed, read the ~/.cups/client.conf or /etc/cups/client.conf * files to get the default values... */ if (cg->encryption == (http_encryption_t)-1 || !cg->server[0] || - !cg->ipp_port) + !cg->user[0] || !cg->ipp_port) { if ((home = getenv("HOME")) != NULL) { @@ -852,7 +813,7 @@ _cupsSetDefaults(void) * functions handle NULL cups_file_t pointers... */ - cups_read_client_conf(fp, cg, cups_encryption, cups_server, + cups_read_client_conf(fp, cg, cups_encryption, cups_server, cups_user, #ifdef HAVE_GSSAPI cups_gssservicename, #endif /* HAVE_GSSAPI */ @@ -873,6 +834,7 @@ cups_read_client_conf( _cups_globals_t *cg, /* I - Global data */ const char *cups_encryption, /* I - CUPS_ENCRYPTION env var */ const char *cups_server, /* I - CUPS_SERVER env var */ + const char *cups_user, /* I - CUPS_USER env var */ #ifdef HAVE_GSSAPI const char *cups_gssservicename, /* I - CUPS_GSSSERVICENAME env var */ @@ -888,6 +850,7 @@ cups_read_client_conf( #ifndef __APPLE__ server_name[1024], /* ServerName value */ #endif /* !__APPLE__ */ + user[256], /* User value */ any_root[1024], /* AllowAnyRoot value */ expired_root[1024], /* AllowExpiredRoot value */ expired_certs[1024]; /* AllowExpiredCerts value */ @@ -921,6 +884,11 @@ cups_read_client_conf( cups_server = server_name; } #endif /* !__APPLE__ */ + else if (!cups_user && !_cups_strcasecmp(line, "User") && value) + { + strlcpy(user, value, sizeof(user)); + cups_user = user; + } else if (!cups_anyroot && !_cups_strcasecmp(line, "AllowAnyRoot") && value) { strlcpy(any_root, value, sizeof(any_root)); @@ -1029,6 +997,49 @@ cups_read_client_conf( cg->ipp_port = CUPS_DEFAULT_IPP_PORT; } + if (!cg->user[0]) + { + if (cups_user) + strlcpy(cg->user, cups_user, sizeof(cg->user)); + else + { +#ifdef WIN32 + /* + * Get the current user name from the OS... + */ + + DWORD size; /* Size of string */ + + size = sizeof(cg->user); + if (!GetUserName(cg->user, &size)) +#else + /* + * Get the user name corresponding to the current UID... + */ + + struct passwd *pwd; /* User/password entry */ + + setpwent(); + if ((pwd = getpwuid(getuid())) != NULL) + { + /* + * Found a match! + */ + + strlcpy(cg->user, pwd->pw_name, sizeof(cg->user)); + } + else +#endif /* WIN32 */ + { + /* + * Use the default "unknown" user name... + */ + + strcpy(cg->user, "unknown"); + } + } + } + #ifdef HAVE_GSSAPI if (!cups_gssservicename) cups_gssservicename = CUPS_DEFAULT_GSSSERVICENAME; diff --git a/doc/help/api-cups.html b/doc/help/api-cups.html index 5ebd932dc..bda8ad661 100644 --- a/doc/help/api-cups.html +++ b/doc/help/api-cups.html @@ -400,8 +400,13 @@ div.contents ul.subcontents li {
  • cupsAdminSetServerSettings
  • cupsCancelJob
  • cupsCancelJob2
  • +
  • cupsConnectDest
  • +
  • cupsConnectDestBlock
  • +
  • cupsCopyDest
  • cupsCreateJob
  • cupsEncryption
  • +
  • cupsEnumDests
  • +
  • cupsEnumDestsBlock
  • cupsFinishDocument
  • cupsFreeDests
  • cupsFreeJobs
  • @@ -463,27 +468,40 @@ connections.">cupsSetCredentials
  • cupsUser
  • Data Types
  • Structures
  • Variables
  • Constants