cups-lpd does not refuse printjobs if the queue is in state reject #515

Closed
michaelrsweet opened this Issue Jan 9, 2004 · 4 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Jan 9, 2004

Version: 1.1-current
CUPS.org User: stefan.klein.materna

Hi,

we put a cups-queue into the state reject and try to print to it via the cups-lpd.

From a network trace i see the client sending a "0x02" and cups-lpd responding with "0x00", from my understanding of the RFC-1179 this is wrong, cups-lpq has to answer with an octet of non-zero bits since the queue is in status reject.

Regards,
Stefan Klein

Collaborator

michaelrsweet commented Jan 12, 2004

CUPS.org User: mike

Reassigned to 1.2; will be fixed there.

Collaborator

michaelrsweet commented Feb 25, 2004

CUPS.org User: mike

Try the attached patch and let me know if you still have any difficulties.

Collaborator

michaelrsweet commented Mar 19, 2004

CUPS.org User: mike

This STR has not been updated by the submitter for two or more weeks and has been closed as required by the CUPS Configuration Management Plan. If the issue still requires resolution, please re-submit a new STR.

Collaborator

michaelrsweet commented Mar 19, 2004

"str515.patch":

Index: cups-lpd.c

RCS file: /development/cvs/cups/scheduler/cups-lpd.c,v
retrieving revision 1.42
diff -u -r1.42 cups-lpd.c
--- cups-lpd.c 25 Feb 2004 20:14:53 -0000 1.42
+++ cups-lpd.c 25 Feb 2004 21:17:29 -0000
@@ -286,6 +286,103 @@

/*

  • * 'check_printer()' - Check that a printer exists and is accepting jobs.
  • /
    +
    +int /
    O - Job ID /
    +check_printer(const char *name) /
    I - Printer or class name */
    +{
  • http_t http; / Connection to server */
  • ipp_t request; / IPP request */
  • ipp_t response; / IPP response */
  • ipp_attribute_t attr; / IPP job-id attribute */
  • char uri[HTTP_MAX_URI]; /* Printer URI */
  • cups_lang_t language; / Language to use */
  • int accepting; /* printer-is-accepting-jobs value */
  • /*
  • * Setup a connection and request data...
  • */
  • if ((http = httpConnectEncrypt(cupsServer(), ippPort(),
  •                             cupsEncryption())) == NULL)
    
  • {
  • syslog(LOG_ERR, "Unable to connect to server %s: %s", cupsServer(),
  •       strerror(errno));
    
  • return (0);
  • }
  • /*
  • * Build a standard CUPS URI for the printer and fill the standard IPP
  • * attributes...
  • */
  • if ((request = ippNew()) == NULL)
  • {
  • syslog(LOG_ERR, "Unable to create request: %s", strerror(errno));
  • httpClose(http);
  • return (0);
  • }
  • request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
  • request->request.op.request_id = 1;
  • snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", name);
  • language = cupsLangDefault();
  • ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
  •           "attributes-charset", NULL, cupsLangEncoding(language));
    
  • ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
  •           "attributes-natural-language", NULL,
    
  •           language != NULL ? language->language : "C");
    
  • ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
  •           NULL, uri);
    
  • ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requested-attributes",
  •           NULL, "printer-is-accepting-jobs");
    
  • /*
  • * Do the request...
  • */
  • response = cupsDoRequest(http, request, "/");
  • if (response == NULL)
  • {
  • syslog(LOG_ERR, "Unable to check printer status - %s",
  •       ippErrorString(cupsLastError()));
    
  • accepting = 0;
  • }
  • else if (response->request.status.status_code > IPP_OK_CONFLICT)
  • {
  • syslog(LOG_ERR, "Unable to check printer status - %s",
  •       ippErrorString(response->request.status.status_code));
    
  • accepting = 0;
  • }
  • else if ((attr = ippFindAttribute(response, "printer-is-accepting-jobs",
  •                                IPP_TAG_BOOLEAN)) == NULL)
    
  • {
  • syslog(LOG_ERR, "No job-id attribute found in response from server!");
  • accepting = 0;
  • }
  • else
  • accepting = attr->values[0].boolean;
  • if (response != NULL)
  • ippDelete(response);
  • httpClose(http);
  • cupsLangFree(language);
  • return (accepting);
    +}

+/*

  • 'print_file()' - Print a file to a printer or class.
    */

@@ -319,8 +416,6 @@
return (0);
}

- language = cupsLangDefault();

/*

  • Build a standard CUPS URI for the printer and fill the standard IPP
  • attributes...
    @@ -329,6 +424,7 @@
    if ((request = ippNew()) == NULL)
    {
    syslog(LOG_ERR, "Unable to create request: %s", strerror(errno));
    • httpClose(http);
      return (0);
      }

@@ -337,6 +433,8 @@

snprintf(uri, sizeof(uri), "ipp://localhost/printers/%s", name);

  • language = cupsLangDefault();

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
"attributes-charset", NULL, cupsLangEncoding(language));

@@ -370,22 +468,28 @@
response = cupsDoFileRequest(http, request, uri, file);

if (response == NULL)

  • {
  • syslog(LOG_ERR, "Unable to print file - %s",
  •       ippErrorString(cupsLastError()));
    
    jobid = 0;
  • }
    else if (response->request.status.status_code > IPP_OK_CONFLICT)
  • {
  • syslog(LOG_ERR, "Unable to print file - %s",
  •       ippErrorString(response->request.status.status_code));
    
    jobid = 0;
  • }
    else if ((attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) == NULL)
  • {
  • syslog(LOG_ERR, "No job-id attribute found in response from server!");
    jobid = 0;
  • }
    else
  • {
    jobid = attr->values[0].integer;
  • if (jobid)
    syslog(LOG_INFO, "Print file - job ID = %d", jobid);
  • else if (response)
  • syslog(LOG_ERR, "Unable to print file - %s",
  •       ippErrorString(response->request.status.status_code));
    
  • else
  • syslog(LOG_ERR, "Unable to print file - %s",
  •       ippErrorString(cupsLastError()));
    
  • }

if (response != NULL)
ippDelete(response);
@@ -468,6 +572,15 @@

 return (1);

}

  • }
  • if (!check_printer(queue))
  • {
  • cupsFreeDests(num_dests, dests);
  • putchar(1);
  • return (1);
    }

putchar(0);

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment