Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorPolicy not validated #4591

Closed
michaelrsweet opened this issue Feb 25, 2015 · 4 comments
Closed

ErrorPolicy not validated #4591

michaelrsweet opened this issue Feb 25, 2015 · 4 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 2.1-current
CUPS.org User: twaugh.redhat

When reading cupsd.conf, the ErrorPolicy is not validated in the same way as, for instance, DefaultPolicy is.

The only validation occurs when printer-error-policy is set via IPP.

Original report:
https://bugzilla.redhat.com/show_bug.cgi?id=1196218

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: twaugh.redhat

Here's one approach.

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

Also added validation to the printers.conf file as well.

@michaelrsweet
Copy link
Collaborator Author

"cups-str4591.patch":

diff -up cups-1.4.2/scheduler/conf.c.str4591 cups-1.4.2/scheduler/conf.c
--- cups-1.4.2/scheduler/conf.c.str4591 2015-03-04 13:56:54.282280765 +0000
+++ cups-1.4.2/scheduler/conf.c 2015-03-04 14:03:28.230838482 +0000
@@ -1192,6 +1192,21 @@ cupsdReadConfiguration(void)
BrowseTimeout);
}

  • /*
  • * Validate the default error policy...
  • */
  • if (strcmp(ErrorPolicy, "retry-current-job") &&
  •  strcmp(ErrorPolicy, "abort-job") &&
    
  •  strcmp(ErrorPolicy, "retry-job") &&
    
  •  strcmp(ErrorPolicy, "stop-printer")) {
    
  • cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid ErrorPolicy %s!",
  •       ErrorPolicy);
    
  • cupsdSetString(&ErrorPolicy, "stop-printer");
  • cupsdLogMessage(CUPSD_LOG_ALERT, "Reset ErrorPolicy to %s!",
  •       ErrorPolicy);
    
  • }

/*

  • Update the default policy, as needed...
    */

@michaelrsweet
Copy link
Collaborator Author

"str4591.patch":

Index: scheduler/conf.c

--- scheduler/conf.c (revision 12599)
+++ scheduler/conf.c (working copy)
@@ -1182,6 +1182,19 @@

cupsdUpdateEnv();

  • /*
  • * Validate the default error policy...
  • */
  • if (strcmp(ErrorPolicy, "retry-current-job") &&
  •  strcmp(ErrorPolicy, "abort-job") &&
    
  •  strcmp(ErrorPolicy, "retry-job") &&
    
  •  strcmp(ErrorPolicy, "stop-printer"))
    
  • {
  • cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid ErrorPolicy "%s", resetting to "stop-printer".", ErrorPolicy);
  • cupsdSetString(&ErrorPolicy, "stop-printer");
  • }

/*

  • Update default paper size setting as needed...
    */
    Index: scheduler/printers.c

    --- scheduler/printers.c (revision 12597)
    +++ scheduler/printers.c (working copy)
    @@ -3,7 +3,7 @@
    *
  • Printer routines for the CUPS scheduler.
    *
  • * 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
      @@ -1214,10 +1214,17 @@
      else if (!_cups_strcasecmp(line, "ErrorPolicy"))
      {
      if (value)
  •    cupsdSetString(&p->error_policy, value);
    
  •  {
    
  • if (strcmp(value, "retry-current-job") &&
  •   strcmp(value, "abort-job") &&
    
  •   strcmp(value, "retry-job") &&
    
  •   strcmp(value, "stop-printer"))
    
  • cupsdLogMessage(CUPSD_LOG_ALERT, "Invalid ErrorPolicy \"%s\" on line %d or printers.conf.", ErrorPolicy, linenum);
    
  • else
  • cupsdSetString(&p->error_policy, value);
    
  •  }
    
    else
  • cupsdLogMessage(CUPSD_LOG_ERROR,
  •               "Syntax error on line %d of printers.conf.", linenum);
    
  • cupsdLogMessage(CUPSD_LOG_ERROR, "Syntax error on line %d of printers.conf.", linenum);
    }
    else if (!_cups_strcasecmp(line, "Attribute") && value)
    {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant