Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Jun 98 19:34:50 +0100 (BST)
From:      dwmalone@maths.tcd.ie
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   bin/7081: lpd remote printer on local host broken.
Message-ID:  <9806261934.aa02238@boole.maths.tcd.ie>

next in thread | raw e-mail | index | archive | help

>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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9806261934.aa02238>