OSDN Git Service

Make /linkerconfig/<apexname> directories accessible to others
authorJiyong Park <jiyong@google.com>
Fri, 21 Feb 2020 04:56:52 +0000 (13:56 +0900)
committerJiyong Park <jiyong@google.com>
Fri, 21 Feb 2020 04:56:52 +0000 (13:56 +0900)
When linkerconfig is exec'ed by init, umask is by default set to 0x0077.
As a result, even though we create the directories with mkdir(...,
0755), they are marked as inaccessible for group and others.

Fixing the issue by explicitly setting umask to 0x0022.

Bug: 144914078
Test: build a device with flattened APEX. Check the mode bits of the
directories of under /linkerconfig.

$ ls -al /linkerconfig
total 96
drwxr-xr-x  9 root root   200 2020-02-21 13:47 .
drwxr-xr-x 22 root root  4096 2020-02-21 13:54 ..
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.adbd
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.art
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.conscrypt
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.media.swcodec
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.os.statsd
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.runtime
drwx--xr-x  2 root root    60 2020-02-21 13:47 com.android.sdkext
-rw-r--r--  1 root root 91651 2020-02-21 13:47 ld.config.txt

Change-Id: Id2f7f8a363ba239943942ba6e3bc984cd8f630b0

main.cc

diff --git a/main.cc b/main.cc
index d82ebf6..0b1a8ff 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -300,6 +300,11 @@ int main(int argc, char* argv[]) {
   LoadVariables(args);
   Context ctx = GetContext(args);
 
+  // when exec'ed from init, this is 0x0077, which makes the subdirectories
+  // inaccessible for others. set umask to 0x0022 so that they can be
+  // accessible.
+  umask(0x0022);
+
   if (args.is_recovery) {
     ExitOnFailure(
         GenerateRecoveryLinkerConfiguration(ctx, args.target_directory));