X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=scheduler%2Fipp.c;h=016a1b1af619972480604078d57598929ab90b34;hb=1f6f3dbcf92ae4c7e22a6b143ef27dd330e8ddbb;hp=936a43d1fa667f52669dd326f6faf393598ea3c0;hpb=b19ccc9e271691cc71a08e9968c58f464ebeade5;p=thirdparty%2Fcups.git diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 936a43d1f..016a1b1af 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -2448,7 +2448,9 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ * Do we have a valid device URI? */ - http_uri_status_t uri_status; /* URI separation status */ + http_uri_status_t uri_status; /* URI separation status */ + char old_device_uri[1024]; + /* Old device URI */ need_restart_job = 1; @@ -2502,21 +2504,25 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ * Could not find device in list! */ - send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"!"), - attr->values[0].string.text); + send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri scheme \"%s\"!"), + scheme); return; } } + if (printer->sanitized_device_uri) + strlcpy(old_device_uri, printer->sanitized_device_uri, + sizeof(old_device_uri)); + else + old_device_uri[0] = '\0'; + + cupsdSetDeviceURI(printer, attr->values[0].string.text); + cupsdLogMessage(CUPSD_LOG_INFO, "Setting %s device-uri to \"%s\" (was \"%s\".)", - printer->name, - cupsdSanitizeURI(attr->values[0].string.text, line, - sizeof(line)), - cupsdSanitizeURI(printer->device_uri, resource, - sizeof(resource))); + printer->name, printer->sanitized_device_uri, + old_device_uri); - cupsdSetString(&printer->device_uri, attr->values[0].string.text); set_device_uri = 1; } @@ -2614,6 +2620,48 @@ add_printer(cupsd_client_t *con, /* I - Client connection */ cupsdAddPrinterHistory(printer); } + if ((attr = ippFindAttribute(con->request, "printer-state-reasons", + IPP_TAG_KEYWORD)) != NULL) + { + if (attr->num_values > + (int)(sizeof(printer->reasons) / sizeof(printer->reasons[0]))) + { + send_ipp_status(con, IPP_NOT_POSSIBLE, + _("Too many printer-state-reasons values (%d > %d)!"), + attr->num_values, + (int)(sizeof(printer->reasons) / + sizeof(printer->reasons[0]))); + return; + } + + for (i = 0; i < printer->num_reasons; i ++) + _cupsStrFree(printer->reasons[i]); + + printer->num_reasons = 0; + for (i = 0; i < attr->num_values; i ++) + { + if (!strcmp(attr->values[i].string.text, "none")) + continue; + + printer->reasons[printer->num_reasons] = + _cupsStrAlloc(attr->values[i].string.text); + + if (!strcmp(printer->reasons[printer->num_reasons], "paused") && + printer->state != IPP_PRINTER_STOPPED) + { + cupsdLogMessage(CUPSD_LOG_INFO, + "Setting %s printer-state to %d (was %d.)", + printer->name, IPP_PRINTER_STOPPED, printer->state); + cupsdStopPrinter(printer, 0); + } + + printer->num_reasons ++; + } + + if (PrintcapFormat == PRINTCAP_PLIST) + cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP); + } + set_printer_defaults(con, printer); if ((attr = ippFindAttribute(con->request, "auth-info-required", @@ -5757,6 +5805,7 @@ create_requested_array(ipp_t *request) /* I - IPP request */ cupsArrayAdd(ra, "job-impressions-supported"); cupsArrayAdd(ra, "job-k-octets-supported"); cupsArrayAdd(ra, "job-media-sheets-supported"); + cupsArrayAdd(ra, "job-settable-attributes-supported"); cupsArrayAdd(ra, "multiple-document-jobs-supported"); cupsArrayAdd(ra, "multiple-operation-time-out"); cupsArrayAdd(ra, "natural-language-configured"); @@ -5789,6 +5838,7 @@ create_requested_array(ipp_t *request) /* I - IPP request */ cupsArrayAdd(ra, "printer-state"); cupsArrayAdd(ra, "printer-state-message"); cupsArrayAdd(ra, "printer-state-reasons"); + cupsArrayAdd(ra, "printer-settable-attributes-supported"); cupsArrayAdd(ra, "printer-type"); cupsArrayAdd(ra, "printer-up-time"); cupsArrayAdd(ra, "printer-uri-supported"); @@ -9258,6 +9308,23 @@ save_krb5_creds(cupsd_client_t *con, /* I - Client connection */ return; # endif /* __APPLE__ */ + if (!KerberosInitialized) + { + /* + * Setup a Kerberos context for the scheduler to use... + */ + + KerberosInitialized = 1; + + if (krb5_init_context(&KerberosContext)) + { + KerberosContext = NULL; + + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to initialize Kerberos context"); + return; + } + } + /* * We MUST create a file-based cache because memory-based caches are * only valid for the current process/address space.