[systemd-commits] 4 commits - TODO src/core src/journal
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Oct 3 08:57:03 PDT 2012
TODO | 3 +++
src/core/selinux-access.c | 1 +
src/journal/journal-send.c | 16 ++++++++--------
src/journal/journald-native.c | 37 ++++++++++++++++++++++++++++++++++---
src/journal/test-journal-send.c | 10 ++++++++++
5 files changed, 56 insertions(+), 11 deletions(-)
New commits:
commit 07c289875fd46331a430c43e8991d3c7407cb703
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Oct 3 11:50:45 2012 -0400
journal-send: simplification
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index d503f3f..8589d94 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -505,10 +505,10 @@ _public_ int sd_journal_printv_with_location(int priority, const char *file, con
/* func is initialized from __func__ which is not a macro, but
* a static const char[], hence cannot easily be prefixed with
* CODE_FUNC=, hence let's do it manually here. */
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
zero(iov);
IOVEC_SET_STRING(iov[0], buffer);
@@ -536,10 +536,10 @@ _public_ int sd_journal_send_with_location(const char *file, const char *line, c
goto finish;
}
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
IOVEC_SET_STRING(iov[0], file);
IOVEC_SET_STRING(iov[1], line);
@@ -574,10 +574,10 @@ _public_ int sd_journal_sendv_with_location(
niov = alloca(sizeof(struct iovec) * (n + 3));
memcpy(niov, iov, sizeof(struct iovec) * n);
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
IOVEC_SET_STRING(niov[n++], file);
IOVEC_SET_STRING(niov[n++], line);
@@ -595,10 +595,10 @@ _public_ int sd_journal_perror_with_location(
size_t fl;
char *f;
- fl = strlen(func);
+ fl = strlen(func) + 1;
f = alloca(fl + 10);
memcpy(f, "CODE_FUNC=", 10);
- memcpy(f + 10, func, fl + 1);
+ memcpy(f + 10, func, fl);
IOVEC_SET_STRING(iov[0], file);
IOVEC_SET_STRING(iov[1], line);
commit 1dfa7e79a60de680086b1d93fcc3629b463f58bd
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Oct 3 11:37:44 2012 -0400
journald: only accept fds from certain directories
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 85458b5..12fb980 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -24,6 +24,7 @@
#include <sys/epoll.h>
#include "socket-util.h"
+#include "path-util.h"
#include "journald.h"
#include "journald-native.h"
#include "journald-kmsg.h"
@@ -281,12 +282,44 @@ void server_process_native_file(
const char *label, size_t label_len) {
struct stat st;
- void *p;
+ _cleanup_free_ void *p = NULL;
ssize_t n;
+ int r;
assert(s);
assert(fd >= 0);
+ if (!ucred || ucred->uid != 0) {
+ _cleanup_free_ char *sl = NULL, *k = NULL;
+ const char *e;
+
+ if (asprintf(&sl, "/proc/self/fd/%i", fd) < 0) {
+ log_oom();
+ return;
+ }
+
+ r = readlink_malloc(sl, &k);
+ if (r < 0) {
+ log_error("readlink(%s) failed: %m", sl);
+ return;
+ }
+
+ e = path_startswith(k, "/dev/shm/");
+ if (!e)
+ e = path_startswith(k, "/tmp/");
+ if (!e)
+ e = path_startswith(k, "/var/tmp/");
+ if (!e) {
+ log_error("Received file outside of allowed directories. Refusing.");
+ return;
+ }
+
+ if (strchr(e, '/')) {
+ log_error("Received file in subdirectory of allowed directories. Refusing.");
+ return;
+ }
+ }
+
/* Data is in the passed file, since it didn't fit in a
* datagram. We can't map the file here, since clients might
* then truncate it and trigger a SIGBUS for us. So let's
@@ -321,8 +354,6 @@ void server_process_native_file(
log_error("Failed to read file, ignoring: %s", strerror(-n));
else if (n > 0)
server_process_native_message(s, p, n, ucred, tv, label, label_len);
-
- free(p);
}
int server_open_native_socket(Server*s) {
diff --git a/src/journal/test-journal-send.c b/src/journal/test-journal-send.c
index e708fa4..168c843 100644
--- a/src/journal/test-journal-send.c
+++ b/src/journal/test-journal-send.c
@@ -24,6 +24,8 @@
#include "log.h"
int main(int argc, char *argv[]) {
+ char huge[4096*1024];
+
log_set_max_level(LOG_DEBUG);
sd_journal_print(LOG_INFO, "piepapo");
@@ -37,5 +39,13 @@ int main(int argc, char *argv[]) {
sd_journal_perror("");
+ memset(huge, 'x', sizeof(huge));
+ memcpy(huge, "HUGE=", 5);
+ char_array_0(huge);
+
+ sd_journal_send("MESSAGE=Huge field attached",
+ huge,
+ NULL);
+
return 0;
}
commit 08f9588885c5d65694b324846b0ed19211d2c178
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Oct 3 11:37:06 2012 -0400
update TODO
diff --git a/TODO b/TODO
index e836e1d..5329c08 100644
--- a/TODO
+++ b/TODO
@@ -18,6 +18,9 @@ F18:
* Retest multi-seat
Features:
+
+* on shutdown: move utmp, wall, audit logic all into PID 1 itsel
+
* add "provisioning" instructions to setup an empty /etc + /var
- used to setup a new container from a shared /usr
- superset of tmpfiles model
commit a9e51d5752babffcaa70a0225bf6b673ab8ffe58
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Oct 3 11:36:57 2012 -0400
selinux: properly free dbus error
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index 4b1dc74..d9c3f9b 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -298,6 +298,7 @@ static int get_calling_context(
return r;
log_debug("bus_get_selinux_security_context failed %m");
+ dbus_error_free(error);
}
if (!dbus_connection_get_unix_fd(connection, &fd)) {
More information about the systemd-commits
mailing list