#endif
#include "socket-util.h"
+#include "selinux-util.h"
#include "journald-server.h"
#include "journald-stream.h"
#include "journald-syslog.h"
priority = s->priority;
if (s->level_prefix)
- syslog_parse_priority((char**) &p, &priority);
+ syslog_parse_priority((char**) &p, &priority, false);
if (s->forward_to_syslog || s->server->forward_to_syslog)
server_forward_syslog(s->server, syslog_fixup_facility(priority), s->identifier, p, &s->ucred, NULL);
}
#endif
- server_dispatch_message(s->server, iovec, n, ELEMENTSOF(iovec), &s->ucred, NULL, label, label_len, s->unit_id, priority);
+ 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);
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) {
}
#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) {
}
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;
}
int server_open_stdout_socket(Server *s) {
- union sockaddr_union sa;
int r;
struct epoll_event ev;
assert(s);
if (s->stdout_fd < 0) {
+ union sockaddr_union sa = {
+ .un.sun_family = AF_UNIX,
+ .un.sun_path = "/run/systemd/journal/stdout",
+ };
s->stdout_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->stdout_fd < 0) {
return -errno;
}
- zero(sa);
- sa.un.sun_family = AF_UNIX;
- strncpy(sa.un.sun_path, "/run/systemd/journal/stdout", sizeof(sa.un.sun_path));
-
unlink(sa.un.sun_path);
r = bind(s->stdout_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
chmod(sa.un.sun_path, 0666);
if (listen(s->stdout_fd, SOMAXCONN) < 0) {
- log_error("liste() failed: %m");
+ log_error("listen() failed: %m");
return -errno;
}
} else