summaryrefslogtreecommitdiff
path: root/services/java
diff options
context:
space:
mode:
author Kenny Root <kroot@google.com> 2012-08-16 16:06:29 -0700
committer android code review <noreply-gerritcodereview@google.com> 2012-08-16 16:06:29 -0700
commita950daf5c14a0009c2c62e9c3e0e8d51eb0cf7d9 (patch)
tree159a05b5baca8a5849aae3e6e5da484ab51719dd /services/java
parentd2fb6e99bda1ae607b5dfbb68905030f2133f8e8 (diff)
parent98e15e78934a00cf46f2be55472b7fd7a39ac0de (diff)
Merge changes Ieb566a2a,I953057cd
* changes: Use Libcore's stat instead of FileUtils#getFileStatus Use Libcore.os.stat instead of FileUtils
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 8c5a0908c9b5..7390cbe2030f 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -144,6 +144,7 @@ import java.util.Set;
import libcore.io.ErrnoException;
import libcore.io.IoUtils;
import libcore.io.Libcore;
+import libcore.io.StructStat;
/**
* Keep track of all those .apks everywhere.
@@ -294,8 +295,6 @@ public class PackageManagerService extends IPackageManager.Stub {
File mScanningPath;
int mLastScanError;
- final int[] mOutPermissions = new int[3];
-
// ----------------------------------------------------------------
// Keys are String (package name), values are Package. This also serves
@@ -3762,14 +3761,18 @@ public class PackageManagerService extends IPackageManager.Stub {
boolean uidError = false;
if (dataPath.exists()) {
- // XXX should really do this check for each user.
- mOutPermissions[1] = 0;
- FileUtils.getPermissions(dataPath.getPath(), mOutPermissions);
+ int currentUid = 0;
+ try {
+ StructStat stat = Libcore.os.stat(dataPath.getPath());
+ currentUid = stat.st_uid;
+ } catch (ErrnoException e) {
+ Slog.e(TAG, "Couldn't stat path " + dataPath.getPath(), e);
+ }
// If we have mismatched owners for the data path, we have a problem.
- if (mOutPermissions[1] != pkg.applicationInfo.uid) {
+ if (currentUid != pkg.applicationInfo.uid) {
boolean recovered = false;
- if (mOutPermissions[1] == 0) {
+ if (currentUid == 0) {
// The directory somehow became owned by root. Wow.
// This is probably because the system was stopped while
// installd was in the middle of messing with its libs
@@ -3798,7 +3801,7 @@ public class PackageManagerService extends IPackageManager.Stub {
? "System package " : "Third party package ";
String msg = prefix + pkg.packageName
+ " has changed from uid: "
- + mOutPermissions[1] + " to "
+ + currentUid + " to "
+ pkg.applicationInfo.uid + "; old data erased";
reportSettingsProblem(Log.WARN, msg);
recovered = true;
@@ -3830,11 +3833,11 @@ public class PackageManagerService extends IPackageManager.Stub {
if (!recovered) {
pkg.applicationInfo.dataDir = "/mismatched_uid/settings_"
+ pkg.applicationInfo.uid + "/fs_"
- + mOutPermissions[1];
+ + currentUid;
pkg.applicationInfo.nativeLibraryDir = pkg.applicationInfo.dataDir;
String msg = "Package " + pkg.packageName
+ " has mismatched uid: "
- + mOutPermissions[1] + " on disk, "
+ + currentUid + " on disk, "
+ pkg.applicationInfo.uid + " in settings";
// writer
synchronized (mPackages) {