]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/ipp.c
Import CUPS v1.7.1
[thirdparty/cups.git] / scheduler / ipp.c
index 11fa79bd5c9391716ba262da782541167262c2a4..a3e55c2bd474e33d9701df0c4df39ebfd769b1ec 100644 (file)
 /*
- * "$Id: ipp.c 7682 2008-06-21 00:06:02Z mike $"
+ * "$Id: ipp.c 11500 2014-01-06 22:21:15Z msweet $"
  *
- *   IPP routines for the Common UNIX Printing System (CUPS) scheduler.
+ * IPP routines for the CUPS scheduler.
  *
- *   Copyright 2007-2008 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
- *   This file contains Kerberos support code, copyright 2006 by
- *   Jelmer Vernooij.
+ * This file contains Kerberos support code, copyright 2006 by
+ * Jelmer Vernooij.
  *
- *   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"
- *   which should have been included with this file.  If this file is
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- *   cupsdProcessIPPRequest()    - Process an incoming IPP request.
- *   cupsdTimeoutJob()           - Timeout a job waiting on job files.
- *   accept_jobs()               - Accept print jobs to a printer.
- *   add_class()                 - Add a class to the system.
- *   add_file()                  - Add a file to a job.
- *   add_job()                   - Add a job to a print queue.
- *   add_job_state_reasons()     - Add the "job-state-reasons" attribute based
- *                                 upon the job and printer state...
- *   add_job_subscriptions()     - Add any subscriptions for a job.
- *   add_job_uuid()              - Add job-uuid attribute to a job.
- *   add_printer()               - Add a printer to the system.
- *   add_printer_state_reasons() - Add the "printer-state-reasons" attribute
- *                                 based upon the printer state...
- *   add_queued_job_count()      - Add the "queued-job-count" attribute for the
- *                                 specified printer or class.
- *   apple_init_profile()        - Initialize a color profile.
- *   apple_register_profiles()   - Register color profiles for a printer.
- *   apple_unregister_profiles() - Remove color profiles for the specified
- *                                 printer.
- *   apply_printer_defaults()    - Apply printer default options to a job.
- *   authenticate_job()          - Set job authentication info.
- *   cancel_all_jobs()           - Cancel all print jobs.
- *   cancel_job()                - Cancel a print job.
- *   cancel_subscription()       - Cancel a subscription.
- *   check_quotas()              - Check quotas for a printer and user.
- *   check_rss_recipient()       - Check that we do not have a duplicate RSS
- *                                 feed URI.
- *   copy_attribute()            - Copy a single attribute.
- *   copy_attrs()                - Copy attributes from one request to another.
- *   copy_banner()               - Copy a banner file to the requests directory
- *                                 for the specified job.
- *   copy_file()                 - Copy a PPD file or interface script...
- *   copy_model()                - Copy a PPD model file, substituting default
- *                                 values as needed...
- *   copy_job_attrs()            - Copy job attributes.
- *   copy_printer_attrs()        - Copy printer attributes.
- *   copy_subscription_attrs()   - Copy subscription attributes.
- *   create_job()                - Print a file to a printer or class.
- *   create_requested_array()    - Create an array for the requested-attributes.
- *   create_subscription()       - Create a notification subscription.
- *   delete_printer()            - Remove a printer or class from the system.
- *   get_default()               - Get the default destination.
- *   get_devices()               - Get the list of available devices on the
- *                                 local system.
- *   get_document()              - Get a copy of a job file.
- *   get_job_attrs()             - Get job attributes.
- *   get_jobs()                  - Get a list of jobs for the specified printer.
- *   get_notifications()         - Get events for a subscription.
- *   get_ppd()                   - Get a named PPD from the local system.
- *   get_ppds()                  - Get the list of PPD files on the local
- *                                 system.
- *   get_printer_attrs()         - Get printer attributes.
- *   get_printers()              - Get a list of printers or classes.
- *   get_subscription_attrs()    - Get subscription attributes.
- *   get_subscriptions()         - Get subscriptions.
- *   get_username()              - Get the username associated with a request.
- *   hold_job()                  - Hold a print job.
- *   move_job()                  - Move a job to a new destination.
- *   ppd_parse_line()            - Parse a PPD default line.
- *   print_job()                 - Print a file to a printer or class.
- *   read_job_ticket()           - Read a job ticket embedded in a print file.
- *   reject_jobs()               - Reject print jobs to a printer.
- *   release_job()               - Release a held print job.
- *   renew_subscription()        - Renew an existing subscription...
- *   restart_job()               - Restart an old print job.
- *   save_auth_info()            - Save authentication information for a job.
- *   save_krb5_creds()           - Save Kerberos credentials for the job.
- *   send_document()             - Send a file to a printer or class.
- *   send_http_error()           - Send a HTTP error back to the IPP client.
- *   send_ipp_status()           - Send a status back to the IPP client.
- *   set_default()               - Set the default destination...
- *   set_job_attrs()             - Set job attributes.
- *   set_printer_defaults()      - Set printer default options from a request.
- *   start_printer()             - Start a printer.
- *   stop_printer()              - Stop a printer.
- *   url_encode_attr()           - URL-encode a string attribute.
- *   url_encode_string()         - URL-encode a string.
- *   user_allowed()              - See if a user is allowed to print to a queue.
- *   validate_job()              - Validate printer options and destination.
- *   validate_name()             - Make sure the printer name only contains
- *                                 valid chars.
- *   validate_user()             - Validate the user for the request.
+ * 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"
+ * which should have been included with this file.  If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
  */
 
 /*
 #include "cupsd.h"
 #include <cups/ppd-private.h>
 
-#ifdef HAVE_LIBPAPER
-#  include <paper.h>
-#endif /* HAVE_LIBPAPER */
-
 #ifdef __APPLE__
-#  include <ApplicationServices/ApplicationServices.h>
-#  include <CoreFoundation/CoreFoundation.h>
+/*#  include <ApplicationServices/ApplicationServices.h>
+extern CFUUIDRef ColorSyncCreateUUIDFromUInt32(unsigned id);
+#  include <CoreFoundation/CoreFoundation.h>*/
 #  ifdef HAVE_MEMBERSHIP_H
 #    include <membership.h>
 #  endif /* HAVE_MEMBERSHIP_H */
@@ -138,21 +50,12 @@ static int add_file(cupsd_client_t *con, cupsd_job_t *job,
                         mime_type_t *filetype, int compression);
 static cupsd_job_t *add_job(cupsd_client_t *con, cupsd_printer_t *printer,
                            mime_type_t *filetype);
-static void    add_job_state_reasons(cupsd_client_t *con, cupsd_job_t *job);
 static void    add_job_subscriptions(cupsd_client_t *con, cupsd_job_t *job);
-static void    add_job_uuid(cupsd_client_t *con, cupsd_job_t *job);
+static void    add_job_uuid(cupsd_job_t *job);
 static void    add_printer(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    add_printer_state_reasons(cupsd_client_t *con,
                                          cupsd_printer_t *p);
 static void    add_queued_job_count(cupsd_client_t *con, cupsd_printer_t *p);
-#ifdef __APPLE__
-static void    apple_init_profile(ppd_file_t *ppd, cups_array_t *languages,
-                                  CMDeviceProfileInfo *profile, unsigned id,
-                                  const char *name, const char *text,
-                                  const char *iccfile);
-static void    apple_register_profiles(cupsd_printer_t *p);
-static void    apple_unregister_profiles(cupsd_printer_t *p);
-#endif /* __APPLE__ */
 static void    apply_printer_defaults(cupsd_printer_t *printer,
                                       cupsd_job_t *job);
 static void    authenticate_job(cupsd_client_t *con, ipp_attribute_t *uri);
@@ -161,10 +64,10 @@ static void        cancel_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    cancel_subscription(cupsd_client_t *con, int id);
 static int     check_rss_recipient(const char *recipient);
 static int     check_quotas(cupsd_client_t *con, cupsd_printer_t *p);
-static ipp_attribute_t *copy_attribute(ipp_t *to, ipp_attribute_t *attr,
-                                       int quickcopy);
+static void    close_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    copy_attrs(ipp_t *to, ipp_t *from, cups_array_t *ra,
-                          ipp_tag_t group, int quickcopy);
+                          ipp_tag_t group, int quickcopy,
+                          cups_array_t *exclude);
 static int     copy_banner(cupsd_client_t *con, cupsd_job_t *job,
                            const char *name);
 static int     copy_file(const char *from, const char *to);
@@ -172,13 +75,14 @@ static int copy_model(cupsd_client_t *con, const char *from,
                           const char *to);
 static void    copy_job_attrs(cupsd_client_t *con,
                               cupsd_job_t *job,
-                              cups_array_t *ra);
+                              cups_array_t *ra, cups_array_t *exclude);
 static void    copy_printer_attrs(cupsd_client_t *con,
                                   cupsd_printer_t *printer,
                                   cups_array_t *ra);
 static void    copy_subscription_attrs(cupsd_client_t *con,
                                        cupsd_subscription_t *sub,
-                                       cups_array_t *ra);
+                                       cups_array_t *ra,
+                                       cups_array_t *exclude);
 static void    create_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static cups_array_t *create_requested_array(ipp_t *request);
 static void    create_subscription(cupsd_client_t *con, ipp_attribute_t *uri);
@@ -193,35 +97,34 @@ static void        get_ppd(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    get_ppds(cupsd_client_t *con);
 static void    get_printers(cupsd_client_t *con, int type);
 static void    get_printer_attrs(cupsd_client_t *con, ipp_attribute_t *uri);
+static void    get_printer_supported(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    get_subscription_attrs(cupsd_client_t *con, int sub_id);
 static void    get_subscriptions(cupsd_client_t *con, ipp_attribute_t *uri);
 static const char *get_username(cupsd_client_t *con);
 static void    hold_job(cupsd_client_t *con, ipp_attribute_t *uri);
+static void    hold_new_jobs(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    move_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static int     ppd_parse_line(const char *line, char *option, int olen,
                               char *choice, int clen);
 static void    print_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    read_job_ticket(cupsd_client_t *con);
 static void    reject_jobs(cupsd_client_t *con, ipp_attribute_t *uri);
+static void    release_held_new_jobs(cupsd_client_t *con,
+                                     ipp_attribute_t *uri);
 static void    release_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    renew_subscription(cupsd_client_t *con, int sub_id);
 static void    restart_job(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    save_auth_info(cupsd_client_t *con, cupsd_job_t *job,
                               ipp_attribute_t *auth_info);
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
-static void    save_krb5_creds(cupsd_client_t *con, cupsd_job_t *job);
-#endif /* HAVE_GSSAPI && HAVE_KRB5_H */
 static void    send_document(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    send_http_error(cupsd_client_t *con, http_status_t status,
                                cupsd_printer_t *printer);
 static void    send_ipp_status(cupsd_client_t *con, ipp_status_t status,
                                const char *message, ...)
-#    ifdef __GNUC__
-__attribute__ ((__format__ (__printf__, 3, 4)))
-#    endif /* __GNUC__ */
-;
+               __attribute__((__format__(__printf__, 3, 4)));
 static void    set_default(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    set_job_attrs(cupsd_client_t *con, ipp_attribute_t *uri);
+static void    set_printer_attrs(cupsd_client_t *con, ipp_attribute_t *uri);
 static void    set_printer_defaults(cupsd_client_t *con,
                                     cupsd_printer_t *printer);
 static void    start_printer(cupsd_client_t *con, ipp_attribute_t *uri);
@@ -275,10 +178,11 @@ cupsdProcessIPPRequest(
   * Then validate the request header and required attributes...
   */
 
-  if (con->request->request.any.version[0] != 1)
+  if (con->request->request.any.version[0] != 1 &&
+      con->request->request.any.version[0] != 2)
   {
    /*
-    * Return an error, since we only support IPP 1.x.
+    * Return an error, since we only support IPP 1.x and 2.x.
     */
 
     cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
@@ -288,17 +192,31 @@ cupsdProcessIPPRequest(
                  con->request->request.any.version[1]);
 
     send_ipp_status(con, IPP_VERSION_NOT_SUPPORTED,
-                    _("Bad request version number %d.%d!"),
+                    _("Bad request version number %d.%d."),
                    con->request->request.any.version[0],
                    con->request->request.any.version[1]);
   }
+  else if (con->request->request.any.request_id < 1)
+  {
+   /*
+    * Return an error, since request IDs must be between 1 and 2^31-1
+    */
+
+    cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
+                  "%04X %s Bad request ID %d",
+                 IPP_BAD_REQUEST, con->http.hostname,
+                  con->request->request.any.request_id);
+
+    send_ipp_status(con, IPP_BAD_REQUEST, _("Bad request ID %d."),
+                   con->request->request.any.request_id);
+  }
   else if (!con->request->attrs)
   {
     cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                   "%04X %s No attributes in request",
                  IPP_BAD_REQUEST, con->http.hostname);
 
-    send_ipp_status(con, IPP_BAD_REQUEST, _("No attributes in request!"));
+    send_ipp_status(con, IPP_BAD_REQUEST, _("No attributes in request."));
   }
   else
   {
@@ -321,7 +239,7 @@ cupsdProcessIPPRequest(
                      IPP_BAD_REQUEST, con->http.hostname);
 
        send_ipp_status(con, IPP_BAD_REQUEST,
-                       _("Attribute groups are out of order (%x < %x)!"),
+                       _("Attribute groups are out of order (%x < %x)."),
                        attr->group_tag, group);
        break;
       }
@@ -339,7 +257,8 @@ cupsdProcessIPPRequest(
       */
 
       attr = con->request->attrs;
-      if (attr && !strcmp(attr->name, "attributes-charset") &&
+      if (attr && attr->name &&
+          !strcmp(attr->name, "attributes-charset") &&
          (attr->value_tag & IPP_TAG_MASK) == IPP_TAG_CHARSET)
        charset = attr;
       else
@@ -348,9 +267,23 @@ cupsdProcessIPPRequest(
       if (attr)
         attr = attr->next;
 
-      if (attr && !strcmp(attr->name, "attributes-natural-language") &&
+      if (attr && attr->name &&
+          !strcmp(attr->name, "attributes-natural-language") &&
          (attr->value_tag & IPP_TAG_MASK) == IPP_TAG_LANGUAGE)
+      {
        language = attr;
+
+       /*
+        * Reset language for this request if different from Accept-Language.
+        */
+
+       if (!con->language ||
+           strcmp(attr->values[0].string.text, con->language->language))
+       {
+         cupsLangFree(con->language);
+         con->language = cupsLangGet(attr->values[0].string.text);
+       }
+      }
       else
        language = NULL;
 
@@ -371,7 +304,7 @@ cupsdProcessIPPRequest(
                     charset->values[0].string.text);
       else
        ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
-                    "attributes-charset", NULL, DefaultCharset);
+                    "attributes-charset", NULL, "utf-8");
 
       if (language)
        ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
@@ -382,21 +315,21 @@ cupsdProcessIPPRequest(
                      "attributes-natural-language", NULL, DefaultLanguage);
 
       if (charset &&
-          strcasecmp(charset->values[0].string.text, "us-ascii") &&
-          strcasecmp(charset->values[0].string.text, "utf-8"))
+          _cups_strcasecmp(charset->values[0].string.text, "us-ascii") &&
+          _cups_strcasecmp(charset->values[0].string.text, "utf-8"))
       {
        /*
         * Bad character set...
        */
 
-        cupsdLogMessage(CUPSD_LOG_ERROR, "Unsupported character set \"%s\"!",
+        cupsdLogMessage(CUPSD_LOG_ERROR, "Unsupported character set \"%s\"",
                        charset->values[0].string.text);
        cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                      "%04X %s Unsupported attributes-charset value \"%s\"",
                      IPP_CHARSET, con->http.hostname,
                      charset->values[0].string.text);
        send_ipp_status(con, IPP_BAD_REQUEST,
-                       _("Unsupported character set \"%s\"!"),
+                       _("Unsupported character set \"%s\"."),
                        charset->values[0].string.text);
       }
       else if (!charset || !language ||
@@ -416,7 +349,7 @@ cupsdProcessIPPRequest(
         if (!charset)
        {
          cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "Missing attributes-charset attribute!");
+                         "Missing attributes-charset attribute");
 
          cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                        "%04X %s Missing attributes-charset attribute",
@@ -426,7 +359,7 @@ cupsdProcessIPPRequest(
         if (!language)
        {
          cupsdLogMessage(CUPSD_LOG_ERROR,
-                         "Missing attributes-natural-language attribute!");
+                         "Missing attributes-natural-language attribute");
 
          cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                        "%04X %s Missing attributes-natural-language attribute",
@@ -437,7 +370,7 @@ cupsdProcessIPPRequest(
        {
          cupsdLogMessage(CUPSD_LOG_ERROR,
                          "Missing printer-uri, job-uri, or ppd-name "
-                         "attribute!");
+                         "attribute");
 
          cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
                        "%04X %s Missing printer-uri, job-uri, or ppd-name "
@@ -455,7 +388,7 @@ cupsdProcessIPPRequest(
        cupsdLogMessage(CUPSD_LOG_DEBUG, "End of attributes...");
 
        send_ipp_status(con, IPP_BAD_REQUEST,
-                       _("Missing required attributes!"));
+                       _("Missing required attributes."));
       }
       else
       {
@@ -472,7 +405,7 @@ cupsdProcessIPPRequest(
          */
 
          if (!strcmp(username->values[0].string.text, "root") &&
-             strcasecmp(con->http.hostname, "localhost") &&
+             _cups_strcasecmp(con->http.hostname, "localhost") &&
              strcmp(con->username, "root"))
          {
           /*
@@ -536,6 +469,10 @@ cupsdProcessIPPRequest(
               get_printer_attrs(con, uri);
               break;
 
+         case IPP_GET_PRINTER_SUPPORTED_VALUES :
+              get_printer_supported(con, uri);
+              break;
+
          case IPP_HOLD_JOB :
               hold_job(con, uri);
               break;
@@ -557,6 +494,8 @@ cupsdProcessIPPRequest(
              break;
 
          case IPP_PURGE_JOBS :
+         case IPP_CANCEL_JOBS :
+         case IPP_CANCEL_MY_JOBS :
               cancel_all_jobs(con, uri);
               break;
 
@@ -564,6 +503,22 @@ cupsdProcessIPPRequest(
               set_job_attrs(con, uri);
               break;
 
+         case IPP_SET_PRINTER_ATTRIBUTES :
+              set_printer_attrs(con, uri);
+              break;
+
+         case IPP_HOLD_NEW_JOBS :
+              hold_new_jobs(con, uri);
+              break;
+
+         case IPP_RELEASE_HELD_NEW_JOBS :
+              release_held_new_jobs(con, uri);
+              break;
+
+         case IPP_CLOSE_JOB :
+              close_job(con, uri);
+              break;
+
          case CUPS_GET_DEFAULT :
               get_default(con);
               break;
@@ -663,7 +618,7 @@ cupsdProcessIPPRequest(
                            ippOpString(con->request->request.op.operation_id));
 
               send_ipp_status(con, IPP_OPERATION_NOT_SUPPORTED,
-                             _("%s not supported!"),
+                             _("%s not supported."),
                              ippOpString(
                                  con->request->request.op.operation_id));
              break;
@@ -682,7 +637,8 @@ cupsdProcessIPPRequest(
                         >= IPP_BAD_REQUEST &&
                     con->response->request.status.status_code
                        != IPP_NOT_FOUND ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG,
-                    "Returning IPP %s for %s (%s) from %s",
+                    "[Client %d] Returning IPP %s for %s (%s) from %s",
+                   con->http.fd,
                    ippErrorString(con->response->request.status.status_code),
                    ippOpString(con->request->request.op.operation_id),
                    uri ? uri->values[0].string.text : "no URI",
@@ -701,6 +657,10 @@ cupsdProcessIPPRequest(
 
       if (con->http.version == HTTP_1_1)
       {
+        cupsdLogMessage(CUPSD_LOG_DEBUG,
+                        "[Client %d] Transfer-Encoding: chunked",
+                        con->http.fd);
+
        if (httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n\r\n") < 0)
          return (0);
 
@@ -721,11 +681,13 @@ cupsdProcessIPPRequest(
        {
          struct stat   fileinfo;       /* File information */
 
-
           if (!fstat(con->file, &fileinfo))
            length += fileinfo.st_size;
        }
 
+        cupsdLogMessage(CUPSD_LOG_DEBUG,
+                        "[Client %d] Content-Length: " CUPS_LLFMT,
+                        con->http.fd, CUPS_LLCAST length);
        if (httpPrintf(HTTP(con), "Content-Length: " CUPS_LLFMT "\r\n\r\n",
                       CUPS_LLCAST length) < 0)
          return (0);
@@ -790,11 +752,13 @@ cupsdTimeoutJob(cupsd_job_t *job) /* I - Job to timeout */
   * See if we need to add the ending sheet...
   */
 
+  if (!cupsdLoadJob(job))
+    return (-1);
+
   printer = cupsdFindDest(job->dest);
   attr    = ippFindAttribute(job->attrs, "job-sheets", IPP_TAG_NAME);
 
-  if (printer &&
-      !(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) &&
+  if (printer && !(printer->type & CUPS_PRINTER_REMOTE) &&
       attr && attr->num_values > 1)
   {
    /*
@@ -841,7 +805,7 @@ accept_jobs(cupsd_client_t  *con,   /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -862,7 +826,8 @@ accept_jobs(cupsd_client_t  *con,   /* I - Client connection */
   printer->accepting        = 1;
   printer->state_message[0] = '\0';
 
-  cupsdAddPrinterHistory(printer);
+  cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL,
+                "Now accepting jobs.");
 
   if (dtype & CUPS_PRINTER_CLASS)
   {
@@ -898,7 +863,7 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
 {
   http_status_t        status;                 /* Policy status */
   int          i;                      /* Looping var */
-  char         method[HTTP_MAX_URI],   /* Method portion of URI */
+  char         scheme[HTTP_MAX_URI],   /* Method portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
@@ -908,7 +873,6 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
   cups_ptype_t dtype;                  /* Destination type */
   ipp_attribute_t *attr;               /* Printer attribute */
   int          modify;                 /* Non-zero if we just modified */
-  char         newname[IPP_MAX_NAME];  /* New class name */
   int          need_restart_job;       /* Need to restart job? */
 
 
@@ -919,8 +883,8 @@ add_class(cupsd_client_t  *con,             /* I - Client connection */
   * Do we have a valid URI?
   */
 
-  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                  sizeof(method), username, sizeof(username), host,
+  httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                  sizeof(scheme), username, sizeof(username), host,
                  sizeof(host), &port, resource, sizeof(resource));
 
 
@@ -962,15 +926,14 @@ add_class(cupsd_client_t  *con,           /* I - Client connection */
     * Class doesn't exist; see if we have a printer of the same name...
     */
 
-    if ((pclass = cupsdFindPrinter(resource + 9)) != NULL &&
-        !(pclass->type & CUPS_PRINTER_DISCOVERED))
+    if ((pclass = cupsdFindPrinter(resource + 9)) != NULL)
     {
      /*
       * Yes, return an error...
       */
 
       send_ipp_status(con, IPP_NOT_POSSIBLE,
-                      _("A printer named \"%s\" already exists!"),
+                      _("A printer named \"%s\" already exists."),
                      resource + 9);
       return;
     }
@@ -988,56 +951,6 @@ add_class(cupsd_client_t  *con,            /* I - Client connection */
     pclass = cupsdAddClass(resource + 9);
     modify = 0;
   }
-  else if (pclass->type & CUPS_PRINTER_IMPLICIT)
-  {
-   /*
-    * Check the default policy, then rename the implicit class to "AnyClass"
-    * or remove it...
-    */
-
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
-    {
-      send_http_error(con, status, NULL);
-      return;
-    }
-
-    if (ImplicitAnyClasses)
-    {
-      snprintf(newname, sizeof(newname), "Any%s", resource + 9);
-      cupsdRenamePrinter(pclass, newname);
-    }
-    else
-      cupsdDeletePrinter(pclass, 1);
-
-   /*
-    * Add the class as a new local class...
-    */
-
-    pclass = cupsdAddClass(resource + 9);
-    modify = 0;
-  }
-  else if (pclass->type & CUPS_PRINTER_DISCOVERED)
-  {
-   /*
-    * Check the default policy, then rename the remote class to "Class"...
-    */
-
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
-    {
-      send_http_error(con, status, NULL);
-      return;
-    }
-
-    snprintf(newname, sizeof(newname), "%s@%s", resource + 9, pclass->hostname);
-    cupsdRenamePrinter(pclass, newname);
-
-   /*
-    * Add the class as a new local class...
-    */
-
-    pclass = cupsdAddClass(resource + 9);
-    modify = 0;
-  }
   else if ((status = cupsdCheckPolicy(pclass->op_policy_ptr, con,
                                       NULL)) != HTTP_OK)
   {
@@ -1062,14 +975,17 @@ add_class(cupsd_client_t  *con,          /* I - Client connection */
     cupsdSetString(&pclass->info, attr->values[0].string.text);
 
   if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs",
-                               IPP_TAG_BOOLEAN)) != NULL)
+                               IPP_TAG_BOOLEAN)) != NULL &&
+      attr->values[0].boolean != pclass->accepting)
   {
     cupsdLogMessage(CUPSD_LOG_INFO,
                     "Setting %s printer-is-accepting-jobs to %d (was %d.)",
                     pclass->name, attr->values[0].boolean, pclass->accepting);
 
     pclass->accepting = attr->values[0].boolean;
-    cupsdAddPrinterHistory(pclass);
+
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, pclass, NULL, "%s accepting jobs.",
+                 pclass->accepting ? "Now" : "No longer");
   }
 
   if ((attr = ippFindAttribute(con->request, "printer-is-shared",
@@ -1092,7 +1008,7 @@ add_class(cupsd_client_t  *con,           /* I - Client connection */
         attr->values[0].integer != IPP_PRINTER_STOPPED)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Attempt to set %s printer-state to bad value %d!"),
+                      _("Attempt to set %s printer-state to bad value %d."),
                       pclass->name, attr->values[0].integer);
       return;
     }
@@ -1113,7 +1029,9 @@ add_class(cupsd_client_t  *con,           /* I - Client connection */
   {
     strlcpy(pclass->state_message, attr->values[0].string.text,
             sizeof(pclass->state_message));
-    cupsdAddPrinterHistory(pclass);
+
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, pclass, NULL, "%s",
+                  pclass->state_message);
   }
   if ((attr = ippFindAttribute(con->request, "member-uris",
                                IPP_TAG_URI)) != NULL)
@@ -1147,9 +1065,15 @@ add_class(cupsd_client_t  *con,          /* I - Client connection */
        */
 
        send_ipp_status(con, IPP_NOT_FOUND,
-                       _("The printer or class was not found."));
+                       _("The printer or class does not exist."));
        return;
       }
+      else if (dtype & CUPS_PRINTER_CLASS)
+      {
+        send_ipp_status(con, IPP_BAD_REQUEST,
+                       _("Nested classes are not allowed."));
+        return;
+      }
 
      /*
       * Add it to the class...
@@ -1174,41 +1098,30 @@ add_class(cupsd_client_t  *con,         /* I - Client connection */
 
   if (need_restart_job && pclass->job)
   {
-    cupsd_job_t *job;
-
    /*
-    * Stop the current job and then restart it below...
+    * Reset the current job to a "pending" status...
     */
 
-    job = (cupsd_job_t *)pclass->job;
-
-    cupsdStopJob(job, 1);
-
-    job->state->values[0].integer = IPP_JOB_PENDING;
-    job->state_value              = IPP_JOB_PENDING;
+    cupsdSetJobState(pclass->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+                     "Job restarted because the class was modified.");
   }
 
-  if (need_restart_job)
-    cupsdCheckJobs();
-
   cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
   if (modify)
   {
-    cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED, pclass, NULL,
-                  "Class \"%s\" modified by \"%s\".", pclass->name,
-                 get_username(con));
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED,
+                 pclass, NULL, "Class \"%s\" modified by \"%s\".",
+                 pclass->name, get_username(con));
 
     cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" modified by \"%s\".",
                     pclass->name, get_username(con));
   }
   else
   {
-    cupsdAddPrinterHistory(pclass);
-
-    cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, pclass, NULL,
-                  "New class \"%s\" added by \"%s\".", pclass->name,
-                 get_username(con));
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED,
+                 pclass, NULL, "New class \"%s\" added by \"%s\".",
+                 pclass->name, get_username(con));
 
     cupsdLogMessage(CUPSD_LOG_INFO, "New class \"%s\" added by \"%s\".",
                     pclass->name, get_username(con));
@@ -1255,20 +1168,25 @@ add_file(cupsd_client_t *con,           /* I - Connection to client */
                                           sizeof(mime_type_t *));
   }
 
+  if (compressions)
+    job->compressions = compressions;
+
+  if (filetypes)
+    job->filetypes = filetypes;
+
   if (!compressions || !filetypes)
   {
-    cupsdCancelJob(job, 1, IPP_JOB_ABORTED);
+    cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE,
+                     "Job aborted because the scheduler ran out of memory.");
 
     if (con)
       send_ipp_status(con, IPP_INTERNAL_ERROR,
-                     _("Unable to allocate memory for file types!"));
+                     _("Unable to allocate memory for file types."));
 
     return (-1);
   }
 
-  job->compressions                 = compressions;
   job->compressions[job->num_files] = compression;
-  job->filetypes                    = filetypes;
   job->filetypes[job->num_files]    = filetype;
 
   job->num_files ++;
@@ -1292,14 +1210,31 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
   http_status_t        status;                 /* Policy status */
   ipp_attribute_t *attr,               /* Current attribute */
                *auth_info;             /* auth-info attribute */
+  const char   *mandatory;             /* Current mandatory job attribute */
   const char   *val;                   /* Default option value */
   int          priority;               /* Job priority */
-  char         *title;                 /* Job name/title */
   cupsd_job_t  *job;                   /* Current job */
   char         job_uri[HTTP_MAX_URI];  /* Job URI */
   int          kbytes;                 /* Size of print file */
   int          i;                      /* Looping var */
   int          lowerpagerange;         /* Page range bound */
+  int          exact;                  /* Did we have an exact match? */
+  ipp_attribute_t *media_col,          /* media-col attribute */
+               *media_margin;          /* media-*-margin attribute */
+  ipp_t                *unsup_col;             /* media-col in unsupported response */
+  static const char * const readonly[] =/* List of read-only attributes */
+  {
+    "job-id",
+    "job-k-octets-completed",
+    "job-impressions-completed",
+    "job-media-sheets-completed",
+    "job-state",
+    "job-state-message",
+    "job-state-reasons",
+    "time-at-completed",
+    "time-at-creation",
+    "time-at-processing"
+  };
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
@@ -1312,11 +1247,11 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
   */
 
   if (!printer->shared &&
-      strcasecmp(con->http.hostname, "localhost") &&
-      strcasecmp(con->http.hostname, ServerName))
+      _cups_strcasecmp(con->http.hostname, "localhost") &&
+      _cups_strcasecmp(con->http.hostname, ServerName))
   {
     send_ipp_status(con, IPP_NOT_AUTHORIZED,
-                    _("The printer or class is not shared!"));
+                    _("The printer or class is not shared."));
     return (NULL);
   }
 
