diff options
author | Damien Miller <djm@mindrot.org> | 2001-01-25 10:32:00 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2001-01-25 10:32:00 +1100 |
commit | 2a5c1cede026faec14b0903a0cdcc4e7ef554e32 (patch) | |
tree | 2534f2a4499b295d01521a5fe90aa1ba9eeb9146 | |
parent | 12aaa04e96be85a684d3f90db46bb62689796a93 (diff) |
- (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
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | bsd-bindresvport.c | 24 | ||||
-rw-r--r-- | bsd-bindresvport.h | 6 | ||||
-rw-r--r-- | bsd-rresvport.c | 5 | ||||
-rw-r--r-- | configure.in | 2 |
5 files changed, 35 insertions, 14 deletions
@@ -1,3 +1,15 @@ | |||
1 | 20010125 | ||
2 | - (djm) Sync bsd-* support files: | ||
3 | - deraadt@cvs.openbsd.org 2000/01/26 03:43:20 | ||
4 | [rresvport.c bindresvport.c] | ||
5 | new bindresvport() semantics that itojun, shin, jean-luc and i have | ||
6 | agreed on, which will be happy for the future. bindresvport_sa() for | ||
7 | sockaddr *, too. docs later.. | ||
8 | - deraadt@cvs.openbsd.org 2000/01/24 02:24:21 | ||
9 | [bindresvport.c] | ||
10 | in bindresvport(), if sin is non-NULL, example sin->sin_family for | ||
11 | the actual family being processed | ||
12 | |||
1 | 20010124 | 13 | 20010124 |
2 | - (bal) OpenBSD Resync | 14 | - (bal) OpenBSD Resync |
3 | - markus@cvs.openbsd.org 2001/01/23 10:45:10 | 15 | - markus@cvs.openbsd.org 2001/01/23 10:45:10 |
diff --git a/bsd-bindresvport.c b/bsd-bindresvport.c index 7faf73191..332bcb016 100644 --- a/bsd-bindresvport.c +++ b/bsd-bindresvport.c | |||
@@ -1,3 +1,5 @@ | |||
1 | /* This file has be modified from the original OpenBSD source */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for | 4 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for |
3 | * unrestricted use provided that this legend is included on all tape | 5 | * unrestricted use provided that this legend is included on all tape |
@@ -29,10 +31,10 @@ | |||
29 | 31 | ||
30 | #include "config.h" | 32 | #include "config.h" |
31 | 33 | ||
32 | #ifndef HAVE_BINDRESVPORT_AF | 34 | #ifndef HAVE_BINDRESVPORT_SA |
33 | 35 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char *rcsid = "$OpenBSD: bindresvport.c,v 1.11 1999/12/17 19:22:08 deraadt Exp $"; | 37 | static char *rcsid = "$OpenBSD: bindresvport.c,v 1.13 2000/01/26 03:43:21 deraadt Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 38 | #endif /* LIBC_SCCS and not lint */ |
37 | 39 | ||
38 | /* | 40 | /* |
@@ -51,12 +53,11 @@ static char *rcsid = "$OpenBSD: bindresvport.c,v 1.11 1999/12/17 19:22:08 deraad | |||
51 | * Bind a socket to a privileged IP port | 53 | * Bind a socket to a privileged IP port |
52 | */ | 54 | */ |
53 | int | 55 | int |
54 | bindresvport_af(sd, sa, af) | 56 | bindresvport_sa(sd, sa) |
55 | int sd; | 57 | int sd; |
56 | struct sockaddr *sa; | 58 | struct sockaddr *sa; |
57 | int af; | ||
58 | { | 59 | { |
59 | int error; | 60 | int error, af; |
60 | struct sockaddr_storage myaddr; | 61 | struct sockaddr_storage myaddr; |
61 | struct sockaddr_in *sin; | 62 | struct sockaddr_in *sin; |
62 | struct sockaddr_in6 *sin6; | 63 | struct sockaddr_in6 *sin6; |
@@ -68,7 +69,14 @@ bindresvport_af(sd, sa, af) | |||
68 | if (sa == NULL) { | 69 | if (sa == NULL) { |
69 | memset(&myaddr, 0, sizeof(myaddr)); | 70 | memset(&myaddr, 0, sizeof(myaddr)); |
70 | sa = (struct sockaddr *)&myaddr; | 71 | sa = (struct sockaddr *)&myaddr; |
71 | } | 72 | |
73 | if (getsockname(sd, sa, &salen) == -1) | ||
74 | return -1; /* errno is correctly set */ | ||
75 | |||
76 | af = sa->sa_family; | ||
77 | memset(&myaddr, 0, salen); | ||
78 | } else | ||
79 | af = sa->sa_family; | ||
72 | 80 | ||
73 | if (af == AF_INET) { | 81 | if (af == AF_INET) { |
74 | sin = (struct sockaddr_in *)sa; | 82 | sin = (struct sockaddr_in *)sa; |
@@ -95,7 +103,7 @@ bindresvport_af(sd, sa, af) | |||
95 | *portp = htons(port); | 103 | *portp = htons(port); |
96 | 104 | ||
97 | error = bind(sd, sa, salen); | 105 | error = bind(sd, sa, salen); |
98 | 106 | ||
99 | /* Terminate on success */ | 107 | /* Terminate on success */ |
100 | if (error == 0) | 108 | if (error == 0) |
101 | break; | 109 | break; |
@@ -112,4 +120,4 @@ bindresvport_af(sd, sa, af) | |||
112 | return (error); | 120 | return (error); |
113 | } | 121 | } |
114 | 122 | ||
115 | #endif /* HAVE_BINDRESVPORT_AF */ | 123 | #endif /* HAVE_BINDRESVPORT_SA */ |
diff --git a/bsd-bindresvport.h b/bsd-bindresvport.h index 4ef4c2f3a..6dbf8a2cb 100644 --- a/bsd-bindresvport.h +++ b/bsd-bindresvport.h | |||
@@ -3,8 +3,8 @@ | |||
3 | 3 | ||
4 | #include "config.h" | 4 | #include "config.h" |
5 | 5 | ||
6 | #ifndef HAVE_BINDRESVPORT_AF | 6 | #ifndef HAVE_BINDRESVPORT_SA |
7 | int bindresvport_af(int sd, struct sockaddr *sa, int af); | 7 | int bindresvport_sa(int sd, struct sockaddr *sa); |
8 | #endif /* !HAVE_BINDRESVPORT_AF */ | 8 | #endif /* !HAVE_BINDRESVPORT_SA */ |
9 | 9 | ||
10 | #endif /* _BSD_BINDRESVPORT_H */ | 10 | #endif /* _BSD_BINDRESVPORT_H */ |
diff --git a/bsd-rresvport.c b/bsd-rresvport.c index 392768c02..44eac2036 100644 --- a/bsd-rresvport.c +++ b/bsd-rresvport.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #ifndef HAVE_RRESVPORT_AF | 38 | #ifndef HAVE_RRESVPORT_AF |
39 | 39 | ||
40 | #if defined(LIBC_SCCS) && !defined(lint) | 40 | #if defined(LIBC_SCCS) && !defined(lint) |
41 | static char *rcsid = "$OpenBSD: rresvport.c,v 1.4 1999/12/17 20:48:03 deraadt Exp $"; | 41 | static char *rcsid = "$OpenBSD: rresvport.c,v 1.5 2000/01/26 03:43:20 deraadt Exp $"; |
42 | #endif /* LIBC_SCCS and not lint */ | 42 | #endif /* LIBC_SCCS and not lint */ |
43 | 43 | ||
44 | #include "includes.h" | 44 | #include "includes.h" |
@@ -94,7 +94,8 @@ rresvport_af(int *alport, sa_family_t af) | |||
94 | } | 94 | } |
95 | 95 | ||
96 | *portp = 0; | 96 | *portp = 0; |
97 | if (bindresvport_af(s, sa, af) == -1) { | 97 | sa->sa_family = af; |
98 | if (bindresvport_sa(s, sa) == -1) { | ||
98 | (void)close(s); | 99 | (void)close(s); |
99 | return (-1); | 100 | return (-1); |
100 | } | 101 | } |
diff --git a/configure.in b/configure.in index 7cc58582b..f217e5ae9 100644 --- a/configure.in +++ b/configure.in | |||
@@ -315,7 +315,7 @@ AC_CHECK_FUNC(utimes, | |||
315 | 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) | 315 | 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) |
316 | 316 | ||
317 | dnl Checks for library functions. | 317 | dnl Checks for library functions. |
318 | 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) | 318 | 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) |
319 | dnl Checks for time functions | 319 | dnl Checks for time functions |
320 | AC_CHECK_FUNCS(gettimeofday time) | 320 | AC_CHECK_FUNCS(gettimeofday time) |
321 | dnl Checks for libutil functions | 321 | dnl Checks for libutil functions |