]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/ipp.c
<rdar://problem/15313228> "Canceling stuck job after XXX seconds" message should...
[thirdparty/cups.git] / backend / ipp.c
index e7f3c3f3e70d73ef5cef9abff3b76799a9e2eda9..d42e27fd1f0c751298bd523f7dccc8b52fc20d21 100644 (file)
@@ -1,36 +1,18 @@
 /*
  * "$Id$"
  *
- *   IPP backend for CUPS.
+ * IPP backend for CUPS.
  *
- *   Copyright 2007-2013 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2013 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   "LICENSE" which should have been included with this file.  If this
- *   file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file.  If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  *
- *   This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- *   main()                - Send a file to the printer or server.
- *   cancel_job()          - Cancel a print job.
- *   check_printer_state()  - Check the printer state.
- *   monitor_printer()     - Monitor the printer state.
- *   new_request()         - Create a new print creation or validation
- *                           request.
- *   password_cb()         - Disable the password prompt for
- *                           cupsDoFileRequest().
- *   quote_string()        - Quote a string value.
- *   report_attr()         - Report an IPP attribute value.
- *   report_printer_state() - Report the printer state.
- *   run_as_user()         - Run the IPP backend as the printing user.
- *   sigterm_handler()     - Handle 'terminate' signals that stop the backend.
- *   timeout_cb()          - Handle HTTP timeouts.
- *   update_reasons()      - Update the printer-state-reasons values.
+ * This file is subject to the Apple OS-Developed Software exception.
  */
 
 /*
@@ -133,6 +115,7 @@ static const char * const pattrs[] =        /* Printer attributes we want */
   "media-col-supported",
   "multiple-document-handling-supported",
   "operations-supported",
+  "print-color-mode-supported",
   "printer-alert",
   "printer-alert-description",
   "printer-is-accepting-jobs",
@@ -366,7 +349,8 @@ main(int  argc,                             /* I - Number of command-line args */
   * that way.
   */
 
-  if (!getuid() && (value = getenv("AUTH_UID")) != NULL)
+  if (!getuid() && (value = getenv("AUTH_UID")) != NULL &&
+      !getenv("AUTH_PASSWORD"))
   {
     uid_t      uid = (uid_t)atoi(value);
                                        /* User ID */
@@ -1698,8 +1682,8 @@ main(int  argc,                           /* I - Number of command-line args */
          ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
                        "requesting-user-name", NULL, argv[2]);
 
-        if ((i + 1) >= num_files)
-         ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", 1);
+       ippAddBoolean(request, IPP_TAG_OPERATION, "last-document",
+                     (i + 1) >= num_files);
 
        if (document_format)
          ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
@@ -1871,6 +1855,8 @@ main(int  argc,                           /* I - Number of command-line args */
     if (!job_id || !waitjob || !get_job_attrs)
       continue;
 
+    fputs("STATE: +cups-waiting-for-job-completed\n", stderr);
+
     _cupsLangPrintFilter(stderr, "INFO", _("Waiting for job to complete."));
 
     for (delay = _cupsNextDelay(0, &prev_delay); !job_canceled;)
@@ -2601,17 +2587,27 @@ new_request(
                      "job-password-encryption", NULL, keyword);
       }
 
-      if (pc->account_id &&
-          (keyword = cupsGetOption("job-account-id", num_options,
-                                   options)) != NULL)
-        ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-account-id",
-                     NULL, keyword);
+      if (pc->account_id)
+      {
+        if ((keyword = cupsGetOption("job-account-id", num_options,
+                                    options)) == NULL)
+         keyword = cupsGetOption("job-billing", num_options, options);
 
-      if (pc->accounting_user_id &&
-          (keyword = cupsGetOption("job-accounting-user-id", num_options,
-                                   options)) != NULL)
-        ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME,
-                     "job-accounting-user-id", NULL, keyword);
+        if (keyword)
+         ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME, "job-account-id",
+                      NULL, keyword);
+      }
+
+      if (pc->accounting_user_id)
+      {
+        if ((keyword = cupsGetOption("job-accounting-user-id", num_options,
+                                    options)) == NULL)
+         keyword = user;
+
+        if (keyword)
+         ippAddString(request, IPP_TAG_JOB, IPP_TAG_NAME,
+                      "job-accounting-user-id", NULL, keyword);
+      }
 
       for (mandatory = (char *)cupsArrayFirst(pc->mandatory);
            mandatory;
@@ -3015,7 +3011,7 @@ quote_string(const char *s,               /* I - String */
   {
     if (*s == '\\' || *s == '\"' || *s == '\'')
     {
-      if (q < (qend - 3))
+      if (qptr < (qend - 4))
       {
        *qptr++ = '\\';
        *qptr++ = '\\';
@@ -3403,7 +3399,6 @@ run_as_user(char       *argv[],           /* I - Command-line arguments */
 
   if (conn)
   {
-    xpc_connection_suspend(conn);
     xpc_connection_cancel(conn);
     xpc_release(conn);
   }