File LPRng-3.8.28-port.diff of Package lprng

--- man/printcap.n
+++ man/printcap.n
@@ -353,10 +353,10 @@
 lk	D	bool	false	lock the lp device to force arbitration
 lockfile	D	str	/var/spool/lpd/lpd
 				lpd lock file (used only in lpd.conf).
-                The lpd_port port value is appended
-                to the lockfile value to provide a unique lockfile
-                even when different versions of LPRng are running
-                on the same system.
+				The lpd_port port value is appended
+				to the lockfile value to provide a unique lockfile
+				even when different versions of LPRng are running
+				on the same system.
 logger_destination	D	str	NULL
 				destination for logging information.  Format is
 				host%port
@@ -384,13 +384,20 @@
 				interval.
 lpd_poll_servers_started	A	num	10
 				Start 'lpd_poll_servers_started' queues at once
-lpd_port	D	str	printer
-                format is [ipaddr%]port.  If the ipaddr is present
-                then the lpd listening socket is bound to the specified
-                ip address and port only, otherwise it is bound to all
-                interfaces. If the port value is not a number then the
-				then the getservbyname() system call is used to get the
-				port number.
+lpd_port	A	str	printer
+				format is [ipaddr%]port. What port lpr should connect to
+				or what port lpd sould listen at if 'lpd_listen_port' is
+				NULL. If the port value is not a number then the
+				getservbyname() system call is used to get the port number.
+lpd_listen_port	D	str	NULL
+				format is [ipaddr%]port.  If the ipaddr is present
+				then the lpd listening socket is bound to the specified
+				ip address and port only, otherwise it is bound to all
+				interfaces. If the port value is not a number then the
+				getservbyname() system call is used to get the port number
+				unless the value is 'off' or NULL. If the value is NULL,
+				the value of 'lpd_port' will be used. The values 'off' and
+				zero suppress opening a port or socket.
 lpd_printcap_path	D	str	(see source)
 				printcap path for lpd, used instead of printcap path
 				(configuration value only)
--- src/common/lpd.c
+++ src/common/lpd.c
@@ -207,14 +207,18 @@
 		s = Lpd_listen_port_arg;
 		if( ISNULL(s) ) s = Lpd_listen_port_DYN;
 		if( ISNULL(s) ) s = Lpd_port_DYN;
-		if( !ISNULL(s) && safestrcasecmp( s,"off") && strtol(s,0,0) ){
-			sock = Link_listen(s);
-			DEBUG1("lpd: listening socket fd %d",sock);
-			if( sock < 0 ){
-				Errorcode = 1;
-				DIEMSG("Cannot bind to lpd port '%s'", s);
+		if( !ISNULL(s) && safestrcasecmp( s,"off") ){
+			char  *t = NULL;
+			long  p = strtol(s,&t,0);
+			if( t && (*t || p) ) {
+				sock = Link_listen(s);
+				DEBUG1("lpd: listening socket fd %d",sock);
+				if( sock < 0 ){
+					Errorcode = 1;
+					DIEMSG("Cannot bind to lpd port '%s'", s);
+				}
+				if( sock >= max_socks ) max_socks = sock;
 			}
-			if( sock >= max_socks ) max_socks = sock;
 		}
 
 		s = Ipp_listen_port_arg;
--- src/common/vars.c
+++ src/common/vars.c
@@ -326,7 +326,7 @@
    /*  interval in secs between servicing all queues */
 { "lpd_poll_time", 0,  INTEGER_K,  &Poll_time_DYN,0,0,"=600"},
    /* lpd port */
-{ "lpd_port", 0, STRING_K, &Lpd_port_DYN,0,0,"=515"},
+{ "lpd_port", 0, STRING_K, &Lpd_port_DYN,0,0,"=printer"},
    /* lpd printcap path */
 { "lpd_printcap_path", 0, STRING_K, &Lpd_printcap_path_DYN,1,0,"=" LPD_PRINTCAP_PATH},
    /* maximum number of lpq status queries kept in cache */
openSUSE Build Service is sponsored by