diff options
author | Thomas Haller <thaller@redhat.com> | 2022-06-17 10:36:54 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-06-17 19:40:37 +0200 |
commit | ddbcd668ec6f8136a54ecfe1d91ac1e900a5d672 (patch) | |
tree | 887c75b1f1a144d696c397a5b15d33766ec2e2bf | |
parent | f5d94284688f9e739658b73809335f3057360db0 (diff) | |
download | NetworkManager-ddbcd668ec6f8136a54ecfe1d91ac1e900a5d672.tar.gz |
platform: move credential check in event_handler_recvmsgs()
-rw-r--r-- | src/libnm-platform/nm-linux-platform.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 15c5c6db7c..f64bb506af 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -9265,6 +9265,15 @@ continue_reading: return n; } + if (!creds_has || creds.pid) { + if (!creds_has) + _LOGT("netlink: recvmsg: received message without credentials"); + else + _LOGT("netlink: recvmsg: received non-kernel message (pid %d)", creds.pid); + err = 0; + goto stop; + } + hdr = (struct nlmsghdr *) priv->netlink_recv_buf.buf; while (nlmsg_ok(hdr, n)) { nm_auto_nlmsg struct nl_msg *msg = NULL; @@ -9278,21 +9287,11 @@ continue_reading: nlmsg_set_proto(msg, NETLINK_ROUTE); nlmsg_set_src(msg, &nla); - - if (!creds_has || creds.pid) { - if (!creds_has) - _LOGT("netlink: recvmsg: received message without credentials"); - else - _LOGT("netlink: recvmsg: received non-kernel message (pid %d)", creds.pid); - err = 0; - goto stop; - } + nlmsg_set_creds(msg, &creds); _LOGt("netlink: recvmsg: new message %s", nl_nlmsghdr_to_str(NETLINK_ROUTE, hdr, buf_nlmsghdr, sizeof(buf_nlmsghdr))); - nlmsg_set_creds(msg, &creds); - if (hdr->nlmsg_flags & NLM_F_MULTI) multipart = TRUE; |