summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-05-17 03:04:43 +0000
committerbrian <brian@FreeBSD.org>1997-05-17 03:04:43 +0000
commit3a163bace77f74a4ece104bf439c6b18c82a8672 (patch)
tree09ff622ddcf25eb6785b5d4e283e56b203a3c6e1 /usr.sbin
parent17bd88ae9b91eb1e6b440064d9bd4ee6c540e243 (diff)
downloadFreeBSD-src-3a163bace77f74a4ece104bf439c6b18c82a8672.zip
FreeBSD-src-3a163bace77f74a4ece104bf439c6b18c82a8672.tar.gz
Check for duplicate spool dirs.
Submitted by: eivind
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/lpr/lpd/lpd.c31
1 files changed, 30 insertions, 1 deletions
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 */
OpenPOWER on IntegriCloud