]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add new StrictConformance directive, fix more usage of Create-Job and add checks.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 18 May 2012 19:51:02 +0000 (19:51 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 18 May 2012 19:51:02 +0000 (19:51 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10482 7a7537e8-13f0-0310-91df-b6672ffda945

backend/ipp.c
cups/util.c
doc/help/ref-cupsd-conf.html.in
man/cupsd.conf.man.in
scheduler/conf.c
scheduler/conf.h
scheduler/ipp.c
test/run-stp-tests.sh

index 40c844fcdcd077dcf2ff6a9e9c0482260812ffb6..267228c68452fc932df62efe7d0d47f78d4d0f5a 100644 (file)
@@ -2569,7 +2569,7 @@ new_request(
       * When talking to another CUPS server, send all options...
       */
 
-      cupsEncodeOptions(request, num_options, options);
+      cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);
     }
 
     if (copies > 1 && (!pc || copies <= pc->max_copies))
index 9e98ff5a336d35ff81dd2469ad8c2cc14b74939f..5aa2720e589ea1f2c08cd3d5859360e6d7de8145 100644 (file)
@@ -248,7 +248,8 @@ cupsCreateJob(
   if (title)
     ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
                  title);
-  cupsEncodeOptions(request, num_options, options);
+  cupsEncodeOptions2(request, num_options, options, IPP_TAG_JOB);
+  cupsEncodeOptions2(request, num_options, options, IPP_TAG_SUBSCRIPTION);
 
  /*
   * Send the request and get the job-id...
index ef697d5d157f8f6b621a1223c26ac432972f8ec4..8454cf78d53a8b302762e5eea0bc6cf9d719f52b 100644 (file)
@@ -2585,6 +2585,23 @@ on for secure connections. Multiple <CODE>SSLPort</CODE> lines
 can be specified to listen on multiple ports.</P>
 
 
+<H2 CLASS="title"><SPAN CLASS="info">CUPS 1.6</SPAN><A NAME="StrictConformance">StrictConformance</A></H2>
+
+<H3>Examples</H3>
+
+<PRE CLASS="command">
+StrictConformance No
+StrictConformance Yes
+</PRE>
+
+<H3>Description</H3>
+
+<P>The <CODE>StrictConformance</CODE> directive specifies whether the scheduler
+requires strict IPP conformance for client requests, for example to not allow
+document attributes in a Create-Job request. The default is
+<code>No</code>.</P>
+
+
 <H2 CLASS="title"><SPAN CLASS="info">CUPS 1.5</SPAN><A NAME="SubscriptionPrivateAccess">SubscriptionPrivateAccess</A></H2>
 
 <H3>Examples</H3>
index 367af5544b8309a16682cde5f12f8e2f73b36d1a..f9303a78e118e8faa26c96605d4af4b1dd1f13c3 100644 (file)
@@ -12,7 +12,7 @@
 .\"   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/".
 .\"
-.TH cupsd.conf 5 "CUPS" "15 February 2012" "Apple Inc."
+.TH cupsd.conf 5 "CUPS" "18 May 2012" "Apple Inc."
 .SH NAME
 cupsd.conf \- server configuration file for cups
 .SH DESCRIPTION
@@ -591,6 +591,13 @@ SSLPort
 .br
 Listens on the specified port for encrypted connections.
 .TP 5
+StrictConformance Yes
+.TP 5
+StrictConformance No
+.br
+Specifies whether the scheduler requires clients to strictly adhere to the IPP
+specifications. The default is No.
+.TP 5
 SubscriptionPrivateAccess all
 .TP 5
 SubscriptionPrivateAccess default
index 98d135b956ea91074d6cfe95a7903d75fa658214..ad5cf12d3ec2cf2cc6a4ae888de2327827ad503a 100644 (file)
@@ -169,6 +169,7 @@ static const cupsd_var_t    variables[] =
   { "ServerRoot",              &ServerRoot,            CUPSD_VARTYPE_PATHNAME },
   { "SMBConfigFile",           &SMBConfigFile,         CUPSD_VARTYPE_STRING },
   { "StateDir",                        &StateDir,              CUPSD_VARTYPE_STRING },
+  { "StrictConformance",       &StrictConformance,     CUPSD_VARTYPE_BOOLEAN },
 #ifdef HAVE_AUTHORIZATION_H
   { "SystemGroupAuthKey",      &SystemGroupAuthKey,    CUPSD_VARTYPE_STRING },
 #endif /* HAVE_AUTHORIZATION_H */
@@ -722,10 +723,11 @@ cupsdReadConfiguration(void)
   MaxLogSize               = 1024 * 1024;
   MaxRequestSize           = 0;
   MultipleOperationTimeout = DEFAULT_TIMEOUT;
+  NumSystemGroups          = 0;
   ReloadTimeout                   = DEFAULT_KEEPALIVE;
   RootCertDuration         = 300;
+  StrictConformance        = FALSE;
   Timeout                  = DEFAULT_TIMEOUT;
-  NumSystemGroups          = 0;
   WebInterface             = CUPS_DEFAULT_WEBIF;
 
   BrowseLocalProtocols     = parse_protocols(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS);
index 947773ff25a7319a65c25903c002a383c09e171a..3b963d7f7f4e9924b19e53d4b3d4240c421cb466 100644 (file)
@@ -169,6 +169,8 @@ VAR int                     ClassifyOverride        VALUE(0),
                                        /* Amount of automatic debug history */
                        FatalErrors             VALUE(CUPSD_FATAL_CONFIG),
                                        /* Which errors are fatal? */
+                       StrictConformance       VALUE(FALSE),
+                                       /* Require strict IPP conformance? */
                        LogFilePerm             VALUE(0644);
                                        /* Permissions for log files */
 VAR cupsd_loglevel_t   LogLevel                VALUE(CUPSD_LOG_WARN);
index 20c2523c80e34465dc1f4534d274b3e39940fe72..e0416589766f5710fbac26b145573c798f4fdc62 100644 (file)
@@ -5795,8 +5795,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,
@@ -5817,6 +5825,29 @@ create_job(cupsd_client_t  *con, /* I - Client connection */
     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...
   */
index cade7a192e40832f8f3a277779d7e14b4618cdf2..6130c95514aa66efdee363bbee536c432ccf1a0d 100755 (executable)
@@ -368,6 +368,7 @@ else
 fi
 
 cat >/tmp/cups-$user/cupsd.conf <<EOF
+StrictConformance Yes
 Browsing Off
 FileDevice yes
 Printcap