+20010125
+ - (djm) Sync bsd-* support files:
+ - deraadt@cvs.openbsd.org 2000/01/26 03:43:20
+ [rresvport.c bindresvport.c]
+ new bindresvport() semantics that itojun, shin, jean-luc and i have
+ agreed on, which will be happy for the future. bindresvport_sa() for
+ sockaddr *, too. docs later..
+ - deraadt@cvs.openbsd.org 2000/01/24 02:24:21
+ [bindresvport.c]
+ in bindresvport(), if sin is non-NULL, example sin->sin_family for
+ the actual family being processed
+
20010124
- (bal) OpenBSD Resync
- markus@cvs.openbsd.org 2001/01/23 10:45:10
+/* This file has be modified from the original OpenBSD source */
+
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
#include "config.h"
-#ifndef HAVE_BINDRESVPORT_AF
+#ifndef HAVE_BINDRESVPORT_SA
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: bindresvport.c,v 1.11 1999/12/17 19:22:08 deraadt Exp $";
+static char *rcsid = "$OpenBSD: bindresvport.c,v 1.13 2000/01/26 03:43:21 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
* Bind a socket to a privileged IP port
*/
int
-bindresvport_af(sd, sa, af)
+bindresvport_sa(sd, sa)
int sd;
struct sockaddr *sa;
- int af;
{
- int error;
+ int error, af;
struct sockaddr_storage myaddr;
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
if (sa == NULL) {
memset(&myaddr, 0, sizeof(myaddr));
sa = (struct sockaddr *)&myaddr;
- }
+
+ if (getsockname(sd, sa, &salen) == -1)
+ return -1; /* errno is correctly set */
+
+ af = sa->sa_family;
+ memset(&myaddr, 0, salen);
+ } else
+ af = sa->sa_family;
if (af == AF_INET) {
sin = (struct sockaddr_in *)sa;
*portp = htons(port);
error = bind(sd, sa, salen);
-
+
/* Terminate on success */
if (error == 0)
break;
return (error);
}
-#endif /* HAVE_BINDRESVPORT_AF */
+#endif /* HAVE_BINDRESVPORT_SA */
#include "config.h"
-#ifndef HAVE_BINDRESVPORT_AF
-int bindresvport_af(int sd, struct sockaddr *sa, int af);
-#endif /* !HAVE_BINDRESVPORT_AF */
+#ifndef HAVE_BINDRESVPORT_SA
+int bindresvport_sa(int sd, struct sockaddr *sa);
+#endif /* !HAVE_BINDRESVPORT_SA */
#endif /* _BSD_BINDRESVPORT_H */
#ifndef HAVE_RRESVPORT_AF
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: rresvport.c,v 1.4 1999/12/17 20:48:03 deraadt Exp $";
+static char *rcsid = "$OpenBSD: rresvport.c,v 1.5 2000/01/26 03:43:20 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include "includes.h"
}
*portp = 0;
- if (bindresvport_af(s, sa, af) == -1) {
+ sa->sa_family = af;
+ if (bindresvport_sa(s, sa) == -1) {
(void)close(s);
return (-1);
}
AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h getopt.h lastlog.h limits.h login.h login_cap.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h regex.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/queue.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h sys/un.h stddef.h time.h ttyent.h usersec.h util.h utime.h utmp.h utmpx.h vis.h)
dnl Checks for library functions.
-AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock fchmod freeaddrinfo futimes gai_strerror getcwd getaddrinfo getgrouplist getnameinfo getrlimit getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty realpath rresvport_af setdtablesize setenv seteuid setlogin setproctitle setreuid setrlimit setsid sigaction sigvec snprintf strerror strlcat strlcpy strmode strsep strtok_r sysconf utimes vsnprintf vhangup vis waitpid _getpty __b64_ntop)
+AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_sa clock fchmod freeaddrinfo futimes gai_strerror getcwd getaddrinfo getgrouplist getnameinfo getrlimit getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty realpath rresvport_af setdtablesize setenv seteuid setlogin setproctitle setreuid setrlimit setsid sigaction sigvec snprintf strerror strlcat strlcpy strmode strsep strtok_r sysconf utimes vsnprintf vhangup vis waitpid _getpty __b64_ntop)
dnl Checks for time functions
AC_CHECK_FUNCS(gettimeofday time)
dnl Checks for libutil functions