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

Commit 6fb848e8 authored by Eric Biggers's avatar Eric Biggers Committed by Automerger Merge Worker
Browse files

Merge "Avoid two SELinux related error messages at boot time" into main am:...

Merge "Avoid two SELinux related error messages at boot time" into main am: 87d6c8a1 am: 5236858b am: db34b3e5 am: 212f1f06 am: 301a1ecd

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2705761



Change-Id: I89ec6fec6e4e7b6075251bec5e962eeb600bf26d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8531d97f 301a1ecd
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -735,6 +735,14 @@ void SelinuxAvcLog(char* buf) {
    TEMP_FAILURE_RETRY(send(fd.get(), &request, sizeof(request), 0));
}

int RestoreconIfExists(const char* path, unsigned int flags) {
    if (access(path, F_OK) != 0 && errno == ENOENT) {
        // Avoid error message for path that is expected to not always exist.
        return 0;
    }
    return selinux_android_restorecon(path, flags);
}

}  // namespace

void SelinuxRestoreContext() {
@@ -762,9 +770,9 @@ void SelinuxRestoreContext() {

    // adb remount, snapshot-based updates, and DSUs all create files during
    // first-stage init.
    selinux_android_restorecon(SnapshotManager::GetGlobalRollbackIndicatorPath().c_str(), 0);
    selinux_android_restorecon("/metadata/gsi", SELINUX_ANDROID_RESTORECON_RECURSE |
                                                        SELINUX_ANDROID_RESTORECON_SKIP_SEHASH);
    RestoreconIfExists(SnapshotManager::GetGlobalRollbackIndicatorPath().c_str(), 0);
    RestoreconIfExists("/metadata/gsi",
                       SELINUX_ANDROID_RESTORECON_RECURSE | SELINUX_ANDROID_RESTORECON_SKIP_SEHASH);
}

int SelinuxKlogCallback(int type, const char* fmt, ...) {