diff options
author | Alex Klyubin <klyubin@google.com> | 2013-04-24 05:54:46 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-04-24 05:54:47 +0000 |
commit | a643652680486bd1009248d1bd8fcea7da92d661 (patch) | |
tree | 4335f97207bf374724fad9f293ff39a77153acd8 /core/java | |
parent | 35587a0c47c33a8eed7817dc705dbf502f7b5b60 (diff) | |
parent | 48a06e740782184bd126ab743150b474abc9e6a4 (diff) | |
download | frameworks_base-a643652680486bd1009248d1bd8fcea7da92d661.zip frameworks_base-a643652680486bd1009248d1bd8fcea7da92d661.tar.gz frameworks_base-a643652680486bd1009248d1bd8fcea7da92d661.tar.bz2 |
Merge "Human-readable POSIX capabilities for SystemServer."
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 9e43749..4ac16d8 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -35,6 +35,7 @@ import dalvik.system.Zygote; import libcore.io.IoUtils; import libcore.io.Libcore; +import libcore.io.OsConstants; import java.io.BufferedReader; import java.io.FileDescriptor; @@ -479,12 +480,25 @@ public class ZygoteInit { */ private static boolean startSystemServer() throws MethodAndArgsCaller, RuntimeException { + long capabilities = posixCapabilitiesAsBits( + OsConstants.CAP_KILL, + OsConstants.CAP_NET_ADMIN, + OsConstants.CAP_NET_BIND_SERVICE, + OsConstants.CAP_NET_BROADCAST, + OsConstants.CAP_NET_RAW, + OsConstants.CAP_SYS_BOOT, + OsConstants.CAP_SYS_MODULE, + OsConstants.CAP_SYS_NICE, + OsConstants.CAP_SYS_RESOURCE, + OsConstants.CAP_SYS_TIME, + OsConstants.CAP_SYS_TTY_CONFIG + ); /* Hardcoded command line to start the system server */ String args[] = { "--setuid=1000", "--setgid=1000", "--setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1018,3001,3002,3003,3006,3007", - "--capabilities=130104352,130104352", + "--capabilities=" + capabilities + "," + capabilities, "--runtime-init", "--nice-name=system_server", "com.android.server.SystemServer", @@ -518,6 +532,20 @@ public class ZygoteInit { return true; } + /** + * Gets the bit array representation of the provided list of POSIX capabilities. + */ + private static long posixCapabilitiesAsBits(int... capabilities) { + long result = 0; + for (int capability : capabilities) { + if ((capability < 0) || (capability > OsConstants.CAP_LAST_CAP)) { + throw new IllegalArgumentException(String.valueOf(capability)); + } + result |= (1L << capability); + } + return result; + } + public static void main(String argv[]) { try { // Start profiling the zygote initialization. |