Paul Vixie tested this and found some problems.
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 10 May 1995 20:58:09 +0000 (12:58 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 10 May 1995 20:58:09 +0000 (12:58 -0800)
SCCS-vsn: usr.sbin/lpr/lpd/lpd.c 8.7
SCCS-vsn: usr.sbin/lpr/lpd/printjob.c 8.7
SCCS-vsn: usr.sbin/lpr/lpq/lpq.c 8.3

usr/src/usr.sbin/lpr/lpd/lpd.c
usr/src/usr.sbin/lpr/lpd/printjob.c
usr/src/usr.sbin/lpr/lpq/lpq.c

index ea0ffc0..593704d 100644 (file)
@@ -13,7 +13,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)lpd.c      8.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)lpd.c      8.7 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -78,6 +78,7 @@ static void       mcleanup __P((int));
 static void       doit __P((void));
 static void       startup __P((void));
 static void       chkhost __P((struct sockaddr_in *));
 static void       doit __P((void));
 static void       startup __P((void));
 static void       chkhost __P((struct sockaddr_in *));
+static int       ckqueue __P((char *));
 
 int
 main(argc, argv)
 
 int
 main(argc, argv)
@@ -404,7 +405,7 @@ startup()
         * Restart the daemons.
         */
        while (cgetnext(&buf, printcapdb) > 0) {
         * Restart the daemons.
         */
        while (cgetnext(&buf, printcapdb) > 0) {
-               if (ckqueue() <= 0) {
+               if (ckqueue(buf) <= 0) {
                        free(buf);
                        continue;       /* no work to do for this printer */
                }
                        free(buf);
                        continue;       /* no work to do for this printer */
                }
@@ -432,13 +433,15 @@ startup()
 /*
  * Make sure there's some work to do before forking off a child
  */
 /*
  * Make sure there's some work to do before forking off a child
  */
-ckqueue()
+static int
+ckqueue(cap)
+       char *cap;
 {
        register struct dirent *d;
        DIR *dirp;
        char *spooldir;
 
 {
        register struct dirent *d;
        DIR *dirp;
        char *spooldir;
 
-       if (cgetstr(bp, "sd", &spooldir) == -1)
+       if (cgetstr(cap, "sd", &spooldir) == -1)
                spooldir = _PATH_DEFSPOOL;
        if ((dirp = opendir(spooldir)) == NULL)
                return (-1);
                spooldir = _PATH_DEFSPOOL;
        if ((dirp = opendir(spooldir)) == NULL)
                return (-1);
index ea52308..d7eae63 100644 (file)
@@ -13,7 +13,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)printjob.c 8.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) %G%";
 #endif /* not lint */
 
 
 #endif /* not lint */
 
 
@@ -1260,17 +1260,20 @@ opennet(cp)
 {
        register int i;
        int resp, port;
 {
        register int i;
        int resp, port;
+       char save_ch;
 
 
-       *cp++ = '\0';
-       port = atoi(cp);
+       save_ch = *cp;
+       *cp = '\0';
+       port = atoi(LP);
        if (port <= 0) {
        if (port <= 0) {
-               syslog(LOG_ERR, "%s: bad port number: %s", printer, cp);
+               syslog(LOG_ERR, "%s: bad port number: %s", printer, LP);
                exit(1);
        }
                exit(1);
        }
+       *cp++ = save_ch;
 
        for (i = 1; ; i = i < 256 ? i << 1 : i) {
                resp = -1;
 
        for (i = 1; ; i = i < 256 ? i << 1 : i) {
                resp = -1;
-               pfd = getport(LP, port);
+               pfd = getport(cp, port);
                if (pfd < 0 && errno == ECONNREFUSED)
                        resp = 1;
                else if (pfd >= 0) {
                if (pfd < 0 && errno == ECONNREFUSED)
                        resp = 1;
                else if (pfd >= 0) {
@@ -1290,8 +1293,7 @@ opennet(cp)
                }
                sleep(i);
        }
                }
                sleep(i);
        }
-       pstatus("sending to %s port %d", LP, port);
-       *(--cp) = '@';  /* restore LP parameter in case we are called again */
+       pstatus("sending to %s port %d", cp, port);
 }
 
 /*
 }
 
 /*
index 2e5ab54..1e3c191 100644 (file)
@@ -13,7 +13,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)lpq.c      8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)lpq.c      8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -43,6 +43,7 @@ int    requests;              /* # of spool requests */
 char   *user[MAXUSERS];        /* users to process */
 int     users;                 /* # of users in user array */
 
 char   *user[MAXUSERS];        /* users to process */
 int     users;                 /* # of users in user array */
 
+static int ckqueue __P((char *));
 void usage __P((void));
 
 int
 void usage __P((void));
 
 int
@@ -96,7 +97,7 @@ main(argc, argv)
 
        if (aflag) {
                while (cgetnext(&buf, printcapdb) > 0) {
 
        if (aflag) {
                while (cgetnext(&buf, printcapdb) > 0) {
-                       if (ckqueue() <= 0) {
+                       if (ckqueue(buf) <= 0) {
                                free(buf);
                                continue;       /* no jobs */
                        }
                                free(buf);
                                continue;       /* no jobs */
                        }
@@ -116,13 +117,15 @@ main(argc, argv)
        exit(0);
 }
 
        exit(0);
 }
 
-ckqueue()
+static int
+ckqueue(cap)
+       char *cap;
 {
        register struct dirent *d;
        DIR *dirp;
        char *spooldir;
 
 {
        register struct dirent *d;
        DIR *dirp;
        char *spooldir;
 
-       if (cgetstr(bp, "sd", &spooldir) == -1)
+       if (cgetstr(cap, "sd", &spooldir) == -1)
                spooldir = _PATH_DEFSPOOL;
        if ((dirp = opendir(spooldir)) == NULL)
                return (-1);
                spooldir = _PATH_DEFSPOOL;
        if ((dirp = opendir(spooldir)) == NULL)
                return (-1);