summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-13 16:00:09 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-13 16:00:09 +0000
commit417697b9a38e31c0c0ed13d77c2f1d8add24c300 (patch)
tree73ed846e97daf55725e5f52ea6f5fbb4e7b66b32 /usr.sbin
parente75d648fe3ce72c9c354aeff44a2b7ad5ae6445e (diff)
bindresvport() for rpc ports
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/inetd/inetd.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 986bd1d6b54..81fc5b0813f 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inetd.c,v 1.2 1996/03/25 15:55:24 niklas Exp $ */
+/* $OpenBSD: inetd.c,v 1.3 1996/05/13 16:00:08 deraadt Exp $ */
/* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */
/*
* Copyright (c) 1983,1991 The Regents of the University of California.
@@ -41,7 +41,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/
-static char rcsid[] = "$OpenBSD: inetd.c,v 1.2 1996/03/25 15:55:24 niklas Exp $";
+static char rcsid[] = "$OpenBSD: inetd.c,v 1.3 1996/05/13 16:00:08 deraadt Exp $";
#endif /* not lint */
/*
@@ -725,6 +725,7 @@ setup(sep)
register struct servtab *sep;
{
int on = 1;
+ int r;
if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) {
syslog(LOG_ERR, "%s/%s: socket: %m",
@@ -739,7 +740,12 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
if (turnon(sep->se_fd, SO_REUSEADDR) < 0)
syslog(LOG_ERR, "setsockopt (SO_REUSEADDR): %m");
#undef turnon
- if (bind(sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size) < 0) {
+ if (isrpcservice(sep))
+ r = bindresvport(sep->se_fd, &sep->se_ctrladdr,
+ sep->se_ctrladdr_size);
+ else
+ r = bind(sep->se_fd, &sep->se_ctrladdr, sep->se_ctrladdr_size);
+ if (r < 0) {
syslog(LOG_ERR, "%s/%s: bind: %m",
sep->se_service, sep->se_proto);
(void) close(sep->se_fd);