Skip to content

Commit

Permalink
Enable close-on-exec flag when opening the tun device node.
Browse files Browse the repository at this point in the history
When the close-on-exec flag is set, the file descriptor is automatically
closed upon a successful exec. This keeps a child process--such as one
started using system()--from inheriting the file descriptor.

Signed-off-by: Tom Carroll <[email protected]>
  • Loading branch information
tomc797 committed May 6, 2023
1 parent f5346a0 commit eeadcf9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion programs/ziti-edge-tunnel/netif_driver/linux/tun.c
Original file line number Diff line number Diff line change
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

0 comments on commit eeadcf9

Please sign in to comment.