@@ -1331,9 +1266,9 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
     send_http_error(con, status, printer);
     return (NULL);
   }
-  else if (printer->num_auth_info_required > 0 &&
-           strcmp(printer->auth_info_required[0], "none") &&
-           !con->username[0] && !auth_info)
+  else if (printer->num_auth_info_required == 1 &&
+           !strcmp(printer->auth_info_required[0], "negotiate") &&
+           !con->username[0])
   {
     send_http_error(con, HTTP_UNAUTHORIZED, printer);
     return (NULL);
@@ -1365,9 +1300,51 @@ add_job(cupsd_client_t  *con,            /* I - Client connection */
 
  /*
   * Validate job template attributes; for now just document-format,
-  * copies, number-up, and page-ranges...
+  * copies, job-sheets, number-up, page-ranges, mandatory attributes, and
+  * media...
   */
 
+  for (i = 0; i < (int)(sizeof(readonly) / sizeof(readonly[0])); i ++)
+  {
+    if ((attr = ippFindAttribute(con->request, readonly[i],
+                                 IPP_TAG_ZERO)) != NULL)
+    {
+      ippDeleteAttribute(con->request, attr);
+
+      if (StrictConformance)
+      {
+       send_ipp_status(con, IPP_BAD_REQUEST,
+                       _("The '%s' Job Description attribute cannot be "
+                         "supplied in a job creation request."), readonly[i]);
+       return (NULL);
+      }
+
+      cupsdLogMessage(CUPSD_LOG_INFO,
+                      "Unexpected '%s' Job Description attribute in a job "
+                      "creation request.", readonly[i]);
+    }
+  }
+
+  if (printer->pc)
+  {
+    for (mandatory = (char *)cupsArrayFirst(printer->pc->mandatory);
+        mandatory;
+        mandatory = (char *)cupsArrayNext(printer->pc->mandatory))
+    {
+      if (!ippFindAttribute(con->request, mandatory, IPP_TAG_ZERO))
+      {
+       /*
+       * Missing a required attribute...
+       */
+
+       send_ipp_status(con, IPP_CONFLICT,
+                       _("The \"%s\" attribute is required for print jobs."),
+                       mandatory);
+       return (NULL);
+      }
+    }
+  }
+
   if (filetype && printer->filetypes &&
       !cupsArrayFind(printer->filetypes, filetype))
   {
@@ -1379,7 +1356,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
              filetype->type);
 
     send_ipp_status(con, IPP_DOCUMENT_FORMAT,
-                    _("Unsupported format \'%s\'!"), mimetype);
+                    _("Unsupported format \"%s\"."), mimetype);
 
     ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
                  "document-format", NULL, mimetype);
@@ -1406,14 +1383,14 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
     if (attr->value_tag != IPP_TAG_KEYWORD &&
         attr->value_tag != IPP_TAG_NAME)
     {
-      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value type!"));
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value type."));
       return (NULL);
     }
 
     if (attr->num_values > 2)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Too many job-sheets values (%d > 2)!"),
+                      _("Too many job-sheets values (%d > 2)."),
                      attr->num_values);
       return (NULL);
     }
@@ -1422,7 +1399,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
       if (strcmp(attr->values[i].string.text, "none") &&
           !cupsdFindBanner(attr->values[i].string.text))
       {
-       send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value \"%s\"!"),
+       send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-sheets value \"%s\"."),
                        attr->values[i].string.text);
        return (NULL);
       }
@@ -1465,6 +1442,51 @@ add_job(cupsd_client_t  *con,            /* I - Client connection */
     }
   }
 
+ /*
+  * Do media selection as needed...
+  */
+
+  if (!ippFindAttribute(con->request, "PageRegion", IPP_TAG_ZERO) &&
+      !ippFindAttribute(con->request, "PageSize", IPP_TAG_ZERO) &&
+      _ppdCacheGetPageSize(printer->pc, con->request, NULL, &exact))
+  {
+    if (!exact &&
+        (media_col = ippFindAttribute(con->request, "media-col",
+                                     IPP_TAG_BEGIN_COLLECTION)) != NULL)
+    {
+      send_ipp_status(con, IPP_OK_SUBST, _("Unsupported margins."));
+
+      unsup_col = ippNew();
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-bottom-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-bottom-margin", media_margin->values[0].integer);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-left-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-left-margin", media_margin->values[0].integer);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-right-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-right-margin", media_margin->values[0].integer);
+
+      if ((media_margin = ippFindAttribute(media_col->values[0].collection,
+                                           "media-top-margin",
+                                          IPP_TAG_INTEGER)) != NULL)
+        ippAddInteger(unsup_col, IPP_TAG_ZERO, IPP_TAG_INTEGER,
+                     "media-top-margin", media_margin->values[0].integer);
+
+      ippAddCollection(con->response, IPP_TAG_UNSUPPORTED_GROUP, "media-col",
+                       unsup_col);
+      ippDelete(unsup_col);
+    }
+  }
+
  /*
   * Make sure we aren't over our limit...
   */
@@ -1474,8 +1496,7 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
   if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs)
   {
-    send_ipp_status(con, IPP_NOT_POSSIBLE,
-                    _("Too many active jobs."));
+    send_ipp_status(con, IPP_NOT_POSSIBLE, _("Too many active jobs."));
     return (NULL);
   }
 
@@ -1509,30 +1530,44 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
                   priority);
   }
 
-  if ((attr = ippFindAttribute(con->request, "job-name",
-                               IPP_TAG_NAME)) != NULL)
-    title = attr->values[0].string.text;
-  else
+  if ((attr = ippFindAttribute(con->request, "job-name", IPP_TAG_ZERO)) == NULL)
     ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL,
-                 title = "Untitled");
+                 "Untitled");
+  else if ((attr->value_tag != IPP_TAG_NAME &&
+            attr->value_tag != IPP_TAG_NAMELANG) ||
+           attr->num_values != 1)
+  {
+    send_ipp_status(con, IPP_ATTRIBUTES,
+                    _("Bad job-name value: Wrong type or count."));
+    if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
+      attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+    return (NULL);
+  }
+  else if (!ippValidateAttribute(attr))
+  {
+    send_ipp_status(con, IPP_ATTRIBUTES, _("Bad job-name value: %s"),
+                    cupsLastErrorString());
+    if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
+      attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+    return (NULL);
+  }
 
   if ((job = cupsdAddJob(priority, printer->name)) == NULL)
   {
     send_ipp_status(con, IPP_INTERNAL_ERROR,
-                    _("Unable to add job for destination \"%s\"!"),
+                    _("Unable to add job for destination \"%s\"."),
                    printer->name);
     return (NULL);
   }
 
-  job->dtype   = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
-                                  CUPS_PRINTER_REMOTE);
+  job->dtype   = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE);
   job->attrs   = con->request;
   job->dirty   = 1;
   con->request = ippNewRequest(job->attrs->request.op.operation_id);
 
   cupsdMarkDirty(CUPSD_DIRTY_JOBS);
 
-  add_job_uuid(con, job);
+  add_job_uuid(job);
   apply_printer_defaults(printer, job);
 
   attr = ippFindAttribute(job->attrs, "requesting-user-name", IPP_TAG_NAME);
@@ -1614,10 +1649,10 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
            {
              _cupsStrFree(attr->values[i].string.text);
              attr->values[i].string.text = NULL;
-             if (attr->values[i].string.charset)
+             if (attr->values[i].string.language)
              {
-               _cupsStrFree(attr->values[i].string.charset);
-               attr->values[i].string.charset = NULL;
+               _cupsStrFree(attr->values[i].string.language);
+               attr->values[i].string.language = NULL;
              }
             }
 
@@ -1664,12 +1699,12 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
   job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM,
                              "job-state", IPP_JOB_STOPPED);
   job->state_value = (ipp_jstate_t)job->state->values[0].integer;
+  job->reasons = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD,
+                              "job-state-reasons", NULL, "job-incoming");
   job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER,
                               "job-media-sheets-completed", 0);
   ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL,
                printer->uri);
-  ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-name", NULL,
-               title);
 
   if ((attr = ippFindAttribute(job->attrs, "job-k-octets",
                                IPP_TAG_INTEGER)) != NULL)
@@ -1689,21 +1724,22 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
     attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD,
                         "job-hold-until", NULL, val);
   }
-  if (attr && strcmp(attr->values[0].string.text, "no-hold") &&
-      !(printer->type & CUPS_PRINTER_REMOTE))
+  if (attr && strcmp(attr->values[0].string.text, "no-hold"))
   {
    /*
     * Hold job until specified time...
     */
 
-    cupsdSetJobHoldUntil(job, attr->values[0].string.text);
+    cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0);
 
     job->state->values[0].integer = IPP_JOB_HELD;
     job->state_value              = IPP_JOB_HELD;
+
+    ippSetString(job->attrs, &job->reasons, 0, "job-hold-until-specified");
   }
   else if (job->attrs->request.op.operation_id == IPP_CREATE_JOB)
   {
-    job->hold_until               = time(NULL) + 60;
+    job->hold_until               = time(NULL) + MultipleOperationTimeout;
     job->state->values[0].integer = IPP_JOB_HELD;
     job->state_value              = IPP_JOB_HELD;
   }
@@ -1711,10 +1747,11 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
   {
     job->state->values[0].integer = IPP_JOB_PENDING;
     job->state_value              = IPP_JOB_PENDING;
+
+    ippSetString(job->attrs, &job->reasons, 0, "none");
   }
 
-  if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)) ||
-      Classification)
+  if (!(printer->type & CUPS_PRINTER_REMOTE) || Classification)
   {
    /*
     * Add job sheets options...
@@ -1729,8 +1766,8 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
       attr = ippAddStrings(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME, "job-sheets",
                            2, NULL, NULL);
-      attr->values[0].string.text = _cupsStrAlloc(printer->job_sheets[0]);
-      attr->values[1].string.text = _cupsStrAlloc(printer->job_sheets[1]);
+      attr->values[0].string.text = _cupsStrRetain(printer->job_sheets[0]);
+      attr->values[1].string.text = _cupsStrRetain(printer->job_sheets[1]);
     }
 
     job->job_sheets = attr;
@@ -1847,14 +1884,16 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
     * See if we need to add the starting sheet...
     */
 
-    if (!(printer->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT)))
+    if (!(printer->type & CUPS_PRINTER_REMOTE))
     {
       cupsdLogJob(job, CUPSD_LOG_INFO, "Adding start banner page \"%s\".",
                  attr->values[0].string.text);
 
       if ((kbytes = copy_banner(con, job, attr->values[0].string.text)) < 0)
       {
-        cupsdDeleteJob(job);
+        cupsdSetJobState(job, IPP_JOB_ABORTED, CUPSD_JOB_PURGE,
+                        "Aborting job because the start banner could not be "
+                        "copied.");
         return (NULL);
       }
 
@@ -1863,15 +1902,14 @@ add_job(cupsd_client_t  *con,           /* I - Client connection */
   }
   else if ((attr = ippFindAttribute(job->attrs, "job-sheets",
                                     IPP_TAG_ZERO)) != NULL)
-    job->sheets = attr;
+    job->job_sheets = attr;
 
  /*
   * Fill in the response info...
   */
 
-  snprintf(job_uri, sizeof(job_uri), "http://%s:%d/jobs/%d", ServerName,
-          LocalPort, job->id);
-
+  httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+                   con->clientname, con->clientport, "/jobs/%d", job->id);
   ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
                job_uri);
 
@@ -1879,7 +1917,8 @@ add_job(cupsd_client_t  *con,             /* I - Client connection */
 
   ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state",
                 job->state_value);
-  add_job_state_reasons(con, job);
+  ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons",
+               NULL, job->reasons->values[0].string.text);
 
   con->response->request.status.status_code = IPP_OK;
 
@@ -1910,75 +1949,6 @@ add_job(cupsd_client_t  *con,            /* I - Client connection */
 }
 
 
-/*
- * 'add_job_state_reasons()' - Add the "job-state-reasons" attribute based
- *                             upon the job and printer state...
- */
-
-static void
-add_job_state_reasons(
-    cupsd_client_t *con,               /* I - Client connection */
-    cupsd_job_t    *job)               /* I - Job info */
-{
-  cupsd_printer_t      *dest;          /* Destination printer */
-
-
-  cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job_state_reasons(%p[%d], %d)",
-                  con, con->http.fd, job ? job->id : 0);
-
-  switch (job ? job->state_value : IPP_JOB_CANCELED)
-  {
-    case IPP_JOB_PENDING :
-       dest = cupsdFindDest(job->dest);
-
-        if (dest && dest->state == IPP_PRINTER_STOPPED)
-          ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                      "job-state-reasons", NULL, "printer-stopped");
-        else
-          ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                      "job-state-reasons", NULL, "none");
-        break;
-
-    case IPP_JOB_HELD :
-        if (ippFindAttribute(job->attrs, "job-hold-until",
-                            IPP_TAG_KEYWORD) != NULL ||
-           ippFindAttribute(job->attrs, "job-hold-until",
-                            IPP_TAG_NAME) != NULL)
-          ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                      "job-state-reasons", NULL, "job-hold-until-specified");
-        else
-          ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                      "job-state-reasons", NULL, "job-incoming");
-        break;
-
-    case IPP_JOB_PROCESSING :
-        ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                    "job-state-reasons", NULL, "job-printing");
-        break;
-
-    case IPP_JOB_STOPPED :
-        ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                    "job-state-reasons", NULL, "job-stopped");
-        break;
-
-    case IPP_JOB_CANCELED :
-        ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                    "job-state-reasons", NULL, "job-canceled-by-user");
-        break;
-
-    case IPP_JOB_ABORTED :
-        ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                    "job-state-reasons", NULL, "aborted-by-system");
-        break;
-
-    case IPP_JOB_COMPLETED :
-        ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD,
-                    "job-state-reasons", NULL, "job-completed-successfully");
-        break;
-  }
-}
-
-
 /*
  * 'add_job_subscriptions()' - Add any subscriptions for a job.
  */
@@ -2050,7 +2020,7 @@ add_job_subscriptions(
                            resource, sizeof(resource)) < HTTP_URI_OK)
         {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
-                         _("Bad notify-recipient-uri URI \"%s\"!"), recipient);
+                         _("Bad notify-recipient-uri \"%s\"."), recipient);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_URI_SCHEME);
          return;
@@ -2062,7 +2032,7 @@ add_job_subscriptions(
        {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
                          _("notify-recipient-uri URI \"%s\" uses unknown "
-                           "scheme!"), recipient);
+                           "scheme."), recipient);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_URI_SCHEME);
          return;
@@ -2071,7 +2041,7 @@ add_job_subscriptions(
         if (!strcmp(scheme, "rss") && !check_rss_recipient(recipient))
        {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
-                         _("notify-recipient-uri URI \"%s\" is already used!"),
+                         _("notify-recipient-uri URI \"%s\" is already used."),
                          recipient);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_ATTRIBUTES);
@@ -2086,7 +2056,7 @@ add_job_subscriptions(
         if (strcmp(pullmethod, "ippget"))
        {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
-                         _("Bad notify-pull-method \"%s\"!"), pullmethod);
+                         _("Bad notify-pull-method \"%s\"."), pullmethod);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_ATTRIBUTES);
          return;
@@ -2098,7 +2068,7 @@ add_job_subscriptions(
               strcmp(attr->values[0].string.text, "utf-8"))
       {
         send_ipp_status(con, IPP_CHARSET,
-                       _("Character set \"%s\" not supported!"),
+                       _("Character set \"%s\" not supported."),
                        attr->values[0].string.text);
        return;
       }
@@ -2107,7 +2077,7 @@ add_job_subscriptions(
                strcmp(attr->values[0].string.text, DefaultLanguage)))
       {
         send_ipp_status(con, IPP_CHARSET,
-                       _("Language \"%s\" not supported!"),
+                       _("Language \"%s\" not supported."),
                        attr->values[0].string.text);
        return;
       }
@@ -2118,7 +2088,7 @@ add_job_subscriptions(
        {
           send_ipp_status(con, IPP_REQUEST_VALUE,
                          _("The notify-user-data value is too large "
-                           "(%d > 63 octets)!"),
+                           "(%d > 63 octets)."),
                          attr->values[0].unknown.length);
          return;
        }
@@ -2151,23 +2121,27 @@ add_job_subscriptions(
     if (mask == CUPSD_EVENT_NONE)
       mask = CUPSD_EVENT_JOB_COMPLETED;
 
-    sub = cupsdAddSubscription(mask, cupsdFindDest(job->dest), job, recipient,
-                               0);
+    if ((sub = cupsdAddSubscription(mask, cupsdFindDest(job->dest), job,
+                                    recipient, 0)) != NULL)
+    {
+      sub->interval = interval;
 
-    sub->interval = interval;
+      cupsdSetString(&sub->owner, job->username);
 
-    cupsdSetString(&sub->owner, job->username);
+      if (user_data)
+      {
+       sub->user_data_len = user_data->values[0].unknown.length;
+       memcpy(sub->user_data, user_data->values[0].unknown.data,
+              sub->user_data_len);
+      }
 
-    if (user_data)
-    {
-      sub->user_data_len = user_data->values[0].unknown.length;
-      memcpy(sub->user_data, user_data->values[0].unknown.data,
-             sub->user_data_len);
-    }
+      ippAddSeparator(con->response);
+      ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
+                   "notify-subscription-id", sub->id);
 
-    ippAddSeparator(con->response);
-    ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
-                  "notify-subscription-id", sub->id);
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription %d for job %d",
+                      sub->id, job->id);
+    }
 
     if (attr)
       attr = attr->next;
@@ -2193,7 +2167,7 @@ add_job_subscriptions(
       * Free and remove this attribute...
       */
 
-      _ippFreeAttr(attr);
+      ippDeleteAttribute(NULL, attr);
 
       if (prev)
         prev->next = next;
@@ -2216,48 +2190,19 @@ add_job_subscriptions(
  */
 
 static void
-add_job_uuid(cupsd_client_t *con,      /* I - Client connection */
-             cupsd_job_t    *job)      /* I - Job */
+add_job_uuid(cupsd_job_t *job)         /* I - Job */
 {
-  char                 uuid[1024];     /* job-uuid string */
-  _cups_md5_state_t    md5state;       /* MD5 state */
-  unsigned char                md5sum[16];     /* MD5 digest/sum */
-
-
- /*
-  * First see if the job already has a job-uuid attribute; if so, return...
-  */
-
-  if (ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI))
-    return;
-
- /*
-  * No job-uuid attribute, so build a version 3 UUID with the local job
-  * ID at the end; see RFC 4122 for details.  Start with the MD5 sum of
-  * the ServerName, server name and port that the client connected to,
-  * and local job ID...
-  */
-
-  snprintf(uuid, sizeof(uuid), "%s:%s:%d:%d", ServerName, con->servername,
-          con->serverport, job->id);
+  char                 uuid[64];       /* job-uuid string */
 
-  _cupsMD5Init(&md5state);
-  _cupsMD5Append(&md5state, (unsigned char *)uuid, strlen(uuid));
-  _cupsMD5Finish(&md5state, md5sum);
 
  /*
-  * Format the UUID URI using the MD5 sum and job ID.
+  * Add a job-uuid attribute if none exists...
   */
 
-  snprintf(uuid, sizeof(uuid),
-           "urn:uuid:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
-          "%02x%02x%02x%02x%02x%02x",
-          md5sum[0], md5sum[1], md5sum[2], md5sum[3], md5sum[4], md5sum[5],
-          (md5sum[6] & 15) | 0x30, md5sum[7], (md5sum[8] & 0x3f) | 0x40,
-          md5sum[9], md5sum[10], md5sum[11], md5sum[12], md5sum[13],
-          md5sum[14], md5sum[15]);
-
-  ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-uuid", NULL, uuid);
+  if (!ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI))
+    ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-uuid", NULL,
+                _httpAssembleUUID(ServerName, RemotePort, job->dest, job->id,
+                                  uuid, sizeof(uuid)));
 }
 
 
@@ -2283,9 +2228,9 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
   char         srcfile[1024],          /* Source Script/PPD file */
                dstfile[1024];          /* Destination Script/PPD file */
   int          modify;                 /* Non-zero if we are modifying */
-  char         newname[IPP_MAX_NAME];  /* New printer name */
-  int          need_restart_job;       /* Need to restart job? */
-  int          set_device_uri,         /* Did we set the device URI? */
+  int          changed_driver,         /* Changed the PPD/interface script? */
+               need_restart_job,       /* Need to restart job? */
+               set_device_uri,         /* Did we set the device URI? */
                set_port_monitor;       /* Did we set the port monitor? */
 
 
@@ -2338,15 +2283,14 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
     * Printer doesn't exist; see if we have a class of the same name...
     */
 
-    if ((printer = cupsdFindClass(resource + 10)) != NULL &&
-        !(printer->type & CUPS_PRINTER_DISCOVERED))
+    if ((printer = cupsdFindClass(resource + 10)) != NULL)
     {
      /*
       * Yes, return an error...
       */
 
       send_ipp_status(con, IPP_NOT_POSSIBLE,
-                      _("A class named \"%s\" already exists!"),
+                      _("A class named \"%s\" already exists."),
                      resource + 10);
       return;
     }
@@ -2364,58 +2308,6 @@ add_printer(cupsd_client_t  *con,        /* I - Client connection */
     printer = cupsdAddPrinter(resource + 10);
     modify  = 0;
   }
-  else if (printer->type & CUPS_PRINTER_IMPLICIT)
-  {
-   /*
-    * Check the default policy, then rename the implicit printer to
-    * "AnyPrinter" or delete it...
-    */
-
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
-    {
-      send_http_error(con, status, NULL);
-      return;
-    }
-
-    if (ImplicitAnyClasses)
-    {
-      snprintf(newname, sizeof(newname), "Any%s", resource + 10);
-      cupsdRenamePrinter(printer, newname);
-    }
-    else
-      cupsdDeletePrinter(printer, 1);
-
-   /*
-    * Add the printer as a new local printer...
-    */
-
-    printer = cupsdAddPrinter(resource + 10);
-    modify  = 0;
-  }
-  else if (printer->type & CUPS_PRINTER_DISCOVERED)
-  {
-   /*
-    * Check the default policy, then rename the remote printer to
-    * "Printer@server"...
-    */
-
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
-    {
-      send_http_error(con, status, NULL);
-      return;
-    }
-
-    snprintf(newname, sizeof(newname), "%s@%s", resource + 10,
-             printer->hostname);
-    cupsdRenamePrinter(printer, newname);
-
-   /*
-    * Add the printer as a new local printer...
-    */
-
-    printer = cupsdAddPrinter(resource + 10);
-    modify  = 0;
-  }
   else if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
                                       NULL)) != HTTP_OK)
   {
@@ -2429,6 +2321,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
   * Look for attributes and copy them over as needed...
   */
 
+  changed_driver   = 0;
   need_restart_job = 0;
 
   if ((attr = ippFindAttribute(con->request, "printer-location",
@@ -2448,7 +2341,24 @@ 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 */
+    static const char * const uri_status_strings[] =
+    {
+      "URI too large.",
+      "Bad arguments to function.",
+      "Bad resource path.",
+      "Bad port number.",
+      "Bad hostname/address.",
+      "Bad username/password.",
+      "Bad URI scheme.",
+      "Bad URI.",
+      "OK",
+      "Missing URI scheme.",
+      "Unknown URI scheme",
+      "Missing resource path."
+    };
 
 
     need_restart_job = 1;
@@ -2460,12 +2370,14 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
                                 host, sizeof(host), &port,
                                 resource, sizeof(resource));
 
+    cupsdLogMessage(CUPSD_LOG_DEBUG,
+                   "%s device-uri: %s", printer->name,
+                   uri_status_strings[uri_status - HTTP_URI_STATUS_OVERFLOW]);
+
     if (uri_status < HTTP_URI_OK)
     {
-      send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"!"),
+      send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri \"%s\"."),
                      attr->values[0].string.text);
-      cupsdLogMessage(CUPSD_LOG_DEBUG,
-                      "add_printer: httpSeparateURI returned %d", uri_status);
       return;
     }
 
@@ -2482,9 +2394,9 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
        */
 
        send_ipp_status(con, IPP_NOT_POSSIBLE,
-                       _("File device URIs have been disabled! "
+                       _("File device URIs have been disabled. "
                          "To enable, see the FileDevice directive in "
-                         "\"%s/cupsd.conf\"."),
+                         "\"%s/cups-files.conf\"."),
                        ServerRoot);
        return;
       }
@@ -2502,21 +2414,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;
   }
 
@@ -2530,7 +2446,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
 
     need_restart_job = 1;
 
-    supported = ippFindAttribute(printer->attrs, "port-monitor-supported",
+    supported = ippFindAttribute(printer->ppd_attrs, "port-monitor-supported",
                                  IPP_TAG_NAME);
     if (supported)
     {
@@ -2542,7 +2458,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
 
     if (!supported || i >= supported->num_values)
     {
-      send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad port-monitor \"%s\"!"),
+      send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad port-monitor \"%s\"."),
                      attr->values[0].string.text);
       return;
     }
@@ -2561,19 +2477,32 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
   }
 
   if ((attr = ippFindAttribute(con->request, "printer-is-accepting-jobs",
-                               IPP_TAG_BOOLEAN)) != NULL)
+                               IPP_TAG_BOOLEAN)) != NULL &&
+      attr->values[0].boolean != printer->accepting)
   {
     cupsdLogMessage(CUPSD_LOG_INFO,
                     "Setting %s printer-is-accepting-jobs to %d (was %d.)",
                     printer->name, attr->values[0].boolean, printer->accepting);
 
     printer->accepting = attr->values[0].boolean;
-    cupsdAddPrinterHistory(printer);
+
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL,
+                  "%s accepting jobs.",
+                 printer->accepting ? "Now" : "No longer");
   }
 
   if ((attr = ippFindAttribute(con->request, "printer-is-shared",
                                IPP_TAG_BOOLEAN)) != NULL)
   {
+    if (attr->values[0].boolean &&
+        printer->num_auth_info_required == 1 &&
+       !strcmp(printer->auth_info_required[0], "negotiate"))
+    {
+      send_ipp_status(con, IPP_BAD_REQUEST,
+                      _("Cannot share a remote Kerberized printer."));
+      return;
+    }
+
     if (printer->shared && !attr->values[0].boolean)
       cupsdDeregisterPrinter(printer, 1);
 
@@ -2590,7 +2519,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
     if (attr->values[0].integer != IPP_PRINTER_IDLE &&
         attr->values[0].integer != IPP_PRINTER_STOPPED)
     {
-      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad printer-state value %d!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad printer-state value %d."),
                       attr->values[0].integer);
       return;
     }
@@ -2606,12 +2535,59 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
       cupsdSetPrinterState(printer, (ipp_pstate_t)(attr->values[0].integer), 0);
     }
   }
+
   if ((attr = ippFindAttribute(con->request, "printer-state-message",
                                IPP_TAG_TEXT)) != NULL)
   {
     strlcpy(printer->state_message, attr->values[0].string.text,
             sizeof(printer->state_message));
-    cupsdAddPrinterHistory(printer);
+
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL, "%s",
+                  printer->state_message);
+  }
+
+  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] =
+          _cupsStrRetain(attr->values[i].string.text);
+      printer->num_reasons ++;
+
+      if (!strcmp(attr->values[i].string.text, "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);
+      }
+    }
+
+    if (PrintcapFormat == PRINTCAP_PLIST)
+      cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL,
+                  "Printer \"%s\" state changed.", printer->name);
   }
 
   set_printer_defaults(con, printer);
@@ -2634,6 +2610,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
   if (con->filename)
   {
     need_restart_job = 1;
+    changed_driver   = 1;
 
     strlcpy(srcfile, con->filename, sizeof(srcfile));
 
@@ -2673,13 +2650,13 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
        if (copy_file(srcfile, dstfile))
        {
           send_ipp_status(con, IPP_INTERNAL_ERROR,
-                         _("Unable to copy interface script - %s!"),
+                         _("Unable to copy interface script - %s"),
                          strerror(errno));
          return;
        }
 
        cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "Copied interface script successfully!");
+                       "Copied interface script successfully");
        chmod(dstfile, 0755);
       }
 
@@ -2696,23 +2673,14 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
        if (copy_file(srcfile, dstfile))
        {
           send_ipp_status(con, IPP_INTERNAL_ERROR,
-                         _("Unable to copy PPD file - %s!"),
+                         _("Unable to copy PPD file - %s"),
                          strerror(errno));
          return;
        }
 
        cupsdLogMessage(CUPSD_LOG_DEBUG,
-                       "Copied PPD file successfully!");
+                       "Copied PPD file successfully");
        chmod(dstfile, 0644);
-
-#ifdef __APPLE__
-       /*
-        * (Re)register color profiles...
-       */
-
-        apple_unregister_profiles(printer);
-       apple_register_profiles(printer);
-#endif /* __APPLE__ */
       }
       else
       {
@@ -2729,6 +2697,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
                                     IPP_TAG_NAME)) != NULL)
   {
     need_restart_job = 1;
+    changed_driver   = 1;
 
     if (!strcmp(attr->values[0].string.text, "raw"))
     {
@@ -2759,23 +2728,36 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
 
       if (copy_model(con, attr->values[0].string.text, dstfile))
       {
-        send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to copy PPD file!"));
+        send_ipp_status(con, IPP_INTERNAL_ERROR, _("Unable to copy PPD file."));
        return;
       }
 
       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                     "Copied PPD file successfully!");
+                     "Copied PPD file successfully");
       chmod(dstfile, 0644);
+    }
+  }
 
-#ifdef __APPLE__
-     /*
-      * (Re)register color profiles...
-      */
+  if (changed_driver)
+  {
+   /*
+    * If we changed the PPD/interface script, then remove the printer's cache
+    * file and clear the printer-state-reasons...
+    */
 
-      apple_unregister_profiles(printer);
-      apple_register_profiles(printer);
-#endif /* __APPLE__ */
-    }
+    char cache_name[1024];             /* Cache filename for printer attrs */
+
+    snprintf(cache_name, sizeof(cache_name), "%s/%s.data", CacheDir,
+             printer->name);
+    unlink(cache_name);
+
+    cupsdSetPrinterReasons(printer, "none");
+
+   /*
+    * (Re)register color profiles...
+    */
+
+    cupsdRegisterColor(printer);
   }
 
  /*
@@ -2795,7 +2777,7 @@ add_printer(cupsd_client_t  *con, /* I - Client connection */
 
     snprintf(srcfile, sizeof(srcfile), "%s/ppd/%s.ppd", ServerRoot,
             printer->name);
