summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorrpcraig <rpcraig@tycho.ncsc.mil>2012-11-14 10:07:28 -0500
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-07-18 20:56:41 +0100
commite6a337246ee3736727f43ed21a2287a59ed4491c (patch)
tree1263d1093b79d5ff0d38aefab78d214d66252a55 /services
parent6c33ad36e429b3a3ad69e53275714ca43cdc03fe (diff)
downloadframeworks_base-e6a337246ee3736727f43ed21a2287a59ed4491c.zip
frameworks_base-e6a337246ee3736727f43ed21a2287a59ed4491c.tar.gz
frameworks_base-e6a337246ee3736727f43ed21a2287a59ed4491c.tar.bz2
Add seinfo parsing to PackageManagerService.
This patch set allows the PMS to parse the mac_permissions.xml file which contains the seinfo values. Each package that is installed on the device will be assigned an seinfo value based on policy. This seinfo value will help label the app process and data directory. Modifications also include, adjustments to ApplicationInfo.java to store the seinfo tag per package, adjustments to installd to communicate the seinfo tag to libselinux, and finally a set of unit tests. Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil> Change-Id: I61ad1ea12fb6a9a6d0b108ec163bc4bf4c954b58
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java2
-rw-r--r--services/java/com/android/server/pm/Installer.java4
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java25
3 files changed, 25 insertions, 6 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index d7f9eb4..4c83116 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2217,7 +2217,7 @@ public final class ActivityManagerService extends ActivityManagerNative
// the PID of the new process, or else throw a RuntimeException.
Process.ProcessStartResult startResult = Process.start("android.app.ActivityThread",
app.processName, uid, uid, gids, debugFlags, mountExternal,
- app.info.targetSdkVersion, null, null);
+ app.info.targetSdkVersion, app.info.seinfo, null);
BatteryStatsImpl bs = app.batteryStats.getBatteryStats();
synchronized (bs) {
diff --git a/services/java/com/android/server/pm/Installer.java b/services/java/com/android/server/pm/Installer.java
index 71a6a01..ddb0d0b 100644
--- a/services/java/com/android/server/pm/Installer.java
+++ b/services/java/com/android/server/pm/Installer.java
@@ -188,7 +188,7 @@ public final class Installer {
}
}
- public int install(String name, int uid, int gid) {
+ public int install(String name, int uid, int gid, String seinfo) {
StringBuilder builder = new StringBuilder("install");
builder.append(' ');
builder.append(name);
@@ -196,6 +196,8 @@ public final class Installer {
builder.append(uid);
builder.append(' ');
builder.append(gid);
+ builder.append(' ');
+ builder.append(seinfo != null ? seinfo : "!");
return execute(builder.toString());
}
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index f134854..0bf7be9 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -85,6 +85,7 @@ import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
+import android.content.pm.SELinuxMMAC;
import android.content.pm.ServiceInfo;
import android.content.pm.Signature;
import android.content.pm.ManifestDigest;
@@ -360,6 +361,9 @@ public class PackageManagerService extends IPackageManager.Stub {
final HashMap<String, FeatureInfo> mAvailableFeatures =
new HashMap<String, FeatureInfo>();
+ // If mac_permissions.xml was found for seinfo labeling.
+ boolean mFoundPolicyFile;
+
// All available activities, for your resolving pleasure.
final ActivityIntentResolver mActivities =
new ActivityIntentResolver();
@@ -1158,6 +1162,13 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
+ // Find potential SELinux install policy
+ long startPolicyTime = SystemClock.uptimeMillis();
+ mFoundPolicyFile = SELinuxMMAC.readInstallPolicy();
+ Slog.i(TAG, "Time to scan SELinux install policy: "
+ + ((SystemClock.uptimeMillis()-startPolicyTime)/1000f)
+ + " seconds");
+
// Find base frameworks (resource packages without code).
mFrameworkInstallObserver = new AppDirObserver(
mFrameworkDir.getPath(), OBSERVER_EVENTS, true);
@@ -3597,9 +3608,9 @@ public class PackageManagerService extends IPackageManager.Stub {
}
}
- private int createDataDirsLI(String packageName, int uid) {
+ private int createDataDirsLI(String packageName, int uid, String seinfo) {
int[] users = sUserManager.getUserIds();
- int res = mInstaller.install(packageName, uid, uid);
+ int res = mInstaller.install(packageName, uid, uid, seinfo);
if (res < 0) {
return res;
}
@@ -3646,6 +3657,10 @@ public class PackageManagerService extends IPackageManager.Stub {
}
mScanningPath = scanFile;
+ if (mFoundPolicyFile) {
+ SELinuxMMAC.assignSeinfoValue(pkg);
+ }
+
if ((parseFlags&PackageParser.PARSE_IS_SYSTEM) != 0) {
pkg.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM;
}
@@ -4014,7 +4029,8 @@ public class PackageManagerService extends IPackageManager.Stub {
recovered = true;
// And now re-install the app.
- ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid);
+ ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid,
+ pkg.applicationInfo.seinfo);
if (ret == -1) {
// Ack should not happen!
msg = prefix + pkg.packageName
@@ -4060,7 +4076,8 @@ public class PackageManagerService extends IPackageManager.Stub {
Log.v(TAG, "Want this data dir: " + dataPath);
}
//invoke installer to do the actual installation
- int ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid);
+ int ret = createDataDirsLI(pkgName, pkg.applicationInfo.uid,
+ pkg.applicationInfo.seinfo);
if (ret < 0) {
// Error from installer
mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;