diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-03 19:18:15 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-04 08:43:20 +0200 |
commit | 62a85fa84560dc296796c3a63f698f8c15794b99 (patch) | |
tree | b41b9d37f332bf6320ea3f93476ba0c806eaf39d | |
parent | d1f7e439c6103f3e635beb221718eb09241c6fdb (diff) | |
download | NetworkManager-62a85fa84560dc296796c3a63f698f8c15794b99.tar.gz |
core: fix setting FD flags in _rfkill_update_system()
F_SETFL will reset the flags. That is wrong, as we only want to add
O_NONBLOCK flag and leaving the other flags alone. Usually, we would
need to call F_GETFL first.
Note that on Linux, F_SETFL can only set certain flags, so the
O_RDWR|O_CLOEXEC flags were unaffected by this. That means, most likely
there are no other flags that our use of F_SETFL would wrongly clear.
Still, it's ugly, because it's not obvious whether there might be other
flags.
Avoid that altogether, by setting the flag already during open().
Fixes: 67e092abcbde ('core: better handling of rfkill for WiMAX and WiFi (bgo #629589) (rh #599002)')
-rw-r--r-- | src/core/nm-manager.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index b10e78bee3..f6902b9786 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -3021,7 +3021,7 @@ _rfkill_update_system(NMManager *self, NMRfkillType rtype, gboolean enabled) nm_assert(NM_IN_SET(rtype, NM_RFKILL_TYPE_WLAN, NM_RFKILL_TYPE_WWAN)); - fd = open("/dev/rfkill", O_RDWR | O_CLOEXEC); + fd = open("/dev/rfkill", O_RDWR | O_NONBLOCK | O_CLOEXEC); if (fd < 0) { if (errno == EACCES) _LOGW(LOGD_RFKILL, @@ -3030,14 +3030,6 @@ _rfkill_update_system(NMManager *self, NMRfkillType rtype, gboolean enabled) return; } - if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { - _LOGW(LOGD_RFKILL, - "rfkill: (%s): failed to set killswitch device for " - "non-blocking operation", - nm_rfkill_type_to_string(rtype)); - return; - } - memset(&event, 0, sizeof(event)); event.op = KERN_RFKILL_OP_CHANGE_ALL; switch (rtype) { |