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

Commit 64458c79 authored by Tom Cherry's avatar Tom Cherry
Browse files

logd: always report the UID of a log message

logd currently only reports the UID of a log message for 'privileged'
readers (those with a uid or gid of root, system, or log).  However,
UIDs are not particularly sensitive.  Much more importantly,
non-privileged readers can only see less messages from their own UID,
so this restriction is essentially a no-op, as those readers will
already know their own uid.

Test: liblog and logd unit tests
Change-Id: I9da7d15eb840ba3200128391e70d618eec79f988
parent f5bad500
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1185,7 +1185,7 @@ log_time LogBuffer::flushTo(SocketClient* reader, const log_time& start,
        unlock();

        // range locking in LastLogTimes looks after us
        curr = element->flushTo(reader, this, privileged, sameTid);
        curr = element->flushTo(reader, this, sameTid);

        if (curr == element->FLUSH_ERROR) {
            return curr;
+3 −7
Original line number Diff line number Diff line
@@ -244,14 +244,10 @@ size_t LogBufferElement::populateDroppedMessage(char*& buffer, LogBuffer* parent
    return retval;
}

log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent,
                                   bool privileged, bool lastSame) {
    struct logger_entry_v4 entry;
log_time LogBufferElement::flushTo(SocketClient* reader, LogBuffer* parent, bool lastSame) {
    struct logger_entry_v4 entry = {};

    memset(&entry, 0, sizeof(struct logger_entry_v4));

    entry.hdr_size = privileged ? sizeof(struct logger_entry_v4)
                                : sizeof(struct logger_entry_v3);
    entry.hdr_size = sizeof(struct logger_entry_v4);
    entry.lid = mLogId;
    entry.pid = mPid;
    entry.tid = mTid;
+2 −6
Original line number Diff line number Diff line
@@ -14,8 +14,7 @@
 * limitations under the License.
 */

#ifndef _LOGD_LOG_BUFFER_ELEMENT_H__
#define _LOGD_LOG_BUFFER_ELEMENT_H__
#pragma once

#include <stdatomic.h>
#include <stdint.h>
@@ -96,8 +95,5 @@ class __attribute__((packed)) LogBufferElement {
    }

    static const log_time FLUSH_ERROR;
    log_time flushTo(SocketClient* writer, LogBuffer* parent, bool privileged,
                     bool lastSame);
    log_time flushTo(SocketClient* writer, LogBuffer* parent, bool lastSame);
};

#endif