- Update classes.conf when a class member printer is deleted (bug #565878,

STR #3505).
This commit is contained in:
Tim Waugh 2010-02-23 12:25:16 +00:00
parent 6297c85cf9
commit cc2070d9d2
2 changed files with 165 additions and 1 deletions

158
cups-str3505.patch Normal file
View File

@ -0,0 +1,158 @@
diff -up cups-1.4.2/scheduler/classes.c.str3505 cups-1.4.2/scheduler/classes.c
--- cups-1.4.2/scheduler/classes.c.str3505 2009-10-07 19:16:09.000000000 +0100
+++ cups-1.4.2/scheduler/classes.c 2010-02-23 11:43:06.033263862 +0000
@@ -3,7 +3,7 @@
*
* Printer class routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2009 by Apple Inc.
+ * Copyright 2007-2010 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -117,7 +117,7 @@ cupsdAddPrinterToClass(
* 'cupsdDeletePrinterFromClass()' - Delete a printer from a class.
*/
-void
+int /* O - 1 if class changed, 0 otherwise */
cupsdDeletePrinterFromClass(
cupsd_printer_t *c, /* I - Class to delete from */
cupsd_printer_t *p) /* I - Printer to delete */
@@ -149,13 +149,15 @@ cupsdDeletePrinterFromClass(
(c->num_printers - i) * sizeof(cupsd_printer_t *));
}
else
- return;
+ return (0);
/*
* Update the IPP attributes (have to do this for member-names)...
*/
cupsdSetPrinterAttrs(c);
+
+ return (1);
}
@@ -163,10 +165,11 @@ cupsdDeletePrinterFromClass(
* 'cupsdDeletePrinterFromClasses()' - Delete a printer from all classes.
*/
-void
+int /* O - 1 if class changed, 0 otherwise */
cupsdDeletePrinterFromClasses(
cupsd_printer_t *p) /* I - Printer to delete */
{
+ int changed = 0; /* Any class changed? */
cupsd_printer_t *c; /* Pointer to current class */
@@ -179,7 +182,7 @@ cupsdDeletePrinterFromClasses(
c;
c = (cupsd_printer_t *)cupsArrayNext(Printers))
if (c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
- cupsdDeletePrinterFromClass(c, p);
+ changed |= cupsdDeletePrinterFromClass(c, p);
/*
* Then clean out any empty implicit classes...
@@ -193,7 +196,10 @@ cupsdDeletePrinterFromClasses(
cupsdLogMessage(CUPSD_LOG_DEBUG, "Deleting implicit class \"%s\"...",
c->name);
cupsdDeletePrinter(c, 0);
+ changed = 1;
}
+
+ return (changed);
}
diff -up cups-1.4.2/scheduler/classes.h.str3505 cups-1.4.2/scheduler/classes.h
--- cups-1.4.2/scheduler/classes.h.str3505 2008-09-19 21:03:36.000000000 +0100
+++ cups-1.4.2/scheduler/classes.h 2010-02-23 11:43:06.012262825 +0000
@@ -3,7 +3,7 @@
*
* Printer class definitions for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007-2008 by Apple Inc.
+ * Copyright 2007-2010 by Apple Inc.
* Copyright 1997-2005 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -21,9 +21,9 @@
extern cupsd_printer_t *cupsdAddClass(const char *name);
extern void cupsdAddPrinterToClass(cupsd_printer_t *c,
cupsd_printer_t *p);
-extern void cupsdDeletePrinterFromClass(cupsd_printer_t *c,
+extern int cupsdDeletePrinterFromClass(cupsd_printer_t *c,
cupsd_printer_t *p);
-extern void cupsdDeletePrinterFromClasses(cupsd_printer_t *p);
+extern int cupsdDeletePrinterFromClasses(cupsd_printer_t *p);
extern cupsd_printer_t *cupsdFindAvailablePrinter(const char *name);
extern cupsd_printer_t *cupsdFindClass(const char *name);
extern void cupsdLoadAllClasses(void);
diff -up cups-1.4.2/scheduler/ipp.c.str3505 cups-1.4.2/scheduler/ipp.c
--- cups-1.4.2/scheduler/ipp.c.str3505 2010-02-23 11:42:12.713386792 +0000
+++ cups-1.4.2/scheduler/ipp.c 2010-02-23 11:43:06.025262343 +0000
@@ -6451,7 +6451,9 @@ delete_printer(cupsd_client_t *con, /*
cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" deleted by \"%s\".",
printer->name, get_username(con));
- cupsdDeletePrinter(printer, 0);
+ if (cupsdDeletePrinter(printer, 0))
+ cupsdMarkDirty(CUPSD_DIRTY_CLASSES);
+
cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
}
diff -up cups-1.4.2/scheduler/printers.c.str3505 cups-1.4.2/scheduler/printers.c
--- cups-1.4.2/scheduler/printers.c.str3505 2010-02-23 11:42:12.223386167 +0000
+++ cups-1.4.2/scheduler/printers.c 2010-02-23 11:43:06.030262135 +0000
@@ -657,12 +657,13 @@ cupsdDeleteAllPrinters(void)
* 'cupsdDeletePrinter()' - Delete a printer from the system.
*/
-void
+int /* O - 1 if classes affected, 0 otherwise */
cupsdDeletePrinter(
cupsd_printer_t *p, /* I - Printer to delete */
int update) /* I - Update printers.conf? */
{
- int i; /* Looping var */
+ int i, /* Looping var */
+ changed = 0; /* Class changed? */
#ifdef __sgi
char filename[1024]; /* Interface script filename */
#endif /* __sgi */
@@ -773,7 +774,7 @@ cupsdDeletePrinter(
if (!(p->type & CUPS_PRINTER_IMPLICIT))
{
- cupsdDeletePrinterFromClasses(p);
+ changed = cupsdDeletePrinterFromClasses(p);
/*
* Deregister from any browse protocols...
@@ -854,6 +855,8 @@ cupsdDeletePrinter(
*/
cupsArrayRestore(Printers);
+
+ return (changed);
}
diff -up cups-1.4.2/scheduler/printers.h.str3505 cups-1.4.2/scheduler/printers.h
--- cups-1.4.2/scheduler/printers.h.str3505 2009-06-25 18:07:26.000000000 +0100
+++ cups-1.4.2/scheduler/printers.h 2010-02-23 11:43:06.032262357 +0000
@@ -141,7 +141,7 @@ extern void cupsdAddPrinterUser(cupsd_p
const char *username);
extern void cupsdCreateCommonData(void);
extern void cupsdDeleteAllPrinters(void);
-extern void cupsdDeletePrinter(cupsd_printer_t *p, int update);
+extern int cupsdDeletePrinter(cupsd_printer_t *p, int update);
extern cupsd_printer_t *cupsdFindDest(const char *name);
extern cupsd_printer_t *cupsdFindPrinter(const char *name);
extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p,

View File

@ -8,7 +8,7 @@
Summary: Common Unix Printing System
Name: cups
Version: 1.4.2
Release: 24%{?dist}
Release: 25%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@ -77,6 +77,7 @@ Patch50: cups-str3458.patch
Patch51: cups-0755.patch
Patch52: cups-str3460.patch
Patch53: cups-EAI_AGAIN.patch
Patch54: cups-str3505.patch
Patch100: cups-lspp.patch
@ -260,6 +261,7 @@ module.
%patch51 -p1 -b .0755
%patch52 -p1 -b .str3460
%patch53 -p1 -b .EAI_AGAIN
%patch54 -p1 -b .str3505
%if %lspp
%patch100 -p1 -b .lspp
@ -558,6 +560,10 @@ rm -rf $RPM_BUILD_ROOT
%{php_extdir}/phpcups.so
%changelog
* Tue Feb 23 2010 Tim Waugh <twaugh@redhat.com> - 1:1.4.2-25
- Update classes.conf when a class member printer is deleted
(bug #565878, STR #3505).
* Tue Feb 23 2010 Tim Waugh <twaugh@redhat.com> - 1:1.4.2-24
- Re-initialize the resolver if getnameinfo() returns EAI_AGAIN
(bug #567353).