-    if ((ppd = ppdOpenFile(srcfile)) != NULL)
+    if ((ppd = _ppdOpenFile(srcfile, _PPD_LOCALIZATION_NONE)) != NULL)
     {
       for (ppdattr = ppdFindAttr(ppd, "cupsPortMonitor", NULL);
           ppdattr;
@@ -2829,41 +2811,30 @@ add_printer(cupsd_client_t  *con,       /* I - Client connection */
 
   if (need_restart_job && printer->job)
   {
-    cupsd_job_t *job;
-
    /*
-    * Stop the current job and then restart it below...
+    * Restart the current job...
     */
 
-    job = (cupsd_job_t *)printer->job;
-
-    cupsdStopJob(job, 1);
-
-    job->state->values[0].integer = IPP_JOB_PENDING;
-    job->state_value              = IPP_JOB_PENDING;
+    cupsdSetJobState(printer->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+                     "Job restarted because the printer was modified.");
   }
 
-  if (need_restart_job)
-    cupsdCheckJobs();
-
   cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
 
   if (modify)
   {
-    cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED, printer, NULL,
-                  "Printer \"%s\" modified by \"%s\".", printer->name,
-                 get_username(con));
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_MODIFIED,
+                  printer, NULL, "Printer \"%s\" modified by \"%s\".",
+                 printer->name, get_username(con));
 
     cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" modified by \"%s\".",
                     printer->name, get_username(con));
   }
   else
   {
-    cupsdAddPrinterHistory(printer);
-
-    cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, printer, NULL,
-                  "New printer \"%s\" added by \"%s\".", printer->name,
-                 get_username(con));
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED,
+                  printer, NULL, "New printer \"%s\" added by \"%s\".",
+                 printer->name, get_username(con));
 
     cupsdLogMessage(CUPSD_LOG_INFO, "New printer \"%s\" added by \"%s\".",
                     printer->name, get_username(con));
@@ -2889,8 +2860,7 @@ add_printer_state_reasons(
 
   if (p->num_reasons == 0)
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
-                 "printer-state-reasons", NULL,
-                p->state == IPP_PRINTER_STOPPED ? "paused" : "none");
+                 "printer-state-reasons", NULL, "none");
   else
     ippAddStrings(con->response, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
                   "printer-state-reasons", p->num_reasons, NULL,
@@ -2921,550 +2891,6 @@ add_queued_job_count(
 }
 
 
-#ifdef __APPLE__
-/*
- * 'apple_init_profile()' - Initialize a color profile.
- */
-
-static void
-apple_init_profile(
-    ppd_file_t          *ppd,          /* I - PPD file */
-    cups_array_t       *languages,     /* I - Languages in the PPD file */
-    CMDeviceProfileInfo *profile,      /* I - Profile record */
-    unsigned            id,            /* I - Profile ID */
-    const char          *name,         /* I - Profile name */
-    const char          *text,         /* I - Profile UI text */
-    const char          *iccfile)      /* I - ICC filename */
-{
-  char                 url[1024];      /* URL for profile filename */
-  CFMutableDictionaryRef dict;         /* Dictionary for name */
-  char                 *language;      /* Current language */
-  ppd_attr_t           *attr;          /* Profile attribute */
-  CFStringRef          cflang,         /* Language string */
-                       cftext;         /* Localized text */
-
-
- /*
-  * Build the profile name dictionary...
-  */
-
-  dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
-                                  &kCFTypeDictionaryKeyCallBacks,
-                                  &kCFTypeDictionaryValueCallBacks);
-
-  cftext = CFStringCreateWithCString(kCFAllocatorDefault, text,
-                                    kCFStringEncodingUTF8);
-
-  if (cftext)
-  {
-    CFDictionarySetValue(dict, CFSTR("en"), cftext);
-    CFRelease(cftext);
-  }
-
-  if (languages)
-  {
-   /*
-    * Find localized names for the color profiles...
-    */
-
-    cupsArraySave(ppd->sorted_attrs);
-
-    for (language = (char *)cupsArrayFirst(languages);
-        language;
-        language = (char *)cupsArrayNext(languages))
-    {
-      if (iccfile)
-      {
-        if ((attr = _ppdLocalizedAttr(ppd, "cupsICCProfile", name,
-                                     language)) == NULL)
-         attr = _ppdLocalizedAttr(ppd, "APTiogaProfile", name, language);
-      }
-      else
-        attr = _ppdLocalizedAttr(ppd, "ColorModel", name, language);
-
-      if (attr && attr->text[0])
-      {
-       cflang = CFStringCreateWithCString(kCFAllocatorDefault, language,
-                                          kCFStringEncodingUTF8);
-       cftext = CFStringCreateWithCString(kCFAllocatorDefault, attr->text,
-                                          kCFStringEncodingUTF8);
-
-        if (cflang && cftext)
-         CFDictionarySetValue(dict, cflang, cftext);
-
-        if (cflang)
-         CFRelease(cflang);
-
-        if (cftext)
-         CFRelease(cftext);
-      }
-    }
-
-    cupsArrayRestore(ppd->sorted_attrs);
-  }
-
- /*
-  * Fill in the profile data...
-  */
-
-  if (iccfile)
-    httpAssembleURI(HTTP_URI_CODING_ALL, url, sizeof(url), "file", NULL, "", 0,
-                   iccfile);
-
-  profile->dataVersion        = cmDeviceProfileInfoVersion1;
-  profile->profileID          = id;
-  profile->profileLoc.locType = iccfile ? cmPathBasedProfile : cmNoProfileBase;
-  profile->profileName        = dict;
-
-  if (iccfile)
-    strlcpy(profile->profileLoc.u.pathLoc.path, iccfile,
-           sizeof(profile->profileLoc.u.pathLoc.path));
-}
-
-
-/*
- * 'apple_register_profiles()' - Register color profiles for a printer.
- */
-
-static void
-apple_register_profiles(
-    cupsd_printer_t *p)                        /* I - Printer */
-{
-  int                  i;              /* Looping var */
-  char                 ppdfile[1024],  /* PPD filename */
-                       iccfile[1024],  /* ICC filename */
-                       selector[PPD_MAX_NAME];
-                                       /* Profile selection string */
-  ppd_file_t           *ppd;           /* PPD file */
-  ppd_attr_t           *attr,          /* Profile attributes */
-                       *profileid_attr,/* cupsProfileID attribute */
-                       *q1_attr,       /* ColorModel (or other) qualifier */
-                       *q2_attr,       /* MediaType (or other) qualifier */
-                       *q3_attr;       /* Resolution (or other) qualifier */
-  char                 q_keyword[PPD_MAX_NAME];
-                                       /* Qualifier keyword */
-  const char           *q1_choice,     /* ColorModel (or other) choice */
-                       *q2_choice,     /* MediaType (or other) choice */
-                       *q3_choice;     /* Resolution (or other) choice */
-  const char           *profile_key;   /* Profile keyword */
-  ppd_option_t         *cm_option;     /* Color model option */
-  ppd_choice_t         *cm_choice;     /* Color model choice */
-  int                  num_profiles;   /* Number of profiles */
-  CMError              error;          /* Last error */
-  unsigned             device_id,      /* Printer device ID */
-                       profile_id,     /* Profile ID */
-                       default_profile_id = 0;
-                                       /* Default profile ID */
-  CFMutableDictionaryRef device_name;  /* Printer device name dictionary */
-  CFStringRef          printer_name;   /* Printer name string */
-  CMDeviceScope                scope =         /* Scope of the registration */
-                       {
-                         kCFPreferencesAnyUser,
-                         kCFPreferencesCurrentHost
-                       };
-  CMDeviceProfileArrayPtr profiles;    /* Profiles */
-  CMDeviceProfileInfo  *profile;       /* Current profile */
-  cups_array_t         *languages;     /* Languages array */
-
-
- /*
-  * Make sure ColorSync is available...
-  */
-
-  if (CMRegisterColorDevice == NULL)
-    return;
-
- /*
-  * Try opening the PPD file for this printer...
-  */
-
-  snprintf(ppdfile, sizeof(ppdfile), "%s/ppd/%s.ppd", ServerRoot, p->name);
-  if ((ppd = ppdOpenFile(ppdfile)) == NULL)
-    return;
-
- /*
-  * See if we have any profiles...
-  */
-
-  if ((attr = ppdFindAttr(ppd, "APTiogaProfile", NULL)) != NULL)
-    profile_key = "APTiogaProfile";
-  else
-  {
-    attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
-    profile_key = "cupsICCProfile";
-  }
-
-  for (num_profiles = 0; attr; attr = ppdFindNextAttr(ppd, profile_key, NULL))
-    if (attr->spec[0] && attr->value && attr->value[0])
-    {
-      if (attr->value[0] != '/')
-       snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir,
-                attr->value);
-      else
-       strlcpy(iccfile, attr->value, sizeof(iccfile));
-
-      if (access(iccfile, 0))
-       continue;
-
-      num_profiles ++;
-    }
-
-  
- /*
-  * If we have profiles, add them...
-  */
-
-  if (num_profiles > 0)
-  {
-    if (profile_key[0] == 'A')
-    {
-     /*
-      * For Tioga PPDs, get the default profile using the DefaultAPTiogaProfile
-      * attribute...
-      */
-
-      if ((attr = ppdFindAttr(ppd, "DefaultAPTiogaProfile", NULL)) != NULL &&
-         attr->value)
-        default_profile_id = atoi(attr->value);
-
-      q1_choice = q2_choice = q3_choice = NULL;
-    }
-    else
-    {
-     /*
-      * For CUPS PPDs, figure out the default profile selector values...
-      */
-
-      if ((attr = ppdFindAttr(ppd, "cupsICCQualifier1", NULL)) != NULL &&
-         attr->value && attr->value[0])
-      {
-       snprintf(q_keyword, sizeof(q_keyword), "Default%s", attr->value);
-       q1_attr = ppdFindAttr(ppd, q_keyword, NULL);
-      }
-      else if ((q1_attr = ppdFindAttr(ppd, "DefaultColorModel", NULL)) == NULL)
-       q1_attr = ppdFindAttr(ppd, "DefaultColorSpace", NULL);
-
-      if (q1_attr && q1_attr->value && q1_attr->value[0])
-       q1_choice = q1_attr->value;
-      else
-       q1_choice = "";
-
-      if ((attr = ppdFindAttr(ppd, "cupsICCQualifier2", NULL)) != NULL &&
-         attr->value && attr->value[0])
-      {
-       snprintf(q_keyword, sizeof(q_keyword), "Default%s", attr->value);
-       q2_attr = ppdFindAttr(ppd, q_keyword, NULL);
-      }
-      else 
-       q2_attr = ppdFindAttr(ppd, "DefaultMediaType", NULL);
-
-      if (q2_attr && q2_attr->value && q2_attr->value[0])
-       q2_choice = q2_attr->value;
-      else
-       q2_choice = NULL;
-
-      if ((attr = ppdFindAttr(ppd, "cupsICCQualifier3", NULL)) != NULL &&
-         attr->value && attr->value[0])
-      {
-       snprintf(q_keyword, sizeof(q_keyword), "Default%s", attr->value);
-       q3_attr = ppdFindAttr(ppd, q_keyword, NULL);
-      }
-      else 
-       q3_attr = ppdFindAttr(ppd, "DefaultResolution", NULL);
-
-      if (q3_attr && q3_attr->value && q3_attr->value[0])
-       q3_choice = q3_attr->value;
-      else
-       q3_choice = NULL;
-    }
-
-   /*
-    * Build the array of profiles...
-    *
-    * Note: This calloc actually requests slightly more memory than needed.
-    */
-
-    if ((profiles = calloc(num_profiles, sizeof(CMDeviceProfileArray))) == NULL)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to allocate memory for %d profiles!",
-                     num_profiles);
-      ppdClose(ppd);
-      return;
-    }
-
-    profiles->profileCount = num_profiles;
-    languages              = _ppdGetLanguages(ppd);
-
-    for (profile = profiles->profiles,
-             attr = ppdFindAttr(ppd, profile_key, NULL);
-        attr;
-        attr = ppdFindNextAttr(ppd, profile_key, NULL))
-      if (attr->spec[0] && attr->value && attr->value[0])
-      {
-       /*
-        * Add this profile...
-       */
-
-        if (attr->value[0] != '/')
-         snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir,
-                  attr->value);
-        else
-         strlcpy(iccfile, attr->value, sizeof(iccfile));
-
-        if (access(iccfile, 0))
-         continue;
-
-        if (profile_key[0] == 'c')
-       {
-         cupsArraySave(ppd->sorted_attrs);
-
-         if ((profileid_attr = ppdFindAttr(ppd, "cupsProfileID",
-                                           attr->spec)) != NULL &&
-             profileid_attr->value && isdigit(profileid_attr->value[0] & 255))
-           profile_id = (unsigned)strtoul(profileid_attr->value, NULL, 10);
-         else
-           profile_id = _ppdHashName(attr->spec);
-
-         cupsArrayRestore(ppd->sorted_attrs);
-        }
-       else
-         profile_id = atoi(attr->spec);
-
-        apple_init_profile(ppd, languages, profile, profile_id, attr->spec,
-                          attr->text[0] ? attr->text : attr->spec, iccfile);
-
-       profile ++;
-
-       /*
-        * See if this is the default profile...
-       */
-
-        if (!default_profile_id)
-       {
-         if (q2_choice)
-         {
-           if (q3_choice)
-           {
-             snprintf(selector, sizeof(selector), "%s.%s.%s",
-                      q1_choice, q2_choice, q3_choice);
-              if (!strcmp(selector, attr->spec))
-               default_profile_id = profile_id;
-            }
-
-            if (!default_profile_id)
-           {
-             snprintf(selector, sizeof(selector), "%s.%s.", q1_choice,
-                      q2_choice);
-              if (!strcmp(selector, attr->spec))
-               default_profile_id = profile_id;
-           }
-          }
-
-          if (!default_profile_id && q3_choice)
-         {
-           snprintf(selector, sizeof(selector), "%s..%s", q1_choice,
-                    q3_choice);
-           if (!strcmp(selector, attr->spec))
-             default_profile_id = profile_id;
-         }
-
-          if (!default_profile_id)
-         {
-           snprintf(selector, sizeof(selector), "%s..", q1_choice);
-           if (!strcmp(selector, attr->spec))
-             default_profile_id = profile_id;
-         }
-       }
-      }
-
-    _ppdFreeLanguages(languages);
-  }
-  else if ((cm_option = ppdFindOption(ppd, "ColorModel")) != NULL)
-  {
-   /*
-    * Extract profiles from ColorModel option...
-    */
-
-    const char *profile_name;          /* Name of generic profile */
-
-
-    num_profiles = cm_option->num_choices;
-
-    if ((profiles = calloc(num_profiles, sizeof(CMDeviceProfileArray))) == NULL)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to allocate memory for %d profiles!",
-                     num_profiles);
-      ppdClose(ppd);
-      return;
-    }
-
-    profiles->profileCount = num_profiles;
-
-    for (profile = profiles->profiles, i = cm_option->num_choices,
-             cm_choice = cm_option->choices;
-         i > 0;
-        i --, cm_choice ++, profile ++)
-    {
-      if (!strcmp(cm_choice->choice, "Gray") ||
-          !strcmp(cm_choice->choice, "Black"))
-        profile_name = "Gray";
-      else if (!strcmp(cm_choice->choice, "RGB") ||
-               !strcmp(cm_choice->choice, "CMY"))
-        profile_name = "RGB";
-      else if (!strcmp(cm_choice->choice, "CMYK") ||
-               !strcmp(cm_choice->choice, "KCMY"))
-        profile_name = "CMYK";
-      else
-        profile_name = "DeviceN";
-
-      snprintf(selector, sizeof(selector), "%s..", profile_name);
-      profile_id = _ppdHashName(selector);
-
-      apple_init_profile(ppd, NULL, profile, profile_id, cm_choice->choice,
-                         cm_choice->text, NULL);
-
-      if (cm_choice->marked)
-        default_profile_id = profile_id;
-    }
-  }
-  else
-  {
-   /*
-    * Use the default colorspace...
-    */
-
-    num_profiles = 1 + ppd->colorspace != PPD_CS_GRAY;
-    
-    if ((profiles = calloc(num_profiles, sizeof(CMDeviceProfileArray))) == NULL)
-    {
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to allocate memory for %d profiles!",
-                     num_profiles);
-      ppdClose(ppd);
-      return;
-    }
-
-    profiles->profileCount = num_profiles;
-
-    apple_init_profile(ppd, NULL, profiles->profiles, _ppdHashName("Gray.."),
-                       "Gray", "Gray", NULL);
-
-    switch (ppd->colorspace)
-    {
-      case PPD_CS_RGB :
-      case PPD_CS_CMY :
-          apple_init_profile(ppd, NULL, profiles->profiles + 1,
-                            _ppdHashName("RGB.."), "RGB", "RGB", NULL);
-          break;
-      case PPD_CS_RGBK :
-      case PPD_CS_CMYK :
-          apple_init_profile(ppd, NULL, profiles->profiles + 1,
-                            _ppdHashName("CMYK.."), "CMYK", "CMYK", NULL);
-          break;
-
-      case PPD_CS_N :
-          apple_init_profile(ppd, NULL, profiles->profiles + 1,
-                            _ppdHashName("DeviceN.."), "DeviceN", "DeviceN",
-                            NULL);
-          break;
-
-      default :
-         break;
-    }
-  }
-
-  if (num_profiles > 0)
-  {
-   /*
-    * Make sure we have a default profile ID...
-    */
-
-    if (!default_profile_id)
-      default_profile_id = profiles->profiles[num_profiles - 1].profileID;
-
-   /*
-    * Get the device ID hash and pathelogical name dictionary.
-    */
-
-    cupsdLogMessage(CUPSD_LOG_INFO, "Registering ICC color profiles for \"%s\"",
-                   p->name);
-
-    device_id    = _ppdHashName(p->name);
-    device_name  = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
-                                            &kCFTypeDictionaryKeyCallBacks,
-                                            &kCFTypeDictionaryValueCallBacks);
-    printer_name = CFStringCreateWithCString(kCFAllocatorDefault,
-                                             p->name, kCFStringEncodingUTF8);
-
-    if (device_name && printer_name)
-    {
-      CFDictionarySetValue(device_name, CFSTR("en"), printer_name);
-
-     /*
-      * Register the device with ColorSync...
-      */
-
-      error = CMRegisterColorDevice(cmPrinterDeviceClass, device_id,
-                                    device_name, &scope);
-
-     /*
-      * Register the profiles...
-      */
-
-      if (error == noErr)
-       error = CMSetDeviceFactoryProfiles(cmPrinterDeviceClass, device_id,
-                                          default_profile_id, profiles);
-    }
-    else
-      error = 1000;
-
-   /*
-    * Clean up...
-    */
-
-    if (error != noErr)
-      cupsdLogMessage(CUPSD_LOG_ERROR,
-                     "Unable to register ICC color profiles for \"%s\" - %d",
-                     p->name, (int)error);
-
-    for (profile = profiles->profiles;
-        num_profiles > 0;
-        profile ++, num_profiles --)
-      CFRelease(profile->profileName);
-
-    free(profiles);
-
-    if (printer_name)
-      CFRelease(printer_name);
-
-    if (device_name)
-      CFRelease(device_name);
-  }
-
-  ppdClose(ppd);
-}
-
-
-/*
- * 'apple_unregister_profiles()' - Remove color profiles for the specified
- *                                 printer.
- */
-
-static void
-apple_unregister_profiles(
-    cupsd_printer_t *p)                        /* I - Printer */
-{
- /*
-  * Make sure ColorSync is available...
-  */
-
-  if (CMUnregisterColorDevice != NULL)
-    CMUnregisterColorDevice(cmPrinterDeviceClass, _ppdHashName(p->name));
-}
-#endif /* __APPLE__ */
-
 /*
  * 'apply_printer_defaults()' - Apply printer default options to a job.
  */
@@ -3516,7 +2942,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
                        *auth_info;     /* auth-info attribute */
   int                  jobid;          /* Job ID */
   cupsd_job_t          *job;           /* Current job */
-  char                 method[HTTP_MAX_URI],
+  char                 scheme[HTTP_MAX_URI],
                                        /* Method portion of URI */
                        username[HTTP_MAX_URI],
                                        /* Username portion of URI */
@@ -3550,7 +2976,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -3562,8 +2988,8 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -3572,7 +2998,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -3590,8 +3016,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND,
-                    _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -3606,7 +3031,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_POSSIBLE,
-                    _("Job #%d is not held for authentication!"),
+                    _("Job #%d is not held for authentication."),
                    jobid);
     return;
   }
@@ -3621,7 +3046,6 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
   {
     cupsd_printer_t    *printer;       /* Job destination */
 
-
    /*
     * No auth data.  If we need to authenticate via Kerberos, send a
     * HTTP auth challenge, otherwise just return an IPP error...
@@ -3634,7 +3058,7 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
       send_http_error(con, HTTP_UNAUTHORIZED, printer);
     else
       send_ipp_status(con, IPP_NOT_AUTHORIZED,
-                     _("No authentication information provided!"));
+                     _("No authentication information provided."));
     return;
   }
 
@@ -3644,7 +3068,8 @@ authenticate_job(cupsd_client_t  *con,    /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
     return;
   }
 
@@ -3674,18 +3099,23 @@ authenticate_job(cupsd_client_t  *con,  /* I - Client connection */
 
   cupsdReleaseJob(job);
 
+  cupsdAddEvent(CUPSD_EVENT_JOB_STATE, NULL, job, "Job authenticated by user");
+
   cupsdLogJob(job, CUPSD_LOG_INFO, "Authenticated by \"%s\".", con->username);
+
+  cupsdCheckJobs();
 }
 
 
 /*
- * 'cancel_all_jobs()' - Cancel all print jobs.
+ * 'cancel_all_jobs()' - Cancel all or selected print jobs.
  */
 
 static void
 cancel_all_jobs(cupsd_client_t  *con,  /* I - Client connection */
                ipp_attribute_t *uri)   /* I - Job or Printer URI */
 {
+  int          i;                      /* Looping var */
   http_status_t        status;                 /* Policy status */
   cups_ptype_t dtype;                  /* Destination type */
   char         scheme[HTTP_MAX_URI],   /* Scheme portion of URI */
@@ -3694,56 +3124,84 @@ cancel_all_jobs(cupsd_client_t  *con,   /* I - Client connection */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
   int          port;                   /* Port portion of URI */
   ipp_attribute_t *attr;               /* Attribute in request */
-  const char   *username;              /* Username */
-  int          purge;                  /* Purge? */
+  const char   *username = NULL;       /* Username */
+  cupsd_jobaction_t purge = CUPSD_JOB_DEFAULT;
+                                       /* Purge? */
   cupsd_printer_t *printer;            /* Printer */
+  ipp_attribute_t *job_ids;            /* job-ids attribute */
+  cupsd_job_t  *job;                   /* Job */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_all_jobs(%p[%d], %s)", con,
                   con->http.fd, uri->values[0].string.text);
 
  /*
-  * See if we have a printer URI...
+  * Get the jobs to cancel/purge...
   */
 
-  if (strcmp(uri->name, "printer-uri"))
+  switch (con->request->request.op.operation_id)
   {
-    send_ipp_status(con, IPP_BAD_REQUEST,
-                    _("The printer-uri attribute is required!"));
-    return;
-  }
+    case IPP_PURGE_JOBS :
+       /*
+       * Get the username (if any) for the jobs we want to cancel (only if
+       * "my-jobs" is specified...
+       */
 
- /*
-  * Get the username (if any) for the jobs we want to cancel (only if
-  * "my-jobs" is specified...
-  */
+        if ((attr = ippFindAttribute(con->request, "my-jobs",
+                                     IPP_TAG_BOOLEAN)) != NULL &&
+            attr->values[0].boolean)
+       {
+         if ((attr = ippFindAttribute(con->request, "requesting-user-name",
+                                      IPP_TAG_NAME)) != NULL)
+           username = attr->values[0].string.text;
+         else
+         {
+           send_ipp_status(con, IPP_BAD_REQUEST,
+                           _("Missing requesting-user-name attribute."));
+           return;
+         }
+       }
 
-  if ((attr = ippFindAttribute(con->request, "my-jobs",
-                               IPP_TAG_BOOLEAN)) != NULL &&
-      attr->values[0].boolean)
-  {
-    if ((attr = ippFindAttribute(con->request, "requesting-user-name",
-                                 IPP_TAG_NAME)) != NULL)
-      username = attr->values[0].string.text;
-    else
-    {
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Missing requesting-user-name attribute!"));
-      return;
-    }
+       /*
+       * Look for the "purge-jobs" attribute...
+       */
+
+       if ((attr = ippFindAttribute(con->request, "purge-jobs",
+                                    IPP_TAG_BOOLEAN)) != NULL)
+         purge = attr->values[0].boolean ? CUPSD_JOB_PURGE : CUPSD_JOB_DEFAULT;
+       else
+         purge = CUPSD_JOB_PURGE;
+       break;
+
+    case IPP_CANCEL_MY_JOBS :
+        if (con->username[0])
+          username = con->username;
+        else if ((attr = ippFindAttribute(con->request, "requesting-user-name",
+                                         IPP_TAG_NAME)) != NULL)
+          username = attr->values[0].string.text;
+        else
+        {
+         send_ipp_status(con, IPP_BAD_REQUEST,
+                         _("Missing requesting-user-name attribute."));
+         return;
+        }
+
+    default :
+        break;
   }
-  else
-    username = NULL;
+
+  job_ids = ippFindAttribute(con->request, "job-ids", IPP_TAG_INTEGER);
 
  /*
-  * Look for the "purge-jobs" attribute...
+  * See if we have a printer URI...
   */
 
-  if ((attr = ippFindAttribute(con->request, "purge-jobs",
-                               IPP_TAG_BOOLEAN)) != NULL)
-    purge = attr->values[0].boolean;
-  else
-    purge = 1;
+  if (strcmp(uri->name, "printer-uri"))
+  {
+    send_ipp_status(con, IPP_BAD_REQUEST,
+                    _("The printer-uri attribute is required."));
+    return;
+  }
 
  /*
   * And if the destination is valid...
@@ -3764,28 +3222,64 @@ cancel_all_jobs(cupsd_client_t  *con,   /* I - Client connection */
         (!strncmp(resource, "/classes/", 9) && resource[9]))
     {
       send_ipp_status(con, IPP_NOT_FOUND,
-                      _("The printer or class was not found."));
+                      _("The printer or class does not exist."));
+      return;
+    }
+
+   /*
+    * Check policy...
+    */
+
+    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+    {
+      send_http_error(con, status, NULL);
       return;
     }
 
-   /*
-    * Check policy...
-    */
+    if (job_ids)
+    {
+      for (i = 0; i < job_ids->num_values; i ++)
+      {
+       if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL)
+         break;
+
+        if (con->request->request.op.operation_id == IPP_CANCEL_MY_JOBS &&
+            _cups_strcasecmp(job->username, username))
+          break;
+      }
+
+      if (i < job_ids->num_values)
+      {
+       send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+                       job_ids->values[i].integer);
+       return;
+      }
 
-    if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
-    {
-      send_http_error(con, status, NULL);
-      return;
-    }
+      for (i = 0; i < job_ids->num_values; i ++)
+      {
+       job = cupsdFindJob(job_ids->values[i].integer);
 
-   /*
-    * Cancel all jobs on all printers...
-    */
+       cupsdSetJobState(job, IPP_JOB_CANCELED, purge,
+                        purge == CUPSD_JOB_PURGE ? "Job purged by user." :
+                                                   "Job canceled by user.");
+      }
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "Selected jobs were %s by \"%s\".",
+                     purge == CUPSD_JOB_PURGE ? "purged" : "canceled",
+                     get_username(con));
+    }
+    else
+    {
+     /*
+      * Cancel all jobs on all printers...
+      */
 
-    cupsdCancelJobs(NULL, username, purge);
+      cupsdCancelJobs(NULL, username, purge);
 
-    cupsdLogMessage(CUPSD_LOG_INFO, "All jobs were %s by \"%s\".",
-                    purge ? "purged" : "canceled", get_username(con));
+      cupsdLogMessage(CUPSD_LOG_INFO, "All jobs were %s by \"%s\".",
+                     purge == CUPSD_JOB_PURGE ? "purged" : "canceled",
+                     get_username(con));
+    }
   }
   else
   {
@@ -3800,15 +3294,52 @@ cancel_all_jobs(cupsd_client_t  *con,   /* I - Client connection */
       return;
     }
 
-   /*
-    * Cancel all of the jobs on the named printer...
-    */
+    if (job_ids)
+    {
+      for (i = 0; i < job_ids->num_values; i ++)
+      {
+       if ((job = cupsdFindJob(job_ids->values[i].integer)) == NULL ||
+           _cups_strcasecmp(job->dest, printer->name))
+         break;
+
+        if (con->request->request.op.operation_id == IPP_CANCEL_MY_JOBS &&
+            _cups_strcasecmp(job->username, username))
+          break;
+      }
+
+      if (i < job_ids->num_values)
+      {
+       send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+                       job_ids->values[i].integer);
+       return;
+      }
+
+      for (i = 0; i < job_ids->num_values; i ++)
+      {
+       job = cupsdFindJob(job_ids->values[i].integer);
+
+       cupsdSetJobState(job, IPP_JOB_CANCELED, purge,
+                        purge == CUPSD_JOB_PURGE ? "Job purged by user." :
+                                                   "Job canceled by user.");
+      }
+
+      cupsdLogMessage(CUPSD_LOG_INFO, "Selected jobs were %s by \"%s\".",
+                     purge == CUPSD_JOB_PURGE ? "purged" : "canceled",
+                     get_username(con));
+    }
+    else
+    {
+     /*
+      * Cancel all of the jobs on the named printer...
+      */
 
-    cupsdCancelJobs(printer->name, username, purge);
+      cupsdCancelJobs(printer->name, username, purge);
 
-    cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".",
-                    printer->name, purge ? "purged" : "canceled",
-                   get_username(con));
+      cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".",
+                     printer->name,
+                     purge == CUPSD_JOB_PURGE ? "purged" : "canceled",
+                     get_username(con));
+    }
   }
 
   con->response->request.status.status_code = IPP_OK;
@@ -3833,7 +3364,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
   cupsd_job_t  *job;                   /* Job information */
   cups_ptype_t dtype;                  /* Destination type (printer/class) */
   cupsd_printer_t *printer;            /* Printer data */
