]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix regression in lpadmin fix (Issue #5305)
authorMichael R Sweet <michaelrsweet@gmail.com>
Wed, 18 Jul 2018 01:57:41 +0000 (21:57 -0400)
committerMichael R Sweet <michaelrsweet@gmail.com>
Wed, 18 Jul 2018 01:57:41 +0000 (21:57 -0400)
systemv/lpadmin.c
test/5.1-lpadmin.sh
test/run-stp-tests.sh

index d7d02591a46a9b772acc3bb835c5ba6c9654c25e..aaebd3eed54563c67d6260bc5abf6d3342a22b15 100644 (file)
@@ -32,7 +32,7 @@ static cups_ptype_t   get_printer_type(http_t *http, char *printer, char *uri,
                                         size_t urisize);
 static int             set_printer_options(http_t *http, char *printer,
                                            int num_options, cups_option_t *options,
-                                           char *file);
+                                           char *file, int enable);
 static int             validate_name(const char *name);
 
 
@@ -50,6 +50,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
                *pclass,                /* Printer class name */
                *opt,                   /* Option pointer */
                *val;                   /* Pointer to allow/deny value */
+  int          enable = 0;             /* Enable/resume printer? */
   int          num_options;            /* Number of options */
   cups_option_t        *options;               /* Options */
   char         *file,                  /* New PPD file */
@@ -259,8 +260,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
                }
              }
 
-             if (enable_printer(http, printer))
-               return (1);
+              enable = 1;
              break;
 
          case 'm' : /* Use the specified standard script/PPD file */
@@ -647,9 +647,11 @@ main(int  argc,                            /* I - Number of command-line arguments */
       }
     }
 
-    if (set_printer_options(http, printer, num_options, options, file))
+    if (set_printer_options(http, printer, num_options, options, file, enable))
       return (1);
   }
+  else if (enable && enable_printer(http, printer))
+    return (1);
 
   if (evefile[0])
     unlink(evefile);
@@ -1331,7 +1333,8 @@ set_printer_options(
     char          *printer,            /* I - Printer */
     int           num_options,         /* I - Number of options */
     cups_option_t *options,            /* I - Options */
-    char          *file)               /* I - PPD file/interface script */
+    char          *file,               /* I - PPD file */
+    int           enable)              /* I - Enable printer? */
 {
   ipp_t                *request;               /* IPP Request */
   const char   *ppdfile;               /* PPD filename */
@@ -1377,6 +1380,12 @@ set_printer_options(
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
   ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
 
+  if (enable)
+  {
+    ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state", IPP_PSTATE_IDLE);
+    ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
+  }
+
  /*
   * Add the options...
   */
index 5b8241884352fada33876ab7b04d4f4787e43f90..612607bd802cd1a526cdee31ec5316b5f665e0d0 100644 (file)
@@ -2,7 +2,7 @@
 #
 # Test the lpadmin command.
 #
-# Copyright © 2007-2013 by Apple Inc.
+# Copyright © 2007-2018 by Apple Inc.
 # Copyright © 1997-2005 by Easy Software Products, all rights reserved.
 #
 # Licensed under Apache License v2.0.  See the file "LICENSE" for more
@@ -52,8 +52,8 @@ echo ""
 
 echo "Add Shared Printer Test"
 echo ""
-echo "    lpadmin -p Test3 -E -v ipp://localhost:$IPP_PORT/printers/Test2 -m raw"
-$VALGRIND ../systemv/lpadmin -p Test3 -E -v ipp://localhost:$IPP_PORT/printers/Test2 -m raw 2>&1
+echo "    lpadmin -p Test3 -E -v ipp://localhost:$IPP_PORT/printers/Test2 -m everywhere"
+$VALGRIND ../systemv/lpadmin -p Test3 -E -v ipp://localhost:$IPP_PORT/printers/Test2 -m everywhere 2>&1
 if test $? != 0; then
        echo "    FAILED"
        exit 1
index f83bd5d91b601a7c4de8c42f8772fc64d68110c2..ae902972330b7705c18a61e3fee0602d73000749 100755 (executable)
@@ -91,40 +91,35 @@ echo ""
 case "$testtype" in
        0)
                echo "Running in test mode (0)"
-               nprinters1=0
-               nprinters2=0
+               nprinters=0
                pjobs=0
                pprinters=0
                loglevel="debug2"
                ;;
        2)
                echo "Running the medium tests (2)"
-               nprinters1=10
-               nprinters2=20
+               nprinters=20
                pjobs=20
                pprinters=10
                loglevel="debug"
                ;;
        3)
                echo "Running the extreme tests (3)"
-               nprinters1=500
-               nprinters2=1000
+               nprinters=1000
                pjobs=100
                pprinters=50
                loglevel="debug"
                ;;
        4)
                echo "Running the torture tests (4)"
-               nprinters1=10000
-               nprinters2=20000
+               nprinters=20000
                pjobs=200
                pprinters=100
                loglevel="debug"
                ;;
        *)
                echo "Running the timid tests (1)"
-               nprinters1=0
-               nprinters2=0
+               nprinters=0
                pjobs=10
                pprinters=0
                loglevel="debug2"
@@ -537,13 +532,13 @@ if test $ssltype != 0 -a `uname` = Darwin; then
 fi
 
 #
-# Setup lots of test queues - half with PPD files, half without...
+# Setup lots of test queues with PPD files...
 #
 
 echo "Creating printers.conf for test..."
 
 i=1
-while test $i -le $nprinters1; do
+while test $i -le $nprinters; do
        cat >>$BASE/printers.conf <<EOF
 <Printer test-$i>
 Accepting Yes
@@ -561,22 +556,6 @@ EOF
        i=`expr $i + 1`
 done
 
-while test $i -le $nprinters2; do
-       cat >>$BASE/printers.conf <<EOF
-<Printer test-$i>
-Accepting Yes
-DeviceURI file:/dev/null
-Info Test raw printer $i
-JobSheets none none
-Location CUPS test suite
-State Idle
-StateMessage Printer $1 is idle.
-</Printer>
-EOF
-
-       i=`expr $i + 1`
-done
-
 if test -f $BASE/printers.conf; then
        cp $BASE/printers.conf $BASE/printers.conf.orig
 else
@@ -927,7 +906,7 @@ fi
 
 # Requests logged
 count=`wc -l $BASE/log/access_log | awk '{print $1}'`
-expected=`expr 37 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
+expected=`expr 35 + 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