meta-netmodule-wlan/recipes-connectivity/hostapd/files/610-hostapd_cli_ujail_permi...

44 lines
1.4 KiB
Diff

From a1d6be648f6aa12d34bc4cfe8fb1c40ce4d1d427 Mon Sep 17 00:00:00 2001
From: OpenEmbedded <oe.patch@oe>
Date: Thu, 15 Sep 2022 12:35:28 +0000
---
src/common/wpa_ctrl.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
index 7e197f094..791fdbf93 100644
--- a/src/common/wpa_ctrl.c
+++ b/src/common/wpa_ctrl.c
@@ -135,7 +135,7 @@ try_again:
return NULL;
}
tries++;
-#ifdef ANDROID
+
/* Set client socket file permissions so that bind() creates the client
* socket with these permissions and there is no need to try to change
* them with chmod() after bind() which would have potential issues with
@@ -147,7 +147,7 @@ try_again:
* operations to allow the response to go through. Those are using the
* no-deference-symlinks version to avoid races. */
fchmod(ctrl->s, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
-#endif /* ANDROID */
+
if (bind(ctrl->s, (struct sockaddr *) &ctrl->local,
sizeof(ctrl->local)) < 0) {
if (errno == EADDRINUSE && tries < 2) {
@@ -165,7 +165,11 @@ try_again:
return NULL;
}
-#ifdef ANDROID
+#ifndef ANDROID
+ /* Set group even if we do not have privileges to change owner */
+ lchown(ctrl->local.sun_path, -1, 101);
+ lchown(ctrl->local.sun_path, 101, 101);
+#else
/* Set group even if we do not have privileges to change owner */
lchown(ctrl->local.sun_path, -1, AID_WIFI);
lchown(ctrl->local.sun_path, AID_SYSTEM, AID_WIFI);