summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Craig <rpcraig@tycho.ncsc.mil>2012-11-13 13:23:39 -0500
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-07-18 20:38:39 +0100
commit584184911e3040bade4695d58ea5a3179406be51 (patch)
tree8dc555ebba80bd3643e41d91bb77242d0820a0ef
parente46e20d18ae842d964836640057554783f564482 (diff)
downloadsystem_core-584184911e3040bade4695d58ea5a3179406be51.tar.gz
system_core-584184911e3040bade4695d58ea5a3179406be51.tar.bz2
system_core-584184911e3040bade4695d58ea5a3179406be51.zip
run-as: Get seinfo from packages.list and pass to libselinux.
-rw-r--r--run-as/package.c13
-rw-r--r--run-as/package.h1
-rw-r--r--run-as/run-as.c2
3 files changed, 15 insertions, 1 deletions
diff --git a/run-as/package.c b/run-as/package.c
index 143d647bf..a836acf06 100644
--- a/run-as/package.c
+++ b/run-as/package.c
@@ -411,6 +411,7 @@ get_package_info(const char* pkgName, PackageInfo *info)
info->uid = 0;
info->isDebuggable = 0;
info->dataDir[0] = '\0';
+ info->seinfo[0] = '\0';
buffer = map_file(PACKAGES_LIST_FILE, &buffer_len);
if (buffer == NULL)
@@ -428,6 +429,7 @@ get_package_info(const char* pkgName, PackageInfo *info)
* <uid> is the application-specific user Id (decimal)
* <debugFlag> is 1 if the package is debuggable, or 0 otherwise
* <dataDir> is the path to the package's data directory (e.g. /data/data/com.example.foo)
+ * <seinfo> is the seinfo label associated with the package
*
* The file is generated in com.android.server.PackageManagerService.Settings.writeLP()
*/
@@ -485,6 +487,17 @@ get_package_info(const char* pkgName, PackageInfo *info)
string_copy(info->dataDir, sizeof info->dataDir, p, q - p);
+ /* skip spaces */
+ if (parse_spaces(&p, end) < 0)
+ goto BAD_FORMAT;
+
+ /* grab the seinfo string */
+ q = skip_non_spaces(p, end);
+ if (q == p)
+ goto BAD_FORMAT;
+
+ string_copy(info->seinfo, sizeof info->seinfo, p, q - p);
+
/* Ignore the rest */
result = 0;
goto EXIT;
diff --git a/run-as/package.h b/run-as/package.h
index 852af0632..34603c013 100644
--- a/run-as/package.h
+++ b/run-as/package.h
@@ -30,6 +30,7 @@ typedef struct {
uid_t uid;
char isDebuggable;
char dataDir[PATH_MAX];
+ char seinfo[PATH_MAX];
} PackageInfo;
/* see documentation in package.c for these functiosn */
diff --git a/run-as/run-as.c b/run-as/run-as.c
index 9eb09aed3..3c0ecc4a9 100644
--- a/run-as/run-as.c
+++ b/run-as/run-as.c
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
return 1;
}
- if (selinux_android_setcontext(uid, 0, NULL, pkgname) < 0) {
+ if (selinux_android_setcontext(uid, 0, info.seinfo, pkgname) < 0) {
panic("Could not set SELinux security context: %s\n", strerror(errno));
return 1;
}