]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Android: Allow wpa_supplicant to write files to osu-info dir
authorKanchanapally, Vidyullatha <vkanchan@qti.qualcomm.com>
Tue, 1 Mar 2016 02:06:53 +0000 (07:36 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 3 Mar 2016 12:50:29 +0000 (14:50 +0200)
This commit allows any process running with group id of AID_WIFI to
read/write files to osu-info directory. Also, it allows other users to
read and search the osu-info directory.

This fixes issues with hs20-osu-client creating a directory for
wpa_supplicant use without wpa_supplicant actually having privileges to
write there on Android where the wpa_supplicant process does not run as
root.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hs20/client/osu_client.c

index 35793c800f20e432f5849a75539582d615f3f9eb..2907c6412a92e0b547c50bd771672f999d368181 100644 (file)
@@ -2339,12 +2339,23 @@ static int cmd_signup(struct hs20_osu_client *ctx, int no_prod_assoc,
                return -1;
 
        snprintf(fname, sizeof(fname), "%s/osu-info", dir);
-       if (mkdir(fname, S_IRWXU | S_IRWXG) < 0 && errno != EEXIST) {
+       if (mkdir(fname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0 &&
+           errno != EEXIST) {
                wpa_printf(MSG_INFO, "mkdir(%s) failed: %s",
                           fname, strerror(errno));
                return -1;
        }
 
+#ifdef ANDROID
+       /* Allow processes running with Group ID as AID_WIFI
+        * to read/write files from osu-info directory
+        */
+       if (chown(fname, -1, AID_WIFI)) {
+               wpa_printf(MSG_INFO, "Could not chown osu-info directory: %s",
+                          strerror(errno));
+       }
+#endif /* ANDROID */
+
        snprintf(buf, sizeof(buf), "SET osu_dir %s", fname);
        if (wpa_command(ifname, buf) < 0) {
                wpa_printf(MSG_INFO, "Failed to configure osu_dir to wpa_supplicant");