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

Commit ba658099 authored by Nick Kralevich's avatar Nick Kralevich Committed by android-build-merger
Browse files

Merge "logd: remove SELinux dup handling"

am: 8e6fb82a

Change-Id: Ifaf6e94171bf99a52fa78697de1aa8ec1047651b
parents 47a38645 8e6fb82a
Loading
Loading
Loading
Loading
+11 −64
Original line number Diff line number Diff line
@@ -229,60 +229,8 @@ int LogAudit::logPrint(const char* fmt, ...) {
        static const char log_warning[] = { KMSG_PRIORITY(LOG_WARNING) };
        static const char newline[] = "\n";

        // Dedupe messages, checking for identical messages starting with avc:
        static unsigned count;
        static char* last_str;
        static bool last_info;

        if (last_str != nullptr) {
            static const char avc[] = "): avc: ";
            char* avcl = strstr(last_str, avc);
            bool skip = false;

            if (avcl) {
                char* avcr = strstr(str, avc);

                skip = avcr &&
                       !fastcmp<strcmp>(avcl + strlen(avc), avcr + strlen(avc));
                if (skip) {
                    ++count;
                    free(last_str);
                    last_str = strdup(str);
                    last_info = info;
                }
            }
            if (!skip) {
                static const char resume[] = " duplicate messages suppressed\n";
                iov[0].iov_base = last_info ? const_cast<char*>(log_info)
                                            : const_cast<char*>(log_warning);
                iov[0].iov_len =
                    last_info ? sizeof(log_info) : sizeof(log_warning);
                iov[1].iov_base = last_str;
                iov[1].iov_len = strlen(last_str);
                iov[2].iov_base = const_cast<char*>(denial_metadata.c_str());
                iov[2].iov_len = denial_metadata.length();
                if (count > 1) {
                    iov[3].iov_base = const_cast<char*>(resume);
                    iov[3].iov_len = strlen(resume);
                } else {
                    iov[3].iov_base = const_cast<char*>(newline);
                    iov[3].iov_len = strlen(newline);
                }

                writev(fdDmesg, iov, arraysize(iov));
                free(last_str);
                last_str = nullptr;
            }
        }
        if (last_str == nullptr) {
            count = 0;
            last_str = strdup(str);
            last_info = info;
        }
        if (count == 0) {
        auditParse(str, uid, &denial_metadata);
            iov[0].iov_base = info ? const_cast<char*>(log_info)
                                   : const_cast<char*>(log_warning);
        iov[0].iov_base = info ? const_cast<char*>(log_info) : const_cast<char*>(log_warning);
        iov[0].iov_len = info ? sizeof(log_info) : sizeof(log_warning);
        iov[1].iov_base = str;
        iov[1].iov_len = strlen(str);
@@ -293,7 +241,6 @@ int LogAudit::logPrint(const char* fmt, ...) {

        writev(fdDmesg, iov, arraysize(iov));
    }
    }

    if (!main && !events) {
        free(str);