Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 3683 - patch to add missing network printer support
Summary: patch to add missing network printer support
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: lpr
Version: 6.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: David Lawrence
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-06-23 19:53 UTC by djm
Modified: 2008-05-01 15:37 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 1999-06-23 22:57:18 UTC


Attachments (Terms of Use)

Description djm 1999-06-23 19:53:55 UTC
The version of the lpr package in RH6.0 doesn't support
network printers in the lp= capability.  HP LaserJets with
the JetDirect Ethernet interface are an example.  Here is a
patch to add the missing functionality, adapted from the
current BSD lpd that comes with BSD/OS 4.0.1.  The extended
syntax for the lp= directive is either a file name or
service@ipaddr.

This should be applied in the directory
/usr/src/redhat/BUILD/lpr-0.35/lpd

--- printjob.c.dist	Tue Feb 16 15:01:45 1999
+++ printjob.c	Tue Jun 22 14:08:15 1999
@@ -1464,6 +1464,44 @@
 	char *cp;

 	if (!sendtorem && *LP) {
+		if ((cp = strchr(LP, '@')) != NULL) {
+			char savech;
+			struct servent *sp;
+			struct hostent *hp;
+			struct sockaddr_in sin;
+
+			savech = *cp;
+			*cp = '\0';
+			if ((sp = getservbyname(LP, "tcp")) != NULL) {
+				sin.sin_port = sp->s_port;
+			} else if (isdigit(*LP)) {
+				sin.sin_port = htons(atoi(LP));
+			} else {
+				syslog(LOG_ERR, "%s: bad service spec", LP);
+				exit(1);
+			}
+			*cp = savech;
+			if (inet_aton(cp+1, &sin.sin_addr))
+				NULL;
+			else if ((hp = gethostbyname(cp+1)) != NULL)
+				sin.sin_addr.s_addr = *(u_long *)hp->h_addr;
+			else {
+				syslog(LOG_ERR, "%s: bad host spec", cp+1);
+				exit(1);
+			}
+			if ((pfd = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) <
0){
+				syslog(LOG_ERR, "socket: %m");
+				exit(1);
+			}
+#ifndef __linux__
+			sin.sin_len = sizeof sin;
+#endif
+			sin.sin_family = AF_INET;
+			if (connect(pfd, (struct sockaddr*)&sin, sizeof sin)
<0){
+				syslog(LOG_ERR, "connect: %m");
+				exit(1);
+			}
+		} else {
 		for (i = 1; ; i = i < 32 ? i << 1 : i) {
 			pfd = open(LP, RW ? O_RDWR : O_WRONLY);
 			if (pfd >= 0)
@@ -1478,6 +1516,7 @@
 		}
 		if (isatty(pfd))
 			setty();
+		}
 		pstatus("%s is ready and printing", printer);
 	} else if (RM != NULL) {
 		for (i = 1; ; i = i < 256 ? i << 1 : i) {

Comment 1 Bill Nottingham 1999-06-23 22:57:59 UTC
Thanks for the patch.

applied in lpr-0.38, available in the next Raw Hide release...


Note You need to log in before you can comment on or make changes to this bug.