hostapd: Android: Force group access to ctrl_iface directory
authorPontus Fuchs <pontus.fuchs@gmail.com>
Mon, 17 Dec 2012 14:30:44 +0000 (16:30 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 17 Dec 2012 14:30:44 +0000 (16:30 +0200)
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

index 1d4fe0d..bd16b17 100644 (file)
@@ -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;