Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/lpr/lpd listen to the port number specified on argu...
details: https://anonhg.NetBSD.org/src/rev/dec44cf48a8f
branches: trunk
changeset: 503192:dec44cf48a8f
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Feb 02 14:20:33 2001 +0000
description:
listen to the port number specified on argument, as advertised
in document. part of PR 12112 from feico%pasta.cs.uit.no@localhost.
diffstat:
usr.sbin/lpr/lpd/lpd.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diffs (83 lines):
diff -r 06a98000ccda -r dec44cf48a8f usr.sbin/lpr/lpd/lpd.c
--- a/usr.sbin/lpr/lpd/lpd.c Fri Feb 02 13:08:04 2001 +0000
+++ b/usr.sbin/lpr/lpd/lpd.c Fri Feb 02 14:20:33 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lpd.c,v 1.25 2000/10/03 13:54:31 itojun Exp $ */
+/* $NetBSD: lpd.c,v 1.26 2001/02/02 14:20:33 itojun Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
@@ -45,7 +45,7 @@
#if 0
static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
#else
-__RCSID("$NetBSD: lpd.c,v 1.25 2000/10/03 13:54:31 itojun Exp $");
+__RCSID("$NetBSD: lpd.c,v 1.26 2001/02/02 14:20:33 itojun Exp $");
#endif
#endif /* not lint */
@@ -126,7 +126,7 @@
static void chkhost __P((struct sockaddr *));
static int ckqueue __P((char *));
static void usage __P((void));
-static int *socksetup __P((int, int));
+static int *socksetup __P((int, int, const char *));
uid_t uid, euid;
int child_count;
@@ -143,7 +143,8 @@
int lfd, errs, i, f, funix, *finet;
int child_max = 32; /* more then enough to hose the system */
int options = 0;
- struct servent *sp, serv;
+ struct servent *sp;
+ const char *port = "printer";
euid = geteuid(); /* these shouldn't be different */
uid = getuid();
@@ -207,13 +208,12 @@
if (i < 0 || i > USHRT_MAX)
errx(1, "port # %d is invalid", i);
- serv.s_port = htons(i);
- sp = &serv;
+ port = argv[0];
break;
case 0:
- sp = getservbyname("printer", "tcp");
+ sp = getservbyname(port, "tcp");
if (sp == NULL)
- errx(1, "printer/tcp: unknown service");
+ errx(1, "%s/tcp: unknown service", port);
break;
default:
usage();
@@ -290,7 +290,7 @@
FD_SET(funix, &defreadfds);
listen(funix, 5);
if (!sflag || blist_addrs)
- finet = socksetup(PF_UNSPEC, options);
+ finet = socksetup(PF_UNSPEC, options, port);
else
finet = NULL; /* pretend we couldn't open TCP socket. */
@@ -696,8 +696,9 @@
/* if af is PF_UNSPEC more than one socket may be returned */
/* the returned list is dynamically allocated, so caller needs to free it */
int *
-socksetup(af, options)
+socksetup(af, options, port)
int af, options;
+ const char *port;
{
struct addrinfo hints, *res, *r;
int error, maxs = 0, *s, *socks = NULL, blidx = 0;
@@ -709,7 +710,7 @@
hints.ai_family = af;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo((blist_addrs == 0) ? NULL : blist[blidx],
- "printer", &hints, &res);
+ port ? port : "printer", &hints, &res);
if (error) {
if (blist_addrs)
syslog(LOG_ERR, "%s: %s", blist[blidx],
Home |
Main Index |
Thread Index |
Old Index