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

classes.conf not updated when class member is deleted #3505

Closed
michaelrsweet opened this issue Feb 16, 2010 · 5 comments
Closed

classes.conf not updated when class member is deleted #3505

michaelrsweet opened this issue Feb 16, 2010 · 5 comments
Milestone

Comments

@michaelrsweet
Copy link
Collaborator

Version: 1.4.2
CUPS.org User: twaugh.redhat

When a printer is deleted, classes.conf is never updated even if the
printer was a member of a class.

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

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

This patch has the side-effect of always writing classes.conf, even if there are no classes (the most common case).

Will look at updating cupsdDeletePrinterFromClasses so we can determine whether any classes were affected...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

OK, I've attached a different patch that updates all of the delete calls to return a status indicating whether a class was affected by the deletion. If so, we update classes.conf...

@michaelrsweet
Copy link
Collaborator Author

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet
Copy link
Collaborator Author

"0001-Update-classes.conf-when-a-printer-is-deleted.patch":

From eeaf0a8d52b0195a59546bc63aa1de26cf86de79 Mon Sep 17 00:00:00 2001
From: Tim Waugh twaugh@redhat.com
Date: Tue, 16 Feb 2010 15:58:24 +0000
Subject: [PATCH] Update classes.conf when a printer is deleted.

When a printer is deleted, classes.conf is never updated even if the
printer was a member of a class.

Original report:

https://bugzilla.redhat.com/show_bug.cgi?id=565823

scheduler/ipp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 06afb5c..1d0ddd9 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -6431,7 +6431,6 @@ delete_printer(cupsd_client_t con, / I - Client connection */
printer->name, get_username(con));

 cupsdDeletePrinter(printer, 0);
  • cupsdMarkDirty(CUPSD_DIRTY_CLASSES);
    }
    else
    {
    @@ -6442,6 +6441,7 @@ delete_printer(cupsd_client_t con, / I - Client connection */
    cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
    }
  • cupsdMarkDirty(CUPSD_DIRTY_CLASSES);
    cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);

/*

1.6.6

@michaelrsweet
Copy link
Collaborator Author

"str3505.patch":

Index: scheduler/classes.h

--- scheduler/classes.h (revision 8995)
+++ scheduler/classes.h (working copy)
@@ -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);
    Index: scheduler/ipp.c
    ===================================================================
    --- scheduler/ipp.c (revision 8995)
    +++ scheduler/ipp.c (working copy)
    @@ -6454,7 +6454,9 @@
    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);
    }

Index: scheduler/printers.c

--- scheduler/printers.c (revision 8995)
+++ scheduler/printers.c (working copy)
@@ -655,12 +655,13 @@

  • '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 */
    @@ -771,7 +772,7 @@

if (!(p->type & CUPS_PRINTER_IMPLICIT))
{

  • cupsdDeletePrinterFromClasses(p);
  • changed = cupsdDeletePrinterFromClasses(p);

/*

  • Deregister from any browse protocols...
    @@ -848,6 +849,8 @@
    */

cupsArrayRestore(Printers);
+

  • return (changed);
    }

Index: scheduler/printers.h

--- scheduler/printers.h (revision 8995)
+++ scheduler/printers.h (working copy)
@@ -140,7 +140,7 @@
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,

Index: scheduler/classes.c

--- scheduler/classes.c (revision 8995)
+++ scheduler/classes.c (working copy)
@@ -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 @@
  • '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 @@
(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 @@

  • '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 @@
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 @@
      cupsdLogMessage(CUPSD_LOG_DEBUG, "Deleting implicit class "%s"...",
      c->name);
      cupsdDeletePrinter(c, 0);
  •  changed = 1;
    

    }
    +

  • return (changed);
    }

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