From owner-freebsd-bugs Fri Jun 26 11:40:46 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA04940 for freebsd-bugs-outgoing; Fri, 26 Jun 1998 11:40:46 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA04906 for ; Fri, 26 Jun 1998 11:40:31 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id LAA23517; Fri, 26 Jun 1998 11:40:01 -0700 (PDT) Received: from salmon.maths.tcd.ie (mmdf@salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id LAA04120 for ; Fri, 26 Jun 1998 11:35:03 -0700 (PDT) (envelope-from dwmalone@maths.tcd.ie) Received: from boole.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 26 Jun 98 19:34:50 +0100 (BST) Message-Id: <9806261934.aa02238@boole.maths.tcd.ie> Date: Fri, 26 Jun 98 19:34:50 +0100 (BST) From: dwmalone@maths.tcd.ie Reply-To: dwmalone@maths.tcd.ie To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/7081: lpd remote printer on local host broken. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 7081 >Category: bin >Synopsis: lpr stuff doesn't deal with RM and RP well if RM = hostname >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jun 26 11:40:00 PDT 1998 >Last-Modified: >Originator: David Malone >Organization: School of Mathematics, Trinity College, Dublin. >Release: FreeBSD 2.2.6-STABLE i386 >Environment: We're tring to use one printcap on all our machines. To do this we set up a printcap entry for "laser" which says "rm=printserver rp=laser-real". We then also have an entry for "laser-real" which has the actual printer details. The idea is that users use the "laser" name for the printer all the time. This solution is documented in "Unix System Administration Handbook" p. 588, so I presume it should work. I've included the actual printcap entries below. >Description: 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. >How-To-Repeat: Try the following printcap on a machine called printserver. laser:\ :rm=printserver:rp=laser-real:mx#0:sf:sh:rw:sb:\ :sd=/var/spool/lpd/laser: laser-real:\ :mx#0:lp=/dev/null:\ :sd=/var/spool/lpd/laser-real:\ :lf=/var/log/lpd-errs:\ :af=/var/log/laser-real.acct:\ :if=/local/etc/laser-psif: You'll get the cryptic syslog message when you try to print: Jun 26 19:00:59 printserver lpd[1249]: /dev/lp: No such file or directory >Fix: I've included a patch to the stable source, which treats the printer as a remote printer iff you set RP and RP doesn't match the current printer. This means there won't be any unexpected printer loops. It's all done with cap library functions, so there shouldn't be many problems. With a little modification this could also be applied to the current source, only to the checkremote function in net.c, just after the line "pp->remote = 1;". However the current source looks more clever - so there might be a better solution. *** /usr/src/usr.sbin/lpr/common_source/common.c Fri Oct 31 21:19:24 1997 --- common.c Fri Jun 26 19:06:14 1998 *************** *** 304,309 **** --- 304,310 ---- char name[MAXHOSTNAMELEN]; register struct hostent *hp; static char errbuf[128]; + char *rp,*rp_b; remote = 0; /* assume printer is local */ if (RM != NULL) { *************** *** 330,338 **** --- 331,355 ---- /* * if the two hosts are not the same, * then the printer must be remote. + * otherwise check if the remote printer name + * and the current printer name match. + * (Can't trust RP, it may have been set to default). */ if (strcasecmp(name, hp->h_name) != 0) remote = 1; + else if (cgetstr(bp, "rp", &rp) > 0) { + if (cgetent(&rp_b, printcapdb, rp) == 0) { + if (cgetmatch(rp_b, printer) != 0) + remote = 1; + free(rp_b); + } else { + (void) snprintf(errbuf, sizeof(errbuf), + "can't find (local) remote printer %s", + rp); + return errbuf; + } + free(rp); + } } return NULL; } >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message