opm: properly check for duplicate listeners

This commit is contained in:
Elizabeth Myers 2016-04-02 21:13:44 -05:00
parent 850ced64fe
commit 7f2272d3d3

View file

@ -506,6 +506,8 @@ create_listener(const char *ip, uint16_t port)
exit(EX_PROVIDER_ERROR); exit(EX_PROVIDER_ERROR);
} }
SET_SS_PORT(&addr, htons(port));
#ifdef RB_IPV6 #ifdef RB_IPV6
if(GET_SS_FAMILY(&addr) == AF_INET6) if(GET_SS_FAMILY(&addr) == AF_INET6)
{ {
@ -557,14 +559,6 @@ create_listener(const char *ip, uint16_t port)
exit(EX_PROVIDER_ERROR); exit(EX_PROVIDER_ERROR);
} }
/* Set up ports for binding */
#ifdef RB_IPV6
if(GET_SS_FAMILY(&addr) == AF_INET6)
((struct sockaddr_in6 *)&addr)->sin6_port = htons(port);
else
#endif
((struct sockaddr_in *)&addr)->sin_port = htons(port);
if(bind(rb_get_fd(F), (struct sockaddr *)&addr, GET_SS_LEN(&addr))) if(bind(rb_get_fd(F), (struct sockaddr *)&addr, GET_SS_LEN(&addr)))
{ {
/* Shit happens, let's not cripple authd over /this/ since it could be user error */ /* Shit happens, let's not cripple authd over /this/ since it could be user error */