Package: lpr
Version: 1:2008.05.17
Severity: wishlist
Tags: upstream patch

It would be very useful to be able to specify remote host ports in "rm", to
take advantage of tunnels (e.g. via ssh -L) and more generally to connect to
remote lpd daemons listening on ports different from the default 515.

A patch is attached to extend the syntax of the rm field in printcap to accept
expressions like
        :rm=hostname%port:
in addition to the usual 
        :rm=hostname:
I believe that '%' is not allowed in host names, therefore this change
shouldn't break anything, but feel free to change it if I'm wrong.

Best regards,
        giuseppe

-- System Information:
Debian Release: 6.0.4
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash

Versions of packages lpr depends on:
ii  libc6                         2.11.3-2   Embedded GNU C Library: Shared lib
ii  netbase                       4.45       Basic TCP/IP networking system

lpr recommends no packages.

Versions of packages lpr suggests:
ii  ghostscript-x [gs]          8.71~dfsg2-9 The GPL Ghostscript PostScript/PDF
pn  magicfilter | apsfilter     <none>       (no description available)

-- no debconf information
diff -ur lpr-2008.05.17/common_source/common.c lpr-2008.05.17.new/common_source/common.c
--- lpr-2008.05.17/common_source/common.c	2008-05-18 00:27:32.000000000 +0200
+++ lpr-2008.05.17.new/common_source/common.c	2012-02-16 17:02:22.000000000 +0100
@@ -342,6 +342,7 @@
 	struct sockaddr_in6 sin6;
 	struct sockaddr_in6 *sin6p;
 #endif
+	char *effRM;
 
 	remote = 0;	/* assume printer is local on failure */
 
@@ -366,7 +367,14 @@
 	hints.ai_socktype = SOCK_STREAM;
 	res = NULL;
 	siginterrupt(SIGINT, 1);
-	error = getaddrinfo(RM, NULL, &hints, &res0);
+	if ((effRM = strchr(RM, '%'))) {
+	    effRM = strndup(RM, effRM - RM);
+	} else {
+	    effRM = RM;
+	}
+	error = getaddrinfo(effRM ? effRM : RM, NULL, &hints, &res0);
+	if (effRM != RM && effRM)
+	    free(effRM);
 	siginterrupt(SIGINT, 0);
 	if (error) {
 		(void)snprintf(errbuf, sizeof(errbuf),
diff -ur lpr-2008.05.17/lpd/printjob.c lpr-2008.05.17.new/lpd/printjob.c
--- lpr-2008.05.17/lpd/printjob.c	2008-05-18 01:31:23.000000000 +0200
+++ lpr-2008.05.17.new/lpd/printjob.c	2012-02-16 17:02:59.000000000 +0100
@@ -1463,10 +1463,21 @@
 {
 	int i, n;
 	int resp;
+	char *effRM;
+	int effport;
+
+	if ((effRM = strchr(RM, '%'))) {
+	    effport = atoi(effRM + 1);
+	    effRM = strndup(RM, effRM - RM);
+	} else {
+	    effRM = RM;
+	    effport = 0;
+	}
 
 	for (i = 1; ; i = i < 256 ? i << 1 : i) {
 		resp = -1;
-		pfd = getport(RM, 0);
+		
+		pfd = getport(effRM ? effRM : RM, effport);
 		if (pfd >= 0) {
 			if ((n = snprintf(line, sizeof(line), "\2%s\n", RP)) >=
 			    sizeof(line) || n == -1)
@@ -1487,6 +1498,9 @@
 		}
 		sleep(i);
 	}
+	if (effRM && effRM != RM) 
+	    free(effRM);
+
 	pstatus("sending to %s", RM);
 }
 

Reply via email to