Patchwork hostapd: Android: Force group access to ctrl_iface directory

login
register
mail settings
Submitter Pontus Fuchs
Date Dec. 14, 2012, 11:58 a.m.
Message ID <1355486281-23143-2-git-send-email-pontus.fuchs@gmail.com>
Download mbox | patch
Permalink /patch/206412/
State Accepted
Commit 5bbf590a583609541cb257a6bc01bdcfc211bd3c
Headers show

Comments

Pontus Fuchs - Dec. 14, 2012, 11:58 a.m.
Same fix as d49ea68284fdb8516d7e0903e526aac484c18c49 in
wpa_supplicant.

From original commit:

wpa_supplicant is started from /init.*.rc on Android and that seems
to be using umask 0077 which would leave the control interface
directory without group access. This breaks things since Wi-Fi
framework assumes that this directory can be accessed by other
applications in the wifi group. Fix this by adding group access even
if umask value would prevent this.

Signed-hostap: Pontus Fuchs <pontus.fuchs@gmail.com>
---
 hostapd/ctrl_iface.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
Jouni Malinen - Dec. 17, 2012, 2:32 p.m.
On Fri, Dec 14, 2012 at 12:58:01PM +0100, Pontus Fuchs wrote:
> Same fix as d49ea68284fdb8516d7e0903e526aac484c18c49 in
> wpa_supplicant.

Thanks, applied.
Dan Williams - Dec. 17, 2012, 4:13 p.m.
On Mon, 2012-12-17 at 16:32 +0200, Jouni Malinen wrote:
> On Fri, Dec 14, 2012 at 12:58:01PM +0100, Pontus Fuchs wrote:
> > Same fix as d49ea68284fdb8516d7e0903e526aac484c18c49 in
> > wpa_supplicant.
> 
> Thanks, applied.

Isn't this a bug in the Android initscripts and shouldn't it be fixed
there instead of in hacks in the supplicant code?  Or are you trying to
ensure the supplicant will keep running well on older Android releases?

Dan
Jouni Malinen - Dec. 17, 2012, 5:28 p.m.
On Mon, Dec 17, 2012 at 10:13:24AM -0600, Dan Williams wrote:
> On Mon, 2012-12-17 at 16:32 +0200, Jouni Malinen wrote:
> > On Fri, Dec 14, 2012 at 12:58:01PM +0100, Pontus Fuchs wrote:
> > > Same fix as d49ea68284fdb8516d7e0903e526aac484c18c49 in
> > > wpa_supplicant.
> > 
> > Thanks, applied.
> 
> Isn't this a bug in the Android initscripts and shouldn't it be fixed
> there instead of in hacks in the supplicant code?  Or are you trying to
> ensure the supplicant will keep running well on older Android releases?

Well, yes, modifying the initscripts (or something else; I'm not
completely sure where umask is set) would likely be the cleanest way of
doing this. That said, it is not exactly convenient to get all the
possible places modified, so I ended up giving up with the cleanest fix
from hostap.git view point and pushed this into wpa_supplicant (and now
into hostapd with this commit). And yes, this needs to work also with
existing Android releases.

Patch

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 1d4fe0d..bd16b17 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -1003,6 +1003,21 @@  int hostapd_ctrl_iface_init(struct hostapd_data *hapd)
 		return -1;
 	}
 
+#ifdef ANDROID
+	/*
+	 * Android is using umask 0077 which would leave the control interface
+	 * directory without group access. This breaks things since Wi-Fi
+	 * framework assumes that this directory can be accessed by other
+	 * applications in the wifi group. Fix this by adding group access even
+	 * if umask value would prevent this.
+	 */
+	if (chmod(hapd->conf->ctrl_interface, S_IRWXU | S_IRWXG) < 0) {
+		wpa_printf(MSG_ERROR, "CTRL: Could not chmod directory: %s",
+			   strerror(errno));
+		/* Try to continue anyway */
+	}
+#endif /* ANDROID */
+
 	if (os_strlen(hapd->conf->ctrl_interface) + 1 +
 	    os_strlen(hapd->conf->iface) >= sizeof(addr.sun_path))
 		goto fail;