Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/lpr Address PR bin/12112



details:   https://anonhg.NetBSD.org/src/rev/6395ed9de56a
branches:  trunk
changeset: 586875:6395ed9de56a
user:      garbled <garbled%NetBSD.org@localhost>
date:      Wed Jan 04 15:32:50 2006 +0000

description:
Address PR bin/12112
Lpd has the ability to start on a port other than "printer" but has no
way to connect to a remote lpd on that port.  This change adds the
ability to specify port@host in the rm element of printcap(5).  Tested to
work with both a standard lpd setup and one running on special ports.

diffstat:

 usr.sbin/lpr/SMM.doc/4.t              |   7 +++++--
 usr.sbin/lpr/common_source/common.c   |  11 ++++++++---
 usr.sbin/lpr/common_source/displayq.c |  11 +++++++----
 usr.sbin/lpr/common_source/rmjob.c    |  11 +++++++----
 usr.sbin/lpr/lpd/printjob.c           |  10 +++++++---
 5 files changed, 34 insertions(+), 16 deletions(-)

diffs (172 lines):

diff -r 79fcceaea510 -r 6395ed9de56a usr.sbin/lpr/SMM.doc/4.t
--- a/usr.sbin/lpr/SMM.doc/4.t  Wed Jan 04 15:31:40 2006 +0000
+++ b/usr.sbin/lpr/SMM.doc/4.t  Wed Jan 04 15:32:50 2006 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: 4.t,v 1.4 2003/08/07 11:25:24 agc Exp $
+.\" $NetBSD: 4.t,v 1.5 2006/01/04 15:32:50 garbled Exp $
 .\" Copyright (c) 1983, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
@@ -111,7 +111,10 @@
 The
 .B rm
 entry is the name of the remote machine to connect to; this name must
-be a known host name for a machine on the network.
+be a known host name for a machine on the network. The
+.B rm
+entry can also specify the port number of the \fIlpd\fP
+server on the remote host with the form ``port@host''.
 The
 .B rp
 capability indicates
diff -r 79fcceaea510 -r 6395ed9de56a usr.sbin/lpr/common_source/common.c
--- a/usr.sbin/lpr/common_source/common.c       Wed Jan 04 15:31:40 2006 +0000
+++ b/usr.sbin/lpr/common_source/common.c       Wed Jan 04 15:32:50 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: common.c,v 1.28 2005/11/28 03:26:06 christos Exp $     */
+/*     $NetBSD: common.c,v 1.29 2006/01/04 15:32:50 garbled Exp $      */
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)common.c   8.5 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: common.c,v 1.28 2005/11/28 03:26:06 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.29 2006/01/04 15:32:50 garbled Exp $");
 #endif
 #endif /* not lint */
 
