* Only init the IPv6 socket once
*/
if (res_addr->ai_addr->sa_family == AF_INET6 && not_init6 == 1) {
- uid_t euid;
dgram_zero(&netfd6.dgram);
- euid = geteuid();
set_root_privs(1);
result_bind = dgram_bind(&netfd6.dgram,
res_addr->ai_addr->sa_family, &port);
* Only init the IPv4 socket once
*/
if (res_addr->ai_addr->sa_family == AF_INET && not_init4 == 1) {
- uid_t euid;
dgram_zero(&netfd4.dgram);
- euid = geteuid();
set_root_privs(1);
result_bind = dgram_bind(&netfd4.dgram,
res_addr->ai_addr->sa_family, &port);
void (*fn)(security_handle_t *, pkt_t *),
void *datap)
{
+ struct stat sbuf;
assert(in >= 0 && out >= 0);
assert(fn != NULL);
netfd4.prefix_packet = &bsd_prefix_packet;
netfd4.driver = &bsd_security_driver;
- udp_addref(&netfd4, &udp_netfd_read_callback);
+ /* check if in is a socket */
+ fstat(in, &sbuf);
+ if (S_ISSOCK(sbuf.st_mode)) {
+ udp_addref(&netfd4, &udp_netfd_read_callback);
+ } else {
+ g_warning("input file descriptor is not a socket; cannot use BSD auth");
+ }
}
/*