Skip to content

Commit

Permalink
Merge pull request #651 from tomc797/fix/set_socket_cloexec
Browse files Browse the repository at this point in the history
Enable close-on-exec on socket
  • Loading branch information
scareything committed May 24, 2023
2 parents f5ce97e + 24176d2 commit 67f75f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions programs/ziti-edge-tunnel/netif_driver/linux/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static void init_dns_maintainer(uv_loop_t *loop, const char *tun_name, uint32_t
local.nl_family = AF_NETLINK;
local.nl_groups = RTMGRP_LINK;// | RTMGRP_IPV4_ROUTE;

int s = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
int s = socket(AF_NETLINK, SOCK_DGRAM|SOCK_CLOEXEC, NETLINK_ROUTE);
if ( s < 0) {
ZITI_LOG(ERROR, "failed to open netlink socket: %d/%s", errno, strerror(errno));
}
Expand Down Expand Up @@ -410,7 +410,7 @@ netif_driver tun_open(uv_loop_t *loop, uint32_t tun_ip, uint32_t dns_ip, const c
return NULL;
}

if ((tun->fd = open(DEVTUN, O_RDWR)) < 0) {
if ((tun->fd = open(DEVTUN, O_RDWR|O_CLOEXEC)) < 0) {
if (error != NULL) {
snprintf(error, error_len,"open %s failed", DEVTUN);
}
Expand Down

0 comments on commit 67f75f1

Please sign in to comment.