From 3a163bace77f74a4ece104bf439c6b18c82a8672 Mon Sep 17 00:00:00 2001 From: brian Date: Sat, 17 May 1997 03:04:43 +0000 Subject: Check for duplicate spool dirs. Submitted by: eivind --- usr.sbin/lpr/lpd/lpd.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'usr.sbin/lpr') diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index 898fc48..85148b1 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -433,11 +433,40 @@ startup() char *buf; register char *cp; int pid; + char *spooldirs[16]; /* Which spooldirs are active? */ + int i; /* Printer index presently processed */ + int j; /* Printer index of potential conflict */ + char *spooldir; /* Spooldir of present printer */ + int canfreespool; /* Is the spooldir malloc()ed? */ /* - * Restart the daemons. + * Restart the daemons and test for spooldir conflict. */ + i = 0; while (cgetnext(&buf, printcapdb) > 0) { + + /* Check for duplicate spooldirs */ + canfreespool = 1; + if (cgetstr(buf, "sd", &spooldir) <= 0) { + spooldir = _PATH_DEFSPOOL; + canfreespool = 0; + } + if (i < sizeof(spooldirs)/sizeof(spooldirs[0])) + spooldirs[i] = spooldir; + for (j = 0; + j < MIN(i,sizeof(spooldirs)/sizeof(spooldirs[0])); + j++) { + if (strcmp(spooldir, spooldirs[j]) == 0) { + syslog(LOG_ERR, + "startup: duplicate spool directories"); + mcleanup(0); + } + } + if (canfreespool && i >= sizeof(spooldirs)/sizeof(spooldirs[0])) + free(spooldir); + i++; + /* Spooldir test done */ + if (ckqueue(buf) <= 0) { free(buf); continue; /* no work to do for this printer */ -- cgit v1.1