Skip to content

Commit c921be1

Browse files
crpalmerhuangqiwu
authored andcommitted
init: Make restorecon_recursive work for /data/
In the following commit: commit f2b7ee7 Author: Stephen Smalley <[email protected]> Date: Thu Feb 6 13:52:52 2014 -0500 Apply restorecon_recursive to all of /data. they removed all the adhoc restorecon_recursive of subdirectories of /data/ and replaced it with: # Set SELinux security contexts on upgrade or policy update. restorecon_recursive /data Unfortunately, that is a no-op because restorecon doesn't recurse through /data/ unless you add a FORCE flag. Since the expectation seems to be that the recursive restorecon in init will actually work, update the built-in to add the force flag and a flag to allow /data/data to also be recursed through. [RC: Removed the DATADATA flag. It throws a ton of errors, and it's supposed to be handled by seapp_contexts, not file_contexts. The actual root paths, however, now get their individual restorecon calls so that installd can deal with them] Change-Id: I435c505188e924b27ef2e6a2e0ee0a6951e43f0e
1 parent 5997ab6 commit c921be1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

init/util.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,11 @@ int restorecon(const char* pathname)
530530
return selinux_android_restorecon(pathname, 0);
531531
}
532532

533+
#define RESTORECON_RECURSIVE_FLAGS \
534+
(SELINUX_ANDROID_RESTORECON_FORCE | \
535+
SELINUX_ANDROID_RESTORECON_RECURSE)
536+
533537
int restorecon_recursive(const char* pathname)
534538
{
535-
return selinux_android_restorecon(pathname, SELINUX_ANDROID_RESTORECON_RECURSE);
539+
return selinux_android_restorecon(pathname, RESTORECON_RECURSIVE_FLAGS);
536540
}

rootdir/init.rc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ on post-fs-data
315315

316316
# Set SELinux security contexts on upgrade or policy update.
317317
restorecon_recursive /data
318+
restorecon /data/data
319+
restorecon /data/user
320+
restorecon /data/user/0
318321

319322
# If there is no fs-post-data action in the init.<device>.rc file, you
320323
# must uncomment this line, otherwise encrypted filesystems

0 commit comments

Comments
 (0)