diff options
author | Elliott Hughes <enh@google.com> | 2013-11-20 13:51:45 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-11-20 14:12:09 -0800 |
commit | e2a70cfbf3b3db7ab87c5799fc264f52a8326ae2 (patch) | |
tree | 244e1c5a288c26a1f45ab1454eb0c09ad39256c8 /rild | |
parent | 24a5c46926c45ce69c83b256b9e3b41647516ad9 (diff) | |
download | android_hardware_ril-e2a70cfbf3b3db7ab87c5799fc264f52a8326ae2.tar.gz android_hardware_ril-e2a70cfbf3b3db7ab87c5799fc264f52a8326ae2.tar.bz2 android_hardware_ril-e2a70cfbf3b3db7ab87c5799fc264f52a8326ae2.zip |
Stop the kernel complaining about rild.
Even if you're only using capabilities that reside in the bottom 32-bits,
the kernel complains unless you're on __LINUX_CAPABILITY_VERSION_3.
warning: `rild' uses 32-bit capabilities (legacy support in use)
Change-Id: I6512cbc158971eb950e0fc2554e95fde72023cb2
Diffstat (limited to 'rild')
-rw-r--r-- | rild/rild.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/rild/rild.c b/rild/rild.c index 70530c6..e37c177 100644 --- a/rild/rild.c +++ b/rild/rild.c @@ -42,7 +42,7 @@ static void usage(const char *argv0) { fprintf(stderr, "Usage: %s -l <ril impl library> [-- <args for impl library>]\n", argv0); - exit(-1); + exit(EXIT_FAILURE); } extern void RIL_register (const RIL_RadioFunctions *callbacks); @@ -89,12 +89,23 @@ void switchUser() { setuid(AID_RADIO); struct __user_cap_header_struct header; - struct __user_cap_data_struct cap; - header.version = _LINUX_CAPABILITY_VERSION; + memset(&header, 0, sizeof(header)); + header.version = _LINUX_CAPABILITY_VERSION_3; header.pid = 0; - cap.effective = cap.permitted = (1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW); - cap.inheritable = 0; - capset(&header, &cap); + + struct __user_cap_data_struct data[2]; + memset(&data, 0, sizeof(data)); + + data[CAP_TO_INDEX(CAP_NET_ADMIN)].effective |= CAP_TO_MASK(CAP_NET_ADMIN); + data[CAP_TO_INDEX(CAP_NET_ADMIN)].permitted |= CAP_TO_MASK(CAP_NET_ADMIN); + + data[CAP_TO_INDEX(CAP_NET_RAW)].effective |= CAP_TO_MASK(CAP_NET_RAW); + data[CAP_TO_INDEX(CAP_NET_RAW)].permitted |= CAP_TO_MASK(CAP_NET_RAW); + + if (capset(&header, &data[0]) == -1) { + RLOGE("capset failed: %s", strerror(errno)); + exit(EXIT_FAILURE); + } } int main(int argc, char **argv) @@ -246,7 +257,7 @@ OpenLib: if (dlHandle == NULL) { RLOGE("dlopen failed: %s", dlerror()); - exit(-1); + exit(EXIT_FAILURE); } RIL_startEventLoop(); @@ -255,7 +266,7 @@ OpenLib: if (rilInit == NULL) { RLOGE("RIL_Init not defined or exported in %s\n", rilLibPath); - exit(-1); + exit(EXIT_FAILURE); } if (hasLibArgs) { |