-  int          purge;                  /* Purge the job? */
+  cupsd_jobaction_t purge;             /* Purge the job? */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "cancel_job(%p[%d], %s)", con,
@@ -3853,7 +3384,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -3870,48 +3401,43 @@ cancel_job(cupsd_client_t  *con,        /* I - Client connection */
        */
 
        send_ipp_status(con, IPP_NOT_FOUND,
-                       _("The printer or class was not found."));
+                       _("The printer or class does not exist."));
        return;
       }
 
      /*
-      * See if the printer is currently printing a job...
+      * See if there are any pending jobs...
       */
 
-      if (printer->job)
-        jobid = ((cupsd_job_t *)printer->job)->id;
+      for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
+          job;
+          job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
+       if (job->state_value <= IPP_JOB_PROCESSING &&
+           !_cups_strcasecmp(job->dest, printer->name))
+         break;
+
+      if (job)
+       jobid = job->id;
       else
       {
        /*
-        * No, see if there are any pending jobs...
+        * No, try stopped jobs...
        */
 
-        for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
+       for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
             job;
             job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
-         if (job->state_value <= IPP_JOB_PROCESSING &&
-             !strcasecmp(job->dest, printer->name))
+         if (job->state_value == IPP_JOB_STOPPED &&
+             !_cups_strcasecmp(job->dest, printer->name))
            break;
 
        if (job)
          jobid = job->id;
        else
        {
-         for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
-              job;
-              job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
-           if (job->state_value == IPP_JOB_STOPPED &&
-               !strcasecmp(job->dest, printer->name))
-             break;
-
-          if (job)
-           jobid = job->id;
-         else
-         {
-           send_ipp_status(con, IPP_NOT_POSSIBLE, _("No active jobs on %s!"),
-                           printer->name);
-           return;
-         }
+         send_ipp_status(con, IPP_NOT_POSSIBLE, _("No active jobs on %s."),
+                         printer->name);
+         return;
        }
       }
     }
@@ -3932,8 +3458,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -3947,9 +3472,9 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
 
   if ((attr = ippFindAttribute(con->request, "purge-job",
                                IPP_TAG_BOOLEAN)) != NULL)
-    purge = attr->values[0].boolean;
+    purge = attr->values[0].boolean ? CUPSD_JOB_PURGE : CUPSD_JOB_DEFAULT;
   else
-    purge = 0;
+    purge = CUPSD_JOB_DEFAULT;
 
  /*
   * See if the job exists...
@@ -3961,7 +3486,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -3971,7 +3496,8 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
     return;
   }
 
@@ -3980,7 +3506,7 @@ cancel_job(cupsd_client_t  *con,  /* I - Client connection */
   * we can't cancel...
   */
 
-  if (job->state_value >= IPP_JOB_CANCELED && !purge)
+  if (job->state_value >= IPP_JOB_CANCELED && purge != CUPSD_JOB_PURGE)
   {
     switch (job->state_value)
     {
@@ -4010,10 +3536,13 @@ cancel_job(cupsd_client_t  *con,        /* I - Client connection */
   * Cancel the job and return...
   */
 
-  cupsdCancelJob(job, purge, IPP_JOB_CANCELED);
+  cupsdSetJobState(job, IPP_JOB_CANCELED, purge,
+                   purge == CUPSD_JOB_PURGE ? "Job purged by \"%s\"" :
+                                             "Job canceled by \"%s\"",
+                  username);
   cupsdCheckJobs();
 
-  if (purge)
+  if (purge == CUPSD_JOB_PURGE)
     cupsdLogMessage(CUPSD_LOG_INFO, "[Job %d] Purged by \"%s\".", jobid,
                    username);
   else
@@ -4052,7 +3581,7 @@ cancel_subscription(
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("notify-subscription-id %d no good!"), sub_id);
+                    _("Subscription #%d does not exist."), sub_id);
     return;
   }
 
@@ -4116,12 +3645,13 @@ check_rss_recipient(
  * 'check_quotas()' - Check quotas for a printer and user.
  */
 
-static int                             /* O - 1 if OK, 0 if not */
+static int                             /* O - 1 if OK, 0 if forbidden,
+                                              -1 if limit reached */
 check_quotas(cupsd_client_t  *con,     /* I - Client connection */
              cupsd_printer_t *p)       /* I - Printer or class */
 {
-  int          i;                      /* Looping var */
-  char         username[33];           /* Username */
+  char         username[33],           /* Username */
+               *name;                  /* Current user name */
   cupsd_quota_t        *q;                     /* Quota data */
 #ifdef HAVE_MBR_UID_TO_UUID
  /*
@@ -4152,6 +3682,9 @@ check_quotas(cupsd_client_t  *con,        /* I - Client connection */
 
   strlcpy(username, get_username(con), sizeof(username));
 
+  if ((name = strchr(username, '@')) != NULL)
+    *name = '\0';                      /* Strip @REALM */
+
  /*
   * Check global active job limits for printers and users...
   */
@@ -4166,7 +3699,7 @@ check_quotas(cupsd_client_t  *con,        /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_INFO, "Too many jobs for printer \"%s\"...",
                       p->name);
-      return (0);
+      return (-1);
     }
   }
 
@@ -4180,7 +3713,7 @@ check_quotas(cupsd_client_t  *con,        /* I - Client connection */
     {
       cupsdLogMessage(CUPSD_LOG_INFO, "Too many jobs for user \"%s\"...",
                       username);
-      return (0);
+      return (-1);
     }
   }
 
@@ -4188,10 +3721,10 @@ check_quotas(cupsd_client_t  *con,      /* I - Client connection */
   * Check against users...
   */
 
-  if (p->num_users == 0 && p->k_limit == 0 && p->page_limit == 0)
+  if (cupsArrayCount(p->users) == 0 && p->k_limit == 0 && p->page_limit == 0)
     return (1);
 
-  if (p->num_users)
+  if (cupsArrayCount(p->users))
   {
 #ifdef HAVE_MBR_UID_TO_UUID
    /*
@@ -4222,21 +3755,22 @@ check_quotas(cupsd_client_t  *con,      /* I - Client connection */
     endpwent();
 #endif /* HAVE_MBR_UID_TO_UUID */
 
-    for (i = 0; i < p->num_users; i ++)
-      if (p->users[i][0] == '@')
+    for (name = (char *)cupsArrayFirst(p->users);
+         name;
+        name = (char *)cupsArrayNext(p->users))
+      if (name[0] == '@')
       {
        /*
         * Check group membership...
        */
 
 #ifdef HAVE_MBR_UID_TO_UUID
-        if (p->users[i][1] == '#')
+        if (name[1] == '#')
        {
-         if (uuid_parse((char *)p->users[i] + 2, grp_uuid))
+         if (uuid_parse(name + 2, grp_uuid))
            uuid_clear(grp_uuid);
        }
-       else if ((mbr_err = mbr_group_name_to_uuid((char *)p->users[i] + 1,
-                                                  grp_uuid)) != 0)
+       else if ((mbr_err = mbr_group_name_to_uuid(name + 1, grp_uuid)) != 0)
        {
         /*
          * Invalid ACL entries are ignored for matching; just record a
@@ -4245,10 +3779,10 @@ check_quotas(cupsd_client_t  *con,      /* I - Client connection */
 
          cupsdLogMessage(CUPSD_LOG_DEBUG,
                          "check_quotas: UUID lookup failed for ACL entry "
-                         "\"%s\" (err=%d)", p->users[i], mbr_err);
+                         "\"%s\" (err=%d)", name, mbr_err);
          cupsdLogMessage(CUPSD_LOG_WARN,
                          "Access control entry \"%s\" not a valid group name; "
-                         "entry ignored", p->users[i]);
+                         "entry ignored", name);
        }
 
        if ((mbr_err = mbr_check_membership(usr_uuid, grp_uuid,
@@ -4260,7 +3794,7 @@ check_quotas(cupsd_client_t  *con,        /* I - Client connection */
 
          cupsdLogMessage(CUPSD_LOG_DEBUG,
                          "check_quotas: group \"%s\" membership check "
-                         "failed (err=%d)", p->users[i] + 1, mbr_err);
+                         "failed (err=%d)", name + 1, mbr_err);
          is_member = 0;
        }
 
@@ -4272,20 +3806,19 @@ check_quotas(cupsd_client_t  *con,      /* I - Client connection */
          break;
 
 #else
-        if (cupsdCheckGroup(username, pw, p->users[i] + 1))
+        if (cupsdCheckGroup(username, pw, name + 1))
          break;
 #endif /* HAVE_MBR_UID_TO_UUID */
       }
 #ifdef HAVE_MBR_UID_TO_UUID
       else
       {
-        if (p->users[i][0] == '#')
+        if (name[0] == '#')
        {
-         if (uuid_parse((char *)p->users[i] + 1, usr2_uuid))
+         if (uuid_parse(name + 1, usr2_uuid))
            uuid_clear(usr2_uuid);
         }
-        else if ((mbr_err = mbr_user_name_to_uuid((char *)p->users[i],
-                                                 usr2_uuid)) != 0)
+        else if ((mbr_err = mbr_user_name_to_uuid(name, usr2_uuid)) != 0)
        {
         /*
          * Invalid ACL entries are ignored for matching; just record a
@@ -4294,30 +3827,21 @@ check_quotas(cupsd_client_t  *con,      /* I - Client connection */
 
           cupsdLogMessage(CUPSD_LOG_DEBUG,
                          "check_quotas: UUID lookup failed for ACL entry "
-                         "\"%s\" (err=%d)", p->users[i], mbr_err);
+                         "\"%s\" (err=%d)", name, mbr_err);
           cupsdLogMessage(CUPSD_LOG_WARN,
                          "Access control entry \"%s\" not a valid user name; "
-                         "entry ignored", p->users[i]);
-       }
-
-       if ((mbr_err = mbr_check_membership(usr_uuid, usr2_uuid,
-                                           &is_member)) != 0)
-       {
-         cupsdLogMessage(CUPSD_LOG_DEBUG,
-                         "check_quotas: User \"%s\" identity check failed "
-                         "(err=%d)", p->users[i], mbr_err);
-         is_member = 0;
+                         "entry ignored", name);
        }
 
-       if (is_member)
+       if (!uuid_compare(usr_uuid, usr2_uuid))
          break;
       }
 #else
-      else if (!strcasecmp(username, p->users[i]))
+      else if (!_cups_strcasecmp(username, name))
        break;
 #endif /* HAVE_MBR_UID_TO_UUID */
 
-    if ((i < p->num_users) == p->deny_users)
+    if ((name != NULL) == p->deny_users)
     {
       cupsdLogMessage(CUPSD_LOG_INFO,
                       "Denying user \"%s\" access to printer \"%s\"...",
@@ -4330,72 +3854,12 @@ check_quotas(cupsd_client_t  *con,      /* I - Client connection */
   * Check quotas...
   */
 
-#ifdef __APPLE__
-  if (AppleQuotas && (q = cupsdFindQuota(p, username)) != NULL)
-  {
-   /*
-    * TODO: Define these special page count values as constants!
-    */
-
-    if (q->page_count == -4) /* special case: unlimited user */
-    {
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                      "User \"%s\" request approved for printer %s (%s): " 
-                     "unlimited quota.",
-                     username, p->name, p->info);
-      q->page_count = 0; /* allow user to print */
-      return (1);
-    }
-    else if (q->page_count == -3) /* quota exceeded */
-    {
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                      "User \"%s\" request denied for printer %s (%s): "
-                     "quota limit exceeded.",
-                     username, p->name, p->info);
-      q->page_count = 2; /* force quota exceeded failure */
-      return (-1);
-    }
-    else if (q->page_count == -2) /* quota disabled for user */
-    {
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                      "User \"%s\" request denied for printer %s (%s): "
-                     "printing disabled for user.",
-                     username, p->name, p->info);
-      q->page_count = 2; /* force quota exceeded failure */
-      return (-1);
-    }
-    else if (q->page_count == -1) /* quota access error */
-    {
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                      "User \"%s\" request denied for printer %s (%s): "
-                     "unable to determine quota limit.",
-                     username, p->name, p->info);
-      q->page_count = 2; /* force quota exceeded failure */
-      return (-1);
-    }
-    else if (q->page_count < 0) /* user not found or other error */
-    {
-      cupsdLogMessage(CUPSD_LOG_INFO,
-                      "User \"%s\" request denied for printer %s (%s): "
-                     "user disabled / missing quota.",
-                     username, p->name, p->info);
-      q->page_count = 2; /* force quota exceeded failure */
-      return (-1);
-    }
-    else /* page within user limits */
-    {
-      q->page_count = 0; /* allow user to print */
-      return (1);
-    }
-  }
-  else
-#endif /* __APPLE__ */
   if (p->k_limit || p->page_limit)
   {
     if ((q = cupsdUpdateQuota(p, username, 0, 0)) == NULL)
     {
       cupsdLogMessage(CUPSD_LOG_ERROR,
-                      "Unable to allocate quota data for user \"%s\"!",
+                      "Unable to allocate quota data for user \"%s\"",
                       username);
       return (-1);
     }
@@ -4418,168 +3882,121 @@ check_quotas(cupsd_client_t  *con,    /* I - Client connection */
 
 
 /*
- * 'copy_attribute()' - Copy a single attribute.
+ * 'close_job()' - Close a multi-file job.
  */
 
-static ipp_attribute_t *               /* O - New attribute */
-copy_attribute(
-    ipp_t           *to,               /* O - Destination request/response */
-    ipp_attribute_t *attr,             /* I - Attribute to copy */
-    int             quickcopy)         /* I - Do a quick copy? */
+static void
+close_job(cupsd_client_t  *con,                /* I - Client connection */
+          ipp_attribute_t *uri)                /* I - Printer URI */
 {
-  int                  i;              /* Looping var */
-  ipp_attribute_t      *toattr;        /* Destination attribute */
+  cupsd_job_t          *job;           /* Job */
+  ipp_attribute_t      *attr;          /* Attribute */
+  char                 job_uri[HTTP_MAX_URI],
+                                       /* Job URI */
+                       username[256];  /* User name */
 
 
-  cupsdLogMessage(CUPSD_LOG_DEBUG2,
-                  "copy_attribute(%p, %p[%s,%x,%x])", to, attr,
-                 attr->name ? attr->name : "(null)", attr->group_tag,
-                 attr->value_tag);
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "close_job(%p[%d], %s)", con,
+                  con->http.fd, uri->values[0].string.text);
+
+ /*
+  * See if we have a job URI or a printer URI...
+  */
 
-  switch (attr->value_tag & ~IPP_TAG_COPY)
+  if (strcmp(uri->name, "printer-uri"))
   {
-    case IPP_TAG_ZERO :
-        toattr = ippAddSeparator(to);
-       break;
+   /*
+    * job-uri is not supported by Close-Job!
+    */
 
-    case IPP_TAG_INTEGER :
-    case IPP_TAG_ENUM :
-        toattr = ippAddIntegers(to, attr->group_tag, attr->value_tag,
-                               attr->name, attr->num_values, NULL);
+    send_ipp_status(con, IPP_BAD_REQUEST,
+                   _("Close-Job doesn't support the job-uri attribute."));
+    return;
+  }
 
-        for (i = 0; i < attr->num_values; i ++)
-         toattr->values[i].integer = attr->values[i].integer;
-        break;
+ /*
+  * Got a printer URI; see if we also have a job-id attribute...
+  */
 
-    case IPP_TAG_BOOLEAN :
-        toattr = ippAddBooleans(to, attr->group_tag, attr->name,
-                               attr->num_values, NULL);
+  if ((attr = ippFindAttribute(con->request, "job-id",
+                              IPP_TAG_INTEGER)) == NULL)
+  {
+    send_ipp_status(con, IPP_BAD_REQUEST,
+                   _("Got a printer-uri attribute but no job-id."));
+    return;
+  }
 
-        for (i = 0; i < attr->num_values; i ++)
-         toattr->values[i].boolean = attr->values[i].boolean;
-        break;
+  if ((job = cupsdFindJob(attr->values[0].integer)) == NULL)
+  {
+   /*
+    * Nope - return a "not found" error...
+    */
 
-    case IPP_TAG_STRING :
-    case IPP_TAG_TEXT :
-    case IPP_TAG_NAME :
-    case IPP_TAG_KEYWORD :
-    case IPP_TAG_URI :
-    case IPP_TAG_URISCHEME :
-    case IPP_TAG_CHARSET :
-    case IPP_TAG_LANGUAGE :
-    case IPP_TAG_MIMETYPE :
-        toattr = ippAddStrings(to, attr->group_tag,
-                              (ipp_tag_t)(attr->value_tag | quickcopy),
-                              attr->name, attr->num_values, NULL, NULL);
-
-        if (quickcopy)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text = attr->values[i].string.text;
-        }
-       else
-       {
-          for (i = 0; i < attr->num_values; i ++)
-           toattr->values[i].string.text =
-               _cupsStrAlloc(attr->values[i].string.text);
-       }
-        break;
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+                    attr->values[0].integer);
+    return;
+  }
 
-    case IPP_TAG_DATE :
-        toattr = ippAddDate(to, attr->group_tag, attr->name,
-                           attr->values[0].date);
-        break;
+ /*
+  * See if the job is owned by the requesting user...
+  */
 
-    case IPP_TAG_RESOLUTION :
-        toattr = ippAddResolutions(to, attr->group_tag, attr->name,
-                                  attr->num_values, IPP_RES_PER_INCH,
-                                  NULL, NULL);
+  if (!validate_user(job, con, job->username, username, sizeof(username)))
+  {
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
+    return;
+  }
 
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].resolution.xres  = attr->values[i].resolution.xres;
-         toattr->values[i].resolution.yres  = attr->values[i].resolution.yres;
-         toattr->values[i].resolution.units = attr->values[i].resolution.units;
-       }
-        break;
+ /*
+  * Add any ending sheet...
+  */
 
-    case IPP_TAG_RANGE :
-        toattr = ippAddRanges(to, attr->group_tag, attr->name,
-                             attr->num_values, NULL, NULL);
+  if (cupsdTimeoutJob(job))
+    return;
 
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].range.lower = attr->values[i].range.lower;
-         toattr->values[i].range.upper = attr->values[i].range.upper;
-       }
-        break;
+  if (job->state_value == IPP_JOB_STOPPED)
+  {
+    job->state->values[0].integer = IPP_JOB_PENDING;
+    job->state_value              = IPP_JOB_PENDING;
+  }
+  else if (job->state_value == IPP_JOB_HELD)
+  {
+    if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
+                                IPP_TAG_KEYWORD)) == NULL)
+      attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME);
 
-    case IPP_TAG_TEXTLANG :
-    case IPP_TAG_NAMELANG :
-        toattr = ippAddStrings(to, attr->group_tag,
-                              (ipp_tag_t)(attr->value_tag | quickcopy),
-                              attr->name, attr->num_values, NULL, NULL);
+    if (!attr || !strcmp(attr->values[0].string.text, "no-hold"))
+    {
+      job->state->values[0].integer = IPP_JOB_PENDING;
+      job->state_value              = IPP_JOB_PENDING;
+    }
+  }
 
-        if (quickcopy)
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-            toattr->values[i].string.charset = attr->values[i].string.charset;
-           toattr->values[i].string.text    = attr->values[i].string.text;
-          }
-        }
-       else
-       {
-          for (i = 0; i < attr->num_values; i ++)
-         {
-           if (!i)
-              toattr->values[i].string.charset =
-                 _cupsStrAlloc(attr->values[i].string.charset);
-           else
-              toattr->values[i].string.charset =
-                 toattr->values[0].string.charset;
-
-           toattr->values[i].string.text =
-               _cupsStrAlloc(attr->values[i].string.text);
-          }
-        }
-        break;
+  job->dirty = 1;
+  cupsdMarkDirty(CUPSD_DIRTY_JOBS);
 
-    case IPP_TAG_BEGIN_COLLECTION :
-        toattr = ippAddCollections(to, attr->group_tag, attr->name,
-                                  attr->num_values, NULL);
+ /*
+  * Fill in the response info...
+  */
 
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].collection = ippNew();
-         copy_attrs(toattr->values[i].collection, attr->values[i].collection,
-                    NULL, IPP_TAG_ZERO, 0);
-       }
-        break;
+  httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+                   con->clientname, con->clientport, "/jobs/%d", job->id);
+  ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
+               job_uri);
 
-    default :
-        toattr = ippAddIntegers(to, attr->group_tag, attr->value_tag,
-                               attr->name, attr->num_values, NULL);
+  ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id);
 
-        for (i = 0; i < attr->num_values; i ++)
-       {
-         toattr->values[i].unknown.length = attr->values[i].unknown.length;
+  ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state",
+                job->state_value);
 
-         if (toattr->values[i].unknown.length > 0)
-         {
-           if ((toattr->values[i].unknown.data =
-                    malloc(toattr->values[i].unknown.length)) == NULL)
-             toattr->values[i].unknown.length = 0;
-           else
-             memcpy(toattr->values[i].unknown.data,
-                    attr->values[i].unknown.data,
-                    toattr->values[i].unknown.length);
-         }
-       }
-        break; /* anti-compiler-warning-code */
-  }
+  con->response->request.status.status_code = IPP_OK;
+
+ /*
+  * Start the job if necessary...
+  */
 
-  return (toattr);
+  cupsdCheckJobs();
 }
 
 
@@ -4592,7 +4009,8 @@ copy_attrs(ipp_t        *to,              /* I - Destination request */
            ipp_t        *from,         /* I - Source request */
            cups_array_t *ra,           /* I - Requested attributes */
           ipp_tag_t    group,          /* I - Group to copy */
-          int          quickcopy)      /* I - Do a quick copy? */
+          int          quickcopy,      /* I - Do a quick copy? */
+          cups_array_t *exclude)       /* I - Attributes to exclude? */
 {
   ipp_attribute_t      *fromattr;      /* Source attribute */
 
@@ -4614,8 +4032,47 @@ copy_attrs(ipp_t        *to,             /* I - Destination request */
          fromattr->group_tag != IPP_TAG_ZERO) || !fromattr->name)
       continue;
 
+    if (!strcmp(fromattr->name, "document-password") ||
+        !strcmp(fromattr->name, "job-authorization-uri") ||
+        !strcmp(fromattr->name, "job-password") ||
+        !strcmp(fromattr->name, "job-password-encryption") ||
+        !strcmp(fromattr->name, "job-printer-uri"))
+      continue;
+
+    if (exclude &&
+        (cupsArrayFind(exclude, fromattr->name) ||
+        cupsArrayFind(exclude, "all")))
+    {
+     /*
+      * We need to exclude this attribute for security reasons; we require the
+      * job-id attribute regardless of the security settings for IPP
+      * conformance.
+      *
+      * The job-printer-uri attribute is handled by copy_job_attrs().
+      *
+      * Subscription attribute security is handled by copy_subscription_attrs().
+      */
+
+      if (strcmp(fromattr->name, "job-id"))
+        continue;
+    }
+
     if (!ra || cupsArrayFind(ra, fromattr->name))
-      copy_attribute(to, fromattr, quickcopy);
+    {
+     /*
+      * Don't send collection attributes by default to IPP/1.x clients
+      * since many do not support collections.  Also don't send
+      * media-col-database unless specifically requested by the client.
+      */
+
+      if (fromattr->value_tag == IPP_TAG_BEGIN_COLLECTION &&
+          !ra &&
+         (to->request.status.version[0] == 1 ||
+          !strcmp(fromattr->name, "media-col-database")))
+       continue;
+
+      ippCopyAttribute(to, fromattr, quickcopy);
+    }
   }
 }
 
@@ -4806,7 +4263,14 @@ copy_banner(cupsd_client_t *con, /* I - Client connection */
          case IPP_TAG_INTEGER :
          case IPP_TAG_ENUM :
              if (!strncmp(s, "time-at-", 8))
-               cupsFilePuts(out, cupsdGetDateTime(attr->values[i].integer));
+             {
+               struct timeval tv;      /* Time value */
+
+               tv.tv_sec  = attr->values[i].integer;
+               tv.tv_usec = 0;
+
+               cupsFilePuts(out, cupsdGetDateTime(&tv, CUPSD_TIME_STANDARD));
+             }
              else
                cupsFilePrintf(out, "%d", attr->values[i].integer);
              break;
@@ -4828,7 +4292,7 @@ copy_banner(cupsd_client_t *con,  /* I - Client connection */
              cupsFilePrintf(out, "%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 :
@@ -4838,7 +4302,7 @@ copy_banner(cupsd_client_t *con,  /* I - Client connection */
          case IPP_TAG_KEYWORD :
          case IPP_TAG_CHARSET :
          case IPP_TAG_LANGUAGE :
-             if (!strcasecmp(banner->filetype->type, "postscript"))
+             if (!_cups_strcasecmp(banner->filetype->type, "postscript"))
              {
               /*
                * Need to quote strings for PS banners...
@@ -4973,6 +4437,7 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
   int          i;                      /* Looping var */
   char         option[PPD_MAX_NAME],   /* Option name */
                choice[PPD_MAX_NAME];   /* Choice name */
+  ppd_size_t   *size;                  /* Default size */
   int          num_defaults;           /* Number of default options */
   cups_option_t        *defaults;              /* Default options */
   char         cups_protocol[PPD_MAX_LINE];
@@ -4997,16 +4462,14 @@ copy_model(cupsd_client_t *con,         /* I - Client connection */
   snprintf(buffer, sizeof(buffer), "%s/daemon/cups-driverd", ServerBin);
   snprintf(tempfile, sizeof(tempfile), "%s/%d.ppd", TempDir, con->http.fd);
   tempfd = open(tempfile, O_WRONLY | O_CREAT | O_TRUNC, 0600);
-  if (tempfd < 0)
+  if (tempfd < 0 || cupsdOpenPipe(temppipe))
     return (-1);
 
-  cupsdOpenPipe(temppipe);
-
   cupsdLogMessage(CUPSD_LOG_DEBUG,
                   "copy_model: Running \"cups-driverd cat %s\"...", from);
 
   if (!cupsdStartProcess(buffer, argv, envp, -1, temppipe[1], CGIPipes[1],
-                         -1, -1, 0, DefaultProfile, &temppid))
+                         -1, -1, 0, DefaultProfile, NULL, &temppid))
   {
     close(tempfd);
     unlink(tempfile);
@@ -5086,7 +4549,17 @@ copy_model(cupsd_client_t *con,          /* I - Client connection */
     * No data from cups-deviced...
     */
 
-    cupsdLogMessage(CUPSD_LOG_ERROR, "copy_model: empty PPD file!");
+    cupsdLogMessage(CUPSD_LOG_ERROR, "copy_model: empty PPD file");
+    unlink(tempfile);
+    return (-1);
+  }
+
+ /*
+  * Open the source file for a copy...
+  */
+
+  if ((src = cupsFileOpen(tempfile, "rb")) == NULL)
+  {
     unlink(tempfile);
     return (-1);
   }
@@ -5095,8 +4568,9 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
   * Read the source file and see what page sizes are supported...
   */
 
-  if ((ppd = ppdOpenFile(tempfile)) == NULL)
+  if ((ppd = _ppdOpen(src, _PPD_LOCALIZATION_NONE)) == NULL)
   {
+    cupsFileClose(src);
     unlink(tempfile);
     return (-1);
   }
@@ -5145,34 +4619,23 @@ copy_model(cupsd_client_t *con,         /* I - Client connection */
 
     cupsFileClose(dst);
   }
-  else if (ppdPageSize(ppd, DefaultPaperSize))
+  else if ((size = ppdPageSize(ppd, DefaultPaperSize)) != NULL)
   {
    /*
     * Add the default media sizes...
     */
 
-    num_defaults = cupsAddOption("PageSize", DefaultPaperSize,
+    num_defaults = cupsAddOption("PageSize", size->name,
                                  num_defaults, &defaults);
-    num_defaults = cupsAddOption("PageRegion", DefaultPaperSize,
+    num_defaults = cupsAddOption("PageRegion", size->name,
                                  num_defaults, &defaults);
-    num_defaults = cupsAddOption("PaperDimension", DefaultPaperSize,
+    num_defaults = cupsAddOption("PaperDimension", size->name,
                                  num_defaults, &defaults);
-    num_defaults = cupsAddOption("ImageableArea", DefaultPaperSize,
+    num_defaults = cupsAddOption("ImageableArea", size->name,
                                  num_defaults, &defaults);
   }
 
-  ppdClose(ppd);
-
- /*
-  * Open the source file for a copy...
-  */
-
-  if ((src = cupsFileOpen(tempfile, "rb")) == NULL)
-  {
-    cupsFreeOptions(num_defaults, defaults);
-    unlink(tempfile);
-    return (-1);
-  }
+  ppdClose(ppd);
 
  /*
   * Open the destination file for a copy...
@@ -5190,6 +4653,8 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
   * Copy the source file to the destination...
   */
 
+  cupsFileRewind(src);
+
   while (cupsFileGets(src, buffer, sizeof(buffer)))
   {
     if (!strncmp(buffer, "*Default", 8))
@@ -5242,7 +4707,8 @@ copy_model(cupsd_client_t *con,           /* I - Client connection */
 static void
 copy_job_attrs(cupsd_client_t *con,    /* I - Client connection */
               cupsd_job_t    *job,     /* I - Job */
-              cups_array_t   *ra)      /* I - Requested attributes array */
+              cups_array_t   *ra,      /* I - Requested attributes array */
+              cups_array_t   *exclude) /* I - Private attributes array */
 {
   char job_uri[HTTP_MAX_URI];          /* Job URI */
 
@@ -5251,39 +4717,61 @@ copy_job_attrs(cupsd_client_t *con,     /* I - Client connection */
   * Send the requested attributes for each job...
   */
 
-  httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
-                   con->servername, con->serverport, "/jobs/%d",
-                  job->id);
-
-  if (!ra || cupsArrayFind(ra, "document-count"))
-    ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER,
-                 "document-count", job->num_files);
+  if (!cupsArrayFind(exclude, "all"))
+  {
+    if ((!exclude || !cupsArrayFind(exclude, "number-of-documents")) &&
+        (!ra || cupsArrayFind(ra, "number-of-documents")))
+      ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER,
+                   "number-of-documents", job->num_files);
 
-  if (!ra || cupsArrayFind(ra, "job-media-progress"))
-    ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER,
-                 "job-media-progress", job->progress);
+    if ((!exclude || !cupsArrayFind(exclude, "job-media-progress")) &&
+        (!ra || cupsArrayFind(ra, "job-media-progress")))
+      ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER,
+                   "job-media-progress", job->progress);
 
-  if (!ra || cupsArrayFind(ra, "job-more-info"))
-    ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI,
-                "job-more-info", NULL, job_uri);
+    if ((!exclude || !cupsArrayFind(exclude, "job-more-info")) &&
+        (!ra || cupsArrayFind(ra, "job-more-info")))
+    {
+      httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "http",
+                       NULL, con->clientname, con->clientport, "/jobs/%d",
+                      job->id);
+      ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI,
+                  "job-more-info", NULL, job_uri);
+    }
 
-  if (job->state_value > IPP_JOB_PROCESSING &&
-      (!ra || cupsArrayFind(ra, "job-preserved")))
-    ippAddBoolean(con->response, IPP_TAG_JOB, "job-preserved",
-                  job->num_files > 0);
+    if (job->state_value > IPP_JOB_PROCESSING &&
+       (!exclude || !cupsArrayFind(exclude, "job-preserved")) &&
+        (!ra || cupsArrayFind(ra, "job-preserved")))
+      ippAddBoolean(con->response, IPP_TAG_JOB, "job-preserved",
+                   job->num_files > 0);
 
-  if (!ra || cupsArrayFind(ra, "job-printer-up-time"))
-    ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER,
-                  "job-printer-up-time", time(NULL));
+    if ((!exclude || !cupsArrayFind(exclude, "job-printer-up-time")) &&
+        (!ra || cupsArrayFind(ra, "job-printer-up-time")))
+      ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER,
+                   "job-printer-up-time", time(NULL));
+  }
 
-  if (!ra || cupsArrayFind(ra, "job-state-reasons"))
-    add_job_state_reasons(con, job);
+  if (!ra || cupsArrayFind(ra, "job-printer-uri"))
+  {
+    httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+                    con->clientname, con->clientport,
+                    (job->dtype & CUPS_PRINTER_CLASS) ? "/classes/%s" :
+                                                        "/printers/%s",
+                    job->dest);
+    ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI,
+                "job-printer-uri", NULL, job_uri);
+  }
 
   if (!ra || cupsArrayFind(ra, "job-uri"))
