diff options
author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-07-19 17:12:37 +0100 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-07-19 17:12:37 +0100 |
commit | 1a18b8bce5d8ae0ed5f8e8e6aeb4541486da64bb (patch) | |
tree | dcec765969f4bc85150a5bd1864d0c2969012a3f /toolbox | |
parent | d0808c7d20b117ea832ca7b5166e20015427ce6f (diff) | |
download | system_core-1a18b8bce5d8ae0ed5f8e8e6aeb4541486da64bb.zip system_core-1a18b8bce5d8ae0ed5f8e8e6aeb4541486da64bb.tar.gz system_core-1a18b8bce5d8ae0ed5f8e8e6aeb4541486da64bb.tar.bz2 |
toolbox: Add levelFromUid categorization support to restorecon
This is necessary for the app data relabeling on migrated devices
to include the proper app context. Freshly installed apps get this
done automagically, as do newly created files.
Change-Id: If7421dac01c6ae8bd78e66f71e69298ed850a7ab
Diffstat (limited to 'toolbox')
-rw-r--r-- | toolbox/restorecon.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/toolbox/restorecon.c b/toolbox/restorecon.c index f9f604f..31b7f12 100644 --- a/toolbox/restorecon.c +++ b/toolbox/restorecon.c @@ -8,6 +8,7 @@ #include <selinux/selinux.h> #include <selinux/label.h> #include <selinux/android.h> +#include <private/android_filesystem_config.h> static struct selabel_handle *sehandle; static const char *progname; @@ -34,6 +35,16 @@ static int restore(const char *pathname, const struct stat *sb) strerror(errno)); return -1; } + if (sb->st_uid >= AID_APP && strcmp(newcontext,",c") && strcmp(newcontext,"app_data_file") >= 0) { + char *catcontext; + uid_t appid = sb->st_uid - AID_APP; + + catcontext = malloc(strlen(newcontext)+16); + sprintf(catcontext,"%s:c%d,c%d",newcontext,appid & 0xff, + 256 + (appid>>8 & 0xff)); + freecon(newcontext); + newcontext = catcontext; + } if (strcmp(newcontext, "<<none>>") && strcmp(oldcontext, newcontext)) { if (verbose) |