summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2005-02-28 03:19:40 +0000
committerneilbrown <neilbrown>2005-02-28 03:19:40 +0000
commitf50dd6fa181def466c455a9d019a3aacb1b33267 (patch)
tree370ec4b6723fd6d5906b856fb2bf77fdadcbb5d4 /utils
parent40136aaabfddc107fa5532a1314e2055a08fc836 (diff)
downloadnfs-utils-f50dd6fa181def466c455a9d019a3aacb1b33267.tar.gz
nfs-utils-f50dd6fa181def466c455a9d019a3aacb1b33267.tar.xz
nfs-utils-f50dd6fa181def466c455a9d019a3aacb1b33267.zip
Make statd_get_socket actually honour the 'port' parameter.
Diffstat (limited to 'utils')
-rw-r--r--utils/statd/rmtcall.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/utils/statd/rmtcall.c b/utils/statd/rmtcall.c
index f6798f9..474bbb4 100644
--- a/utils/statd/rmtcall.c
+++ b/utils/statd/rmtcall.c
@@ -65,7 +65,7 @@ statd_get_socket(int port)
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
- sin.sin_port = port;
+ sin.sin_addr.s_addr = INADDR_ANY;
/*
* If a local hostname is given (-n option to statd), bind to the address
* specified. This is required to support clients that ignore the mon_name in
@@ -76,11 +76,18 @@ statd_get_socket(int port)
if (hp)
sin.sin_addr = *(struct in_addr *) hp->h_addr;
}
+ if (port != 0) {
+ sin.sin_port = htons(port);
+ if (bind(sockfd, &sin, sizeof(sin)) == 0)
+ goto out_success;
+ note(N_CRIT, "statd: failed to bind to outgoing port, %d\n"
+ " falling back on randomly chosen port\n", port);
+ }
if (bindresvport(sockfd, &sin) < 0) {
dprintf(N_WARNING,
"process_hosts: can't bind to reserved port\n");
}
-
+out_success:
return sockfd;
}