diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-05-10 11:20:46 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-05-10 11:20:46 +0000 |
commit | 277932cb7975ebb14a214bef208b916a9f251342 (patch) | |
tree | 69cd1e2a715e1cbd2cf643f7f40d3b3c071f5a26 /source3 | |
parent | 15c1b7663d63a481ae7719efbdd38f5a05b494d2 (diff) | |
download | samba-277932cb7975ebb14a214bef208b916a9f251342.tar.gz samba-277932cb7975ebb14a214bef208b916a9f251342.tar.bz2 samba-277932cb7975ebb14a214bef208b916a9f251342.zip |
remove autoloaded printers that are no longer in /etc/printcap when we
get a HUP
(This used to be commit 23f16c5ce60f76633458cc21b2d260d347b1b459)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/param/loadparm.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 1945dcffb2..14da552dcb 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -268,6 +268,7 @@ static global Globals; typedef struct { BOOL valid; + BOOL autoloaded; char *szService; char *szPath; char *szUsername; @@ -381,6 +382,7 @@ typedef struct static service sDefault = { True, /* valid */ + False, /* not autoloaded */ NULL, /* szService */ NULL, /* szPath */ NULL, /* szUsername */ @@ -2778,8 +2780,10 @@ void lp_add_one_printer(char *name,char *comment) if (lp_servicenumber(name) < 0) { lp_add_printer(name,printers); - if ((i=lp_servicenumber(name)) >= 0) + if ((i=lp_servicenumber(name)) >= 0) { string_set(&iSERVICE(i).comment,comment); + iSERVICE(i).autoloaded = True; + } } } @@ -2788,7 +2792,7 @@ have we loaded a services file yet? ***************************************************************************/ BOOL lp_loaded(void) { - return(bLoaded); + return(bLoaded); } /*************************************************************************** @@ -2796,13 +2800,27 @@ unload unused services ***************************************************************************/ void lp_killunused(BOOL (*snumused)(int )) { - int i; - for (i=0;i<iNumServices;i++) - if (VALID(i) && (!snumused || !snumused(i))) - { - iSERVICE(i).valid = False; - free_service(pSERVICE(i)); - } + int i; + for (i=0;i<iNumServices;i++) { + BOOL killthisone; + + if (!VALID(i)) continue; + + killthisone = (!snumused || !snumused(i)); + + /* we also want to remove autoloaded printers that are no longer + in /etc/printcap */ + if (!killthisone && + iSERVICE(i).autoloaded && iSERVICE(i).bPrint_ok && + !pcap_printername_ok(iSERVICE(i).szPrintername, NULL)) { + killthisone = True; + } + + if (killthisone) { + iSERVICE(i).valid = False; + free_service(pSERVICE(i)); + } + } } |