Skip to content

Commit cb48698

Browse files
smiraaboch
authored andcommitted
fix: add missing CLOEXEC flag
Some calls were already using it, some were not, but fix the remaining ones. Without this flag, the file descriptor would to the child process after fork/exec. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 5d6ad2b commit cb48698

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

ioctl_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ func newIocltStringSetReq(linkName string) (*Ifreq, *ethtoolSset) {
8686
// getSocketUDP returns file descriptor to new UDP socket
8787
// It is used for communication with ioctl interface.
8888
func getSocketUDP() (int, error) {
89-
return syscall.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
89+
return syscall.Socket(unix.AF_INET, unix.SOCK_DGRAM|unix.SOCK_CLOEXEC, 0)
9090
}

nl/nl_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ func executeInNetns(newNs, curNs netns.NsHandle) (func(), error) {
789789
// Returns the netlink socket on which Receive() method can be called
790790
// to retrieve the messages from the kernel.
791791
func Subscribe(protocol int, groups ...uint) (*NetlinkSocket, error) {
792-
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOCK_RAW, protocol)
792+
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOCK_RAW|unix.SOCK_CLOEXEC, protocol)
793793
if err != nil {
794794
return nil, err
795795
}

0 commit comments

Comments
 (0)