aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/wpa_ctrl.c
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-02-27 16:19:17 (GMT)
committerJouni Malinen <j@w1.fi>2011-02-27 16:19:17 (GMT)
commitb3f3865e0e7f8d2362c2bfb6019d84a67f2b2dff (patch)
treeea76939c5aebc7c163c0733c2b9be17342a863dd /src/common/wpa_ctrl.c
parent1480633f965cb846f99c46a2aecc4357f7478281 (diff)
downloadhostap-b3f3865e0e7f8d2362c2bfb6019d84a67f2b2dff.zip
hostap-b3f3865e0e7f8d2362c2bfb6019d84a67f2b2dff.tar.gz
hostap-b3f3865e0e7f8d2362c2bfb6019d84a67f2b2dff.tar.bz2
Use Android reserved namespace for control interface
On Android, use a special reserved namespace for the UNIX domain socket.
Diffstat (limited to 'src/common/wpa_ctrl.c')
-rw-r--r--src/common/wpa_ctrl.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
index 7c9b638..899b6bd 100644
--- a/src/common/wpa_ctrl.c
+++ b/src/common/wpa_ctrl.c
@@ -20,6 +20,11 @@
#include <sys/un.h>
#endif /* CONFIG_CTRL_IFACE_UNIX */
+#ifdef ANDROID
+#include <cutils/sockets.h>
+#include "private/android_filesystem_config.h"
+#endif /* ANDROID */
+
#include "wpa_ctrl.h"
#include "common.h"
@@ -105,6 +110,31 @@ try_again:
return NULL;
}
+#ifdef ANDROID
+ chmod(ctrl->local.sun_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ chown(ctrl->local.sun_path, AID_SYSTEM, AID_WIFI);
+ /*
+ * If the ctrl_path isn't an absolute pathname, assume that
+ * it's the name of a socket in the Android reserved namespace.
+ * Otherwise, it's a normal UNIX domain socket appearing in the
+ * filesystem.
+ */
+ if (ctrl_path != NULL && *ctrl_path != '/') {
+ char buf[21];
+ os_snprintf(buf, sizeof(buf), "wpa_%s", ctrl_path);
+ if (socket_local_client_connect(
+ ctrl->s, buf,
+ ANDROID_SOCKET_NAMESPACE_RESERVED,
+ SOCK_DGRAM) < 0) {
+ close(ctrl->s);
+ unlink(ctrl->local.sun_path);
+ os_free(ctrl);
+ return NULL;
+ }
+ return ctrl;
+ }
+#endif /* ANDROID */
+
ctrl->dest.sun_family = AF_UNIX;
res = os_strlcpy(ctrl->dest.sun_path, ctrl_path,
sizeof(ctrl->dest.sun_path));