+  {
+    httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+                    con->clientname, con->clientport, "/jobs/%d",
+                    job->id);
     ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI,
                 "job-uri", NULL, job_uri);
+  }
 
-  copy_attrs(con->response, job->attrs, ra, IPP_TAG_JOB, 0);
+  copy_attrs(con->response, job->attrs, ra, IPP_TAG_JOB, 0, exclude);
 }
 
 
@@ -5299,9 +4787,10 @@ copy_printer_attrs(
 {
   char                 printer_uri[HTTP_MAX_URI];
                                        /* Printer URI */
+  char                 printer_icons[HTTP_MAX_URI];
+                                       /* Printer icons */
   time_t               curtime;        /* Current time */
   int                  i;              /* Looping var */
-  ipp_attribute_t      *history;       /* History collection */
 
 
  /*
@@ -5311,14 +4800,6 @@ copy_printer_attrs(
 
   curtime = time(NULL);
 
-#ifdef __APPLE__
-  if ((!ra || cupsArrayFind(ra, "com.apple.print.recoverable-message")) &&
-      printer->recoverable)
-    ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT,
-                 "com.apple.print.recoverable-message", NULL,
-                printer->recoverable);
-#endif /* __APPLE__ */
-
   if (!ra || cupsArrayFind(ra, "marker-change-time"))
     ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
                   "marker-change-time", printer->marker_time);
@@ -5343,12 +4824,12 @@ copy_printer_attrs(
         if ((p2_uri = ippFindAttribute(p2->attrs, "printer-uri-supported",
                                       IPP_TAG_URI)) != NULL)
           member_uris->values[i].string.text =
-             _cupsStrAlloc(p2_uri->values[0].string.text);
+             _cupsStrRetain(p2_uri->values[0].string.text);
         else
        {
          httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri,
-                          sizeof(printer_uri), "ipp", NULL, con->servername,
-                          con->serverport,
+                          sizeof(printer_uri), "ipp", NULL, con->clientname,
+                          con->clientport,
                           (p2->type & CUPS_PRINTER_CLASS) ?
                               "/classes/%s" : "/printers/%s", p2->name);
          member_uris->values[i].string.text = _cupsStrAlloc(printer_uri);
@@ -5371,7 +4852,7 @@ copy_printer_attrs(
     ippAddDate(con->response, IPP_TAG_PRINTER, "printer-current-time",
                ippTimeToDate(curtime));
 
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
   if (!ra || cupsArrayFind(ra, "printer-dns-sd-name"))
   {
     if (printer->reg_name)
@@ -5381,12 +4862,41 @@ copy_printer_attrs(
       ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE,
                    "printer-dns-sd-name", 0);
   }
-#endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
 
   if (!ra || cupsArrayFind(ra, "printer-error-policy"))
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME,
                 "printer-error-policy", NULL, printer->error_policy);
 
+  if (!ra || cupsArrayFind(ra, "printer-error-policy-supported"))
+  {
+    static const char * const errors[] =/* printer-error-policy-supported values */
+                 {
+                   "abort-job",
+                   "retry-current-job",
+                   "retry-job",
+                   "stop-printer"
+                 };
+
+    if (printer->type & CUPS_PRINTER_CLASS)
+      ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME | IPP_TAG_COPY,
+                   "printer-error-policy-supported", NULL, "retry-current-job");
+    else
+      ippAddStrings(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME | IPP_TAG_COPY,
+                   "printer-error-policy-supported",
+                   sizeof(errors) / sizeof(errors[0]), NULL, errors);
+  }
+
+  if (!ra || cupsArrayFind(ra, "printer-icons"))
+  {
+    httpAssembleURIf(HTTP_URI_CODING_ALL, printer_icons, sizeof(printer_icons),
+                     "http", NULL, con->clientname, con->clientport,
+                    "/icons/%s.png", printer->name);
+    ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-icons",
+                 NULL, printer_icons);
+    cupsdLogMessage(CUPSD_LOG_DEBUG2, "printer-icons=\"%s\"", printer_icons);
+  }
+
   if (!ra || cupsArrayFind(ra, "printer-is-accepting-jobs"))
     ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-accepting-jobs",
                   printer->accepting);
@@ -5395,6 +4905,16 @@ copy_printer_attrs(
     ippAddBoolean(con->response, IPP_TAG_PRINTER, "printer-is-shared",
                   printer->shared);
 
+  if (!ra || cupsArrayFind(ra, "printer-more-info"))
+  {
+    httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+                     "http", NULL, con->clientname, con->clientport,
+                    (printer->type & CUPS_PRINTER_CLASS) ?
+                        "/classes/%s" : "/printers/%s", printer->name);
+    ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
+                "printer-more-info", NULL, printer_uri);
+  }
+
   if (!ra || cupsArrayFind(ra, "printer-op-policy"))
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME,
                 "printer-op-policy", NULL, printer->op_policy);
@@ -5407,23 +4927,6 @@ copy_printer_attrs(
     ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
                   "printer-state-change-time", printer->state_time);
 
-  if (MaxPrinterHistory > 0 && printer->num_history > 0 &&
-      cupsArrayFind(ra, "printer-state-history"))
-  {
-   /*
-    * Printer history is only sent if specifically requested, so that
-    * older CUPS/IPP clients won't barf on the collection attributes.
-    */
-
-    history = ippAddCollections(con->response, IPP_TAG_PRINTER,
-                                "printer-state-history",
-                                printer->num_history, NULL);
-
-    for (i = 0; i < printer->num_history; i ++)
-      copy_attrs(history->values[i].collection = ippNew(), printer->history[i],
-                 NULL, IPP_TAG_ZERO, 0);
-  }
-
   if (!ra || cupsArrayFind(ra, "printer-state-message"))
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT,
                 "printer-state-message", NULL, printer->state_message);
@@ -5435,7 +4938,6 @@ copy_printer_attrs(
   {
     int type;                          /* printer-type value */
 
-
    /*
     * Add the CUPS-specific printer-type attribute...
     */
@@ -5459,12 +4961,10 @@ copy_printer_attrs(
     ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
                   "printer-up-time", curtime);
 
-  if ((!ra || cupsArrayFind(ra, "printer-uri-supported")) &&
-      !ippFindAttribute(printer->attrs, "printer-uri-supported",
-                        IPP_TAG_URI))
+  if (!ra || cupsArrayFind(ra, "printer-uri-supported"))
   {
     httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
-                     "ipp", NULL, con->servername, con->serverport,
+                     "ipp", NULL, con->clientname, con->clientport,
                     (printer->type & CUPS_PRINTER_CLASS) ?
                         "/classes/%s" : "/printers/%s", printer->name);
     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
@@ -5476,8 +4976,10 @@ copy_printer_attrs(
   if (!ra || cupsArrayFind(ra, "queued-job-count"))
     add_queued_job_count(con, printer);
 
-  copy_attrs(con->response, printer->attrs, ra, IPP_TAG_ZERO, 0);
-  copy_attrs(con->response, CommonData, ra, IPP_TAG_ZERO, IPP_TAG_COPY);
+  copy_attrs(con->response, printer->attrs, ra, IPP_TAG_ZERO, 0, NULL);
+  if (printer->ppd_attrs)
+    copy_attrs(con->response, printer->ppd_attrs, ra, IPP_TAG_ZERO, 0, NULL);
+  copy_attrs(con->response, CommonData, ra, IPP_TAG_ZERO, IPP_TAG_COPY, NULL);
 }
 
 
@@ -5489,7 +4991,8 @@ static void
 copy_subscription_attrs(
     cupsd_client_t       *con,         /* I - Client connection */
     cupsd_subscription_t *sub,         /* I - Subscription */
-    cups_array_t         *ra)          /* I - Requested attributes array */
+    cups_array_t         *ra,          /* I - Requested attributes array */
+    cups_array_t         *exclude)     /* I - Private attributes array */
 {
   ipp_attribute_t      *attr;          /* Current attribute */
   char                 printer_uri[HTTP_MAX_URI];
@@ -5499,87 +5002,104 @@ copy_subscription_attrs(
   const char           *name;          /* Current event name */
 
 
+  cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                  "copy_subscription_attrs(con=%p, sub=%p, ra=%p, exclude=%p)",
+                 con, sub, ra, exclude);
+
  /*
   * Copy the subscription attributes to the response using the
   * requested-attributes attribute that may be provided by the client.
   */
 
-  if (!ra || cupsArrayFind(ra, "notify-events"))
+  if (!exclude || !cupsArrayFind(exclude, "all"))
   {
-    if ((name = cupsdEventName((cupsd_eventmask_t)sub->mask)) != NULL)
+    if ((!exclude || !cupsArrayFind(exclude, "notify-events")) &&
+        (!ra || cupsArrayFind(ra, "notify-events")))
     {
-     /*
-      * Simple event list...
-      */
+      cupsdLogMessage(CUPSD_LOG_DEBUG2, "copy_subscription_attrs: notify-events");
 
-      ippAddString(con->response, IPP_TAG_SUBSCRIPTION,
-                   (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY),
-                   "notify-events", NULL, name);
-    }
-    else
-    {
-     /*
-      * Complex event list...
-      */
+      if ((name = cupsdEventName((cupsd_eventmask_t)sub->mask)) != NULL)
+      {
+       /*
+       * Simple event list...
+       */
+
+       ippAddString(con->response, IPP_TAG_SUBSCRIPTION,
+                    (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY),
+                    "notify-events", NULL, name);
+      }
+      else
+      {
+       /*
+       * Complex event list...
+       */
 
-      for (mask = 1, count = 0; mask < CUPSD_EVENT_ALL; mask <<= 1)
-       if (sub->mask & mask)
-          count ++;
+       for (mask = 1, count = 0; mask < CUPSD_EVENT_ALL; mask <<= 1)
+         if (sub->mask & mask)
+           count ++;
 
-      attr = ippAddStrings(con->response, IPP_TAG_SUBSCRIPTION,
-                           (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY),
-                           "notify-events", count, NULL, NULL);
+       attr = ippAddStrings(con->response, IPP_TAG_SUBSCRIPTION,
+                            (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY),
+                            "notify-events", count, NULL, NULL);
 
-      for (mask = 1, count = 0; mask < CUPSD_EVENT_ALL; mask <<= 1)
-       if (sub->mask & mask)
-       {
-          attr->values[count].string.text =
-             (char *)cupsdEventName((cupsd_eventmask_t)mask);
+       for (mask = 1, count = 0; mask < CUPSD_EVENT_ALL; mask <<= 1)
+         if (sub->mask & mask)
+         {
+           attr->values[count].string.text =
+               (char *)cupsdEventName((cupsd_eventmask_t)mask);
 
-          count ++;
-       }
+           count ++;
+         }
+      }
     }
+
+    if ((!exclude || !cupsArrayFind(exclude, "notify-lease-duration")) &&
+        (!sub->job && (!ra || cupsArrayFind(ra, "notify-lease-duration"))))
+      ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
+                   "notify-lease-duration", sub->lease);
+
+    if ((!exclude || !cupsArrayFind(exclude, "notify-recipient-uri")) &&
+        (sub->recipient && (!ra || cupsArrayFind(ra, "notify-recipient-uri"))))
+      ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
+                  "notify-recipient-uri", NULL, sub->recipient);
+    else if ((!exclude || !cupsArrayFind(exclude, "notify-pull-method")) &&
+             (!ra || cupsArrayFind(ra, "notify-pull-method")))
+      ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD,
+                  "notify-pull-method", NULL, "ippget");
+
+    if ((!exclude || !cupsArrayFind(exclude, "notify-subscriber-user-name")) &&
+        (!ra || cupsArrayFind(ra, "notify-subscriber-user-name")))
+      ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_NAME,
+                  "notify-subscriber-user-name", NULL, sub->owner);
+
+    if ((!exclude || !cupsArrayFind(exclude, "notify-time-interval")) &&
+        (!ra || cupsArrayFind(ra, "notify-time-interval")))
+      ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
+                   "notify-time-interval", sub->interval);
+
+    if (sub->user_data_len > 0 &&
+       (!exclude || !cupsArrayFind(exclude, "notify-user-data")) &&
+        (!ra || cupsArrayFind(ra, "notify-user-data")))
+      ippAddOctetString(con->response, IPP_TAG_SUBSCRIPTION, "notify-user-data",
+                       sub->user_data, sub->user_data_len);
   }
 
   if (sub->job && (!ra || cupsArrayFind(ra, "notify-job-id")))
     ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
                   "notify-job-id", sub->job->id);
 
-  if (!sub->job && (!ra || cupsArrayFind(ra, "notify-lease-duration")))
-    ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
-                  "notify-lease-duration", sub->lease);
-
   if (sub->dest && (!ra || cupsArrayFind(ra, "notify-printer-uri")))
   {
     httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
-                     "ipp", NULL, con->servername, con->serverport,
+                     "ipp", NULL, con->clientname, con->clientport,
                     "/printers/%s", sub->dest->name);
     ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
                 "notify-printer-uri", NULL, printer_uri);
   }
 
-  if (sub->recipient && (!ra || cupsArrayFind(ra, "notify-recipient-uri")))
-    ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
-                "notify-recipient-uri", NULL, sub->recipient);
-  else if (!ra || cupsArrayFind(ra, "notify-pull-method"))
-    ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD,
-                 "notify-pull-method", NULL, "ippget");
-
-  if (!ra || cupsArrayFind(ra, "notify-subscriber-user-name"))
-    ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_NAME,
-                "notify-subscriber-user-name", NULL, sub->owner);
-
   if (!ra || cupsArrayFind(ra, "notify-subscription-id"))
     ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
                   "notify-subscription-id", sub->id);
-
-  if (!ra || cupsArrayFind(ra, "notify-time-interval"))
-    ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
-                  "notify-time-interval", sub->interval);
-
-  if (sub->user_data_len > 0 && (!ra || cupsArrayFind(ra, "notify-user-data")))
-    ippAddOctetString(con->response, IPP_TAG_SUBSCRIPTION, "notify-user-data",
-                      sub->user_data, sub->user_data_len);
 }
 
 
@@ -5591,8 +5111,16 @@ static void
 create_job(cupsd_client_t  *con,       /* I - Client connection */
           ipp_attribute_t *uri)        /* I - Printer URI */
 {
+  int                  i;              /* Looping var */
   cupsd_printer_t      *printer;       /* Printer */
   cupsd_job_t          *job;           /* New job */
+  static const char * const forbidden_attrs[] =
+  {                                    /* List of forbidden attributes */
+    "compression",
+    "document-format",
+    "document-name",
+    "document-natural-language"
+  };
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", con,
@@ -5609,10 +5137,33 @@ create_job(cupsd_client_t  *con,        /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
+ /*
+  * Check for invalid Create-Job attributes and log a warning or error depending
+  * on whether cupsd is running in "strict conformance" mode...
+  */
+
+  for (i = 0;
+       i < (int)(sizeof(forbidden_attrs) / sizeof(forbidden_attrs[0]));
+       i ++)
+    if (ippFindAttribute(con->request, forbidden_attrs[i], IPP_TAG_ZERO))
+    {
+      if (StrictConformance)
+      {
+       send_ipp_status(con, IPP_BAD_REQUEST,
+                       _("The '%s' operation attribute cannot be supplied in a "
+                         "Create-Job request."), forbidden_attrs[i]);
+       return;
+      }
+
+      cupsdLogMessage(CUPSD_LOG_WARN,
+                      "Unexpected '%s' operation attribute in a Create-Job "
+                      "request.", forbidden_attrs[i]);
+    }
+
  /*
   * Create the job object...
   */
@@ -5638,189 +5189,34 @@ create_job(cupsd_client_t  *con,       /* I - Client connection */
 static cups_array_t *                  /* O - Array of attributes or NULL */
 create_requested_array(ipp_t *request) /* I - IPP request */
 {
-  int                  i;              /* Looping var */
-  ipp_attribute_t      *requested;     /* requested-attributes attribute */
   cups_array_t         *ra;            /* Requested attributes array */
-  char                 *value;         /* Current value */
 
 
  /*
-  * Get the requested-attributes attribute, and return NULL if we don't
-  * have one...
+  * Create the array for standard attributes...
   */
 
-  if ((requested = ippFindAttribute(request, "requested-attributes",
-                                    IPP_TAG_KEYWORD)) == NULL)
-    return (NULL);
+  ra = ippCreateRequestedArray(request);
 
  /*
-  * If the attribute contains a single "all" keyword, return NULL...
+  * Add CUPS defaults as needed...
   */
 
-  if (requested->num_values == 1 &&
-      !strcmp(requested->values[0].string.text, "all"))
-    return (NULL);
+  if (cupsArrayFind(ra, "printer-defaults"))
+  {
+   /*
+    * Include user-set defaults...
+    */
 
- /*
-  * Create an array using "strcmp" as the comparison function...
-  */
-
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
-
-  for (i = 0; i < requested->num_values; i ++)
-  {
-    value = requested->values[i].string.text;
-
-    if (!strcmp(value, "job-template"))
-    {
-      cupsArrayAdd(ra, "copies");
-      cupsArrayAdd(ra, "copies-default");
-      cupsArrayAdd(ra, "copies-supported");
-      cupsArrayAdd(ra, "finishings");
-      cupsArrayAdd(ra, "finishings-default");
-      cupsArrayAdd(ra, "finishings-supported");
-      cupsArrayAdd(ra, "job-hold-until");
-      cupsArrayAdd(ra, "job-hold-until-default");
-      cupsArrayAdd(ra, "job-hold-until-supported");
-      cupsArrayAdd(ra, "job-priority");
-      cupsArrayAdd(ra, "job-priority-default");
-      cupsArrayAdd(ra, "job-priority-supported");
-      cupsArrayAdd(ra, "job-sheets");
-      cupsArrayAdd(ra, "job-sheets-default");
-      cupsArrayAdd(ra, "job-sheets-supported");
-      cupsArrayAdd(ra, "media");
-      cupsArrayAdd(ra, "media-default");
-      cupsArrayAdd(ra, "media-supported");
-      cupsArrayAdd(ra, "multiple-document-handling");
-      cupsArrayAdd(ra, "multiple-document-handling-default");
-      cupsArrayAdd(ra, "multiple-document-handling-supported");
-      cupsArrayAdd(ra, "number-up");
-      cupsArrayAdd(ra, "number-up-default");
-      cupsArrayAdd(ra, "number-up-supported");
-      cupsArrayAdd(ra, "orientation-requested");
-      cupsArrayAdd(ra, "orientation-requested-default");
-      cupsArrayAdd(ra, "orientation-requested-supported");
-      cupsArrayAdd(ra, "page-ranges");
-      cupsArrayAdd(ra, "page-ranges-supported");
-      cupsArrayAdd(ra, "printer-resolution");
-      cupsArrayAdd(ra, "printer-resolution-default");
-      cupsArrayAdd(ra, "printer-resolution-supported");
-      cupsArrayAdd(ra, "print-quality");
-      cupsArrayAdd(ra, "print-quality-default");
-      cupsArrayAdd(ra, "print-quality-supported");
-      cupsArrayAdd(ra, "sides");
-      cupsArrayAdd(ra, "sides-default");
-      cupsArrayAdd(ra, "sides-supported");
-    }
-    else if (!strcmp(value, "job-description"))
-    {
-      cupsArrayAdd(ra, "date-time-at-completed");
-      cupsArrayAdd(ra, "date-time-at-creation");
-      cupsArrayAdd(ra, "date-time-at-processing");
-      cupsArrayAdd(ra, "job-detailed-status-message");
-      cupsArrayAdd(ra, "job-document-access-errors");
-      cupsArrayAdd(ra, "job-id");
-      cupsArrayAdd(ra, "job-impressions");
-      cupsArrayAdd(ra, "job-impressions-completed");
-      cupsArrayAdd(ra, "job-k-octets");
-      cupsArrayAdd(ra, "job-k-octets-processed");
-      cupsArrayAdd(ra, "job-media-progress");
-      cupsArrayAdd(ra, "job-media-sheets");
-      cupsArrayAdd(ra, "job-media-sheets-completed");
-      cupsArrayAdd(ra, "job-message-from-operator");
-      cupsArrayAdd(ra, "job-more-info");
-      cupsArrayAdd(ra, "job-name");
-      cupsArrayAdd(ra, "job-originating-user-name");
-      cupsArrayAdd(ra, "job-printer-up-time");
-      cupsArrayAdd(ra, "job-printer-uri");
-      cupsArrayAdd(ra, "job-state");
-      cupsArrayAdd(ra, "job-state-message");
-      cupsArrayAdd(ra, "job-state-reasons");
-      cupsArrayAdd(ra, "job-uri");
-      cupsArrayAdd(ra, "number-of-documents");
-      cupsArrayAdd(ra, "number-of-intervening-jobs");
-      cupsArrayAdd(ra, "output-device-assigned");
-      cupsArrayAdd(ra, "time-at-completed");
-      cupsArrayAdd(ra, "time-at-creation");
-      cupsArrayAdd(ra, "time-at-processing");
-    }
-    else if (!strcmp(value, "printer-description"))
-    {
-      cupsArrayAdd(ra, "charset-configured");
-      cupsArrayAdd(ra, "charset-supported");
-      cupsArrayAdd(ra, "color-supported");
-      cupsArrayAdd(ra, "compression-supported");
-      cupsArrayAdd(ra, "document-format-default");
-      cupsArrayAdd(ra, "document-format-supported");
-      cupsArrayAdd(ra, "generated-natural-language-supported");
-      cupsArrayAdd(ra, "ipp-versions-supported");
-      cupsArrayAdd(ra, "job-impressions-supported");
-      cupsArrayAdd(ra, "job-k-octets-supported");
-      cupsArrayAdd(ra, "job-media-sheets-supported");
-      cupsArrayAdd(ra, "multiple-document-jobs-supported");
-      cupsArrayAdd(ra, "multiple-operation-time-out");
-      cupsArrayAdd(ra, "natural-language-configured");
-      cupsArrayAdd(ra, "notify-attributes-supported");
-      cupsArrayAdd(ra, "notify-lease-duration-default");
-      cupsArrayAdd(ra, "notify-lease-duration-supported");
-      cupsArrayAdd(ra, "notify-max-events-supported");
-      cupsArrayAdd(ra, "notify-events-default");
-      cupsArrayAdd(ra, "notify-events-supported");
-      cupsArrayAdd(ra, "notify-pull-method-supported");
-      cupsArrayAdd(ra, "notify-schemes-supported");
-      cupsArrayAdd(ra, "operations-supported");
-      cupsArrayAdd(ra, "pages-per-minute");
-      cupsArrayAdd(ra, "pages-per-minute-color");
-      cupsArrayAdd(ra, "pdl-override-supported");
-      cupsArrayAdd(ra, "printer-alert");
-      cupsArrayAdd(ra, "printer-alert-description");
-      cupsArrayAdd(ra, "printer-commands");
-      cupsArrayAdd(ra, "printer-current-time");
-      cupsArrayAdd(ra, "printer-driver-installer");
-      cupsArrayAdd(ra, "printer-dns-sd-name");
-      cupsArrayAdd(ra, "printer-info");
-      cupsArrayAdd(ra, "printer-is-accepting-jobs");
-      cupsArrayAdd(ra, "printer-location");
-      cupsArrayAdd(ra, "printer-make-and-model");
-      cupsArrayAdd(ra, "printer-message-from-operator");
-      cupsArrayAdd(ra, "printer-more-info");
-      cupsArrayAdd(ra, "printer-more-info-manufacturer");
-      cupsArrayAdd(ra, "printer-name");
-      cupsArrayAdd(ra, "printer-state");
-      cupsArrayAdd(ra, "printer-state-message");
-      cupsArrayAdd(ra, "printer-state-reasons");
-      cupsArrayAdd(ra, "printer-type");
-      cupsArrayAdd(ra, "printer-up-time");
-      cupsArrayAdd(ra, "printer-uri-supported");
-      cupsArrayAdd(ra, "queued-job-count");
-      cupsArrayAdd(ra, "reference-uri-schemes-supported");
-      cupsArrayAdd(ra, "uri-authentication-supported");
-      cupsArrayAdd(ra, "uri-security-supported");
-    }
-    else if (!strcmp(value, "printer-defaults"))
-    {
-      char     *name;                  /* Option name */
-
-
-      for (name = (char *)cupsArrayFirst(CommonDefaults);
-           name;
-          name = (char *)cupsArrayNext(CommonDefaults))
+    char       *name;                  /* Option name */
+
+    cupsArrayRemove(ra, "printer-defaults");
+
+    for (name = (char *)cupsArrayFirst(CommonDefaults);
+        name;
+        name = (char *)cupsArrayNext(CommonDefaults))
+      if (!cupsArrayFind(ra, name))
         cupsArrayAdd(ra, name);
-    }
-    else if (!strcmp(value, "subscription-template"))
-    {
-      cupsArrayAdd(ra, "notify-attributes");
-      cupsArrayAdd(ra, "notify-charset");
-      cupsArrayAdd(ra, "notify-events");
-      cupsArrayAdd(ra, "notify-lease-duration");
-      cupsArrayAdd(ra, "notify-natural-language");
-      cupsArrayAdd(ra, "notify-pull-method");
-      cupsArrayAdd(ra, "notify-recipient-uri");
-      cupsArrayAdd(ra, "notify-time-interval");
-      cupsArrayAdd(ra, "notify-user-data");
-    }
-    else
-      cupsArrayAdd(ra, value);
   }
 
   return (ra);
@@ -5910,7 +5306,7 @@ create_subscription(
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -5951,7 +5347,7 @@ create_subscription(
   if (!attr)
   {
     send_ipp_status(con, IPP_BAD_REQUEST,
-                    _("No subscription attributes in request!"));
+                    _("No subscription attributes in request."));
     return;
   }
 
@@ -6009,7 +5405,7 @@ create_subscription(
                            resource, sizeof(resource)) < HTTP_URI_OK)
         {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
-                         _("Bad notify-recipient-uri URI \"%s\"!"), recipient);
+                         _("Bad notify-recipient-uri \"%s\"."), recipient);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_URI_SCHEME);
          return;
@@ -6021,7 +5417,7 @@ create_subscription(
        {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
                          _("notify-recipient-uri URI \"%s\" uses unknown "
-                           "scheme!"), recipient);
+                           "scheme."), recipient);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_URI_SCHEME);
          return;
@@ -6030,7 +5426,7 @@ create_subscription(
         if (!strcmp(scheme, "rss") && !check_rss_recipient(recipient))
        {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
-                         _("notify-recipient-uri URI \"%s\" is already used!"),
+                         _("notify-recipient-uri URI \"%s\" is already used."),
                          recipient);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_ATTRIBUTES);
@@ -6045,7 +5441,7 @@ create_subscription(
         if (strcmp(pullmethod, "ippget"))
        {
           send_ipp_status(con, IPP_NOT_POSSIBLE,
-                         _("Bad notify-pull-method \"%s\"!"), pullmethod);
+                         _("Bad notify-pull-method \"%s\"."), pullmethod);
          ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM,
                        "notify-status-code", IPP_ATTRIBUTES);
          return;
@@ -6057,7 +5453,7 @@ create_subscription(
               strcmp(attr->values[0].string.text, "utf-8"))
       {
         send_ipp_status(con, IPP_CHARSET,
-                       _("Character set \"%s\" not supported!"),
+                       _("Character set \"%s\" not supported."),
                        attr->values[0].string.text);
        return;
       }
@@ -6066,7 +5462,7 @@ create_subscription(
                strcmp(attr->values[0].string.text, DefaultLanguage)))
       {
         send_ipp_status(con, IPP_CHARSET,
-                       _("Language \"%s\" not supported!"),
+                       _("Language \"%s\" not supported."),
                        attr->values[0].string.text);
        return;
       }
@@ -6077,7 +5473,7 @@ create_subscription(
        {
           send_ipp_status(con, IPP_REQUEST_VALUE,
                          _("The notify-user-data value is too large "
-                           "(%d > 63 octets)!"),
+                           "(%d > 63 octets)."),
                          attr->values[0].unknown.length);
          return;
        }
@@ -6125,7 +5521,7 @@ create_subscription(
       else
       {
         send_ipp_status(con, IPP_BAD_REQUEST,
-                       _("notify-events not specified!"));
+                       _("notify-events not specified."));
        return;
       }
     }
@@ -6143,24 +5539,30 @@ create_subscription(
     {
       if ((job = cupsdFindJob(jobid)) == NULL)
       {
-       send_ipp_status(con, IPP_NOT_FOUND, _("Job %d not found!"), jobid);
+       send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+                       jobid);
        return;
       }
     }
     else
       job = NULL;
 
-    sub = cupsdAddSubscription(mask, printer, job, recipient, 0);
+    if ((sub = cupsdAddSubscription(mask, printer, job, recipient, 0)) == NULL)
+    {
+      send_ipp_status(con, IPP_TOO_MANY_SUBSCRIPTIONS,
+                     _("There are too many subscriptions."));
+      return;
+    }
 
     if (job)
-      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription %d for job %d",
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription #%d for job %d.",
                      sub->id, job->id);
     else if (printer)
       cupsdLogMessage(CUPSD_LOG_DEBUG,
-                      "Added subscription %d for printer \"%s\"",
+                      "Added subscription #%d for printer \"%s\".",
                      sub->id, printer->name);
     else
