From aba5e776bb95610ea3e3355cbf47aadb844773eb Mon Sep 17 00:00:00 2001 From: jkh Date: Tue, 27 Apr 1999 07:09:18 +0000 Subject: lpd tries to be clever and checks if RM == my_hostname. However, it doesn't check if the remote printer name it is sending it to is the same as the local printer name, and so chokes 'cos "laser" is not a real printer. PR: 7081 Submitted by: David Malone --- usr.sbin/lpr/common_source/lp.h | 3 ++- usr.sbin/lpr/common_source/net.c | 7 ++++++- usr.sbin/lpr/common_source/printcap.c | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'usr.sbin/lpr/common_source') diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index 8b3cd5f..7ab0e76 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * From: @(#)lp.h 8.2 (Berkeley) 4/28/95 - * $Id$ + * $Id: lp.h,v 1.7 1997/12/02 20:45:21 wollman Exp $ */ #include @@ -50,6 +50,7 @@ enum lpd_filters { LPF_CIFPLOT, LPF_DVI, LPF_GRAPH, LPF_INPUT, struct printer { char *printer; /* printer name */ int remote; /* true if RM points to a remote host */ + int rp_matches_local; /* true if rp has same name as us */ int tof; /* true if we are at top-of-form */ /* ------------------------------------------------------ */ char *acct_file; /* AF: accounting file */ diff --git a/usr.sbin/lpr/common_source/net.c b/usr.sbin/lpr/common_source/net.c index d5886f9..05c8085 100644 --- a/usr.sbin/lpr/common_source/net.c +++ b/usr.sbin/lpr/common_source/net.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: net.c,v 1.1 1997/12/02 20:45:22 wollman Exp $"; #endif /* not lint */ #include @@ -160,6 +160,11 @@ checkremote(struct printer *pp) struct in_addr *localaddrs; int i, j, nlocaladdrs, ncommonaddrs; + if (!pp->rp_matches_local) { /* Remote printer doesn't match local */ + pp->remote = 1; + return NULL; + } + pp->remote = 0; /* assume printer is local */ if (pp->remote_host != NULL) { /* get the addresses of the local host */ diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c index a061c0e..ff82589 100644 --- a/usr.sbin/lpr/common_source/printcap.c +++ b/usr.sbin/lpr/common_source/printcap.c @@ -40,7 +40,7 @@ #ifndef lint static const char rcsid[] = - "$Id: printcap.c,v 1.3 1997/12/02 20:45:25 wollman Exp $"; + "$Id: printcap.c,v 1.4 1997/12/27 20:49:39 wollman Exp $"; #endif /* not lint */ #include @@ -215,6 +215,8 @@ getprintcap_int(bp, pp) struct printer *pp; { enum lpd_filters filt; + char *rp_name; + int error; if ((pp->printer = capdb_canonical_name(bp)) == 0) return PCAPERR_OSERR; @@ -263,6 +265,20 @@ getprintcap_int(bp, pp) pp->tof = !capdb_getaltlog(bp, "fo", "job.topofform"); /* + * Decide if the remote printer name matches the local printer name. + * If no name is given then we assume they mean them to match. + * If a name is given see if the rp_name is one of the names for + * this printer. + */ + pp->rp_matches_local = 1; + CHK((error = capdb_getaltstr(bp, "rp", "remote.queue", 0, &rp_name))); + if (error != PCAPERR_NOTFOUND && rp_name != NULL) { + if (cgetmatch(bp,rp_name) != 0) + pp->rp_matches_local = 0; + free(rp_name); + } + + /* * Filters: */ for (filt = 0; filt < LPF_COUNT; filt++) { -- cgit v1.1