* sunrpc/bindrsvprt.c (LOWPORT): Apparently some mountd
implementations are broken and don't accept ports < 512.
This commit is contained in:
parent
c179df4e93
commit
8fd2bb35c7
|
@ -1,3 +1,8 @@
|
||||||
|
2005-05-23 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* sunrpc/bindrsvprt.c (LOWPORT): Apparently some mountd
|
||||||
|
implementations are broken and don't accept ports < 512.
|
||||||
|
|
||||||
2005-05-22 Dmitry V. Levin <ldv@altlinux.org>
|
2005-05-22 Dmitry V. Levin <ldv@altlinux.org>
|
||||||
|
|
||||||
[BZ #961]
|
[BZ #961]
|
||||||
|
|
|
@ -43,13 +43,12 @@
|
||||||
int
|
int
|
||||||
bindresvport (int sd, struct sockaddr_in *sin)
|
bindresvport (int sd, struct sockaddr_in *sin)
|
||||||
{
|
{
|
||||||
int res;
|
|
||||||
static short port;
|
static short port;
|
||||||
struct sockaddr_in myaddr;
|
struct sockaddr_in myaddr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#define STARTPORT 600
|
#define STARTPORT 600
|
||||||
#define LOWPORT 200
|
#define LOWPORT 512
|
||||||
#define ENDPORT (IPPORT_RESERVED - 1)
|
#define ENDPORT (IPPORT_RESERVED - 1)
|
||||||
#define NPORTS (ENDPORT - STARTPORT + 1)
|
#define NPORTS (ENDPORT - STARTPORT + 1)
|
||||||
static short startport = STARTPORT;
|
static short startport = STARTPORT;
|
||||||
|
@ -70,12 +69,13 @@ bindresvport (int sd, struct sockaddr_in *sin)
|
||||||
{
|
{
|
||||||
port = (__getpid () % NPORTS) + STARTPORT;
|
port = (__getpid () % NPORTS) + STARTPORT;
|
||||||
}
|
}
|
||||||
res = -1;
|
|
||||||
__set_errno (EADDRINUSE);
|
/* Initialize to make gcc happy. */
|
||||||
|
int res = -1;
|
||||||
|
|
||||||
int nports = ENDPORT - startport + 1;
|
int nports = ENDPORT - startport + 1;
|
||||||
again:
|
again:
|
||||||
for (i = 0; i < nports && res < 0 && errno == EADDRINUSE; ++i)
|
for (i = 0; i < nports; ++i)
|
||||||
{
|
{
|
||||||
sin->sin_port = htons (port++);
|
sin->sin_port = htons (port++);
|
||||||
if (port > ENDPORT)
|
if (port > ENDPORT)
|
||||||
|
@ -83,6 +83,8 @@ bindresvport (int sd, struct sockaddr_in *sin)
|
||||||
port = startport;
|
port = startport;
|
||||||
}
|
}
|
||||||
res = __bind (sd, sin, sizeof (struct sockaddr_in));
|
res = __bind (sd, sin, sizeof (struct sockaddr_in));
|
||||||
|
if (res >= 0 || errno != EADDRINUSE)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i == nports && startport != LOWPORT)
|
if (i == nports && startport != LOWPORT)
|
||||||
|
|
Loading…
Reference in New Issue