@@ -308,6 +308,7 @@
 checkremote(void)
 {
        char lname[NI_MAXHOST], rname[NI_MAXHOST];
+       const char *rmhost;
        struct addrinfo hints, *res, *res0;
        static char errbuf[128];
        int error;
@@ -337,7 +338,11 @@
        hints.ai_family = PF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
        res = NULL;
-       error = getaddrinfo(RM, NULL, &hints, &res0);
+       if ((rmhost = strchr(RM, '@')))
+               rmhost++;
+       else
+               rmhost = RM;
+       error = getaddrinfo(rmhost, NULL, &hints, &res0);
        if (error) {
                (void)snprintf(errbuf, sizeof(errbuf),
                    "unable to resolve remote machine %s: %s",
diff -r 79fcceaea510 -r 6395ed9de56a usr.sbin/lpr/common_source/displayq.c
--- a/usr.sbin/lpr/common_source/displayq.c     Wed Jan 04 15:31:40 2006 +0000
+++ b/usr.sbin/lpr/common_source/displayq.c     Wed Jan 04 15:32:50 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: displayq.c,v 1.28 2005/11/28 03:26:06 christos Exp $   */
+/*     $NetBSD: displayq.c,v 1.29 2006/01/04 15:32:50 garbled Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: displayq.c,v 1.28 2005/11/28 03:26:06 christos Exp $");
+__RCSID("$NetBSD: displayq.c,v 1.29 2006/01/04 15:32:50 garbled Exp $");
 #endif
 #endif /* not lint */
 
@@ -95,7 +95,7 @@
 {
        struct queue *q;
        int i, nitems, fd, ret;
-       char *cp, *ecp;
+       char *cp, *ecp, *rmhost;
        struct queue **queue;
        struct stat statb;
        FILE *fp;
@@ -235,7 +235,10 @@
                (void)strlcpy(cp, user[i], ecp - cp);
        }
        (void)strlcat(line, "\n", sizeof(line));
-       fd = getport(RM, 0);
+       if ((rmhost = strchr(RM, '@')))
+               fd = getport(rmhost+1, atoi(RM));
+       else
+               fd = getport(RM, 0);
        if (fd < 0) {
                if (from != host)
                        printf("%s: ", host);
diff -r 79fcceaea510 -r 6395ed9de56a usr.sbin/lpr/common_source/rmjob.c
--- a/usr.sbin/lpr/common_source/rmjob.c        Wed Jan 04 15:31:40 2006 +0000
+++ b/usr.sbin/lpr/common_source/rmjob.c        Wed Jan 04 15:32:50 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rmjob.c,v 1.21 2005/11/28 03:26:06 christos Exp $      */
+/*     $NetBSD: rmjob.c,v 1.22 2006/01/04 15:32:50 garbled Exp $       */
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rmjob.c    8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: rmjob.c,v 1.21 2005/11/28 03:26:06 christos Exp $");
+__RCSID("$NetBSD: rmjob.c,v 1.22 2006/01/04 15:32:50 garbled Exp $");
 #endif
 #endif /* not lint */
 
@@ -297,7 +297,7 @@
 void
 rmremote(void)
 {
-       char *cp, *s;
+       char *cp, *s, *rmhost;
        int i, rem;
        size_t len;
 
@@ -339,7 +339,10 @@
        cp[0] = '\n';
        cp[1] = '\0';
 
-       rem = getport(RM, 0);
+       if ((rmhost = strchr(RM, '@')))
+               rem = getport(rmhost+1, atoi(RM));
+       else
+               rem = getport(RM, 0);
        if (rem < 0) {
                if (from != host)
                        printf("%s: ", host);
diff -r 79fcceaea510 -r 6395ed9de56a usr.sbin/lpr/lpd/printjob.c
--- a/usr.sbin/lpr/lpd/printjob.c       Wed Jan 04 15:31:40 2006 +0000
+++ b/usr.sbin/lpr/lpd/printjob.c       Wed Jan 04 15:32:50 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: printjob.c,v 1.43 2005/11/28 03:26:06 christos Exp $   */
+/*     $NetBSD: printjob.c,v 1.44 2006/01/04 15:32:50 garbled Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)printjob.c 8.7 (Berkeley) 5/10/95";
 #else
-__RCSID("$NetBSD: printjob.c,v 1.43 2005/11/28 03:26:06 christos Exp $");
+__RCSID("$NetBSD: printjob.c,v 1.44 2006/01/04 15:32:50 garbled Exp $");
 #endif
 #endif /* not lint */
 
@@ -1440,10 +1440,14 @@
 {
        int i, n;
        int resp;
+       char *rmhost;
 
        for (i = 1; ; i = i < 256 ? i << 1 : i) {
                resp = -1;
-               pfd = getport(RM, 0);
+               if ((rmhost = strchr(RM, '@')))
+                       pfd = getport(rmhost+1, atoi(RM));
+               else
+                       pfd = getport(RM, 0);
                if (pfd >= 0) {
                        n = snprintf(line, sizeof(line), "\2%s\n", RP);
                        if (write(pfd, line, n) == n &&



Home | Main Index | Thread Index | Old Index