On systems with IP_PORTRANGE, have ftpd use `high-numbered'
ports by default. Add a -U option to get the old behavior. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@10583 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -221,6 +221,31 @@ socket_set_port (struct sockaddr *sa, int port)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the range of ports to use when binding with port = 0.
|
||||
*/
|
||||
void
|
||||
socket_set_portrange (int sock, int restrict, int af)
|
||||
{
|
||||
#if defined(IP_PORTRANGE)
|
||||
if (af == AF_INET) {
|
||||
int on = restrict ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT;
|
||||
if (setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on,
|
||||
sizeof(on)) < 0)
|
||||
warn ("setsockopt IP_PORTRANGE (ignored)");
|
||||
}
|
||||
#endif
|
||||
#if defined(IPV6_PORTRANGE)
|
||||
if (af == AF_INET6) {
|
||||
int on = restrict ? IPV6_PORTRANGE_HIGH :
|
||||
IPV6_PORTRANGE_DEFAULT;
|
||||
if (setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on,
|
||||
sizeof(on)) < 0)
|
||||
warn ("setsockopt IPV6_PORTRANGE (ignored)");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable debug on `sock'.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user