diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2010-03-03 22:36:38 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2010-03-03 22:36:38 +0000 |
commit | 5a6b583acf40fd75a0eacaf886c6127fc122e516 (patch) | |
tree | 15a7ff6e21f42830571b87d4309f7ee645ebd92c /scheduler | |
parent | f8b3a85b79b8eb74c37c839079ecbf8266a6f4ed (diff) |
Merge changes from CUPS 1.5svn-r9022.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1937 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler')
-rw-r--r-- | scheduler/conf.c | 3 | ||||
-rw-r--r-- | scheduler/cupsfilter.c | 45 | ||||
-rw-r--r-- | scheduler/dirsvc.c | 69 | ||||
-rw-r--r-- | scheduler/main.c | 8 | ||||
-rw-r--r-- | scheduler/printers.c | 105 | ||||
-rw-r--r-- | scheduler/process.c | 43 |
6 files changed, 226 insertions, 47 deletions
diff --git a/scheduler/conf.c b/scheduler/conf.c index bc83cc11c..5288f9846 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -713,6 +713,9 @@ cupsdReadConfiguration(void) cupsdLogMessage(CUPSD_LOG_INFO, "Remote access is %s.", RemotePort ? "enabled" : "disabled"); + if (!RemotePort) + BrowseLocalProtocols = 0; /* Disable sharing - no remote access */ + /* * See if the ServerName is an IP address... */ diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c index 6f73b62d5..5470bf549 100644 --- a/scheduler/cupsfilter.c +++ b/scheduler/cupsfilter.c @@ -3,7 +3,7 @@ * * CUPS filtering program for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -835,7 +835,7 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ { int i; /* Looping var */ const char *argv[8], /* Command-line arguments */ - *envp[12], /* Environment variables */ + *envp[15], /* Environment variables */ *temp; /* Temporary string */ char *optstr, /* Filter options */ content_type[1024], /* CONTENT_TYPE */ @@ -846,6 +846,9 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ lang[1024], /* LANG */ path[1024], /* PATH */ ppd[1024], /* PPD */ + printer_info[255], /* PRINTER_INFO env variable */ + printer_location[255], /* PRINTER_LOCATION env variable */ + printer_name[255], /* PRINTER env variable */ rip_cache[1024], /* RIP_CACHE */ userenv[1024], /* USER */ program[1024]; /* Program to run */ @@ -859,6 +862,7 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ cups_array_t *pids; /* Executed filters array */ mime_filter_t key; /* Search key for filters */ cups_lang_t *language; /* Current language */ + cups_dest_t *dest; /* Destination information */ /* @@ -900,6 +904,34 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ snprintf(rip_cache, sizeof(rip_cache), "RIP_CACHE=%s", RIPCache); snprintf(userenv, sizeof(userenv), "USER=%s", user); + if (printer && + (dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer, NULL)) != NULL) + { + if ((temp = cupsGetOption("printer-info", dest->num_options, + dest->options)) != NULL) + snprintf(printer_info, sizeof(printer_info), "PRINTER_INFO=%s", temp); + else + snprintf(printer_info, sizeof(printer_info), "PRINTER_INFO=%s", printer); + + if ((temp = cupsGetOption("printer-location", dest->num_options, + dest->options)) != NULL) + snprintf(printer_location, sizeof(printer_location), + "PRINTER_LOCATION=%s", temp); + else + strlcpy(printer_location, "PRINTER_LOCATION=Unknown", + sizeof(printer_location)); + } + else + { + snprintf(printer_info, sizeof(printer_info), "PRINTER_INFO=%s", + printer ? printer : "Unknown"); + strlcpy(printer_location, "PRINTER_LOCATION=Unknown", + sizeof(printer_location)); + } + + snprintf(printer_name, sizeof(printer_name), "PRINTER=%s", + printer ? printer : "Unknown"); + argv[0] = (char *)printer; argv[1] = "1"; argv[2] = user; @@ -921,9 +953,12 @@ exec_filters(mime_type_t *srctype, /* I - Source type */ envp[6] = lang; envp[7] = path; envp[8] = ppd; - envp[9] = rip_cache; - envp[10] = userenv; - envp[11] = NULL; + envp[9] = printer_info; + envp[10] = printer_location; + envp[11] = printer_name; + envp[12] = rip_cache; + envp[13] = userenv; + envp[14] = NULL; for (i = 0; argv[i]; i ++) fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]); diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index f8d882e3a..3fe8f0549 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -3,7 +3,7 @@ * * Directory services routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -120,7 +120,7 @@ static void process_implicit_classes(void); static void send_cups_browse(cupsd_printer_t *p); #ifdef HAVE_LDAP static LDAP *ldap_connect(void); -static void ldap_reconnect(void); +static LDAP *ldap_reconnect(void); static void ldap_disconnect(LDAP *ld); static int ldap_search_rec(LDAP *ld, char *base, int scope, char *filter, char *attrs[], @@ -1357,7 +1357,7 @@ ldap_connect(void) * 'ldap_reconnect()' - Reconnect to LDAP Server */ -static void +static LDAP * /* O - New LDAP handle */ ldap_reconnect(void) { LDAP *TempBrowseLDAPHandle = NULL; /* Temp Handle to LDAP server */ @@ -1365,7 +1365,7 @@ ldap_reconnect(void) /* * Get a new LDAP Handle and replace the global Handle - * if the new connection was successful + * if the new connection was successful. */ cupsdLogMessage(CUPSD_LOG_INFO, "Try LDAP reconnect..."); @@ -1379,6 +1379,8 @@ ldap_reconnect(void) BrowseLDAPHandle = TempBrowseLDAPHandle; } + + return (BrowseLDAPHandle); } @@ -3982,6 +3984,7 @@ ldap_search_rec(LDAP *ld, /* I - LDAP handler */ LDAPMessage **res) /* I - LDAP handler */ { int rc; /* Return code */ + LDAP *ldr; /* LDAP handler after reconnect */ # if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 @@ -4004,13 +4007,13 @@ ldap_search_rec(LDAP *ld, /* I - LDAP handler */ "We try the LDAP search once again after reconnecting to " "the server"); ldap_freeres(*res); - ldap_reconnect(); + ldr = ldap_reconnect(); # if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 - rc = ldap_search_ext_s(ld, base, scope, filter, attrs, attrsonly, NULL, + rc = ldap_search_ext_s(ldr, base, scope, filter, attrs, attrsonly, NULL, NULL, NULL, LDAP_NO_LIMIT, res); # else - rc = ldap_search_s(ld, base, scope, filter, attrs, attrsonly, res); + rc = ldap_search_s(ldr, base, scope, filter, attrs, attrsonly, res); # endif /* defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 */ } @@ -4086,7 +4089,7 @@ ldap_getval_firststring( */ size = maxsize; - if (size < bval[0]->bv_len) + if (size < (bval[0]->bv_len + 1)) { rc = -1; dn = ldap_get_dn(ld, entry); @@ -4096,7 +4099,7 @@ ldap_getval_firststring( ldap_memfree(dn); } else - size = bval[0]->bv_len; + size = bval[0]->bv_len + 1; strlcpy(retval, bval[0]->bv_val, size); ldap_value_free_len(bval); @@ -4142,6 +4145,7 @@ send_ldap_ou(char *ou, /* I - Servername/ou to register */ LDAPMessage *res, /* Search result token */ *e; /* Current entry from search */ int rc; /* LDAP status */ + int rcmod; /* LDAP status for modifications */ char dn[1024], /* DN of the organizational unit we are adding */ *desc[2], /* Change records */ *ou_value[2]; @@ -4252,16 +4256,16 @@ send_ldap_ou(char *ou, /* I - Servername/ou to register */ pmods[i] = NULL; # if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 - if ((rc = ldap_modify_ext_s(BrowseLDAPHandle, dn, pmods, NULL, - NULL)) != LDAP_SUCCESS) + if ((rcmod = ldap_modify_ext_s(BrowseLDAPHandle, dn, pmods, NULL, + NULL)) != LDAP_SUCCESS) # else - if ((rc = ldap_modify_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) + if ((rcmod = ldap_modify_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) # endif /* defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 */ { cupsdLogMessage(CUPSD_LOG_ERROR, "LDAP modify for %s failed with status %d: %s", - ou, rc, ldap_err2string(rc)); - if ( LDAP_SERVER_DOWN == rc ) + ou, rcmod, ldap_err2string(rcmod)); + if (rcmod == LDAP_SERVER_DOWN) ldap_reconnect(); } } @@ -4284,21 +4288,22 @@ send_ldap_ou(char *ou, /* I - Servername/ou to register */ pmods[i] = NULL; # if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 - if ((rc = ldap_add_ext_s(BrowseLDAPHandle, dn, pmods, NULL, - NULL)) != LDAP_SUCCESS) + if ((rcmod = ldap_add_ext_s(BrowseLDAPHandle, dn, pmods, NULL, + NULL)) != LDAP_SUCCESS) # else - if ((rc = ldap_add_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) + if ((rcmod = ldap_add_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) # endif /* defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 */ { cupsdLogMessage(CUPSD_LOG_ERROR, "LDAP add for %s failed with status %d: %s", - ou, rc, ldap_err2string(rc)); - if ( LDAP_SERVER_DOWN == rc ) + ou, rcmod, ldap_err2string(rcmod)); + if (rcmod == LDAP_SERVER_DOWN) ldap_reconnect(); } } - ldap_freeres(res); + if (rc == LDAP_SUCCESS) + ldap_freeres(res); } @@ -4323,6 +4328,7 @@ send_ldap_browse(cupsd_printer_t *p) /* I - Printer to register */ typestring[255], /* String to hold printer-type */ dn[1024]; /* DN of the printer we are adding */ int rc; /* LDAP status */ + int rcmod; /* LDAP status for modifications */ char old_uri[HTTP_MAX_URI], /* Printer URI */ old_location[1024], /* Printer location */ old_info[1024], /* Printer information */ @@ -4506,16 +4512,16 @@ send_ldap_browse(cupsd_printer_t *p) /* I - Printer to register */ pmods[i] = NULL; # if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 - if ((rc = ldap_modify_ext_s(BrowseLDAPHandle, dn, pmods, NULL, - NULL)) != LDAP_SUCCESS) + if ((rcmod = ldap_modify_ext_s(BrowseLDAPHandle, dn, pmods, NULL, + NULL)) != LDAP_SUCCESS) # else - if ((rc = ldap_modify_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) + if ((rcmod = ldap_modify_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) # endif /* defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 */ { cupsdLogMessage(CUPSD_LOG_ERROR, "LDAP modify for %s failed with status %d: %s", - p->name, rc, ldap_err2string(rc)); - if (rc == LDAP_SERVER_DOWN) + p->name, rcmod, ldap_err2string(rcmod)); + if (rcmod == LDAP_SERVER_DOWN) ldap_reconnect(); } } @@ -4540,21 +4546,22 @@ send_ldap_browse(cupsd_printer_t *p) /* I - Printer to register */ pmods[i] = NULL; # if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 - if ((rc = ldap_add_ext_s(BrowseLDAPHandle, dn, pmods, NULL, - NULL)) != LDAP_SUCCESS) + if ((rcmod = ldap_add_ext_s(BrowseLDAPHandle, dn, pmods, NULL, + NULL)) != LDAP_SUCCESS) # else - if ((rc = ldap_add_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) + if ((rcmod = ldap_add_s(BrowseLDAPHandle, dn, pmods)) != LDAP_SUCCESS) # endif /* defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 */ { cupsdLogMessage(CUPSD_LOG_ERROR, "LDAP add for %s failed with status %d: %s", - p->name, rc, ldap_err2string(rc)); - if (rc == LDAP_SERVER_DOWN) + p->name, rcmod, ldap_err2string(rcmod)); + if (rcmod == LDAP_SERVER_DOWN) ldap_reconnect(); } } - ldap_freeres(res); + if (rc == LDAP_SUCCESS) + ldap_freeres(res); } diff --git a/scheduler/main.c b/scheduler/main.c index 9dfb38966..c4378d0d8 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1730,7 +1730,7 @@ process_children(void) job->backend = -pid; if (status && status != SIGTERM && status != SIGKILL && - job->status >= 0) + status != SIGPIPE && job->status >= 0) { /* * An error occurred; save the exit status so we know to stop @@ -1826,6 +1826,12 @@ process_children(void) "PID %d (%s) was terminated normally with signal %d.", pid, name, status); } + else if (status == SIGPIPE) + { + cupsdLogMessage(CUPSD_LOG_DEBUG, + "PID %d (%s) did not catch or ignore signal %d.", + pid, name, status); + } else if (status) { if (WIFEXITED(status)) diff --git a/scheduler/printers.c b/scheduler/printers.c index 876231d45..3a02ab629 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -3889,9 +3889,14 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ char custom_in[256], /* Custom size name in inches */ custom_mm[256]; /* Custom size name in millimeters */ ppd_size_t *size; /* Current size */ - ppd_option_t *output_bin, /* OutputBin options */ - *duplex; /* Duplex options */ + ppd_option_t *duplex, /* Duplex option */ + *output_bin, /* OutputBin option */ + *resolution; /* (Set|JCL|)Resolution option */ + ppd_choice_t *choice; /* Current PPD choice */ ppd_attr_t *ppd_attr; /* PPD attribute */ + int xdpi, /* Horizontal resolution */ + ydpi; /* Vertical resolution */ + const char *resptr; /* Pointer into resolution keyword */ _cups_pwg_media_t *pwgmedia; /* Matching PWG size name */ ipp_attribute_t *attr; /* Attribute data */ ipp_t *media_col_default, /* media-col-default collection value */ @@ -4149,6 +4154,102 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */ } /* + * Printer resolutions... + */ + + if ((resolution = ppdFindOption(ppd, "Resolution")) == NULL) + if ((resolution = ppdFindOption(ppd, "JCLResolution")) == NULL) + if ((resolution = ppdFindOption(ppd, "SetResolution")) == NULL) + resolution = ppdFindOption(ppd, "CNRes_PGP"); + + if (resolution) + { + /* + * Report all supported resolutions... + */ + + attr = ippAddResolutions(p->ppd_attrs, IPP_TAG_PRINTER, + "printer-resolution-supported", + resolution->num_choices, IPP_RES_PER_INCH, + NULL, NULL); + + for (i = 0, choice = resolution->choices; + i < resolution->num_choices; + i ++, choice ++) + { + xdpi = (int)strtol(choice->choice, (char **)&resptr, 10); + if (resptr > choice->choice && xdpi > 0) + { + if (*resptr == 'x') + ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10); + else + ydpi = xdpi; + } + + if (xdpi <= 0 || ydpi <= 0) + { + cupsdLogMessage(CUPSD_LOG_WARN, + "Bad resolution \"%s\" for printer %s.", + choice->choice, p->name); + xdpi = ydpi = 72; + } + + attr->values[i].resolution.xres = xdpi; + attr->values[i].resolution.yres = xdpi; + attr->values[i].resolution.units = IPP_RES_PER_INCH; + + if (choice->marked) + ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, + "printer-resolution-default", IPP_RES_PER_INCH, + xdpi, ydpi); + } + } + else if ((ppd_attr = ppdFindAttr(ppd, "DefaultResolution", NULL)) != NULL && + ppd_attr->value) + { + /* + * Just the DefaultResolution to report... + */ + + xdpi = (int)strtol(ppd_attr->value, (char **)&resptr, 10); + if (resptr > ppd_attr->value && xdpi > 0) + { + if (*resptr == 'x') + ydpi = (int)strtol(resptr + 1, (char **)&resptr, 10); + else + ydpi = xdpi; + } + + if (xdpi <= 0 || ydpi <= 0) + { + cupsdLogMessage(CUPSD_LOG_WARN, + "Bad default resolution \"%s\" for printer %s.", + ppd_attr->value, p->name); + xdpi = ydpi = 72; + } + + ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, + "printer-resolution-default", IPP_RES_PER_INCH, + xdpi, ydpi); + ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, + "printer-resolution-supported", IPP_RES_PER_INCH, + xdpi, ydpi); + } + else + { + /* + * No resolutions in PPD - make one up... + */ + + ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, + "printer-resolution-default", IPP_RES_PER_INCH, + 72, 72); + ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, + "printer-resolution-supported", IPP_RES_PER_INCH, + 72, 72); + } + + /* * Duplexing, etc... */ diff --git a/scheduler/process.c b/scheduler/process.c index b19dc103c..2bc6d164a 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -3,7 +3,7 @@ * * Process management routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2009 by Apple Inc. + * Copyright 2007-2010 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -114,23 +114,50 @@ cupsdCreateProfile(int job_id) /* I - Job ID or 0 for none */ cupsFilePuts(fp, "(allow default)\n"); cupsFilePrintf(fp, "(deny file-write* file-read-data file-read-metadata\n" - " (regex #\"^%s/\"))\n", request); + " (regex" + " #\"^%s$\"" /* RequestRoot */ + " #\"^%s/\"" /* RequestRoot/... */ + " #\"^/Users$\"" + " #\"^/Users/\"" + "))\n", + request, request); cupsFilePrintf(fp, "(deny file-write*\n" - " (regex #\"^%s\" #\"^/private/etc\" #\"^/usr/local/etc\" " - "#\"^/Library\" #\"^/System\" #\"^/Users\"))\n", root); + " (regex" + " #\"^%s$\"" /* ServerRoot */ + " #\"^%s/\"" /* ServerRoot/... */ + " #\"^/private/etc$\"" + " #\"^/private/etc/\"" + " #\"^/usr/local/etc$\"" + " #\"^/usr/local/etc/\"" + " #\"^/Library$\"" + " #\"^/Library/\"" + " #\"^/System$\"" + " #\"^/System/\"" + "))\n", + root, root); cupsFilePrintf(fp, "(allow file-write* file-read-data file-read-metadata\n" - " (regex #\"^%s$\" #\"^%s/\" #\"^%s$\" #\"^%s/\"" + " (regex" + " #\"^%s$\"" /* TempDir */ + " #\"^%s/\"" /* TempDir/... */ + " #\"^%s$\"" /* CacheDir */ + " #\"^%s/\"" /* CacheDir/... */ + " #\"^%s/Library$\"" /* RequestRoot/Library */ + " #\"^%s/Library/\"" /* RequestRoot/Library/... */ " #\"^/Library/Application Support/\"" " #\"^/Library/Caches/\"" " #\"^/Library/Preferences/\"" - " #\"^/Library/Printers/\"" + " #\"^/Library/Printers/.*/\"" + " #\"^/Users/Shared/\"" "))\n", - temp, temp, cache, cache); + temp, temp, cache, cache, request, request); cupsFilePuts(fp, "(deny file-write*\n" - " (regex #\"^/Library/Printers/PPDs/\"" + " (regex" + " #\"^/Library/Printers/PPDs$\"" + " #\"^/Library/Printers/PPDs/\"" + " #\"^/Library/Printers/PPD Plugins$\"" " #\"^/Library/Printers/PPD Plugins/\"" "))\n"); if (job_id) |