Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bd6b8c1c authored by Alex Buynytskyy's avatar Alex Buynytskyy Committed by Automerger Merge Worker
Browse files

Merge "More robust restorecon and additional debug info." into tm-dev am:...

Merge "More robust restorecon and additional debug info." into tm-dev am: 8169e839 am: a18cf5d2 am: 4225882e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18129666



Change-Id: I9d48969a20aa1728a163f89201363071ca8d2b41
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents d85eb94f 4225882e
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -239,8 +239,12 @@ static jboolean setFileCon(JNIEnv *env, jobject, jstring pathStr, jstring contex
    char *tmp = const_cast<char *>(context.c_str());
    int ret = setfilecon(path.c_str(), tmp);

    if (ret == 0) {
        ALOGV("setFileCon(%s, %s) => %d", path.c_str(), context.c_str(), ret);
    return (ret == 0) ? true : false;
        return true;
    }
    ALOGE("setFileCon(%s, %s) => %d, err: %s", path.c_str(), context.c_str(), ret, strerror(errno));
    return false;
}

/*
+10 −1
Original line number Diff line number Diff line
@@ -1034,9 +1034,18 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }

        if (!SELinux.restorecon(stageDir)) {
            String path = stageDir.getCanonicalPath();
            String ctx = SELinux.fileSelabelLookup(path);
            boolean success = SELinux.setFileContext(path, ctx);
            Slog.e(TAG,
                    "Failed to SELinux.restorecon session dir, path: [" + path + "], ctx: [" + ctx
                            + "]. Retrying via SELinux.fileSelabelLookup/SELinux.setFileContext: "
                            + (success ? "SUCCESS" : "FAILURE"));
            if (!success) {
                throw new IOException("Failed to restorecon session dir: " + stageDir);
            }
        }
    }

    private String buildExternalStageCid(int sessionId) {
        return "smdl" + sessionId + ".tmp";