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.
This commit is contained in:
garbled 2006-01-04 15:32:50 +00:00
parent 026a2bfc50
commit 97f8851cc8
5 changed files with 34 additions and 16 deletions

View File

@ -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 @@ lp|default line printer:\e
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

View File

@ -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 @@ const char *
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 @@ checkremote(void)
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",

View File

@ -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 @@ displayq(int format)
{
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 @@ displayq(int format)
(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);

View File

@ -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 @@ isowner(const char *owner, const char *file)
void
rmremote(void)
{
char *cp, *s;
char *cp, *s, *rmhost;
int i, rem;
size_t len;
@ -339,7 +339,10 @@ rmremote(void)
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);

View File

@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#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 @@ openrem(void)
{
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 &&