aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2011-02-25 14:21:18 (GMT)
committerJouni Malinen <j@w1.fi>2011-02-25 14:21:18 (GMT)
commit1a13534f1789f0634ccac0c0d4c0c6c11b4a622e (patch)
treead9c972d590f1018c228e2666c0b488c2fad4226 /src
parentc4d4aebe69ac10d610d724210ccfcd2104a17af8 (diff)
downloadhostap-1a13534f1789f0634ccac0c0d4c0c6c11b4a622e.zip
hostap-1a13534f1789f0634ccac0c0d4c0c6c11b4a622e.tar.gz
hostap-1a13534f1789f0634ccac0c0d4c0c6c11b4a622e.tar.bz2
Change executable permissions for Android
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/utils/os_unix.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index c696fae..9a2465a 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -14,6 +14,12 @@
#include "includes.h"
+#ifdef ANDROID
+#include <linux/capability.h>
+#include <linux/prctl.h>
+#include <private/android_filesystem_config.h>
+#endif /* ANDROID */
+
#include "os.h"
#ifdef WPA_TRACE
@@ -232,6 +238,30 @@ char * os_rel2abs_path(const char *rel_path)
int os_program_init(void)
{
+#ifdef ANDROID
+ /*
+ * We ignore errors here since errors are normal if we
+ * are already running as non-root.
+ */
+ gid_t groups[] = { AID_INET, AID_WIFI, AID_KEYSTORE };
+ struct __user_cap_header_struct header;
+ struct __user_cap_data_struct cap;
+
+ setgroups(sizeof(groups)/sizeof(groups[0]), groups);
+
+ prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
+
+ setgid(AID_WIFI);
+ setuid(AID_WIFI);
+
+ header.version = _LINUX_CAPABILITY_VERSION;
+ header.pid = 0;
+ cap.effective = cap.permitted =
+ (1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW);
+ cap.inheritable = 0;
+ capset(&header, &cap);
+#endif /* ANDROID */
+
#ifdef WPA_TRACE
dl_list_init(&alloc_list);
#endif /* WPA_TRACE */