From: msweet Date: Wed, 6 May 2015 21:11:47 +0000 (+0000) Subject: The scheduler now validates ErrorPolicy values in config files (STR #4591) X-Git-Tag: v2.2b1~309 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fcups.git;a=commitdiff_plain;h=d4cda727d53475332ecfac31449013cd439576cd The scheduler now validates ErrorPolicy values in config files (STR #4591) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12620 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/CHANGES.txt b/CHANGES.txt index 3196a0629..d6a4a2873 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -26,4 +26,7 @@ CHANGES IN CUPS V2.1b1 () - The cupstestppd program did not handle "maxsize(nnn)" entries in cupsFilter/cupsFilter2 values () - - Now check the return value of rename() calls (STR #4589) \ No newline at end of file + - The scheduler now checks the return value of rename() calls + (STR #4589) + - The scheduler now validates ErrorPolicy values in config files + (STR #4591) \ No newline at end of file diff --git a/scheduler/conf.c b/scheduler/conf.c index 79ef54653..a58de4204 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1182,6 +1182,19 @@ cupsdReadConfiguration(void) 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... */ diff --git a/scheduler/printers.c b/scheduler/printers.c index 262c9908f..88391af83 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -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 @@ cupsdLoadAllPrinters(void) 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) {