[systemd-commits] 2 commits - src/journal
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Jan 11 13:45:13 PST 2012
src/journal/journal-file.c | 5 ++---
src/journal/journal-file.h | 2 +-
src/journal/journald.c | 22 ++++++++++++++++++++--
3 files changed, 23 insertions(+), 6 deletions(-)
New commits:
commit 8a0f04e6a283cc6734ee09a20305c13e09ba0418
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 11 22:45:05 2012 +0100
journal: add SELinux context to all logged messages
diff --git a/src/journal/journald.c b/src/journal/journald.c
index 33865b8..56cd313 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -52,6 +52,10 @@
#include "acl-util.h"
#endif
+#ifdef HAVE_SELINUX
+#include <selinux/selinux.h>
+#endif
+
#define USER_JOURNALS_MAX 1024
#define STDOUT_STREAMS_MAX 4096
@@ -64,7 +68,7 @@
#define SYSLOG_TIMEOUT_USEC (250*USEC_PER_MSEC)
-#define N_IOVEC_META_FIELDS 16
+#define N_IOVEC_META_FIELDS 17
typedef enum StdoutStreamState {
STDOUT_STREAM_IDENTIFIER,
@@ -436,7 +440,7 @@ static void dispatch_message_real(Server *s,
*comm = NULL, *cmdline = NULL, *hostname = NULL,
*audit_session = NULL, *audit_loginuid = NULL,
*exe = NULL, *cgroup = NULL, *session = NULL,
- *owner_uid = NULL, *unit = NULL;
+ *owner_uid = NULL, *unit = NULL, *selinux_context = NULL;
char idbuf[33];
sd_id128_t id;
@@ -454,6 +458,9 @@ static void dispatch_message_real(Server *s,
if (ucred) {
uint32_t audit;
uid_t owner;
+#ifdef HAVE_SELINUX
+ security_context_t con;
+#endif
realuid = ucred->uid;
@@ -531,6 +538,16 @@ static void dispatch_message_real(Server *s,
if (sd_pid_get_owner_uid(ucred->uid, &owner) >= 0)
if (asprintf(&owner_uid, "_SYSTEMD_OWNER_UID=%lu", (unsigned long) owner) >= 0)
IOVEC_SET_STRING(iovec[n++], owner_uid);
+
+#ifdef HAVE_SELINUX
+ if (getpidcon(ucred->pid, &con) >= 0) {
+ selinux_context = strappend("_SELINUX_CONTEXT=", con);
+ if (selinux_context)
+ IOVEC_SET_STRING(iovec[n++], selinux_context);
+
+ freecon(con);
+ }
+#endif
}
if (tv) {
@@ -602,6 +619,7 @@ retry:
free(session);
free(owner_uid);
free(unit);
+ free(selinux_context);
}
static void driver_message(Server *s, sd_id128_t message_id, const char *format, ...) {
commit b785c858c3baf855ec42e3b83f5d23dadfece069
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jan 11 22:44:43 2012 +0100
journal: fix more 32/64 bit issues
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 6ba3d8d..419e15e 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -640,8 +640,7 @@ int journal_file_find_data_object_with_hash(
if (o->object.flags & OBJECT_COMPRESSED) {
#ifdef HAVE_XZ
- uint64_t l;
- size_t rsize;
+ uint64_t l, rsize;
l = le64toh(o->object.size);
if (l <= offsetof(Object, data.payload))
@@ -652,7 +651,7 @@ int journal_file_find_data_object_with_hash(
if (!uncompress_blob(o->data.payload, l, &f->compress_buffer, &f->compress_buffer_size, &rsize))
return -EBADMSG;
- if ((uint64_t) rsize == size &&
+ if (rsize == size &&
memcmp(f->compress_buffer, data, size) == 0) {
if (ret)
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index 0be3932..4ef4a14 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -77,7 +77,7 @@ typedef struct JournalFile {
#ifdef HAVE_XZ
void *compress_buffer;
- size_t compress_buffer_size;
+ uint64_t compress_buffer_size;
#endif
} JournalFile;
More information about the systemd-commits
mailing list