]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix lpadmin when both -m and -o are used (STR #4578)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 6 May 2015 01:42:51 +0000 (01:42 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 6 May 2015 01:42:51 +0000 (01:42 +0000)
Grab server PPD and edit it as needed.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12603 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES-2.0.txt
cups/testppd.c
systemv/lpadmin.c
test/run-stp-tests.sh

index 6422d712a0cc4039ac7bc325f3994866b5d6a17b..2d6dd8e1d163173b212f4a709c9eb0adc20dcb8f 100644 (file)
@@ -9,6 +9,7 @@ CHANGES IN CUPS V2.0.3
          (STR #4598, STR #4599, STR #4600, STR #4601)
        - Fixed a gzip processing bug (#4602)
        - Fixed <Limit> inside <Location> (STR #4575)
+       - Fixed lpadmin when both -m and -o are used (STR #4578)
        - Added Russian translation (STR #4577)
 
 
index 42b5ab8756dff22bf110603aec071cc1d6fd7014..e87435fd8ef5353b53b88d813509e1d979827cfe 100644 (file)
@@ -910,7 +910,19 @@ main(int  argc,                            /* I - Number of command-line arguments */
     struct stat        fileinfo;               /* File information */
 
 
-    if (!strncmp(argv[1], "-d", 2))
+    if (strchr(argv[1], ':'))
+    {
+     /*
+      * Server PPD...
+      */
+
+      if ((filename = cupsGetServerPPD(CUPS_HTTP_DEFAULT, argv[1])) == NULL)
+      {
+        printf("%s: %s\n", argv[1], cupsLastErrorString());
+        return (1);
+      }
+    }
+    else if (!strncmp(argv[1], "-d", 2))
     {
       const char *printer;             /* Printer name */
 
index 492ff9d6fa360946164c3f64aadb22f1b0c79b80..fa077b2b94c84b5c737261e674a0f1deef976b4b 100644 (file)
@@ -1318,7 +1318,7 @@ set_printer_options(
 {
   ipp_t                *request;               /* IPP Request */
   const char   *ppdfile;               /* PPD filename */
-  int          ppdchanged;             /* PPD changed? */
+  int          ppdchanged = 0;         /* PPD changed? */
   ppd_file_t   *ppd;                   /* PPD file */
   ppd_choice_t *choice;                /* Marked choice */
   char         uri[HTTP_MAX_URI],      /* URI for printer/class */
@@ -1328,11 +1328,13 @@ set_printer_options(
                tempfile[1024];         /* Temporary filename */
   cups_file_t  *in,                    /* PPD file */
                *out;                   /* Temporary file */
-  const char   *protocol,              /* Old protocol option */
+  const char   *ppdname,               /* ppd-name value */
+               *protocol,              /* Old protocol option */
                *customval,             /* Custom option value */
                *boolval;               /* Boolean value */
   int          wrote_ipp_supplies = 0, /* Wrote cupsIPPSupplies keyword? */
-               wrote_snmp_supplies = 0;/* Wrote cupsSNMPSupplies keyword? */
+               wrote_snmp_supplies = 0,/* Wrote cupsSNMPSupplies keyword? */
+               copied_options = 0;     /* Copied options? */
 
 
   DEBUG_printf(("set_printer_options(http=%p, printer=\"%s\", num_options=%d, "
@@ -1364,6 +1366,26 @@ set_printer_options(
 
   if (file)
     ppdfile = file;
+  else if ((ppdname = cupsGetOption("ppd-name", num_options, options)) != NULL && strcmp(ppdname, "raw") && num_options > 1)
+  {
+    if ((ppdfile = cupsGetServerPPD(http, ppdname)) != NULL)
+    {
+     /*
+      * Copy options array and remove ppd-name from it...
+      */
+
+      cups_option_t *temp = NULL, *optr;
+      int i, num_temp = 0;
+      for (i = num_options, optr = options; i > 0; i --, optr ++)
+        if (strcmp(optr->name, "ppd-name"))
+         num_temp = cupsAddOption(optr->name, optr->value, num_temp, &temp);
+
+      copied_options = 1;
+      ppdchanged     = 1;
+      num_options    = num_temp;
+      options        = temp;
+    }
+  }
   else if (request->request.op.operation_id == IPP_OP_CUPS_ADD_MODIFY_PRINTER)
     ppdfile = cupsGetPPD(printer);
   else
@@ -1388,7 +1410,15 @@ set_printer_options(
     * Set default options in the PPD file...
     */
 
-    ppd = ppdOpenFile(ppdfile);
+    if ((ppd = ppdOpenFile(ppdfile)) == NULL)
+    {
+      int              linenum;        /* Line number of error */
+      ppd_status_t     status = ppdLastError(&linenum);
+                                       /* Status code */
+
+      _cupsLangPrintf(stderr, _("lpadmin: Unable to open PPD \"%s\": %s on line %d."), ppdfile, ppdErrorString(status), linenum);
+    }
+
     ppdMarkDefaults(ppd);
     cupsMarkOptions(ppd, num_options, options);
 
@@ -1398,6 +1428,8 @@ set_printer_options(
       ippDelete(request);
       if (ppdfile != file)
         unlink(ppdfile);
+      if (copied_options)
+        cupsFreeOptions(num_options, options);
       return (1);
     }
 
@@ -1409,13 +1441,13 @@ set_printer_options(
       ippDelete(request);
       if (ppdfile != file)
        unlink(ppdfile);
+      if (copied_options)
+        cupsFreeOptions(num_options, options);
       cupsFileClose(out);
       unlink(tempfile);
       return (1);
     }
 
-    ppdchanged = 0;
-
     while (cupsFileGets(in, line, sizeof(line)))
     {
       if (!strncmp(line, "*cupsIPPSupplies:", 17) &&
@@ -1537,6 +1569,9 @@ set_printer_options(
     ippDelete(cupsDoRequest(http, request, "/admin/"));
   }
 
+  if (copied_options)
+    cupsFreeOptions(num_options, options);
+
  /*
   * Check the response...
   */
index 938d14d1f14b983d97424dd6c7bb2274e51414a8..0709e33aa16f9ffd5a7453b02da1e28aa0cb09a5 100755 (executable)
@@ -5,7 +5,7 @@
 # Perform the complete set of IPP compliance tests specified in the
 # CUPS Software Test Plan.
 #
-# Copyright 2007-2014 by Apple Inc.
+# Copyright 2007-2015 by Apple Inc.
 # Copyright 1997-2007 by Easy Software Products, all rights reserved.
 #
 # These coded instructions, statements, and computer programs are the
@@ -906,7 +906,7 @@ fi
 
 # Requests logged
 count=`wc -l $BASE/log/access_log | awk '{print $1}'`
-expected=`expr 37 + 18 + 29 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
+expected=`expr 37 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
 if test $count != $expected; then
        echo "FAIL: $count requests logged, expected $expected."
        echo "<P>FAIL: $count requests logged, expected $expected.</P>" >>$strfile