Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F162407789
D57181.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D57181.diff
View Options
diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 19, 2026
+.Dd May 25, 2026
.Dt LPD 8
.Os
.Sh NAME
@@ -35,7 +35,7 @@
.Nm
.Op Fl cdlpsFW46
.Op Fl t Ar timeout
-.Op Ar port#
+.Op Ar port
.Sh DEPRECATION NOTICE
This facility is scheduled for removal prior to the release of
.Fx 16.0 .
@@ -143,13 +143,13 @@
Inet6 only.
.It Fl 46
Inet and inet6 (default).
-.It Ar "port#"
-The Internet port number used to rendezvous
-with other processes is normally obtained with
-.Xr getservbyname 3
-but can be changed with the
-.Ar port#
-argument.
+.It Ar "port"
+The Internet port number or service name used to rendezvous with other
+processes.
+Can be any number from 1 to 65,535 or any service name defined in
+.Pa /etc/services .
+Defaults to
+.Li printer .
.El
.Pp
Access control is provided by two means.
@@ -346,6 +346,7 @@
.Xr syslog 3 ,
.Xr hosts.lpd 5 ,
.Xr printcap 5 ,
+.Xr services 5 ,
.Xr chkprintcap 8 ,
.Xr lpc 8 ,
.Xr pac 8
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -101,7 +101,7 @@
static void chkhost(struct sockaddr *_f, int _ch_opts);
static int ckqueue(struct printer *_pp);
static void fhosterr(int _ch_opts, char *_sysmsg, char *_usermsg);
-static int *socksetup(int _af, int _debuglvl);
+static int *socksetup(int _af, const char *portstr, int _debuglvl);
static void usage(void);
/* XXX from libc/net/rcmd.c */
@@ -124,7 +124,7 @@
struct sockaddr_storage frominet;
socklen_t fromlen;
sigset_t omask, nmask;
- struct servent *sp, serv;
+ const char *portstr = "printer";
int inet_flag = 0, inet6_flag = 0;
euid = geteuid(); /* these shouldn't be different */
@@ -215,19 +215,9 @@
if (errs)
usage();
- if (argc == 1) {
- if ((i = atoi(argv[0])) == 0)
- usage();
- if (i < 0 || i > USHRT_MAX)
- errx(EX_USAGE, "port # %d is invalid", i);
-
- serv.s_port = htons(i);
- sp = &serv;
+ if (argc > 0) {
+ portstr = *argv++;
argc--;
- } else {
- sp = getservbyname("printer", "tcp");
- if (sp == NULL)
- errx(EX_OSFILE, "printer/tcp: unknown service");
}
if (argc != 0)
@@ -339,7 +329,7 @@
FD_SET(funix, &defreadfds);
listen(funix, 5);
if (sflag == 0) {
- finet = socksetup(family, socket_debug);
+ finet = socksetup(family, portstr, socket_debug);
} else
finet = NULL; /* pretend we couldn't open TCP socket. */
if (finet) {
@@ -855,7 +845,7 @@
/* if af is PF_UNSPEC more than one socket may be returned */
/* the returned list is dynamically allocated, so caller needs to free it */
static int *
-socksetup(int af, int debuglvl)
+socksetup(int af, const char *portstr, int debuglvl)
{
struct addrinfo hints, *res, *r;
int error, maxs, *s, *socks;
@@ -865,7 +855,7 @@
hints.ai_flags = AI_PASSIVE;
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
- error = getaddrinfo(NULL, "printer", &hints, &res);
+ error = getaddrinfo(NULL, portstr, &hints, &res);
if (error) {
syslog(LOG_ERR, "%s", gai_strerror(error));
mcleanup(0);
@@ -934,9 +924,9 @@
usage(void)
{
#ifdef INET6
- fprintf(stderr, "usage: lpd [-cdlsFW46] [port#]\n");
+ fprintf(stderr, "usage: lpd [-cdlsFW46] [port]\n");
#else
- fprintf(stderr, "usage: lpd [-cdlsFW] [port#]\n");
+ fprintf(stderr, "usage: lpd [-cdlsFW] [port]\n");
#endif
exit(EX_USAGE);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jul 13, 11:20 PM (12 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35048550
Default Alt Text
D57181.diff (3 KB)
Attached To
Mode
D57181: lpd: Restore ability to specify a port number
Attached
Detach File
Event Timeline
Log In to Comment