diff options
author | peter <peter@FreeBSD.org> | 1996-12-30 14:12:36 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-12-30 14:12:36 +0000 |
commit | 3f7f69c440e3515ba1e7a2b85eccaa91dc75feca (patch) | |
tree | d0b62aab1d6753e4217040b652dbe97e68425bd3 | |
parent | 55c2a4947b6ad40d28901906fbdc9983afd7a373 (diff) | |
download | FreeBSD-src-3f7f69c440e3515ba1e7a2b85eccaa91dc75feca.zip FreeBSD-src-3f7f69c440e3515ba1e7a2b85eccaa91dc75feca.tar.gz |
- Man page fix, updates.
- minor cosmetic tweaks
Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
-rw-r--r-- | lib/libc/rpc/bindresvport.3 | 9 | ||||
-rw-r--r-- | lib/libc/rpc/bindresvport.c | 10 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/libc/rpc/bindresvport.3 b/lib/libc/rpc/bindresvport.3 index 8b9f3bf..5dd71e3 100644 --- a/lib/libc/rpc/bindresvport.3 +++ b/lib/libc/rpc/bindresvport.3 @@ -9,11 +9,11 @@ .Fd #include <sys/types.h> .Fd #include <netinet/in.h> .Ft int -.Fn bindresvport "int sd "struct sockaddr_in **sin" +.Fn bindresvport "int sd" "struct sockaddr_in **sin" .Sh DESCRIPTION .Nm Bindresvport is used to bind a socket descriptor to a privileged -.Em IP +.Tn IP port, that is, a port number in the range 0-1023. The routine returns 0 if it is successful, @@ -23,3 +23,8 @@ set to reflect the cause of the error. .Pp Only root can bind to a privileged port; this call will fail for any other users. +.Pp +If the value of sin->sin_port is non-zero +.Fn bindresvport +will attempt to use that specific port. If it fails, it chooses another +privileged port automatically. diff --git a/lib/libc/rpc/bindresvport.c b/lib/libc/rpc/bindresvport.c index 4411ba9..9508818 100644 --- a/lib/libc/rpc/bindresvport.c +++ b/lib/libc/rpc/bindresvport.c @@ -31,7 +31,7 @@ /*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/ /*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/ /*from: OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp */ -static char *rcsid = "$Id: bindresvport.c,v 1.4 1996/06/10 00:49:15 jraynard Exp $"; +static char *rcsid = "$Id: bindresvport.c,v 1.5 1996/08/12 14:09:46 peter Exp $"; #endif /* @@ -61,8 +61,8 @@ bindresvport(sd, sin) if (sin == (struct sockaddr_in *)0) { sin = &myaddr; - memset(sin, 0, sizeof(*sin)); - sin->sin_len = sizeof(*sin); + memset(sin, 0, sinlen); + sin->sin_len = sinlen; sin->sin_family = AF_INET; } else if (sin->sin_family != AF_INET) { errno = EPFNOSUPPORT; @@ -83,7 +83,7 @@ bindresvport(sd, sin) return(error); } - error = bind(sd, (struct sockaddr *)sin, sizeof(*sin)); + error = bind(sd, (struct sockaddr *)sin, sinlen); if (sin->sin_port == 0) { int saved_errno = errno; @@ -96,8 +96,6 @@ bindresvport(sd, sin) } if (sin != &myaddr) { - int sinlen = sizeof(*sin); - /* Hmm, what did the kernel assign... */ if (getsockname(sd, (struct sockaddr *)sin, &sinlen) < 0) |