-      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription %d for server",
+      cupsdLogMessage(CUPSD_LOG_DEBUG, "Added subscription #%d for server.",
                      sub->id);
 
     sub->interval = interval;
@@ -6218,7 +5620,7 @@ delete_printer(cupsd_client_t  *con,      /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -6256,18 +5658,28 @@ delete_printer(cupsd_client_t  *con,    /* I - Client connection */
   snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot,
            printer->name);
   unlink(filename);
+  snprintf(filename, sizeof(filename), "%s/interfaces/%s.O", ServerRoot,
+           printer->name);
+  unlink(filename);
 
   snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot,
            printer->name);
   unlink(filename);
+  snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd.O", ServerRoot,
+           printer->name);
+  unlink(filename);
+
+  snprintf(filename, sizeof(filename), "%s/%s.png", CacheDir, printer->name);
+  unlink(filename);
+
+  snprintf(filename, sizeof(filename), "%s/%s.data", CacheDir, printer->name);
+  unlink(filename);
 
-#ifdef __APPLE__
  /*
   * Unregister color profiles...
   */
 
-  apple_unregister_profiles(printer);
-#endif /* __APPLE__ */
+  cupsdUnregisterColor(printer);
 
   if (dtype & CUPS_PRINTER_CLASS)
   {
@@ -6282,7 +5694,9 @@ delete_printer(cupsd_client_t  *con,      /* I - Client connection */
     cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" deleted by \"%s\".",
                     printer->name, get_username(con));
 
-    cupsdDeletePrinter(printer, 0);
+    if (cupsdDeletePrinter(printer, 0))
+      cupsdMarkDirty(CUPSD_DIRTY_CLASSES);
+
     cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
   }
 
@@ -6330,7 +5744,7 @@ get_default(cupsd_client_t *con)  /* I - Client connection */
     con->response->request.status.status_code = IPP_OK;
   }
   else
-    send_ipp_status(con, IPP_NOT_FOUND, _("No default printer"));
+    send_ipp_status(con, IPP_NOT_FOUND, _("No default printer."));
 }
 
 
@@ -6345,13 +5759,16 @@ get_devices(cupsd_client_t *con)        /* I - Client connection */
   ipp_attribute_t      *limit,         /* limit attribute */
                        *timeout,       /* timeout attribute */
                        *requested,     /* requested-attributes attribute */
-                       *exclude;       /* exclude-schemes attribute */
+                       *exclude,       /* exclude-schemes attribute */
+                       *include;       /* include-schemes attribute */
   char                 command[1024],  /* cups-deviced command */
-                       options[1024],  /* Options to pass to command */
+                       options[2048],  /* Options to pass to command */
                        requested_str[256],
                                        /* String for requested attributes */
-                       exclude_str[512];
-                                       /* String for excluded attributes */
+                       exclude_str[512],
+                                       /* String for excluded schemes */
+                       include_str[512];
+                                       /* String for included schemes */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_devices(%p[%d])", con, con->http.fd);
@@ -6375,6 +5792,7 @@ get_devices(cupsd_client_t *con)  /* I - Client connection */
   requested = ippFindAttribute(con->request, "requested-attributes",
                                IPP_TAG_KEYWORD);
   exclude   = ippFindAttribute(con->request, "exclude-schemes", IPP_TAG_NAME);
+  include   = ippFindAttribute(con->request, "include-schemes", IPP_TAG_NAME);
 
   if (requested)
     url_encode_attr(requested, requested_str, sizeof(requested_str));
@@ -6386,15 +5804,21 @@ get_devices(cupsd_client_t *con)        /* I - Client connection */
   else
     exclude_str[0] = '\0';
 
+  if (include)
+    url_encode_attr(include, include_str, sizeof(include_str));
+  else
+    include_str[0] = '\0';
+
   snprintf(command, sizeof(command), "%s/daemon/cups-deviced", ServerBin);
   snprintf(options, sizeof(options),
-           "%d+%d+%d+%d+%s%s%s",
+           "%d+%d+%d+%d+%s%s%s%s%s",
            con->request->request.op.request_id,
            limit ? limit->values[0].integer : 0,
-          timeout ? timeout->values[0].integer : 10,
+          timeout ? timeout->values[0].integer : 15,
           (int)User,
           requested_str,
-          exclude_str[0] ? "%20" : "", exclude_str);
+          exclude_str[0] ? "%20" : "", exclude_str,
+          include_str[0] ? "%20" : "", include_str);
 
   if (cupsdSendCommand(con, command, options, 1))
   {
@@ -6431,7 +5855,7 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
   int          jobid;                  /* Job ID */
   int          docnum;                 /* Document number */
   cupsd_job_t  *job;                   /* Current job */
-  char         method[HTTP_MAX_URI],   /* Method portion of URI */
+  char         scheme[HTTP_MAX_URI],   /* Method portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
@@ -6457,7 +5881,7 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -6469,8 +5893,8 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -6479,8 +5903,7 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -6498,7 +5921,7 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -6506,7 +5929,8 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con,
+                                 job->username)) != HTTP_OK)
   {
     send_http_error(con, status, NULL);
     return;
@@ -6520,15 +5944,16 @@ get_document(cupsd_client_t  *con,      /* I - Client connection */
                                IPP_TAG_INTEGER)) == NULL)
   {
     send_ipp_status(con, IPP_BAD_REQUEST,
-                    _("Missing document-number attribute!"));
+                    _("Missing document-number attribute."));
     return;
   }
 
   if ((docnum = attr->values[0].integer) < 1 || docnum > job->num_files ||
       attr->num_values > 1)
   {
-    send_ipp_status(con, IPP_NOT_FOUND, _("Document %d not found in job %d."),
-                    docnum, jobid);
+    send_ipp_status(con, IPP_NOT_FOUND,
+                    _("Document #%d does not exist in job #%d."), docnum,
+                   jobid);
     return;
   }
 
@@ -6540,7 +5965,8 @@ get_document(cupsd_client_t  *con,        /* I - Client connection */
                     "Unable to open document %d in job %d - %s", docnum, jobid,
                    strerror(errno));
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("Unable to open document %d in job %d!"), docnum, jobid);
+                    _("Unable to open document #%d in job #%d."), docnum,
+                   jobid);
     return;
   }
 
@@ -6574,12 +6000,15 @@ get_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
   ipp_attribute_t *attr;               /* Current attribute */
   int          jobid;                  /* Job ID */
   cupsd_job_t  *job;                   /* Current job */
-  char         method[HTTP_MAX_URI],   /* Method portion of URI */
+  cupsd_printer_t *printer;            /* Current printer */
+  cupsd_policy_t *policy;              /* Current security policy */
+  char         scheme[HTTP_MAX_URI],   /* Scheme portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
   int          port;                   /* Port portion of URI */
-  cups_array_t *ra;                    /* Requested attributes array */
+  cups_array_t *ra,                    /* Requested attributes array */
+               *exclude;               /* Private attributes array */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_job_attrs(%p[%d], %s)", con,
@@ -6599,7 +6028,7 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -6611,8 +6040,8 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -6621,8 +6050,7 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -6640,7 +6068,7 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -6648,12 +6076,22 @@ get_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+  if ((printer = job->printer) == NULL)
+    printer = cupsdFindDest(job->dest);
+
+  if (printer)
+    policy = printer->op_policy_ptr;
+  else
+    policy = DefaultPolicyPtr;
+
+  if ((status = cupsdCheckPolicy(policy, con, job->username)) != HTTP_OK)
   {
     send_http_error(con, status, NULL);
     return;
   }
 
+  exclude = cupsdGetPrivateAttrs(policy, con, printer, job->username);
+
  /*
   * Copy attributes...
   */
@@ -6661,7 +6099,7 @@ get_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
   cupsdLoadJob(job);
 
   ra = create_requested_array(con->request);
-  copy_job_attrs(con, job, ra);
+  copy_job_attrs(con, job, ra, exclude);
   cupsArrayDelete(ra);
 
   con->response->request.status.status_code = IPP_OK;
@@ -6686,14 +6124,18 @@ get_jobs(cupsd_client_t  *con,          /* I - Client connection */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
   int          port;                   /* Port portion of URI */
-  int          completed;              /* Completed jobs? */
+  int          job_comparison;         /* Job comparison */
+  ipp_jstate_t job_state;              /* job-state value */
   int          first_job_id;           /* First job ID */
   int          limit;                  /* Maximum number of jobs to return */
   int          count;                  /* Number of jobs that match */
+  ipp_attribute_t *job_ids;            /* job-ids attribute */
   cupsd_job_t  *job;                   /* Current job pointer */
   cupsd_printer_t *printer;            /* Printer */
   cups_array_t *list;                  /* Which job list... */
-  cups_array_t *ra;                    /* Requested attributes array */
+  cups_array_t *ra,                    /* Requested attributes array */
+               *exclude;               /* Private attributes array */
+  cupsd_policy_t *policy;              /* Current policy */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs(%p[%d], %s)", con, con->http.fd,
@@ -6703,12 +6145,17 @@ get_jobs(cupsd_client_t  *con,          /* I - Client connection */
   * Is the destination valid?
   */
 
+  if (strcmp(uri->name, "printer-uri"))
+  {
+    send_ipp_status(con, IPP_BAD_REQUEST, _("No printer-uri in request."));
+    return;
+  }
+
   httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
                   sizeof(scheme), username, sizeof(username), host,
                  sizeof(host), &port, resource, sizeof(resource));
 
-  if (!strcmp(resource, "/") ||
-      (!strncmp(resource, "/jobs", 5) && strlen(resource) <= 6))
+  if (!strcmp(resource, "/") || !strcmp(resource, "/jobs"))
   {
     dest    = NULL;
     dtype   = (cups_ptype_t)0;
@@ -6737,7 +6184,7 @@ get_jobs(cupsd_client_t  *con,            /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
   else
@@ -6751,45 +6198,92 @@ get_jobs(cupsd_client_t  *con,          /* I - Client connection */
   */
 
   if (printer)
-  {
-    if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
-                                   NULL)) != HTTP_OK)
-    {
-      send_http_error(con, status, printer);
-      return;
-    }
-  }
-  else if ((status = cupsdCheckPolicy(DefaultPolicyPtr, con, NULL)) != HTTP_OK)
+    policy = printer->op_policy_ptr;
+  else
+    policy = DefaultPolicyPtr;
+
+  if ((status = cupsdCheckPolicy(policy, con, NULL)) != HTTP_OK)
   {
     send_http_error(con, status, NULL);
     return;
   }
 
+  job_ids = ippFindAttribute(con->request, "job-ids", IPP_TAG_INTEGER);
+
  /*
   * See if the "which-jobs" attribute have been specified...
   */
 
   if ((attr = ippFindAttribute(con->request, "which-jobs",
-                               IPP_TAG_KEYWORD)) != NULL &&
-      !strcmp(attr->values[0].string.text, "completed"))
+                               IPP_TAG_KEYWORD)) != NULL && job_ids)
+  {
+    send_ipp_status(con, IPP_CONFLICT,
+                    _("The %s attribute cannot be provided with job-ids."),
+                    "which-jobs");
+    return;
+  }
+  else if (!attr || !strcmp(attr->values[0].string.text, "not-completed"))
+  {
+    job_comparison = -1;
+    job_state      = IPP_JOB_STOPPED;
+    list           = ActiveJobs;
+  }
+  else if (!strcmp(attr->values[0].string.text, "completed"))
+  {
+    job_comparison = 1;
+    job_state      = IPP_JOB_CANCELED;
+    list           = Jobs;
+  }
+  else if (!strcmp(attr->values[0].string.text, "aborted"))
+  {
+    job_comparison = 0;
+    job_state      = IPP_JOB_ABORTED;
+    list           = Jobs;
+  }
+  else if (!strcmp(attr->values[0].string.text, "all"))
   {
-    completed = 1;
-    list      = Jobs;
+    job_comparison = 1;
+    job_state      = IPP_JOB_PENDING;
+    list           = Jobs;
   }
-  else if (attr && !strcmp(attr->values[0].string.text, "all"))
+  else if (!strcmp(attr->values[0].string.text, "canceled"))
   {
-    completed = 0;
-    list      = Jobs;
+    job_comparison = 0;
+    job_state      = IPP_JOB_CANCELED;
+    list           = Jobs;
   }
-  else if (attr && !strcmp(attr->values[0].string.text, "printing"))
+  else if (!strcmp(attr->values[0].string.text, "pending"))
   {
-    completed = 0;
-    list      = PrintingJobs;
+    job_comparison = 0;
+    job_state      = IPP_JOB_PENDING;
+    list           = ActiveJobs;
+  }
+  else if (!strcmp(attr->values[0].string.text, "pending-held"))
+  {
+    job_comparison = 0;
+    job_state      = IPP_JOB_HELD;
+    list           = ActiveJobs;
+  }
+  else if (!strcmp(attr->values[0].string.text, "processing"))
+  {
+    job_comparison = 0;
+    job_state      = IPP_JOB_PROCESSING;
+    list           = PrintingJobs;
+  }
+  else if (!strcmp(attr->values[0].string.text, "processing-stopped"))
+  {
+    job_comparison = 0;
+    job_state      = IPP_JOB_STOPPED;
+    list           = ActiveJobs;
   }
   else
   {
-    completed = 0;
-    list      = ActiveJobs;
+    send_ipp_status(con, IPP_ATTRIBUTES,
+                    _("The which-jobs value \"%s\" is not supported."),
+                   attr->values[0].string.text);
+    ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
+                 "which-jobs", NULL, attr->values[0].string.text);
+    return;
   }
 
  /*
@@ -6798,13 +6292,33 @@ get_jobs(cupsd_client_t  *con,          /* I - Client connection */
 
   if ((attr = ippFindAttribute(con->request, "limit",
                                IPP_TAG_INTEGER)) != NULL)
+  {
+    if (job_ids)
+    {
+      send_ipp_status(con, IPP_CONFLICT,
+                     _("The %s attribute cannot be provided with job-ids."),
+                     "limit");
+      return;
+    }
+
     limit = attr->values[0].integer;
+  }
   else
     limit = 0;
 
   if ((attr = ippFindAttribute(con->request, "first-job-id",
                                IPP_TAG_INTEGER)) != NULL)
+  {
+    if (job_ids)
+    {
+      send_ipp_status(con, IPP_CONFLICT,
+                     _("The %s attribute cannot be provided with job-ids."),
+                     "first-job-id");
+      return;
+    }
+
     first_job_id = attr->values[0].integer;
+  }
   else
     first_job_id = 1;
 
@@ -6813,8 +6327,14 @@ get_jobs(cupsd_client_t  *con,           /* I - Client connection */
   */
 
   if ((attr = ippFindAttribute(con->request, "my-jobs",
-                               IPP_TAG_BOOLEAN)) != NULL &&
-      attr->values[0].boolean)
+                               IPP_TAG_BOOLEAN)) != NULL && job_ids)
+  {
+    send_ipp_status(con, IPP_CONFLICT,
+                    _("The %s attribute cannot be provided with job-ids."),
+                    "my-jobs");
+    return;
+  }
+  else if (attr && attr->values[0].boolean)
     strlcpy(username, get_username(con), sizeof(username));
   else
     username[0] = '\0';
@@ -6825,50 +6345,109 @@ get_jobs(cupsd_client_t  *con,         /* I - Client connection */
   * OK, build a list of jobs for this printer...
   */
 
-  for (count = 0, job = (cupsd_job_t *)cupsArrayFirst(list);
-       (limit <= 0 || count < limit) && job;
-       job = (cupsd_job_t *)cupsArrayNext(list))
+  if (job_ids)
   {
-   /*
-    * Filter out jobs that don't match...
-    */
+    int        i;                              /* Looping var */
+
+    for (i = 0; i < job_ids->num_values; i ++)
+    {
+      if (!cupsdFindJob(job_ids->values[i].integer))
+        break;
+    }
+
+    if (i < job_ids->num_values)
+    {
+      send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+                      job_ids->values[i].integer);
+      return;
+    }
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: job->id = %d", job->id);
+    for (i = 0; i < job_ids->num_values; i ++)
+    {
+      job = cupsdFindJob(job_ids->values[i].integer);
 
-    if (!job->dest || !job->username)
       cupsdLoadJob(job);
 
-    if (!job->dest || !job->username)
-      continue;
+      if (!job->attrs)
+      {
+       cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d",
+                       job->id);
+       continue;
+      }
 
-    if ((dest && strcmp(job->dest, dest)) &&
-        (!job->printer || !dest || strcmp(job->printer->name, dest)))
-      continue;
-    if ((job->dtype & dmask) != dtype &&
-        (!job->printer || (job->printer->type & dmask) != dtype))
-      continue;
-    if (completed && job->state_value <= IPP_JOB_STOPPED)
-      continue;
+      if (i > 0)
+       ippAddSeparator(con->response);
 
-    if (job->id < first_job_id)
-      continue;
+      exclude = cupsdGetPrivateAttrs(job->printer ?
+                                         job->printer->op_policy_ptr :
+                                        policy, con, job->printer,
+                                        job->username);
 
-    cupsdLoadJob(job);
+      copy_job_attrs(con, job, ra, exclude);
+    }
+  }
+  else
+  {
+    for (count = 0, job = (cupsd_job_t *)cupsArrayFirst(list);
+        (limit <= 0 || count < limit) && job;
+        job = (cupsd_job_t *)cupsArrayNext(list))
+    {
+     /*
+      * Filter out jobs that don't match...
+      */
 
-    if (!job->attrs)
-      continue;
+      cupsdLogMessage(CUPSD_LOG_DEBUG2,
+                     "get_jobs: job->id=%d, dest=\"%s\", username=\"%s\", "
+                     "state_value=%d, attrs=%p", job->id, job->dest,
+                     job->username, job->state_value, job->attrs);
 
-    if (username[0] && strcasecmp(username, job->username))
-      continue;
+      if (!job->dest || !job->username)
+       cupsdLoadJob(job);
 
-    if (count > 0)
-      ippAddSeparator(con->response);
+      if (!job->dest || !job->username)
+       continue;
+
+      if ((dest && strcmp(job->dest, dest)) &&
+         (!job->printer || !dest || strcmp(job->printer->name, dest)))
+       continue;
+      if ((job->dtype & dmask) != dtype &&
+         (!job->printer || (job->printer->type & dmask) != dtype))
+       continue;
+
+      if ((job_comparison < 0 && job->state_value > job_state) ||
+          (job_comparison == 0 && job->state_value != job_state) ||
+          (job_comparison > 0 && job->state_value < job_state))
+       continue;
+
+      if (job->id < first_job_id)
+       continue;
+
+      cupsdLoadJob(job);
+
+      if (!job->attrs)
+      {
+       cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: No attributes for job %d",
+                       job->id);
+       continue;
+      }
+
+      if (username[0] && _cups_strcasecmp(username, job->username))
+       continue;
 
-    count ++;
+      if (count > 0)
+       ippAddSeparator(con->response);
+
+      count ++;
+
+      exclude = cupsdGetPrivateAttrs(job->printer ?
+                                         job->printer->op_policy_ptr :
+                                        policy, con, job->printer,
+                                        job->username);
 
-    cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count = %d", count);
+      copy_job_attrs(con, job, ra, exclude);
+    }
 
-    copy_job_attrs(con, job, ra);
+    cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_jobs: count=%d", count);
   }
 
   cupsArrayDelete(ra);
@@ -6908,7 +6487,7 @@ get_notifications(cupsd_client_t *con)    /* I - Client connection */
   if (!ids)
   {
     send_ipp_status(con, IPP_BAD_REQUEST,
-                    _("Missing notify-subscription-ids attribute!"));
+                    _("Missing notify-subscription-ids attribute."));
     return;
   }
 
@@ -6924,8 +6503,7 @@ get_notifications(cupsd_client_t *con)    /* I - Client connection */
       * Bad subscription ID...
       */
 
-      send_ipp_status(con, IPP_NOT_FOUND,
-                      _("notify-subscription-id %d no good!"),
+      send_ipp_status(con, IPP_NOT_FOUND, _("Subscription #%d does not exist."),
                      ids->values[i].integer);
       return;
     }
@@ -6991,7 +6569,7 @@ get_notifications(cupsd_client_t *con)    /* I - Client connection */
     * If we don't have any new events, nothing to do here...
     */
 
-    if (min_seq > (sub->first_event_id + sub->num_events))
+    if (min_seq > (sub->first_event_id + cupsArrayCount(sub->events)))
       continue;
 
    /*
@@ -7003,12 +6581,13 @@ get_notifications(cupsd_client_t *con)  /* I - Client connection */
     else
       j = min_seq - sub->first_event_id;
 
-    for (; j < sub->num_events; j ++)
+    for (; j < cupsArrayCount(sub->events); j ++)
     {
       ippAddSeparator(con->response);
 
-      copy_attrs(con->response, sub->events[j]->attrs, NULL,
-                IPP_TAG_EVENT_NOTIFICATION, 0);
+      copy_attrs(con->response,
+                 ((cupsd_event_t *)cupsArrayIndex(sub->events, j))->attrs, NULL,
+                IPP_TAG_EVENT_NOTIFICATION, 0, NULL);
     }
   }
 }
@@ -7111,11 +6690,10 @@ get_ppd(cupsd_client_t  *con,           /* I - Client connection */
                    "printer-uri", NULL, dest->uri);
       return;
     }
-    else if (dtype & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
+    else if (dtype & CUPS_PRINTER_CLASS)
     {
       for (i = 0; i < dest->num_printers; i ++)
-        if (!(dest->printers[i]->type &
-             (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)))
+        if (!(dest->printers[i]->type & CUPS_PRINTER_CLASS))
        {
          snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot,
                   dest->printers[i]->name);
@@ -7177,9 +6755,11 @@ get_ppds(cupsd_client_t *con)            /* I - Client connection */
                        *product,       /* ppd-product attribute */
                        *psversion,     /* ppd-psverion attribute */
                        *type,          /* ppd-type attribute */
-                       *requested;     /* requested-attributes attribute */
+                       *requested,     /* requested-attributes attribute */
+                       *exclude,       /* exclude-schemes attribute */
+                       *include;       /* include-schemes attribute */
   char                 command[1024],  /* cups-driverd command */
-                       options[1024],  /* Options to pass to command */
+                       options[4096],  /* Options to pass to command */
                        device_str[256],/* Escaped ppd-device-id string */
                        language_str[256],
                                        /* Escaped ppd-natural-language */
@@ -7192,8 +6772,12 @@ get_ppds(cupsd_client_t *con)            /* I - Client connection */
                        psversion_str[256],
                                        /* Escaped ppd-psversion string */
                        type_str[256],  /* Escaped ppd-type string */
-                       requested_str[256];
+                       requested_str[256],
                                        /* String for requested attributes */
+                       exclude_str[512],
+                                       /* String for excluded schemes */
+                       include_str[512];
+                                       /* String for included schemes */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_ppds(%p[%d])", con, con->http.fd);
@@ -7226,6 +6810,10 @@ get_ppds(cupsd_client_t *con)            /* I - Client connection */
   type         = ippFindAttribute(con->request, "ppd-type", IPP_TAG_KEYWORD);
   requested    = ippFindAttribute(con->request, "requested-attributes",
                                   IPP_TAG_KEYWORD);
+  exclude      = ippFindAttribute(con->request, "exclude-schemes",
+                                  IPP_TAG_NAME);
+  include      = ippFindAttribute(con->request, "include-schemes",
+                                  IPP_TAG_NAME);
 
   if (requested)
     url_encode_attr(requested, requested_str, sizeof(requested_str));
@@ -7271,11 +6859,21 @@ get_ppds(cupsd_client_t *con)           /* I - Client connection */
   if (type)
     url_encode_attr(type, type_str, sizeof(type_str));
   else
-    type_str[0] = '\0';
+    type_str[0] = '\0';
+
+  if (exclude)
+    url_encode_attr(exclude, exclude_str, sizeof(exclude_str));
+  else
+    exclude_str[0] = '\0';
+
+  if (include)
+    url_encode_attr(include, include_str, sizeof(include_str));
+  else
+    include_str[0] = '\0';
 
   snprintf(command, sizeof(command), "%s/daemon/cups-driverd", ServerBin);
   snprintf(options, sizeof(options),
-           "list+%d+%d+%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+           "list+%d+%d+%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
            con->request->request.op.request_id,
            limit ? limit->values[0].integer : 0,
           requested_str,
@@ -7286,7 +6884,9 @@ get_ppds(cupsd_client_t *con)             /* I - Client connection */
           model_number ? "%20" : "", model_number_str,
           product ? "%20" : "", product_str,
           psversion ? "%20" : "", psversion_str,
-          type ? "%20" : "", type_str);
+          type ? "%20" : "", type_str,
+          exclude_str[0] ? "%20" : "", exclude_str,
+          include_str[0] ? "%20" : "", include_str);
 
   if (cupsdSendCommand(con, command, options, 0))
   {
@@ -7338,7 +6938,7 @@ get_printer_attrs(cupsd_client_t  *con,   /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -7366,6 +6966,61 @@ get_printer_attrs(cupsd_client_t  *con,  /* I - Client connection */
 }
 
 
+/*
+ * 'get_printer_supported()' - Get printer supported values.
+ */
+
+static void
+get_printer_supported(
+    cupsd_client_t  *con,              /* I - Client connection */
+    ipp_attribute_t *uri)              /* I - Printer URI */
+{
+  http_status_t                status;         /* Policy status */
+  cups_ptype_t         dtype;          /* Destination type (printer/class) */
+  cupsd_printer_t      *printer;       /* Printer/class */
+
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printer_supported(%p[%d], %s)", con,
+                  con->http.fd, uri->values[0].string.text);
+
+ /*
+  * Is the destination valid?
+  */
+
+  if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+  {
+   /*
+    * Bad URI...
+    */
+
+    send_ipp_status(con, IPP_NOT_FOUND,
+                    _("The printer or class does not exist."));
+    return;
+  }
+
+ /*
+  * Check policy...
+  */
+
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  {
+    send_http_error(con, status, printer);
+    return;
+  }
+
+ /*
+  * Return a list of attributes that can be set via Set-Printer-Attributes.
+  */
+
+  ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ADMINDEFINE,
+                "printer-info", 0);
+  ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_ADMINDEFINE,
+                "printer-location", 0);
+
+  con->response->request.status.status_code = IPP_OK;
+}
+
+
 /*
  * 'get_printers()' - Get a list of printers or classes.
  */
@@ -7385,6 +7040,7 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
   const char   *username;              /* Current user */
   char         *first_printer_name;    /* first-printer-name attribute */
   cups_array_t *ra;                    /* Requested attributes array */
+  int          local;                  /* Local connection? */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_printers(%p[%d], %x)", con,
@@ -7442,6 +7098,8 @@ get_printers(cupsd_client_t *con, /* I - Client connection */
   else
     printer_mask = 0;
 
+  local = httpAddrLocalhost(&(con->clientaddr));
+
   if ((attr = ippFindAttribute(con->request, "printer-location",
                                IPP_TAG_TEXT)) != NULL)
     location = attr->values[0].string.text;
@@ -7474,27 +7132,21 @@ get_printers(cupsd_client_t *con,       /* I - Client connection */
        count < limit && printer;
        printer = (cupsd_printer_t *)cupsArrayNext(Printers))
   {
+    if (!local && !printer->shared)
+      continue;
+
     if ((!type || (printer->type & CUPS_PRINTER_CLASS) == type) &&
         (printer->type & printer_mask) == printer_type &&
-       (!location || !printer->location ||
-        !strcasecmp(printer->location, location)))
+       (!location ||
+        (printer->location && !_cups_strcasecmp(printer->location, location))))
     {
-     /*
-      * If HideImplicitMembers is enabled, see if this printer or class
-      * is a member of an implicit class...
-      */
-
-      if (ImplicitClasses && HideImplicitMembers &&
-          printer->in_implicit_class)
-        continue;
-
      /*
       * If a username is specified, see if it is allowed or denied
       * access...
       */
 
-      if (!(printer->type & CUPS_PRINTER_AUTHENTICATED) &&
-          printer->num_users && username && !user_allowed(printer, username))
+      if (cupsArrayCount(printer->users) && username &&
+         !user_allowed(printer, username))
         continue;
 
      /*
@@ -7531,7 +7183,9 @@ get_subscription_attrs(
 {
   http_status_t                status;         /* Policy status */
   cupsd_subscription_t *sub;           /* Subscription */
-  cups_array_t         *ra;            /* Requested attributes array */
+  cupsd_policy_t       *policy;        /* Current security policy */
+  cups_array_t         *ra,            /* Requested attributes array */
+                       *exclude;       /* Private attributes array */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
@@ -7548,8 +7202,8 @@ get_subscription_attrs(
     * Bad subscription ID...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND,
-                    _("notify-subscription-id %d no good!"), sub_id);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Subscription #%d does not exist."),
+                    sub_id);
     return;
   }
 
@@ -7557,14 +7211,19 @@ get_subscription_attrs(
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(sub->dest ? sub->dest->op_policy_ptr :
-                                             DefaultPolicyPtr,
-                                 con, sub->owner)) != HTTP_OK)
+  if (sub->dest)
+    policy = sub->dest->op_policy_ptr;
+  else
+    policy = DefaultPolicyPtr;
+
+  if ((status = cupsdCheckPolicy(policy, con, sub->owner)) != HTTP_OK)
   {
     send_http_error(con, status, sub->dest);
     return;
   }
 
+  exclude = cupsdGetPrivateAttrs(policy, con, sub->dest, sub->owner);
+
  /*
   * Copy the subscription attributes to the response using the
   * requested-attributes attribute that may be provided by the client.
@@ -7572,7 +7231,7 @@ get_subscription_attrs(
 
   ra = create_requested_array(con->request);
 
-  copy_subscription_attrs(con, sub, ra);
+  copy_subscription_attrs(con, sub, ra, exclude);
 
   cupsArrayDelete(ra);
 
@@ -7606,6 +7265,8 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
   int                  port;           /* Port portion of URI */
   cupsd_job_t          *job;           /* Job pointer */
   cupsd_printer_t      *printer;       /* Printer */
+  cupsd_policy_t       *policy;        /* Policy */
+  cups_array_t         *exclude;       /* Private attributes array */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2,
@@ -7635,8 +7296,8 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
 
     if (!job)
     {
-      send_ipp_status(con, IPP_NOT_FOUND, _("Job #%s does not exist!"),
-                      resource + 6);
+      send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
+                      atoi(resource + 6));
       return;
     }
   }
