vold: Enable the SO_PASSCRED socket option
Ensure that sender credentials are available when we
receive a netlink message.
This is a manual cherry-pick of
c51920c82463b240e2be0430849837d6fdc5352e
Change-Id: I98aff8733449617d35d20bff2fe77e9d3f22f57e
diff --git a/NetlinkManager.cpp b/NetlinkManager.cpp
index 36db0ff..29cd88e 100644
--- a/NetlinkManager.cpp
+++ b/NetlinkManager.cpp
@@ -50,6 +50,7 @@
int NetlinkManager::start() {
struct sockaddr_nl nladdr;
int sz = 64 * 1024;
+ int on = 1;
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
@@ -63,7 +64,12 @@
}
if (setsockopt(mSock, SOL_SOCKET, SO_RCVBUFFORCE, &sz, sizeof(sz)) < 0) {
- SLOGE("Unable to set uevent socket options: %s", strerror(errno));
+ SLOGE("Unable to set uevent socket SO_RECBUFFORCE option: %s", strerror(errno));
+ return -1;
+ }
+
+ if (setsockopt(mSock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0) {
+ SLOGE("Unable to set uevent socket SO_PASSCRED option: %s", strerror(errno));
return -1;
}