[arch-commits] Commit in dhcpcd/trunk (2 files)
Date: Friday, July 10, 2020 @ 13:00:42 Author: grazzolini Revision: 391533 upgpkg: dhcpcd 9.1.4-1 Modified: dhcpcd/trunk/PKGBUILD Deleted: dhcpcd/trunk/0001-generic_netlink_ssid_privsep.patch -+ 0001-generic_netlink_ssid_privsep.patch | 196 -- PKGBUILD| 15 -- 2 files changed, 6 insertions(+), 205 deletions(-) Deleted: 0001-generic_netlink_ssid_privsep.patch === --- 0001-generic_netlink_ssid_privsep.patch 2020-07-10 11:28:41 UTC (rev 391532) +++ 0001-generic_netlink_ssid_privsep.patch 2020-07-10 13:00:42 UTC (rev 391533) @@ -1,196 +0,0 @@ -From 5d5ff024cbffa09bb3b3457a5a45be688adca949 Mon Sep 17 00:00:00 2001 -From: Roy Marples -Date: Mon, 22 Jun 2020 21:56:16 +0100 -Subject: Linux: keep the generic netlink socket around to get ssid with - privsep - -While here, improve our reading of netlink(7) and terminate on either -ERROR or DONE. If neither are in the message, read again unless it's -the link receiving socket. -Also, only callback if this is the sequence number expected. - src/if-linux.c | 81 ++ - 1 file changed, 48 insertions(+), 33 deletions(-) - -diff --git a/src/if-linux.c b/src/if-linux.c -index b3ab8280..815a06b7 100644 a/src/if-linux.c -+++ b/src/if-linux.c -@@ -130,6 +130,7 @@ int if_getssid_wext(const char *ifname, uint8_t *ssid); - - struct priv { - int route_fd; -+ int generic_fd; - uint32_t route_pid; - }; - -@@ -414,6 +415,12 @@ if_opensockets_os(struct dhcpcd_ctx *ctx) - if (getsockname(priv->route_fd, (struct sockaddr *), ) == -1) - return -1; - priv->route_pid = snl.nl_pid; -+ -+ memset(, 0, sizeof(snl)); -+ priv->generic_fd = if_linksocket(, NETLINK_GENERIC, 0); -+ if (priv->generic_fd == -1) -+ return -1; -+ - return 0; - } - -@@ -425,6 +432,7 @@ if_closesockets_os(struct dhcpcd_ctx *ctx) - if (ctx->priv != NULL) { - priv = (struct priv *)ctx->priv; - close(priv->route_fd); -+ close(priv->generic_fd); - } - } - -@@ -465,26 +473,27 @@ if_getnetlink(struct dhcpcd_ctx *ctx, struct iovec *iov, int fd, int flags, - }; - ssize_t len; - struct nlmsghdr *nlm; -- int r; -+ int r = 0; - unsigned int again; -+ bool terminated; - - recv_again: -- if ((len = recvmsg(fd, , flags)) == -1) -- return -1; -- if (len == 0) -- return 0; -+ len = recvmsg(fd, , flags); -+ if (len == -1 || len == 0) -+ return (int)len; - - /* Check sender */ - if (msg.msg_namelen != sizeof(nladdr)) { - errno = EINVAL; - return -1; - } -+ - /* Ignore message if it is not from kernel */ - if (nladdr.nl_pid != 0) - return 0; - -- r = 0; - again = 0; -+ terminated = false; - for (nlm = iov->iov_base; -nlm && NLMSG_OK(nlm, (size_t)len); -nlm = NLMSG_NEXT(nlm, len)) -@@ -492,6 +501,7 @@ recv_again: - again = (nlm->nlmsg_flags & NLM_F_MULTI); - if (nlm->nlmsg_type == NLMSG_NOOP) - continue; -+ - if (nlm->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *err; - -@@ -504,17 +514,21 @@ recv_again: - errno = -err->error; - return -1; - } -+ again = 0; -+ terminated = true; - break; - } - if (nlm->nlmsg_type == NLMSG_DONE) { - again = 0; -+ terminated = true; - break; - } -- if (cb != NULL && (r = cb(ctx, cbarg, nlm)) != 0) -- break; -+ if (cb != NULL && -+ (nlm->nlmsg_seq == (uint32_t)ctx->seq || fd == ctx->link_fd)) -+ r = cb(ctx, cbarg, nlm); - } - -- if (r == 0 && again) -+ if ((again || !terminated) && (ctx != NULL && ctx->link_fd != fd)) - goto recv_again; - - return r; -@@ -982,16 +996,19 @@ static int - if_sendnetlink(struct dhcpcd_ctx *ctx, int protocol, struct nlmsghdr *hdr, - int (*cb)(struct dhcpcd_ctx *, void *, struct nlmsghdr *), void *cbarg) - { -- int s, r; -+ int s; - struct sockaddr_nl snl = { .nl_family = AF_NETLINK }; - struct iovec iov = { .iov_base = hdr, .iov_len = hdr->nlmsg_len }; - struct msghdr msg = { - .msg_name = , .msg_namelen = sizeof(snl), - .msg_iov = , .msg_iovlen = 1 - }; -- bool use_rfd; -- -- use_rfd = (protocol == NETLINK_ROUTE && hdr->nlmsg_type != RTM_GETADDR); -+
[arch-commits] Commit in dhcpcd/trunk (2 files)
Date: Tuesday, June 23, 2020 @ 12:56:30 Author: grazzolini Revision: 390159 upgpkg: dhcpcd 9.1.2-2 Fix for FS#67053 Added: dhcpcd/trunk/0001-generic_netlink_ssid_privsep.patch Modified: dhcpcd/trunk/PKGBUILD -+ 0001-generic_netlink_ssid_privsep.patch | 196 ++ PKGBUILD| 14 +- 2 files changed, 207 insertions(+), 3 deletions(-) Added: 0001-generic_netlink_ssid_privsep.patch === --- 0001-generic_netlink_ssid_privsep.patch (rev 0) +++ 0001-generic_netlink_ssid_privsep.patch 2020-06-23 12:56:30 UTC (rev 390159) @@ -0,0 +1,196 @@ +From 5d5ff024cbffa09bb3b3457a5a45be688adca949 Mon Sep 17 00:00:00 2001 +From: Roy Marples +Date: Mon, 22 Jun 2020 21:56:16 +0100 +Subject: Linux: keep the generic netlink socket around to get ssid with + privsep + +While here, improve our reading of netlink(7) and terminate on either +ERROR or DONE. If neither are in the message, read again unless it's +the link receiving socket. +Also, only callback if this is the sequence number expected. +--- + src/if-linux.c | 81 ++ + 1 file changed, 48 insertions(+), 33 deletions(-) + +diff --git a/src/if-linux.c b/src/if-linux.c +index b3ab8280..815a06b7 100644 +--- a/src/if-linux.c b/src/if-linux.c +@@ -130,6 +130,7 @@ int if_getssid_wext(const char *ifname, uint8_t *ssid); + + struct priv { + int route_fd; ++ int generic_fd; + uint32_t route_pid; + }; + +@@ -414,6 +415,12 @@ if_opensockets_os(struct dhcpcd_ctx *ctx) + if (getsockname(priv->route_fd, (struct sockaddr *), ) == -1) + return -1; + priv->route_pid = snl.nl_pid; ++ ++ memset(, 0, sizeof(snl)); ++ priv->generic_fd = if_linksocket(, NETLINK_GENERIC, 0); ++ if (priv->generic_fd == -1) ++ return -1; ++ + return 0; + } + +@@ -425,6 +432,7 @@ if_closesockets_os(struct dhcpcd_ctx *ctx) + if (ctx->priv != NULL) { + priv = (struct priv *)ctx->priv; + close(priv->route_fd); ++ close(priv->generic_fd); + } + } + +@@ -465,26 +473,27 @@ if_getnetlink(struct dhcpcd_ctx *ctx, struct iovec *iov, int fd, int flags, + }; + ssize_t len; + struct nlmsghdr *nlm; +- int r; ++ int r = 0; + unsigned int again; ++ bool terminated; + + recv_again: +- if ((len = recvmsg(fd, , flags)) == -1) +- return -1; +- if (len == 0) +- return 0; ++ len = recvmsg(fd, , flags); ++ if (len == -1 || len == 0) ++ return (int)len; + + /* Check sender */ + if (msg.msg_namelen != sizeof(nladdr)) { + errno = EINVAL; + return -1; + } ++ + /* Ignore message if it is not from kernel */ + if (nladdr.nl_pid != 0) + return 0; + +- r = 0; + again = 0; ++ terminated = false; + for (nlm = iov->iov_base; +nlm && NLMSG_OK(nlm, (size_t)len); +nlm = NLMSG_NEXT(nlm, len)) +@@ -492,6 +501,7 @@ recv_again: + again = (nlm->nlmsg_flags & NLM_F_MULTI); + if (nlm->nlmsg_type == NLMSG_NOOP) + continue; ++ + if (nlm->nlmsg_type == NLMSG_ERROR) { + struct nlmsgerr *err; + +@@ -504,17 +514,21 @@ recv_again: + errno = -err->error; + return -1; + } ++ again = 0; ++ terminated = true; + break; + } + if (nlm->nlmsg_type == NLMSG_DONE) { + again = 0; ++ terminated = true; + break; + } +- if (cb != NULL && (r = cb(ctx, cbarg, nlm)) != 0) +- break; ++ if (cb != NULL && ++ (nlm->nlmsg_seq == (uint32_t)ctx->seq || fd == ctx->link_fd)) ++ r = cb(ctx, cbarg, nlm); + } + +- if (r == 0 && again) ++ if ((again || !terminated) && (ctx != NULL && ctx->link_fd != fd)) + goto recv_again; + + return r; +@@ -982,16 +996,19 @@ static int + if_sendnetlink(struct dhcpcd_ctx *ctx, int protocol, struct nlmsghdr *hdr, + int (*cb)(struct dhcpcd_ctx *, void *, struct nlmsghdr *), void *cbarg) + { +- int s, r; ++ int s; + struct sockaddr_nl snl = { .nl_family = AF_NETLINK }; + struct iovec iov = { .iov_base = hdr, .iov_len = hdr->nlmsg_len }; + struct msghdr msg = { + .msg_name = , .msg_namelen = sizeof(snl), + .msg_iov = , .msg_iovlen = 1 + }; +- bool use_rfd; +- +- use_rfd = (protocol == NETLINK_ROUTE && hdr->nlmsg_type != RTM_GETADDR); ++