@@ -7647,7 +7308,7 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
   else if ((attr = ippFindAttribute(con->request, "notify-job-id",
@@ -7657,7 +7318,7 @@ get_subscriptions(cupsd_client_t  *con,   /* I - Client connection */
 
     if (!job)
     {
-      send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"),
+      send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."),
                       attr->values[0].integer);
       return;
     }
@@ -7669,9 +7330,12 @@ get_subscriptions(cupsd_client_t  *con,  /* I - Client connection */
   * Check policy...
   */
 
-  if ((status = cupsdCheckPolicy(printer ? printer->op_policy_ptr :
-                                           DefaultPolicyPtr,
-                                 con, NULL)) != HTTP_OK)
+  if (printer)
+    policy = printer->op_policy_ptr;
+  else
+    policy = DefaultPolicyPtr;
+
+  if ((status = cupsdCheckPolicy(policy, con, NULL)) != HTTP_OK)
   {
     send_http_error(con, status, printer);
     return;
@@ -7705,10 +7369,15 @@ get_subscriptions(cupsd_client_t  *con, /* I - Client connection */
        sub;
        sub = (cupsd_subscription_t *)cupsArrayNext(Subscriptions))
     if ((!printer || sub->dest == printer) && (!job || sub->job == job) &&
-        (!username[0] || !strcasecmp(username, sub->owner)))
+        (!username[0] || !_cups_strcasecmp(username, sub->owner)))
     {
       ippAddSeparator(con->response);
-      copy_subscription_attrs(con, sub, ra);
+
+      exclude = cupsdGetPrivateAttrs(sub->dest ? sub->dest->op_policy_ptr :
+                                                policy, con, sub->dest,
+                                                sub->owner);
+
+      copy_subscription_attrs(con, sub, ra, exclude);
 
       count ++;
       if (limit && count >= limit)
@@ -7752,10 +7421,10 @@ static void
 hold_job(cupsd_client_t  *con,         /* I - Client connection */
          ipp_attribute_t *uri)         /* I - Job or Printer URI */
 {
-  ipp_attribute_t *attr,               /* Current job-hold-until */
-               *newattr;               /* New job-hold-until */
+  ipp_attribute_t *attr;               /* Current job-hold-until */
+  const char   *when;                  /* New value */
   int          jobid;                  /* Job ID */
-  char         method[HTTP_MAX_URI],   /* Method portion of URI */
+  char         scheme[HTTP_MAX_URI],   /* Method portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
@@ -7780,7 +7449,7 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -7792,8 +7461,8 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -7803,7 +7472,7 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
       */
 
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+                      _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -7821,7 +7490,7 @@ hold_job(cupsd_client_t  *con,            /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -7831,58 +7500,114 @@ hold_job(cupsd_client_t  *con,         /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                   cupsdFindDest(job->dest));
     return;
   }
 
  /*
-  * Hold the job and return...
+  * See if the job is in a state that allows holding...
   */
 
-  cupsdHoldJob(job);
+  if (job->state_value > IPP_JOB_STOPPED)
+  {
+   /*
+    * Return a "not-possible" error...
+    */
 
-  cupsdAddEvent(CUPSD_EVENT_JOB_STATE, cupsdFindDest(job->dest), job,
-                "Job held by user.");
+    send_ipp_status(con, IPP_NOT_POSSIBLE,
+                   _("Job #%d is finished and cannot be altered."),
+                   job->id);
+    return;
+  }
 
-  if ((newattr = ippFindAttribute(con->request, "job-hold-until",
-                                  IPP_TAG_KEYWORD)) == NULL)
-    newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME);
+ /*
+  * Hold the job and return...
+  */
 
-  if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
-                               IPP_TAG_KEYWORD)) == NULL)
-    attr = ippFindAttribute(job->attrs, "job-hold-until", IPP_TAG_NAME);
+  if ((attr = ippFindAttribute(con->request, "job-hold-until",
+                              IPP_TAG_KEYWORD)) == NULL)
+    attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME);
 
   if (attr)
   {
-   /*
-    * Free the old hold value and copy the new one over...
-    */
+    when = attr->values[0].string.text;
 
-    _cupsStrFree(attr->values[0].string.text);
+    cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
+                 "Job job-hold-until value changed by user.");
+  }
+  else
+    when = "indefinite";
 
-    if (newattr)
-    {
-      attr->value_tag = newattr->value_tag;
-      attr->values[0].string.text =
-          _cupsStrAlloc(newattr->values[0].string.text);
-    }
-    else
-    {
-      attr->value_tag = IPP_TAG_KEYWORD;
-      attr->values[0].string.text = _cupsStrAlloc("indefinite");
-    }
+  cupsdSetJobHoldUntil(job, when, 1);
+  cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".",
+                   username);
+
+  con->response->request.status.status_code = IPP_OK;
+}
+
+
+/*
+ * 'hold_new_jobs()' - Hold pending/new jobs on a printer or class.
+ */
+
+static void
+hold_new_jobs(cupsd_client_t  *con,    /* I - Connection */
+              ipp_attribute_t *uri)    /* I - Printer URI */
+{
+  http_status_t                status;         /* Policy status */
+  cups_ptype_t         dtype;          /* Destination type (printer/class) */
+  cupsd_printer_t      *printer;       /* Printer data */
 
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "hold_new_jobs(%p[%d], %s)", con,
+                  con->http.fd, uri->values[0].string.text);
+
+ /*
+  * Is the destination valid?
+  */
+
+  if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+  {
    /*
-    * Hold job until specified time...
+    * Bad URI...
     */
 
-    cupsdSetJobHoldUntil(job, attr->values[0].string.text);
+    send_ipp_status(con, IPP_NOT_FOUND,
+                    _("The printer or class does not exist."));
+    return;
+  }
 
-    cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
-                  "Job job-hold-until value changed by user.");
+ /*
+  * Check policy...
+  */
+
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  {
+    send_http_error(con, status, printer);
+    return;
   }
 
-  cupsdLogJob(job, CUPSD_LOG_INFO, "Held by \"%s\".", username);
+ /*
+  * Hold pending/new jobs sent to the printer...
+  */
+
+  printer->holding_new_jobs = 1;
+
+  cupsdSetPrinterReasons(printer, "+hold-new-jobs");
+
+  if (dtype & CUPS_PRINTER_CLASS)
+    cupsdLogMessage(CUPSD_LOG_INFO,
+                    "Class \"%s\" now holding pending/new jobs (\"%s\").",
+                    printer->name, get_username(con));
+  else
+    cupsdLogMessage(CUPSD_LOG_INFO,
+                    "Printer \"%s\" now holding pending/new jobs (\"%s\").",
+                    printer->name, get_username(con));
+
+ /*
+  * Everything was ok, so return OK status...
+  */
 
   con->response->request.status.status_code = IPP_OK;
 }
@@ -7927,7 +7652,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_BAD_REQUEST,
-                    _("job-printer-uri attribute missing!"));
+                    _("job-printer-uri attribute missing."));
     return;
   }
 
@@ -7938,7 +7663,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -7971,7 +7696,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
        */
 
        send_ipp_status(con, IPP_NOT_FOUND,
-                       _("The printer or class was not found."));
+                       _("The printer or class does not exist."));
        return;
       }
 
@@ -7990,7 +7715,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
        */
 
        send_ipp_status(con, IPP_NOT_FOUND,
-                       _("Job #%d does not exist!"), attr->values[0].integer);
+                       _("Job #%d does not exist."), attr->values[0].integer);
        return;
       }
       else
@@ -8016,8 +7741,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -8034,8 +7758,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
       * Nope - return a "not found" error...
       */
 
-      send_ipp_status(con, IPP_NOT_FOUND,
-                      _("Job #%d does not exist!"), jobid);
+      send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
       return;
     }
     else
@@ -8077,7 +7800,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
       */
 
       send_ipp_status(con, IPP_NOT_POSSIBLE,
-                      _("Job #%d is finished and cannot be altered!"),
+                      _("Job #%d is finished and cannot be altered."),
                      job->id);
       return;
     }
@@ -8088,7 +7811,8 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
 
     if (!validate_user(job, con, job->username, username, sizeof(username)))
     {
-      send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+      send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                      cupsdFindDest(job->dest));
       return;
     }
 
@@ -8113,7 +7837,7 @@ move_job(cupsd_client_t  *con,            /* I - Client connection */
       * completed...
       */
 
-      if (strcasecmp(job->dest, src) ||
+      if (_cups_strcasecmp(job->dest, src) ||
           job->state_value > IPP_JOB_STOPPED)
        continue;
 
@@ -8168,7 +7892,9 @@ ppd_parse_line(const char *line,  /* I - Line */
   * Read the option name...
   */
 
-  for (line += 8, olen --; isalnum(*line & 255); line ++)
+  for (line += 8, olen --;
+       *line > ' ' && *line < 0x7f && *line != ':' && *line != '/';
+       line ++)
     if (olen > 0)
     {
       *option++ = *line;
@@ -8196,7 +7922,9 @@ ppd_parse_line(const char *line,  /* I - Line */
   while (isspace(*line & 255))
     line ++;
 
-  for (clen --; isalnum(*line & 255); line ++)
+  for (clen --;
+       *line > ' ' && *line < 0x7f && *line != ':' && *line != '/';
+       line ++)
     if (clen > 0)
     {
       *choice++ = *line;
@@ -8257,7 +7985,7 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
       )
     {
       send_ipp_status(con, IPP_ATTRIBUTES,
-                      _("Unsupported compression \"%s\"!"),
+                      _("Unsupported compression \"%s\"."),
                      attr->values[0].string.text);
       ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
                   "compression", NULL, attr->values[0].string.text);
@@ -8276,7 +8004,7 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
 
   if (!con->filename)
   {
-    send_ipp_status(con, IPP_BAD_REQUEST, _("No file!?!"));
+    send_ipp_status(con, IPP_BAD_REQUEST, _("No file in print request."));
     return;
   }
 
@@ -8291,7 +8019,7 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -8306,11 +8034,11 @@ print_job(cupsd_client_t  *con,         /* I - Client connection */
     * Grab format from client...
     */
 
-    if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super,
+    if (sscanf(format->values[0].string.text, "%15[^/]/%255[^;]", super,
                type) != 2)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Could not scan type \"%s\"!"),
+                      _("Bad document-format \"%s\"."),
                      format->values[0].string.text);
       return;
     }
@@ -8323,10 +8051,10 @@ print_job(cupsd_client_t  *con,         /* I - Client connection */
     * Use default document format...
     */
 
-    if (sscanf(default_format, "%15[^/]/%31[^;]", super, type) != 2)
+    if (sscanf(default_format, "%15[^/]/%255[^;]", super, type) != 2)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Could not scan type \"%s\"!"),
+                      _("Bad document-format \"%s\"."),
                      default_format);
       return;
     }
@@ -8337,8 +8065,8 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
     * Auto-type it!
     */
 
-    strcpy(super, "application");
-    strcpy(type, "octet-stream");
+    strlcpy(super, "application", sizeof(super));
+    strlcpy(type, "octet-stream", sizeof(type));
   }
 
   if (!strcmp(super, "application") && !strcmp(type, "octet-stream"))
@@ -8391,7 +8119,9 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
   else if (!filetype)
   {
     send_ipp_status(con, IPP_DOCUMENT_FORMAT,
-                    _("Unsupported format \'%s/%s\'!"), super, type);
+                    _("Unsupported document-format \"%s\"."),
+                   format ? format->values[0].string.text :
+                            "application/octet-stream");
     cupsdLogMessage(CUPSD_LOG_INFO,
                     "Hint: Do you have the raw file printing rules enabled?");
 
@@ -8406,9 +8136,9 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
   * Read any embedded job ticket info from PS files...
   */
 
-  if (!strcasecmp(filetype->super, "application") &&
-      (!strcasecmp(filetype->type, "postscript") ||
-       !strcasecmp(filetype->type, "pdf")))
+  if (!_cups_strcasecmp(filetype->super, "application") &&
+      (!_cups_strcasecmp(filetype->type, "postscript") ||
+       !_cups_strcasecmp(filetype->type, "pdf")))
     read_job_ticket(con);
 
  /*
@@ -8460,6 +8190,8 @@ print_job(cupsd_client_t  *con,           /* I - Client connection */
              "File of type %s/%s queued by \"%s\".",
              filetype->super, filetype->type, job->username);
   cupsdLogJob(job, CUPSD_LOG_DEBUG, "hold_until=%d", (int)job->hold_until);
+  cupsdLogJob(job, CUPSD_LOG_INFO, "Queued on \"%s\" by \"%s\".",
+             job->dest, job->username);
 
  /*
   * Start the job if possible...
@@ -8633,14 +8365,14 @@ read_job_ticket(cupsd_client_t *con)    /* I - Client connection */
       if (con->request->last == attr2)
         con->request->last = prev2;
 
-      _ippFreeAttr(attr2);
+      ippDeleteAttribute(NULL, attr2);
     }
 
    /*
     * Add new option by copying it...
     */
 
-    copy_attribute(con->request, attr, 0);
+    ippCopyAttribute(con->request, attr, 0);
   }
 
  /*
@@ -8680,7 +8412,7 @@ reject_jobs(cupsd_client_t  *con, /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -8702,12 +8434,14 @@ reject_jobs(cupsd_client_t  *con,       /* I - Client connection */
 
   if ((attr = ippFindAttribute(con->request, "printer-state-message",
                                IPP_TAG_TEXT)) == NULL)
-    strcpy(printer->state_message, "Rejecting Jobs");
+    strlcpy(printer->state_message, "Rejecting Jobs",
+            sizeof(printer->state_message));
   else
     strlcpy(printer->state_message, attr->values[0].string.text,
             sizeof(printer->state_message));
 
-  cupsdAddPrinterHistory(printer);
+  cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL,
+                "No longer accepting jobs.");
 
   if (dtype & CUPS_PRINTER_CLASS)
   {
@@ -8732,6 +8466,73 @@ reject_jobs(cupsd_client_t  *con,        /* I - Client connection */
 }
 
 
+/*
+ * 'release_held_new_jobs()' - Release pending/new jobs on a printer or class.
+ */
+
+static void
+release_held_new_jobs(
+    cupsd_client_t  *con,              /* I - Connection */
+    ipp_attribute_t *uri)              /* I - Printer URI */
+{
+  http_status_t                status;         /* Policy status */
+  cups_ptype_t         dtype;          /* Destination type (printer/class) */
+  cupsd_printer_t      *printer;       /* Printer data */
+
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "release_held_new_jobs(%p[%d], %s)", con,
+                  con->http.fd, uri->values[0].string.text);
+
+ /*
+  * Is the destination valid?
+  */
+
+  if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+  {
+   /*
+    * Bad URI...
+    */
+
+    send_ipp_status(con, IPP_NOT_FOUND,
+                    _("The printer or class does not exist."));
+    return;
+  }
+
+ /*
+  * Check policy...
+  */
+
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  {
+    send_http_error(con, status, printer);
+    return;
+  }
+
+ /*
+  * Hold pending/new jobs sent to the printer...
+  */
+
+  printer->holding_new_jobs = 0;
+
+  cupsdSetPrinterReasons(printer, "-hold-new-jobs");
+
+  if (dtype & CUPS_PRINTER_CLASS)
+    cupsdLogMessage(CUPSD_LOG_INFO,
+                    "Class \"%s\" now printing pending/new jobs (\"%s\").",
+                    printer->name, get_username(con));
+  else
+    cupsdLogMessage(CUPSD_LOG_INFO,
+                    "Printer \"%s\" now printing pending/new jobs (\"%s\").",
+                    printer->name, get_username(con));
+
+ /*
+  * Everything was ok, so return OK status...
+  */
+
+  con->response->request.status.status_code = IPP_OK;
+}
+
+
 /*
  * 'release_job()' - Release a held print job.
  */
@@ -8742,7 +8543,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
 {
   ipp_attribute_t *attr;               /* Current attribute */
   int          jobid;                  /* Job ID */
-  char         method[HTTP_MAX_URI],   /* Method portion of URI */
+  char         scheme[HTTP_MAX_URI],   /* Method portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
@@ -8767,7 +8568,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -8779,8 +8580,8 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -8789,8 +8590,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -8808,7 +8608,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -8822,7 +8622,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
     * Nope - return a "not possible" error...
     */
 
-    send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not held!"), jobid);
+    send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not held."), jobid);
     return;
   }
 
@@ -8832,7 +8632,8 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
     return;
   }
 
@@ -8853,6 +8654,7 @@ release_job(cupsd_client_t  *con, /* I - Client connection */
 
     cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
                   "Job job-hold-until value changed by user.");
+    ippSetString(job->attrs, &job->reasons, 0, "none");
   }
 
  /*
@@ -8900,8 +8702,8 @@ renew_subscription(
     * Bad subscription ID...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND,
-                    _("notify-subscription-id %d no good!"), sub_id);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Subscription #%d does not exist."),
+                    sub_id);
     return;
   }
 
@@ -8912,7 +8714,7 @@ renew_subscription(
     */
 
     send_ipp_status(con, IPP_NOT_POSSIBLE,
-                    _("Job subscriptions cannot be renewed!"));
+                    _("Job subscriptions cannot be renewed."));
     return;
   }
 
@@ -8967,12 +8769,12 @@ restart_job(cupsd_client_t  *con,       /* I - Client connection */
 {
   ipp_attribute_t *attr;               /* Current attribute */
   int          jobid;                  /* Job ID */
-  char         method[HTTP_MAX_URI],   /* Method portion of URI */
+  cupsd_job_t  *job;                   /* Job information */
+  char         scheme[HTTP_MAX_URI],   /* Method portion of URI */
                username[HTTP_MAX_URI], /* Username portion of URI */
                host[HTTP_MAX_URI],     /* Host portion of URI */
                resource[HTTP_MAX_URI]; /* Resource portion of URI */
   int          port;                   /* Port portion of URI */
-  cupsd_job_t  *job;                   /* Job information */
 
 
   cupsdLogMessage(CUPSD_LOG_DEBUG2, "restart_job(%p[%d], %s)", con,
@@ -8992,7 +8794,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -9004,8 +8806,8 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -9014,8 +8816,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -9033,7 +8834,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -9047,7 +8848,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
     * Nope - return a "not possible" error...
     */
 
-    send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not complete!"),
+    send_ipp_status(con, IPP_NOT_POSSIBLE, _("Job #%d is not complete."),
                     jobid);
     return;
   }
@@ -9065,7 +8866,7 @@ restart_job(cupsd_client_t  *con, /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_POSSIBLE,
-                    _("Job #%d cannot be restarted - no files!"), jobid);
+                    _("Job #%d cannot be restarted - no files."), jobid);
     return;
   }
 
@@ -9075,15 +8876,43 @@ restart_job(cupsd_client_t  *con,       /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
     return;
   }
 
  /*
-  * Restart the job and return...
+  * See if the job-hold-until attribute is specified...
   */
 
-  cupsdRestartJob(job);
+  if ((attr = ippFindAttribute(con->request, "job-hold-until",
+                               IPP_TAG_KEYWORD)) == NULL)
+    attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME);
+
+  if (attr && strcmp(attr->values[0].string.text, "no-hold"))
+  {
+   /*
+    * Return the job to a held state...
+    */
+
+    cupsdLogJob(job, CUPSD_LOG_DEBUG,
+               "Restarted by \"%s\" with job-hold-until=%s.",
+                username, attr->values[0].string.text);
+    cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0);
+
+    cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE,
+                  NULL, job, "Job restarted by user with job-hold-until=%s",
+                 attr->values[0].string.text);
+  }
+  else
+  {
+   /*
+    * Restart the job...
+    */
+
+    cupsdRestartJob(job);
+    cupsdCheckJobs();
+  }
 
   cupsdLogJob(job, CUPSD_LOG_INFO, "Restarted by \"%s\".", username);
 
@@ -9104,7 +8933,7 @@ save_auth_info(
   int                  i;              /* Looping var */
   char                 filename[1024]; /* Job authentication filename */
   cups_file_t          *fp;            /* Job authentication file */
-  char                 line[2048];     /* Line for file */
+  char                 line[65536];    /* Line for file */
   cupsd_printer_t      *dest;          /* Destination printer/class */
 
 
@@ -9153,33 +8982,72 @@ save_auth_info(
   fchown(cupsFileNumber(fp), 0, 0);
   fchmod(cupsFileNumber(fp), 0400);
 
+  cupsFilePuts(fp, "CUPSD-AUTH-V3\n");
+
+  for (i = 0;
+       i < (int)(sizeof(job->auth_env) / sizeof(job->auth_env[0]));
+       i ++)
+    cupsdClearString(job->auth_env + i);
+
   if (auth_info && auth_info->num_values == dest->num_auth_info_required)
   {
    /*
     * Write 1 to 3 auth values...
     */
 
-    cupsdClearString(&job->auth_username);
-    cupsdClearString(&job->auth_domain);
-    cupsdClearString(&job->auth_password);
-
-    for (i = 0; i < auth_info->num_values; i ++)
+    for (i = 0;
+         i < auth_info->num_values &&
+            i < (int)(sizeof(job->auth_env) / sizeof(job->auth_env[0]));
+        i ++)
     {
-      httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text,
-                     strlen(auth_info->values[i].string.text));
-      cupsFilePrintf(fp, "%s\n", line);
+      if (strcmp(dest->auth_info_required[i], "negotiate"))
+      {
+       httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text,
+                      strlen(auth_info->values[i].string.text));
+       cupsFilePutConf(fp, dest->auth_info_required[i], line);
+      }
+      else
+       cupsFilePutConf(fp, dest->auth_info_required[i],
+                       auth_info->values[i].string.text);
 
       if (!strcmp(dest->auth_info_required[i], "username"))
-        cupsdSetStringf(&job->auth_username, "AUTH_USERNAME=%s",
+        cupsdSetStringf(job->auth_env + i, "AUTH_USERNAME=%s",
                        auth_info->values[i].string.text);
       else if (!strcmp(dest->auth_info_required[i], "domain"))
-        cupsdSetStringf(&job->auth_domain, "AUTH_DOMAIN=%s",
+        cupsdSetStringf(job->auth_env + i, "AUTH_DOMAIN=%s",
                        auth_info->values[i].string.text);
       else if (!strcmp(dest->auth_info_required[i], "password"))
-        cupsdSetStringf(&job->auth_password, "AUTH_PASSWORD=%s",
+        cupsdSetStringf(job->auth_env + i, "AUTH_PASSWORD=%s",
                        auth_info->values[i].string.text);
+      else if (!strcmp(dest->auth_info_required[i], "negotiate"))
+        cupsdSetStringf(job->auth_env + i, "AUTH_NEGOTIATE=%s",
+                       auth_info->values[i].string.text);
+      else
+        i --;
     }
   }
+  else if (auth_info && auth_info->num_values == 2 &&
+           dest->num_auth_info_required == 1 &&
+           !strcmp(dest->auth_info_required[0], "negotiate"))
+  {
+   /*
+    * Allow fallback to username+password for Kerberized queues...
+    */
+
+    httpEncode64_2(line, sizeof(line), auth_info->values[0].string.text,
+                   strlen(auth_info->values[0].string.text));
+    cupsFilePutConf(fp, "username", line);
+
+    cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s",
+                    auth_info->values[0].string.text);
+
+    httpEncode64_2(line, sizeof(line), auth_info->values[1].string.text,
+                   strlen(auth_info->values[1].string.text));
+    cupsFilePutConf(fp, "password", line);
+
+    cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s",
+                    auth_info->values[1].string.text);
+  }
   else if (con->username[0])
   {
    /*
@@ -9187,26 +9055,33 @@ save_auth_info(
     */
 
     httpEncode64_2(line, sizeof(line), con->username, strlen(con->username));
-    cupsFilePrintf(fp, "%s\n", line);
+    cupsFilePutConf(fp, "username", line);
 
-    cupsdSetStringf(&job->auth_username, "AUTH_USERNAME=%s", con->username);
-    cupsdClearString(&job->auth_domain);
+    cupsdSetStringf(job->auth_env + 0, "AUTH_USERNAME=%s", con->username);
 
    /*
     * Write the authenticated password...
     */
 
     httpEncode64_2(line, sizeof(line), con->password, strlen(con->password));
-    cupsFilePrintf(fp, "%s\n", line);
+    cupsFilePutConf(fp, "password", line);
+
+    cupsdSetStringf(job->auth_env + 1, "AUTH_PASSWORD=%s", con->password);
+  }
 
-    cupsdSetStringf(&job->auth_password, "AUTH_PASSWORD=%s", con->password);
+#ifdef HAVE_GSSAPI
+  if (con->gss_uid > 0)
+  {
+    cupsFilePrintf(fp, "uid %d\n", (int)con->gss_uid);
+    cupsdSetStringf(&job->auth_uid, "AUTH_UID=%d", (int)con->gss_uid);
   }
+#endif /* HAVE_GSSAPI */
 
  /*
   * Write a random number of newlines to the end of the file...
   */
 
-  for (i = (rand() % 1024); i >= 0; i --)
+  for (i = (CUPS_RAND() % 1024); i >= 0; i --)
     cupsFilePutChar(fp, '\n');
 
  /*
@@ -9214,125 +9089,7 @@ save_auth_info(
   */
 
   cupsFileClose(fp);
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
-  if (con->gss_have_creds)
-    save_krb5_creds(con, job);
-  else if (job->ccname)
-    cupsdClearString(&(job->ccname));
-#endif /* HAVE_GSSAPI && HAVE_KRB5_H */
-}
-
-
-#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
-/*
- * 'save_krb5_creds()' - Save Kerberos credentials for the job.
- */
-
-static void
-save_krb5_creds(cupsd_client_t *con,   /* I - Client connection */
-                cupsd_job_t    *job)   /* I - Job */
-{
-#  if !defined(HAVE_KRB5_CC_NEW_UNIQUE) && !defined(HAVE_HEIMDAL)
-  cupsdLogMessage(CUPSD_LOG_INFO,
-                  "Sorry, your version of Kerberos does not support delegated "
-                 "credentials!");
-  return;
-
-#  else
-  krb5_error_code      error;          /* Kerberos error code */
-  OM_uint32            major_status,   /* Major status code */
-                       minor_status;   /* Minor status code */
-  krb5_principal       principal;      /* Kerberos principal */
-
-
-#   ifdef __APPLE__
- /*
-  * If the weak-linked GSSAPI/Kerberos library is not present, don't try
-  * to use it...
-  */
-
-  if (krb5_init_context == NULL)
-    return;
-#    endif /* __APPLE__ */
-
- /*
-  * We MUST create a file-based cache because memory-based caches are
-  * only valid for the current process/address space.
-  *
-  * Due to various bugs/features in different versions of Kerberos, we
-  * need either the krb5_cc_new_unique() function or Heimdal's version
-  * of krb5_cc_gen_new() to create a new FILE: credential cache that
-  * can be passed to the backend.  These functions create a temporary
-  * file (typically in /tmp) containing the cached credentials, which
-  * are removed when we have successfully printed a job.
-  */
-
-#    ifdef HAVE_KRB5_CC_NEW_UNIQUE
-  if ((error = krb5_cc_new_unique(KerberosContext, "FILE", NULL,
-                                  &(job->ccache))) != 0)
-#    else /* HAVE_HEIMDAL */
-  if ((error = krb5_cc_gen_new(KerberosContext, &krb5_fcc_ops,
-                               &(job->ccache))) != 0)
-#    endif /* HAVE_KRB5_CC_NEW_UNIQUE */
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "Unable to create new credentials cache (%d/%s)",
-                    error, strerror(errno));
-    job->ccache = NULL;
-    return;
-  }
-
-  if ((error = krb5_parse_name(KerberosContext, con->username, &principal)) != 0)
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to parse kerberos username (%d/%s)",
-                    error, strerror(errno));
-    krb5_cc_destroy(KerberosContext, job->ccache);
-    job->ccache = NULL;
-    return;
-  }
-
-  if ((error = krb5_cc_initialize(KerberosContext, job->ccache, principal)))
-  {
-    cupsdLogMessage(CUPSD_LOG_ERROR,
-                    "Unable to initialize credentials cache (%d/%s)", error,
-                   strerror(errno));
-    krb5_cc_destroy(KerberosContext, job->ccache);
-    krb5_free_principal(KerberosContext, principal);
-    job->ccache = NULL;
-    return;
-  }
-
-  krb5_free_principal(KerberosContext, principal);
-
- /*
-  * Copy the user's credentials to the new cache file...
-  */
-
-  major_status = gss_krb5_copy_ccache(&minor_status, con->gss_delegated_cred,
-                                     job->ccache);
-
-  if (GSS_ERROR(major_status))
-  {
-    cupsdLogGSSMessage(CUPSD_LOG_ERROR, major_status, minor_status,
-                       "Unable to import client credentials cache");
-    krb5_cc_destroy(KerberosContext, job->ccache);
-    job->ccache = NULL;
-    return;
-  }
-
- /*
-  * Add the KRB5CCNAME environment variable to the job so that the
-  * backend can use the credentials when printing.
-  */
-
-  cupsdSetStringf(&(job->ccname), "KRB5CCNAME=FILE:%s",
-                  krb5_cc_get_name(KerberosContext, job->ccache));
-
-  cupsdLogJob(job, CUPSD_LOG_DEBUG2, "save_krb5_creds: %s", job->ccname);
-#  endif /* HAVE_KRB5_CC_NEW_UNIQUE || HAVE_HEIMDAL */
 }
-#endif /* HAVE_GSSAPI && HAVE_KRB5_H */
 
 
 /*
@@ -9351,7 +9108,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
   cupsd_job_t          *job;           /* Current job */
   char                 job_uri[HTTP_MAX_URI],
                                        /* Job URI */
-                       method[HTTP_MAX_URI],
+                       scheme[HTTP_MAX_URI],
                                        /* Method portion of URI */
                        username[HTTP_MAX_URI],
                                        /* Username portion of URI */
@@ -9392,7 +9149,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -9404,8 +9161,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -9414,8 +9171,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -9433,7 +9189,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -9445,7 +9201,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
     return;
   }
 
@@ -9465,7 +9222,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 #endif /* HAVE_LIBZ */
       )
     {
-      send_ipp_status(con, IPP_ATTRIBUTES, _("Unsupported compression \"%s\"!"),
+      send_ipp_status(con, IPP_ATTRIBUTES, _("Unsupported compression \"%s\"."),
                      attr->values[0].string.text);
       ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
                   "compression", NULL, attr->values[0].string.text);
@@ -9482,9 +9239,25 @@ send_document(cupsd_client_t  *con,      /* I - Client connection */
   * Do we have a file to print?
   */
 
+  if ((attr = ippFindAttribute(con->request, "last-document",
+                              IPP_TAG_BOOLEAN)) == NULL)
+  {
+    send_ipp_status(con, IPP_BAD_REQUEST,
+                    _("Missing last-document attribute in request."));
+    return;
+  }
+
   if (!con->filename)
   {
-    send_ipp_status(con, IPP_BAD_REQUEST, _("No file!?!"));
+   /*
+    * Check for an empty request with "last-document" set to true, which is
+    * used to close an "open" job by RFC 2911, section 3.3.2.
+    */
+
+    if (job->num_files > 0 && attr->values[0].boolean)
+      goto last_document;
+
+    send_ipp_status(con, IPP_BAD_REQUEST, _("No file in print request."));
     return;
   }
 
@@ -9499,10 +9272,10 @@ send_document(cupsd_client_t  *con,     /* I - Client connection */
     * Grab format from client...
     */
 
-    if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]",
+    if (sscanf(format->values[0].string.text, "%15[^/]/%255[^;]",
                super, type) != 2)
     {
-      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad document-format \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad document-format \"%s\"."),
                      format->values[0].string.text);
       return;
     }
