- Man page fix, updates.

- minor cosmetic tweaks

Obtained from: a diff of FreeBSD vs. OpenBSD/NetBSD rpc code.
This commit is contained in:
peter 1996-12-30 14:12:36 +00:00
parent 07d5a36288
commit a1d408df49
2 changed files with 11 additions and 8 deletions

View File

@ -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.

View File

@ -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)