chiark / gitweb /
ptyfwd: Don't set the output prop of stdin, nor the input props of stdout.
[elogind.git] / src / journal / journald-stream.c
index 9c4efec9bcd4713f83285a0088ddbab259a149bb..42a846b8eae615c65c09a5b95dd0141e77bb99d7 100644 (file)
@@ -29,6 +29,7 @@
 #endif
 
 #include "socket-util.h"
+#include "selinux-util.h"
 #include "journald-server.h"
 #include "journald-stream.h"
 #include "journald-syslog.h"
@@ -75,7 +76,7 @@ struct StdoutStream {
 
 static int stdout_stream_log(StdoutStream *s, const char *p) {
         struct iovec iovec[N_IOVEC_META_FIELDS + 5];
-        char *message = NULL, *syslog_priority = NULL, *syslog_facility = NULL, *syslog_identifier = NULL;
+        _cleanup_free_ char *message = NULL, *syslog_priority = NULL, *syslog_facility = NULL, *syslog_identifier = NULL;
         unsigned n = 0;
         int priority;
         char *label = NULL;
@@ -128,12 +129,6 @@ static int stdout_stream_log(StdoutStream *s, const char *p) {
 #endif
 
         server_dispatch_message(s->server, iovec, n, ELEMENTSOF(iovec), &s->ucred, NULL, label, label_len, s->unit_id, priority, 0);
-
-        free(message);
-        free(syslog_priority);
-        free(syslog_facility);
-        free(syslog_identifier);
-
         return 0;
 }
 
@@ -323,7 +318,7 @@ void stdout_stream_free(StdoutStream *s) {
         if (s->server) {
                 assert(s->server->n_stdout_streams > 0);
                 s->server->n_stdout_streams --;
-                LIST_REMOVE(StdoutStream, stdout_stream, s->server->stdout_streams, s);
+                LIST_REMOVE(stdout_stream, s->server->stdout_streams, s);
         }
 
         if (s->fd >= 0) {
@@ -339,6 +334,7 @@ void stdout_stream_free(StdoutStream *s) {
 #endif
 
         free(s->identifier);
+        free(s->unit_id);
         free(s);
 }
 
@@ -381,8 +377,10 @@ int stdout_stream_new(Server *s) {
         }
 
 #ifdef HAVE_SELINUX
-        if (getpeercon(fd, &stream->security_context) < 0 && errno != ENOPROTOOPT)
-                log_error("Failed to determine peer security context: %m");
+        if (use_selinux()) {
+                if (getpeercon(fd, &stream->security_context) < 0 && errno != ENOPROTOOPT)
+                        log_error("Failed to determine peer security context: %m");
+        }
 #endif
 
         if (shutdown(fd, SHUT_WR) < 0) {
@@ -401,7 +399,7 @@ int stdout_stream_new(Server *s) {
         }
 
         stream->server = s;
-        LIST_PREPEND(StdoutStream, stdout_stream, s->stdout_streams, stream);
+        LIST_PREPEND(stdout_stream, s->stdout_streams, stream);
         s->n_stdout_streams ++;
 
         return 0;