@@ -9515,11 +9288,10 @@ send_document(cupsd_client_t  *con,     /* I - Client connection */
     * Use default document format...
     */
 
-    if (sscanf(default_format, "%15[^/]/%31[^;]", super, type) != 2)
+    if (sscanf(default_format, "%15[^/]/%255[^;]", super, type) != 2)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Could not scan type \"%s\"!"),
-                     default_format);
+                      _("Bad document-format-default \"%s\"."), default_format);
       return;
     }
   }
@@ -9529,8 +9301,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     * No document format attribute?  Auto-type it!
     */
 
-    strcpy(super, "application");
-    strcpy(type, "octet-stream");
+    strlcpy(super, "application", sizeof(super));
+    strlcpy(type, "octet-stream", sizeof(type));
   }
 
   if (!strcmp(super, "application") && !strcmp(type, "octet-stream"))
@@ -9552,17 +9324,14 @@ send_document(cupsd_client_t  *con,     /* I - Client connection */
     if (!filetype)
       filetype = mimeType(MimeDatabase, super, type);
 
-    cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
-               filetype->super, filetype->type);
+    if (filetype)
+      cupsdLogJob(job, CUPSD_LOG_DEBUG, "Request file type is %s/%s.",
+                 filetype->super, filetype->type);
   }
   else
     filetype = mimeType(MimeDatabase, super, type);
 
-  jformat = ippFindAttribute(job->attrs, "document-format", IPP_TAG_MIMETYPE);
-
-  if (filetype &&
-      (!jformat ||
-       (!strcmp(super, "application") && !strcmp(type, "octet-stream"))))
+  if (filetype)
   {
    /*
     * Replace the document-format attribute value with the auto-typed or
@@ -9572,7 +9341,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
              filetype->type);
 
-    if (jformat)
+    if ((jformat = ippFindAttribute(job->attrs, "document-format",
+                                    IPP_TAG_MIMETYPE)) != NULL)
     {
       _cupsStrFree(jformat->values[0].string.text);
 
@@ -9585,7 +9355,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
   else if (!filetype)
   {
     send_ipp_status(con, IPP_DOCUMENT_FORMAT,
-                    _("Unsupported format \'%s/%s\'!"), super, type);
+                    _("Unsupported document-format \"%s/%s\"."), super, type);
     cupsdLogMessage(CUPSD_LOG_INFO,
                     "Hint: Do you have the raw file printing rules enabled?");
 
@@ -9602,7 +9372,7 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
              filetype->type);
 
     send_ipp_status(con, IPP_DOCUMENT_FORMAT,
-                    _("Unsupported format \'%s\'!"), mimetype);
+                    _("Unsupported document-format \"%s\"."), mimetype);
 
     ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
                  "document-format", NULL, mimetype);
@@ -9643,6 +9413,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
   * Start the job if this is the last document...
   */
 
+  last_document:
+
   if ((attr = ippFindAttribute(con->request, "last-document",
                                IPP_TAG_BOOLEAN)) != NULL &&
       attr->values[0].boolean)
@@ -9658,6 +9430,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
     {
       job->state->values[0].integer = IPP_JOB_PENDING;
       job->state_value              = IPP_JOB_PENDING;
+
+      ippSetString(job->attrs, &job->reasons, 0, "none");
     }
     else if (job->state_value == IPP_JOB_HELD)
     {
@@ -9669,7 +9443,11 @@ send_document(cupsd_client_t  *con,      /* I - Client connection */
       {
        job->state->values[0].integer = IPP_JOB_PENDING;
        job->state_value              = IPP_JOB_PENDING;
+
+       ippSetString(job->attrs, &job->reasons, 0, "none");
       }
+      else
+       ippSetString(job->attrs, &job->reasons, 0, "job-hold-until-specified");
     }
 
     job->dirty = 1;
@@ -9687,9 +9465,11 @@ send_document(cupsd_client_t  *con,      /* I - Client connection */
     {
       job->state->values[0].integer = IPP_JOB_HELD;
       job->state_value              = IPP_JOB_HELD;
-      job->hold_until               = time(NULL) + 60;
-      job->dirty                    = 1;
+      job->hold_until               = time(NULL) + MultipleOperationTimeout;
 
+      ippSetString(job->attrs, &job->reasons, 0, "job-incoming");
+
+      job->dirty = 1;
       cupsdMarkDirty(CUPSD_DIRTY_JOBS);
     }
 
@@ -9700,9 +9480,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
   * Fill in the response info...
   */
 
-  snprintf(job_uri, sizeof(job_uri), "http://%s:%d/jobs/%d", ServerName,
-          LocalPort, jobid);
-
+  httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+                   con->clientname, con->clientport, "/jobs/%d", jobid);
   ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_URI, "job-uri", NULL,
                job_uri);
 
@@ -9710,7 +9489,8 @@ send_document(cupsd_client_t  *con,       /* I - Client connection */
 
   ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state",
                 job->state_value);
-  add_job_state_reasons(con, job);
+  ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons",
+               NULL, job->reasons->values[0].string.text);
 
   con->response->request.status.status_code = IPP_OK;
 
@@ -9741,9 +9521,11 @@ send_http_error(
     uri = ippFindAttribute(con->request, "job-uri", IPP_TAG_URI);
 
   cupsdLogMessage(status == HTTP_FORBIDDEN ? CUPSD_LOG_ERROR : CUPSD_LOG_DEBUG,
-                  "Returning HTTP %s for %s (%s) from %s",
-                  httpStatus(status),
-                 ippOpString(con->request->request.op.operation_id),
+                  "[Client %d] Returning HTTP %s for %s (%s) from %s",
+                  con->http.fd, httpStatus(status),
+                 con->request ?
+                     ippOpString(con->request->request.op.operation_id) :
+                     "no operation-id",
                  uri ? uri->values[0].string.text : "no URI",
                  con->http.hostname);
 
@@ -9793,7 +9575,7 @@ send_http_error(
       if (auth)
       {
         if (auth->type == CUPSD_AUTH_DEFAULT)
-         auth_type = DefaultAuthType;
+         auth_type = cupsdDefaultAuthType();
        else
          auth_type = auth->type;
       }
@@ -9839,7 +9621,7 @@ send_ipp_status(cupsd_client_t *con,      /* I - Client connection */
   if (ippFindAttribute(con->response, "attributes-charset",
                        IPP_TAG_ZERO) == NULL)
     ippAddString(con->response, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
-                 "attributes-charset", NULL, DefaultCharset);
+                 "attributes-charset", NULL, "utf-8");
 
   if (ippFindAttribute(con->response, "attributes-natural-language",
                        IPP_TAG_ZERO) == NULL)
@@ -9879,7 +9661,7 @@ set_default(cupsd_client_t  *con, /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -9908,7 +9690,7 @@ set_default(cupsd_client_t  *con, /* I - Client connection */
                "%s is now the default printer.", printer->name);
 
   cupsdMarkDirty(CUPSD_DIRTY_PRINTERS | CUPSD_DIRTY_CLASSES |
-                 CUPSD_DIRTY_REMOTE | CUPSD_DIRTY_PRINTCAP);
+                 CUPSD_DIRTY_PRINTCAP);
 
   cupsdLogMessage(CUPSD_LOG_INFO,
                   "Default destination set to \"%s\" by \"%s\".",
@@ -9934,7 +9716,7 @@ set_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
                        *attr2;         /* Job attribute */
   int                  jobid;          /* Job ID */
   cupsd_job_t          *job;           /* Current job */
-  char                 method[HTTP_MAX_URI],
+  char                 scheme[HTTP_MAX_URI],
                                        /* Method portion of URI */
                        username[HTTP_MAX_URI],
                                        /* Username portion of URI */
@@ -9970,7 +9752,7 @@ set_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
                                  IPP_TAG_INTEGER)) == NULL)
     {
       send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Got a printer-uri attribute but no job-id!"));
+                      _("Got a printer-uri attribute but no job-id."));
       return;
     }
 
@@ -9982,8 +9764,8 @@ set_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
     * Got a job URI; parse it to get the job ID...
     */
 
-    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
-                    sizeof(method), username, sizeof(username), host,
+    httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+                    sizeof(scheme), username, sizeof(username), host,
                    sizeof(host), &port, resource, sizeof(resource));
 
     if (strncmp(resource, "/jobs/", 6))
@@ -9992,8 +9774,7 @@ set_job_attrs(cupsd_client_t  *con,       /* I - Client connection */
       * Not a valid URI!
       */
 
-      send_ipp_status(con, IPP_BAD_REQUEST,
-                      _("Bad job-uri attribute \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad job-uri \"%s\"."),
                       uri->values[0].string.text);
       return;
     }
@@ -10011,7 +9792,7 @@ set_job_attrs(cupsd_client_t  *con,      /* I - Client connection */
     * Nope - return a "not found" error...
     */
 
-    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist!"), jobid);
+    send_ipp_status(con, IPP_NOT_FOUND, _("Job #%d does not exist."), jobid);
     return;
   }
 
@@ -10026,7 +9807,7 @@ set_job_attrs(cupsd_client_t  *con,      /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_POSSIBLE,
-                    _("Job #%d is finished and cannot be altered!"), jobid);
+                    _("Job #%d is finished and cannot be altered."), jobid);
     return;
   }
 
@@ -10036,7 +9817,8 @@ set_job_attrs(cupsd_client_t  *con,      /* I - Client connection */
 
   if (!validate_user(job, con, job->username, username, sizeof(username)))
   {
-    send_http_error(con, HTTP_UNAUTHORIZED, cupsdFindDest(job->dest));
+    send_http_error(con, con->username[0] ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED,
+                    cupsdFindDest(job->dest));
     return;
   }
 
@@ -10086,9 +9868,8 @@ set_job_attrs(cupsd_client_t  *con,      /* I - Client connection */
       send_ipp_status(con, IPP_ATTRIBUTES_NOT_SETTABLE,
                       _("%s cannot be changed."), attr->name);
 
-      if ((attr2 = copy_attribute(con->response, attr, 0)) != NULL)
-        attr2->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
-
+      attr2 = ippCopyAttribute(con->response, attr, 0);
+      ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
       continue;
     }
 
@@ -10100,10 +9881,10 @@ set_job_attrs(cupsd_client_t  *con,    /* I - Client connection */
 
       if (attr->value_tag != IPP_TAG_INTEGER)
       {
-       send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-priority value!"));
+       send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-priority value."));
 
-       if ((attr2 = copy_attribute(con->response, attr, 0)) != NULL)
-          attr2->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+       attr2 = ippCopyAttribute(con->response, attr, 0);
+       ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
       }
       else if (job->state_value >= IPP_JOB_PROCESSING)
       {
@@ -10130,10 +9911,10 @@ set_job_attrs(cupsd_client_t  *con,    /* I - Client connection */
 
       if (attr->value_tag != IPP_TAG_ENUM)
       {
-       send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-state value!"));
+       send_ipp_status(con, IPP_REQUEST_VALUE, _("Bad job-state value."));
 
-       if ((attr2 = copy_attribute(con->response, attr, 0)) != NULL)
-          attr2->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+       attr2 = ippCopyAttribute(con->response, attr, 0);
+       ippSetGroupTag(con->response, &attr2, IPP_TAG_UNSUPPORTED_GROUP);
       }
       else
       {
@@ -10151,11 +9932,9 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
              {
                cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d",
                            attr->values[0].integer);
-
-               job->state->values[0].integer = attr->values[0].integer;
-               job->state_value = (ipp_jstate_t)attr->values[0].integer;
-
-                event |= CUPSD_EVENT_JOB_STATE;
+                cupsdSetJobState(job, attr->values[0].integer,
+                                CUPSD_JOB_DEFAULT,
+                                "Job state changed by \"%s\"", username);
                check_jobs = 1;
              }
              break;
@@ -10183,8 +9962,9 @@ set_job_attrs(cupsd_client_t  *con,      /* I - Client connection */
              {
                cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-state to %d",
                            attr->values[0].integer);
-                cupsdCancelJob(job, 0, (ipp_jstate_t)attr->values[0].integer);
-
+                cupsdSetJobState(job, (ipp_jstate_t)attr->values[0].integer,
+                                CUPSD_JOB_DEFAULT,
+                                "Job state changed by \"%s\"", username);
                 check_jobs = 1;
              }
              break;
@@ -10208,13 +9988,13 @@ set_job_attrs(cupsd_client_t  *con,    /* I - Client connection */
       if (job->attrs->last == attr2)
         job->attrs->last = job->attrs->prev;
 
-      _ippFreeAttr(attr2);
+      ippDeleteAttribute(NULL, attr2);
 
      /*
       * Then copy the attribute...
       */
 
-      copy_attribute(job->attrs, attr, 0);
+      ippCopyAttribute(job->attrs, attr, 0);
 
      /*
       * See if the job-name or job-hold-until is being changed.
@@ -10224,15 +10004,18 @@ set_job_attrs(cupsd_client_t  *con,   /* I - Client connection */
       {
         cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-hold-until to %s",
                    attr->values[0].string.text);
-        cupsdSetJobHoldUntil(job, attr->values[0].string.text);
+        cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0);
 
        if (!strcmp(attr->values[0].string.text, "no-hold"))
+       {
          cupsdReleaseJob(job);
+          check_jobs = 1;
+       }
        else
-         cupsdHoldJob(job);
+         cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT,
+                          "Job held by \"%s\".", username);
 
-        check_jobs = 1;
-        event      |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE;
+        event |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE;
       }
     }
     else if (attr->value_tag == IPP_TAG_DELETEATTR)
@@ -10252,7 +10035,7 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
         if (attr2 == job->attrs->last)
          job->attrs->last = job->attrs->prev;
 
-        _ippFreeAttr(attr2);
+        ippDeleteAttribute(NULL, attr2);
 
         event |= CUPSD_EVENT_JOB_CONFIG_CHANGED;
       }
@@ -10263,7 +10046,7 @@ set_job_attrs(cupsd_client_t  *con,     /* I - Client connection */
       * Add new option by copying it...
       */
 
-      copy_attribute(job->attrs, attr, 0);
+      ippCopyAttribute(job->attrs, attr, 0);
 
       event |= CUPSD_EVENT_JOB_CONFIG_CHANGED;
     }
@@ -10303,6 +10086,89 @@ set_job_attrs(cupsd_client_t  *con,    /* I - Client connection */
 }
 
 
+/*
+ * 'set_printer_attrs()' - Set printer attributes.
+ */
+
+static void
+set_printer_attrs(cupsd_client_t  *con,        /* I - Client connection */
+                  ipp_attribute_t *uri)        /* I - Printer */
+{
+  http_status_t                status;         /* Policy status */
+  cups_ptype_t         dtype;          /* Destination type (printer/class) */
+  cupsd_printer_t      *printer;       /* Printer/class */
+  ipp_attribute_t      *attr;          /* Printer attribute */
+  int                  changed = 0;    /* Was anything changed? */
+
+
+  cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_printer_attrs(%p[%d], %s)", con,
+                  con->http.fd, uri->values[0].string.text);
+
+ /*
+  * Is the destination valid?
+  */
+
+  if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
+  {
+   /*
+    * Bad URI...
+    */
+
+    send_ipp_status(con, IPP_NOT_FOUND,
+                    _("The printer or class does not exist."));
+    return;
+  }
+
+ /*
+  * Check policy...
+  */
+
+  if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+  {
+    send_http_error(con, status, printer);
+    return;
+  }
+
+ /*
+  * Return a list of attributes that can be set via Set-Printer-Attributes.
+  */
+
+  if ((attr = ippFindAttribute(con->request, "printer-location",
+                               IPP_TAG_TEXT)) != NULL)
+  {
+    cupsdSetString(&printer->location, attr->values[0].string.text);
+    changed = 1;
+  }
+
+  if ((attr = ippFindAttribute(con->request, "printer-info",
+                               IPP_TAG_TEXT)) != NULL)
+  {
+    cupsdSetString(&printer->info, attr->values[0].string.text);
+    changed = 1;
+  }
+
+ /*
+  * Update the printer attributes and return...
+  */
+
+  if (changed)
+  {
+    cupsdSetPrinterAttrs(printer);
+    cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
+
+    cupsdAddEvent(CUPSD_EVENT_PRINTER_CONFIG, printer, NULL,
+                  "Printer \"%s\" description or location changed by \"%s\".",
+                 printer->name, get_username(con));
+
+    cupsdLogMessage(CUPSD_LOG_INFO,
+                    "Printer \"%s\" description or location changed by \"%s\".",
+                    printer->name, get_username(con));
+  }
+
+  con->response->request.status.status_code = IPP_OK;
+}
+
+
 /*
  * 'set_printer_defaults()' - Set printer default options from a request.
  */
@@ -10356,7 +10222,7 @@ set_printer_defaults(
     }
     else if (!strcmp(attr->name, "requesting-user-name-allowed"))
     {
-      cupsdFreePrinterUsers(printer);
+      cupsdFreeStrings(&(printer->users));
 
       printer->deny_users = 0;
 
@@ -10365,12 +10231,12 @@ set_printer_defaults(
           strcmp(attr->values[0].string.text, "all")))
       {
        for (i = 0; i < attr->num_values; i ++)
-         cupsdAddPrinterUser(printer, attr->values[i].string.text);
+         cupsdAddString(&(printer->users), attr->values[i].string.text);
       }
     }
     else if (!strcmp(attr->name, "requesting-user-name-denied"))
     {
-      cupsdFreePrinterUsers(printer);
+      cupsdFreeStrings(&(printer->users));
 
       printer->deny_users = 1;
 
@@ -10379,7 +10245,7 @@ set_printer_defaults(
           strcmp(attr->values[0].string.text, "none")))
       {
        for (i = 0; i < attr->num_values; i ++)
-         cupsdAddPrinterUser(printer, attr->values[i].string.text);
+         cupsdAddString(&(printer->users), attr->values[i].string.text);
       }
     }
     else if (!strcmp(attr->name, "job-quota-period"))
@@ -10444,10 +10310,11 @@ set_printer_defaults(
       if (attr->value_tag != IPP_TAG_NAME && attr->value_tag != IPP_TAG_KEYWORD)
         continue;
 
-      if (strcmp(attr->values[0].string.text, "abort-job") &&
-          strcmp(attr->values[0].string.text, "retry-current-job") &&
-          strcmp(attr->values[0].string.text, "retry-job") &&
-          strcmp(attr->values[0].string.text, "stop-printer"))
+      if (strcmp(attr->values[0].string.text, "retry-current-job") &&
+          ((printer->type & CUPS_PRINTER_CLASS) ||
+          (strcmp(attr->values[0].string.text, "abort-job") &&
+           strcmp(attr->values[0].string.text, "retry-job") &&
+           strcmp(attr->values[0].string.text, "stop-printer"))))
       {
        send_ipp_status(con, IPP_NOT_POSSIBLE,
                        _("Unknown printer-error-policy \"%s\"."),
@@ -10488,6 +10355,7 @@ set_printer_defaults(
           break;
 
       case IPP_TAG_NAME :
+      case IPP_TAG_TEXT :
       case IPP_TAG_KEYWORD :
       case IPP_TAG_URI :
           printer->num_options = cupsAddOption(name,
@@ -10534,7 +10402,7 @@ set_printer_defaults(
           sprintf(value, "%dx%d%s", attr->values[0].resolution.xres,
                  attr->values[0].resolution.yres,
                  attr->values[0].resolution.units == IPP_RES_PER_INCH ?
-                     "dpi" : "dpc");
+                     "dpi" : "dpcm");
           printer->num_options = cupsAddOption(name, value,
                                               printer->num_options,
                                               &(printer->options));
@@ -10558,6 +10426,7 @@ static void
 start_printer(cupsd_client_t  *con,    /* I - Client connection */
               ipp_attribute_t *uri)    /* I - Printer URI */
 {
+  int                  i;              /* Temporary variable */
   http_status_t                status;         /* Policy status */
   cups_ptype_t         dtype;          /* Destination type (printer/class) */
   cupsd_printer_t      *printer;       /* Printer data */
@@ -10577,7 +10446,7 @@ start_printer(cupsd_client_t  *con,     /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -10608,6 +10477,21 @@ start_printer(cupsd_client_t  *con,    /* I - Client connection */
 
   cupsdCheckJobs();
 
+ /*
+  * Check quotas...
+  */
+
+  if ((i = check_quotas(con, printer)) < 0)
+  {
+    send_ipp_status(con, IPP_NOT_POSSIBLE, _("Quota limit reached."));
+    return;
+  }
+  else if (i == 0)
+  {
+    send_ipp_status(con, IPP_NOT_AUTHORIZED, _("Not allowed to print."));
+    return;
+  }
+
  /*
   * Everything was ok, so return OK status...
   */
@@ -10644,7 +10528,7 @@ stop_printer(cupsd_client_t  *con,      /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -10664,7 +10548,7 @@ stop_printer(cupsd_client_t  *con,      /* I - Client connection */
 
   if ((attr = ippFindAttribute(con->request, "printer-state-message",
                                IPP_TAG_TEXT)) == NULL)
-    strcpy(printer->state_message, "Paused");
+    strlcpy(printer->state_message, "Paused", sizeof(printer->state_message));
   else
   {
     strlcpy(printer->state_message, attr->values[0].string.text,
@@ -10754,7 +10638,7 @@ url_encode_string(const char *s,        /* I - String */
 
   while (*s && bufptr < bufend)
   {
-    if (*s == ' ' || *s == '%')
+    if (*s == ' ' || *s == '%' || *s == '+')
     {
       if (bufptr >= (bufend - 2))
        break;
@@ -10791,13 +10675,13 @@ static int                            /* O - 0 if not allowed, 1 if allowed */
 user_allowed(cupsd_printer_t *p,       /* I - Printer or class */
              const char      *username)        /* I - Username */
 {
-  int          i;                      /* Looping var */
   struct passwd        *pw;                    /* User password data */
   char         baseuser[256],          /* Base username */
-               *baseptr;               /* Pointer to "@" in base username */
+               *baseptr,               /* Pointer to "@" in base username */
+               *name;                  /* Current user name */
 
 
-  if (p->num_users == 0)
+  if (cupsArrayCount(p->users) == 0)
     return (1);
 
   if (!strcmp(username, "root"))
@@ -10820,31 +10704,33 @@ user_allowed(cupsd_printer_t *p,      /* I - Printer or class */
   pw = getpwnam(username);
   endpwent();
 
-  for (i = 0; i < p->num_users; i ++)
+  for (name = (char *)cupsArrayFirst(p->users);
+       name;
+       name = (char *)cupsArrayNext(p->users))
   {
-    if (p->users[i][0] == '@')
+    if (name[0] == '@')
     {
      /*
       * Check group membership...
       */
 
-      if (cupsdCheckGroup(username, pw, p->users[i] + 1))
+      if (cupsdCheckGroup(username, pw, name + 1))
         break;
     }
-    else if (p->users[i][0] == '#')
+    else if (name[0] == '#')
     {
      /*
       * Check UUID...
       */
 
-      if (cupsdCheckGroup(username, pw, p->users[i]))
+      if (cupsdCheckGroup(username, pw, name))
         break;
     }
-    else if (!strcasecmp(username, p->users[i]))
+    else if (!_cups_strcasecmp(username, name))
       break;
   }
 
-  return ((i < p->num_users) != p->deny_users);
+  return ((name != NULL) != p->deny_users);
 }
 
 
@@ -10857,8 +10743,10 @@ validate_job(cupsd_client_t  *con,     /* I - Client connection */
             ipp_attribute_t *uri)      /* I - Printer URI */
 {
   http_status_t                status;         /* Policy status */
-  ipp_attribute_t      *attr;          /* Current attribute */
-  ipp_attribute_t      *format;        /* Document-format attribute */
+  ipp_attribute_t      *attr,          /* Current attribute */
+                       *auth_info;     /* auth-info attribute */
+  ipp_attribute_t      *format,        /* Document-format attribute */
+                       *name;          /* Job-name attribute */
   cups_ptype_t         dtype;          /* Destination type (printer/class) */
   char                 super[MIME_MAX_SUPER],
                                        /* Supertype of file */
@@ -10876,15 +10764,21 @@ validate_job(cupsd_client_t  *con,    /* I - Client connection */
   */
 
   if ((attr = ippFindAttribute(con->request, "compression",
-                               IPP_TAG_KEYWORD)) != NULL &&
-      !strcmp(attr->values[0].string.text, "none"))
+                               IPP_TAG_KEYWORD)) != NULL)
   {
-    send_ipp_status(con, IPP_ATTRIBUTES,
-                    _("Unsupported compression attribute %s!"),
-                    attr->values[0].string.text);
-    ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
-                "compression", NULL, attr->values[0].string.text);
-    return;
+    if (strcmp(attr->values[0].string.text, "none")
+#ifdef HAVE_LIBZ
+        && strcmp(attr->values[0].string.text, "gzip")
+#endif /* HAVE_LIBZ */
+      )
+    {
+      send_ipp_status(con, IPP_ATTRIBUTES,
+                      _("Unsupported 'compression' value \"%s\"."),
+                     attr->values[0].string.text);
+      ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_KEYWORD,
+                  "compression", NULL, attr->values[0].string.text);
+      return;
+    }
   }
 
  /*
@@ -10894,10 +10788,11 @@ validate_job(cupsd_client_t  *con,    /* I - Client connection */
   if ((format = ippFindAttribute(con->request, "document-format",
                                  IPP_TAG_MIMETYPE)) != NULL)
   {
-    if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]",
+    if (sscanf(format->values[0].string.text, "%15[^/]/%255[^;]",
                super, type) != 2)
     {
-      send_ipp_status(con, IPP_BAD_REQUEST, _("Bad document-format \"%s\"!"),
+      send_ipp_status(con, IPP_BAD_REQUEST,
+                      _("Bad 'document-format' value \"%s\"."),
                      format->values[0].string.text);
       return;
     }
@@ -10908,7 +10803,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
       cupsdLogMessage(CUPSD_LOG_INFO,
                       "Hint: Do you have the raw file printing rules enabled?");
       send_ipp_status(con, IPP_DOCUMENT_FORMAT,
-                      _("Unsupported format \"%s\"!"),
+                      _("Unsupported 'document-format' value \"%s\"."),
                      format->values[0].string.text);
       ippAddString(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_MIMETYPE,
                    "document-format", NULL, format->values[0].string.text);
@@ -10916,6 +10811,86 @@ validate_job(cupsd_client_t  *con,     /* I - Client connection */
     }
   }
 
+ /*
+  * Is the job-name valid?
+  */
+
+  if ((name = ippFindAttribute(con->request, "job-name", IPP_TAG_ZERO)) != NULL)
+  {
+    int bad_name = 0;                  /* Is the job-name value bad? */
+
+    if ((name->value_tag != IPP_TAG_NAME && name->value_tag != IPP_TAG_NAMELANG) ||
+        name->num_values != 1)
+    {
+      bad_name = 1;
+    }
+    else
+    {
+     /*
+      * Validate that job-name conforms to RFC 5198 (Network Unicode) and
+      * IPP Everywhere requirements for "name" values...
+      */
+
+      const unsigned char *nameptr;    /* Pointer into "job-name" attribute */
+
+      for (nameptr = (unsigned char *)name->values[0].string.text;
+           *nameptr;
+           nameptr ++)
+      {
+        if (*nameptr < ' ' && *nameptr != '\t')
+          break;
+        else if (*nameptr == 0x7f)
+          break;
+        else if ((*nameptr & 0xe0) == 0xc0)
+        {
+          if ((nameptr[1] & 0xc0) != 0x80)
+            break;
+
+          nameptr ++;
+        }
+        else if ((*nameptr & 0xf0) == 0xe0)
+        {
+          if ((nameptr[1] & 0xc0) != 0x80 ||
+              (nameptr[2] & 0xc0) != 0x80)
+           break;
+
+         nameptr += 2;
+       }
+        else if ((*nameptr & 0xf8) == 0xf0)
+        {
+          if ((nameptr[1] & 0xc0) != 0x80 ||
+             (nameptr[2] & 0xc0) != 0x80 ||
+             (nameptr[3] & 0xc0) != 0x80)
+           break;
+
+         nameptr += 3;
+       }
+        else if (*nameptr & 0x80)
+          break;
+      }
+
+      if (*nameptr)
+        bad_name = 1;
+    }
+
+    if (bad_name)
+    {
+      if (StrictConformance)
+      {
+       send_ipp_status(con, IPP_ATTRIBUTES,
+                       _("Unsupported 'job-name' value."));
+       ippCopyAttribute(con->response, name, 0);
+       return;
+      }
+      else
+      {
+        cupsdLogMessage(CUPSD_LOG_WARN,
+                        "Unsupported 'job-name' value, deleting from request.");
+        ippDeleteAttribute(con->request, name);
+      }
+    }
+  }
+
  /*
   * Is the destination valid?
   */
@@ -10927,7 +10902,7 @@ validate_job(cupsd_client_t  *con,      /* I - Client connection */
     */
 
     send_ipp_status(con, IPP_NOT_FOUND,
-                    _("The printer or class was not found."));
+                    _("The printer or class does not exist."));
     return;
   }
 
@@ -10935,11 +10910,32 @@ validate_job(cupsd_client_t  *con,    /* I - Client connection */
   * Check policy...
   */
 
+  auth_info = ippFindAttribute(con->request, "auth-info", IPP_TAG_TEXT);
+
   if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
   {
     send_http_error(con, status, printer);
     return;
   }
+  else if (printer->num_auth_info_required == 1 &&
+           !strcmp(printer->auth_info_required[0], "negotiate") &&
+           !con->username[0])
+  {
+    send_http_error(con, HTTP_UNAUTHORIZED, printer);
+    return;
+  }
+#ifdef HAVE_SSL
+  else if (auth_info && !con->http.tls &&
+           !httpAddrLocalhost(con->http.hostaddr))
+  {
+   /*
+    * Require encryption of auth-info over non-local connections...
+    */
+
+    send_http_error(con, HTTP_UPGRADE_REQUIRED, printer);
+    return;
+  }
+#endif /* HAVE_SSL */
 
  /*
   * Everything was ok, so return OK status...
@@ -11020,5 +11016,5 @@ validate_user(cupsd_job_t    *job,      /* I - Job */
 
 
 /*
- * End of "$Id: ipp.c 7682 2008-06-21 00:06:02Z mike $".
+ * End of "$Id: ipp.c 11500 2014-01-06 22:21:15Z msweet $".
  */