fixed lprm segmentation fault when remote is down.
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 19 May 1983 07:45:49 +0000 (23:45 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 19 May 1983 07:45:49 +0000 (23:45 -0800)
SCCS-vsn: usr.sbin/lpr/lpr/lpr.c 4.17
SCCS-vsn: usr.sbin/lpr/common_source/rmjob.c 4.3
SCCS-vsn: usr.sbin/lpr/common_source/common.c 4.3
SCCS-vsn: usr.sbin/lpr/lpd/printjob.c 4.3

usr/src/usr.sbin/lpr/common_source/common.c
usr/src/usr.sbin/lpr/common_source/rmjob.c
usr/src/usr.sbin/lpr/lpd/printjob.c
usr/src/usr.sbin/lpr/lpr/lpr.c

index 9703265..939c108 100644 (file)
@@ -1,4 +1,4 @@
-/*     common.c        4.2     83/05/13        */
+/*     common.c        4.3     83/05/18        */
 /*
  * Routines and data common to all the line printer functions.
  */
 /*
  * Routines and data common to all the line printer functions.
  */
@@ -53,7 +53,8 @@ char  *from = host;   /* client's machine name */
  * Create a connection to the remote printer server.
  * Most of this code comes from rcmd.c.
  */
  * Create a connection to the remote printer server.
  * Most of this code comes from rcmd.c.
  */
-getport()
+getport(rhost)
+       char *rhost;
 {
        struct hostent *hp;
        struct servent *sp;
 {
        struct hostent *hp;
        struct servent *sp;
@@ -63,11 +64,11 @@ getport()
        /*
         * Get the host address and port number to connect to.
         */
        /*
         * Get the host address and port number to connect to.
         */
-       if (RM == NULL)
+       if (rhost == NULL)
                fatal("no remote host to connect to");
                fatal("no remote host to connect to");
-       hp = gethostbyname(RM);
+       hp = gethostbyname(rhost);
        if (hp == NULL)
        if (hp == NULL)
-               fatal("unknown host %s", RM);
+               fatal("unknown host %s", rhost);
        sp = getservbyname("printer", "tcp");
        if (sp == NULL)
                fatal("printer/tcp: unknown service");
        sp = getservbyname("printer", "tcp");
        if (sp == NULL)
                fatal("printer/tcp: unknown service");
@@ -118,10 +119,8 @@ rresvport(alport)
                if (errno != EADDRINUSE && errno != EADDRNOTAVAIL)
                        return(-1);
                (*alport)--;
                if (errno != EADDRINUSE && errno != EADDRNOTAVAIL)
                        return(-1);
                (*alport)--;
-               if (*alport == IPPORT_RESERVED/2) {
-                       printf("%s: All ports in use\n", name);
+               if (*alport == IPPORT_RESERVED/2)
                        return(-1);
                        return(-1);
-               }
        }
 }
 
        }
 }
 
index f9c2aa5..76ed955 100644 (file)
@@ -1,4 +1,4 @@
-/*     rmjob.c 4.2     83/05/13        */
+/*     rmjob.c 4.3     83/05/18        */
 /*
  * rmjob - remove the specified jobs from the queue.
  */
 /*
  * rmjob - remove the specified jobs from the queue.
  */
@@ -39,8 +39,7 @@ rmjob()
                LP = DEFDEVLP;
        if ((RP = pgetstr("rp", &bp)) == NULL)
                RP = DEFLP;
                LP = DEFDEVLP;
        if ((RP = pgetstr("rp", &bp)) == NULL)
                RP = DEFLP;
-       if ((RM = pgetstr("rm", &bp)) == NULL)
-               RM = host;
+       RM = pgetstr("rm", &bp);
 
        /*
         * If the format was `lprm -' and the user isn't the super-user,
 
        /*
         * If the format was `lprm -' and the user isn't the super-user,
@@ -114,7 +113,7 @@ lockchk(s)
        }
        cur_daemon = atoi(line);
        for (i = 1; (n = fread(current, sizeof(char), sizeof(current), fp)) <= 0; i++) {
        }
        cur_daemon = atoi(line);
        for (i = 1; (n = fread(current, sizeof(char), sizeof(current), fp)) <= 0; i++) {
-               if (i > 20) {
+               if (i > 5) {
                        n = 1;
                        break;
                }
                        n = 1;
                        break;
                }
@@ -247,7 +246,7 @@ chkremote()
                (void) sprintf(cp, " %d", requ[i]);
        }
        strcat(cp, "\n");
                (void) sprintf(cp, " %d", requ[i]);
        }
        strcat(cp, "\n");
-       rem = getport();
+       rem = getport(RM);
        if (rem < 0) {
                if (from != host)
                        printf("%s: ", host);
        if (rem < 0) {
                if (from != host)
                        printf("%s: ", host);
index 2e95d82..8af58b6 100644 (file)
@@ -1,4 +1,4 @@
-/*     printjob.c      4.2     83/05/16        */
+/*     printjob.c      4.3     83/05/18        */
 /*
  * printjob -- print jobs in the queue.
  *
 /*
  * printjob -- print jobs in the queue.
  *
@@ -928,7 +928,7 @@ openpr()
                status("%s is ready and printing", printer);
        } else if (RM != NULL) {
                for (i = 1; ; i = i < 512 ? i << 1 : i) {
                status("%s is ready and printing", printer);
        } else if (RM != NULL) {
                for (i = 1; ; i = i < 512 ? i << 1 : i) {
-                       pfd = getport();
+                       pfd = getport(RM);
                        if (pfd >= 0) {
                                (void) sprintf(line, "\2%s\n", RP);
                                n = strlen(line);
                        if (pfd >= 0) {
                                (void) sprintf(line, "\2%s\n", RP);
                                n = strlen(line);
index 0928fef..2b2e533 100644 (file)
@@ -55,7 +55,7 @@
 
 char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
 
 
 char lpr_id[] = "~|^`lpr.c:\t4.2\t1 May 1981\n";
 
-/*     lpr.c   4.16    83/05/13        */
+/*     lpr.c   4.17    83/05/18        */
 /*
  *      lpr -- off line print
  *
 /*
  *      lpr -- off line print
  *
@@ -577,7 +577,6 @@ chkprinter(s)
                MX = DEFMX;
        if ((DU = pgetnum("du")) < 0)
                DU = DEFUID;
                MX = DEFMX;
        if ((DU = pgetnum("du")) < 0)
                DU = DEFUID;
-       RM = host;              /* machine for getport to connect to */
 }
 
 /*
 }
 
 /*