summaryrefslogtreecommitdiff
path: root/src/devices
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-12-10 15:28:15 +0100
committerThomas Haller <thaller@redhat.com>2016-12-13 11:26:59 +0100
commit4bdee37771ae741f4f9548b52c1db53ddf080fe8 (patch)
treea531d21aa0fc18c62c50669bd5faa083af270566 /src/devices
parente332c278245abc2c0d6e63ca9f36aa77961b15d5 (diff)
all: use O_CLOEXEC for file descriptors
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/adsl/nm-device-adsl.c4
-rw-r--r--src/devices/bluetooth/nm-bluez5-dun.c4
-rw-r--r--src/devices/tests/test-lldp.c4
-rw-r--r--src/devices/wwan/nm-modem.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c
index 8f8037c25..9af6e6903 100644
--- a/src/devices/adsl/nm-device-adsl.c
+++ b/src/devices/adsl/nm-device-adsl.c
@@ -158,7 +158,7 @@ br2684_assign_vcc (NMDeviceAdsl *self, NMSettingAdsl *s_adsl)
g_return_val_if_fail (priv->brfd == -1, FALSE);
g_return_val_if_fail (priv->nas_ifname != NULL, FALSE);
- priv->brfd = socket (PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
+ priv->brfd = socket (PF_ATMPVC, SOCK_DGRAM | SOCK_CLOEXEC, ATM_AAL5);
if (priv->brfd < 0) {
errsv = errno;
_LOGE (LOGD_ADSL, "failed to open ATM control socket (%d)", errsv);
@@ -344,7 +344,7 @@ br2684_create_iface (NMDeviceAdsl *self,
nm_clear_g_source (&priv->nas_update_id);
}
- fd = socket (PF_ATMPVC, SOCK_DGRAM, ATM_AAL5);
+ fd = socket (PF_ATMPVC, SOCK_DGRAM | SOCK_CLOEXEC, ATM_AAL5);
if (fd < 0) {
errsv = errno;
_LOGE (LOGD_ADSL, "failed to open ATM control socket (%d)", errsv);
diff --git a/src/devices/bluetooth/nm-bluez5-dun.c b/src/devices/bluetooth/nm-bluez5-dun.c
index 4c93feba6..aba3a0dd9 100644
--- a/src/devices/bluetooth/nm-bluez5-dun.c
+++ b/src/devices/bluetooth/nm-bluez5-dun.c
@@ -64,7 +64,7 @@ dun_connect (NMBluez5DunContext *context)
.channel = context->rfcomm_channel
};
- context->rfcomm_fd = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+ context->rfcomm_fd = socket (AF_BLUETOOTH, SOCK_STREAM | SOCK_CLOEXEC, BTPROTO_RFCOMM);
if (context->rfcomm_fd < 0) {
int errsv = errno;
error = g_error_new (NM_BT_ERROR, NM_BT_ERROR_DUN_CONNECT_FAILED,
@@ -112,7 +112,7 @@ dun_connect (NMBluez5DunContext *context)
context->rfcomm_id = devid;
snprintf (tty, ttylen, "/dev/rfcomm%d", devid);
- while ((context->rfcomm_tty_fd = open (tty, O_RDONLY | O_NOCTTY)) < 0 && try--) {
+ while ((context->rfcomm_tty_fd = open (tty, O_RDONLY | O_NOCTTY | O_CLOEXEC)) < 0 && try--) {
if (try) {
g_usleep (100 * 1000);
continue;
diff --git a/src/devices/tests/test-lldp.c b/src/devices/tests/test-lldp.c
index 5d28d461d..4d25f9a68 100644
--- a/src/devices/tests/test-lldp.c
+++ b/src/devices/tests/test-lldp.c
@@ -350,7 +350,7 @@ _test_recv_fixture_setup (TestRecvFixture *fixture, gconstpointer user_data)
struct ifreq ifr = { };
int fd, s;
- fd = open ("/dev/net/tun", O_RDWR);
+ fd = open ("/dev/net/tun", O_RDWR | O_CLOEXEC);
g_assert (fd >= 0);
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
@@ -358,7 +358,7 @@ _test_recv_fixture_setup (TestRecvFixture *fixture, gconstpointer user_data)
g_assert (ioctl (fd, TUNSETIFF, &ifr) >= 0);
/* Bring the interface up */
- s = socket (AF_INET, SOCK_DGRAM, 0);
+ s = socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
g_assert (s >= 0);
ifr.ifr_flags |= IFF_UP;
g_assert (ioctl (s, SIOCSIFFLAGS, &ifr) >= 0);
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c
index 1c72c70e0..635f20ea7 100644
--- a/src/devices/wwan/nm-modem.c
+++ b/src/devices/wwan/nm-modem.c
@@ -500,7 +500,7 @@ port_speed_is_zero (const char *port)
struct termios options;
nm_auto_close int fd = -1;
- fd = open (port, O_RDWR | O_NONBLOCK | O_NOCTTY);
+ fd = open (port, O_RDWR | O_NONBLOCK | O_NOCTTY | O_CLOEXEC);
if (fd < 0)
return FALSE;