Bug 3683 - patch to add missing network printer support
patch to add missing network printer support
Status: CLOSED NEXTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: lpr (Show other bugs)
6.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-06-23 15:53 EDT by djm
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-06-23 18:57:18 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description djm 1999-06-23 15:53:55 EDT
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 18:57:59 EDT
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.