Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable close-on-exec on socket #651

Merged
merged 2 commits into from
May 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -305,7 +305,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 @@ -376,7 +376,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