summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-audit.c3
-rw-r--r--src/journal/journald-context.c7
-rw-r--r--src/journal/journald-kmsg.c7
-rw-r--r--src/journal/journald-native.c25
-rw-r--r--src/journal/journald-server.c92
-rw-r--r--src/journal/journald-server.h2
-rw-r--r--src/journal/journald-stream.c35
-rw-r--r--src/journal/journald-syslog.c3
8 files changed, 93 insertions, 81 deletions
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index d301d28966..a2ebf97c9c 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -8,6 +8,7 @@
#include "fd-util.h"
#include "hexdecoct.h"
#include "io-util.h"
+#include "journal-internal.h"
#include "journald-audit.h"
#include "missing_audit.h"
#include "string-util.h"
@@ -441,7 +442,7 @@ void server_process_audit_message(
}
if (!NLMSG_OK(nl, buffer_size)) {
- log_ratelimit_error(JOURNALD_LOG_RATELIMIT, "Audit netlink message truncated.");
+ log_ratelimit_error(JOURNAL_LOG_RATELIMIT, "Audit netlink message truncated.");
return;
}
diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c
index 6d58422ddd..222855ae60 100644
--- a/src/journal/journald-context.c
+++ b/src/journal/journald-context.c
@@ -12,6 +12,7 @@
#include "fileio.h"
#include "fs-util.h"
#include "io-util.h"
+#include "journal-internal.h"
#include "journal-util.h"
#include "journald-context.h"
#include "parse-util.h"
@@ -258,7 +259,7 @@ static int client_context_read_label(
/* If we got no SELinux label passed in, let's try to acquire one */
- if (getpidcon(c->pid, &con) >= 0) {
+ if (getpidcon(c->pid, &con) >= 0 && con) {
free_and_replace(c->label, con);
c->label_size = strlen(c->label);
}
@@ -771,7 +772,7 @@ void client_context_acquire_default(Server *s) {
r = client_context_acquire(s, ucred.pid, &ucred, NULL, 0, NULL, &s->my_context);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to acquire our own context, ignoring: %m");
}
@@ -781,7 +782,7 @@ void client_context_acquire_default(Server *s) {
r = client_context_acquire(s, 1, NULL, NULL, 0, NULL, &s->pid1_context);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to acquire PID1's context, ignoring: %m");
}
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 6c1e7892d1..99eace0848 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -16,6 +16,7 @@
#include "format-util.h"
#include "fs-util.h"
#include "io-util.h"
+#include "journal-internal.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-syslog.h"
@@ -320,7 +321,7 @@ static int server_read_dev_kmsg(Server *s) {
if (l < 0) {
/* Old kernels who don't allow reading from /dev/kmsg
* return EINVAL when we try. So handle this cleanly,
- * but don' try to ever read from it again. */
+ * but don't try to ever read from it again. */
if (errno == EINVAL) {
s->dev_kmsg_event_source = sd_event_source_unref(s->dev_kmsg_event_source);
return 0;
@@ -329,7 +330,7 @@ static int server_read_dev_kmsg(Server *s) {
if (ERRNO_IS_TRANSIENT(errno) || errno == EPIPE)
return 0;
- return log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT, "Failed to read from /dev/kmsg: %m");
+ return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT, "Failed to read from /dev/kmsg: %m");
}
dev_kmsg_record(s, buffer, l);
@@ -368,7 +369,7 @@ static int dispatch_dev_kmsg(sd_event_source *es, int fd, uint32_t revents, void
assert(fd == s->dev_kmsg_fd);
if (revents & EPOLLERR)
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"/dev/kmsg buffer overrun, some messages lost.");
if (!(revents & EPOLLIN))
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 21e20db2d4..847f69c1ff 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -11,6 +11,7 @@
#include "fs-util.h"
#include "io-util.h"
#include "journal-importer.h"
+#include "journal-internal.h"
#include "journal-util.h"
#include "journald-console.h"
#include "journald-kmsg.h"
@@ -309,7 +310,7 @@ void server_process_native_message(
if (ucred && pid_is_valid(ucred->pid)) {
r = client_context_get(s, ucred->pid, ucred, label, label_len, NULL, &context);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to retrieve credentials for PID " PID_FMT ", ignoring: %m",
ucred->pid);
}
@@ -350,33 +351,33 @@ void server_process_native_file(
r = fd_get_path(fd, &k);
if (r < 0) {
- log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"readlink(/proc/self/fd/%i) failed: %m", fd);
return;
}
e = PATH_STARTSWITH_SET(k, "/dev/shm/", "/tmp/", "/var/tmp/");
if (!e) {
- log_ratelimit_error(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error(JOURNAL_LOG_RATELIMIT,
"Received file outside of allowed directories. Refusing.");
return;
}
if (!filename_is_valid(e)) {
- log_ratelimit_error(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error(JOURNAL_LOG_RATELIMIT,
"Received file in subdirectory of allowed directories. Refusing.");
return;
}
}
if (fstat(fd, &st) < 0) {
- log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to stat passed file, ignoring: %m");
return;
}
if (!S_ISREG(st.st_mode)) {
- log_ratelimit_error(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error(JOURNAL_LOG_RATELIMIT,
"File passed is not regular. Ignoring.");
return;
}
@@ -387,7 +388,7 @@ void server_process_native_file(
/* When !sealed, set a lower memory limit. We have to read the file,
* effectively doubling memory use. */
if (st.st_size > ENTRY_SIZE_MAX / (sealed ? 1 : 2)) {
- log_ratelimit_error(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error(JOURNAL_LOG_RATELIMIT,
"File passed too large (%"PRIu64" bytes). Ignoring.",
(uint64_t) st.st_size);
return;
@@ -402,7 +403,7 @@ void server_process_native_file(
ps = PAGE_ALIGN(st.st_size);
p = mmap(NULL, ps, PROT_READ, MAP_PRIVATE, fd, 0);
if (p == MAP_FAILED) {
- log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to map memfd, ignoring: %m");
return;
}
@@ -415,7 +416,7 @@ void server_process_native_file(
ssize_t n;
if (fstatvfs(fd, &vfs) < 0) {
- log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to stat file system of passed file, not processing it: %m");
return;
}
@@ -426,7 +427,7 @@ void server_process_native_file(
* https://github.com/systemd/systemd/issues/1822
*/
if (vfs.f_flag & ST_MANDLOCK) {
- log_ratelimit_error(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error(JOURNAL_LOG_RATELIMIT,
"Received file descriptor from file system with mandatory locking enabled, not processing it.");
return;
}
@@ -440,7 +441,7 @@ void server_process_native_file(
* and so is SMB. */
r = fd_nonblock(fd, true);
if (r < 0) {
- log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to make fd non-blocking, not processing it: %m");
return;
}
@@ -457,7 +458,7 @@ void server_process_native_file(
n = pread(fd, p, st.st_size, 0);
if (n < 0)
- log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to read file, ignoring: %m");
else if (n > 0)
server_process_native_message(s, p, n, ucred, tv, label, label_len);
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index cb94a037d5..b268db0220 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -102,10 +102,10 @@ static int determine_path_usage(
d = opendir(path);
if (!d)
return log_ratelimit_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR,
- errno, JOURNALD_LOG_RATELIMIT, "Failed to open %s: %m", path);
+ errno, JOURNAL_LOG_RATELIMIT, "Failed to open %s: %m", path);
if (fstatvfs(dirfd(d), &ss) < 0)
- return log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to fstatvfs(%s): %m", path);
*ret_free = ss.f_bsize * ss.f_bavail;
@@ -256,7 +256,7 @@ static void server_add_acls(ManagedJournalFile *f, uid_t uid) {
r = fd_add_uid_acl_permission(f->file->fd, uid, ACL_READ);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to set ACL on %s, ignoring: %m", f->file->path);
#endif
}
@@ -357,7 +357,7 @@ static int system_journal_open(Server *s, bool flush_requested, bool relinquish_
patch_min_use(&s->system_storage);
} else {
if (!IN_SET(r, -ENOENT, -EROFS))
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to open system journal: %m");
r = 0;
@@ -387,7 +387,7 @@ static int system_journal_open(Server *s, bool flush_requested, bool relinquish_
r = open_journal(s, false, fn, O_RDWR, false, &s->runtime_storage.metrics, &s->runtime_journal);
if (r < 0) {
if (r != -ENOENT)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to open runtime journal: %m");
r = 0;
@@ -402,7 +402,7 @@ static int system_journal_open(Server *s, bool flush_requested, bool relinquish_
r = open_journal(s, true, fn, O_RDWR|O_CREAT, false, &s->runtime_storage.metrics, &s->runtime_journal);
if (r < 0)
- return log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to open runtime journal: %m");
}
@@ -500,10 +500,10 @@ static int do_rotate(
r = managed_journal_file_rotate(f, s->mmap, file_flags, s->compress.threshold_bytes, s->deferred_closes);
if (r < 0) {
if (*f)
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to rotate %s: %m", (*f)->file->path);
else
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to create new %s journal: %m", name);
}
@@ -554,7 +554,7 @@ static int vacuum_offline_user_journals(Server *s) {
if (errno == ENOENT)
return 0;
- return log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to open %s: %m", s->system_storage.path);
}
@@ -570,7 +570,7 @@ static int vacuum_offline_user_journals(Server *s) {
de = readdir_no_dot(d);
if (!de) {
if (errno != 0)
- log_ratelimit_warning_errno(errno, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to enumerate %s, ignoring: %m",
s->system_storage.path);
@@ -605,7 +605,7 @@ static int vacuum_offline_user_journals(Server *s) {
fd = openat(dirfd(d), de->d_name, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW|O_NONBLOCK);
if (fd < 0) {
log_ratelimit_full_errno(IN_SET(errno, ELOOP, ENOENT) ? LOG_DEBUG : LOG_WARNING,
- errno, JOURNALD_LOG_RATELIMIT,
+ errno, JOURNAL_LOG_RATELIMIT,
"Failed to open journal file '%s' for rotation: %m", full);
continue;
}
@@ -628,13 +628,13 @@ static int vacuum_offline_user_journals(Server *s) {
NULL,
&f);
if (r < 0) {
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to read journal file %s for rotation, trying to move it out of the way: %m",
full);
r = journal_file_dispose(dirfd(d), de->d_name);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to move %s out of the way, ignoring: %m",
full);
else
@@ -692,21 +692,21 @@ void server_sync(Server *s) {
if (s->system_journal) {
r = managed_journal_file_set_offline(s->system_journal, false);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to sync system journal, ignoring: %m");
}
ORDERED_HASHMAP_FOREACH(f, s->user_journals) {
r = managed_journal_file_set_offline(f, false);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to sync user journal, ignoring: %m");
}
if (s->sync_event_source) {
r = sd_event_source_set_enabled(s->sync_event_source, SD_EVENT_OFF);
if (r < 0)
- log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to disable sync timer source: %m");
}
@@ -729,7 +729,7 @@ static void do_vacuum(Server *s, JournalStorage *storage, bool verbose) {
storage->metrics.n_max_files, s->max_retention_usec,
&s->oldest_file_usec, verbose);
if (r < 0 && r != -ENOENT)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to vacuum %s, ignoring: %m", storage->path);
cache_space_invalidate(&storage->space);
@@ -801,38 +801,46 @@ static bool shall_try_append_again(JournalFile *f, int r) {
log_debug("%s: Allocation limit reached, rotating.", f->path);
return true;
+ case -EROFS: /* Read-only file system */
+ /* When appending an entry fails if shall_try_append_again returns true, the journal is
+ * rotated. If the FS is read-only, rotation will fail and s->system_journal will be set to
+ * NULL. After that, when find_journal will try to open the journal since s->system_journal
+ * will be NULL, it will open the runtime journal. */
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Read-only file system, rotating.", f->path);
+ return true;
+
case -EIO: /* I/O error of some kind (mmap) */
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT, "%s: IO error, rotating.", f->path);
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: IO error, rotating.", f->path);
return true;
case -EHOSTDOWN: /* Other machine */
- log_ratelimit_info(JOURNALD_LOG_RATELIMIT, "%s: Journal file from other machine, rotating.", f->path);
+ log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Journal file from other machine, rotating.", f->path);
return true;
case -EBUSY: /* Unclean shutdown */
- log_ratelimit_info(JOURNALD_LOG_RATELIMIT, "%s: Unclean shutdown, rotating.", f->path);
+ log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Unclean shutdown, rotating.", f->path);
return true;
case -EPROTONOSUPPORT: /* Unsupported feature */
- log_ratelimit_info(JOURNALD_LOG_RATELIMIT, "%s: Unsupported feature, rotating.", f->path);
+ log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "%s: Unsupported feature, rotating.", f->path);
return true;
case -EBADMSG: /* Corrupted */
case -ENODATA: /* Truncated */
case -ESHUTDOWN: /* Already archived */
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT, "%s: Journal file corrupted, rotating.", f->path);
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Journal file corrupted, rotating.", f->path);
return true;
case -EIDRM: /* Journal file has been deleted */
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT, "%s: Journal file has been deleted, rotating.", f->path);
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Journal file has been deleted, rotating.", f->path);
return true;
case -ETXTBSY: /* Journal file is from the future */
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT, "%s: Journal file is from the future, rotating.", f->path);
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT, "%s: Journal file is from the future, rotating.", f->path);
return true;
case -EAFNOSUPPORT:
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"%s: underlying file system does not support memory mapping or another required file system feature.",
f->path);
return false;
@@ -864,7 +872,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n
* to ensure that the entries in the journal files are strictly ordered by time, in order to ensure
* bisection works correctly. */
- log_ratelimit_info(JOURNALD_LOG_RATELIMIT, "Time jumped backwards, rotating.");
+ log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "Time jumped backwards, rotating.");
rotate = true;
} else {
@@ -873,7 +881,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n
return;
if (journal_file_rotate_suggested(f->file, s->max_file_usec, LOG_INFO)) {
- log_ratelimit_info(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_info(JOURNAL_LOG_RATELIMIT,
"%s: Journal header limits reached or header out-of-date, rotating.",
f->file->path);
rotate = true;
@@ -1212,7 +1220,7 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY);
if (r < 0)
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to read runtime journal: %m");
sd_journal_set_data_threshold(j, 0);
@@ -1228,7 +1236,7 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
r = journal_file_move_to_object(f, OBJECT_ENTRY, f->current_offset, &o);
if (r < 0) {
- log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Can't read entry: %m");
+ log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Can't read entry: %m");
goto finish;
}
@@ -1237,17 +1245,17 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
continue;
if (!shall_try_append_again(s->system_journal->file, r)) {
- log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Can't write entry: %m");
+ log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Can't write entry: %m");
goto finish;
}
- log_ratelimit_info(JOURNALD_LOG_RATELIMIT, "Rotating system journal.");
+ log_ratelimit_info(JOURNAL_LOG_RATELIMIT, "Rotating system journal.");
server_rotate(s);
server_vacuum(s, false);
if (!s->system_journal) {
- log_ratelimit_notice(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_notice(JOURNAL_LOG_RATELIMIT,
"Didn't flush runtime journal since rotation of system journal wasn't successful.");
r = -EIO;
goto finish;
@@ -1256,7 +1264,7 @@ int server_flush_to_var(Server *s, bool require_flag_file) {
log_debug("Retrying write.");
r = journal_file_copy_entry(f, s->system_journal->file, o, f->current_offset);
if (r < 0) {
- log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Can't write entry: %m");
+ log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Can't write entry: %m");
goto finish;
}
}
@@ -1284,7 +1292,7 @@ finish:
fn = strjoina(s->runtime_directory, "/flushed");
k = touch(fn);
if (k < 0)
- log_ratelimit_warning_errno(k, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(k, JOURNAL_LOG_RATELIMIT,
"Failed to touch %s, ignoring: %m", fn);
server_refresh_idle_timer(s);
@@ -1314,7 +1322,7 @@ static int server_relinquish_var(Server *s) {
fn = strjoina(s->runtime_directory, "/flushed");
if (unlink(fn) < 0 && errno != ENOENT)
- log_ratelimit_warning_errno(errno, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to unlink %s, ignoring: %m", fn);
server_refresh_idle_timer(s);
@@ -1387,11 +1395,11 @@ int server_process_datagram(
if (ERRNO_IS_TRANSIENT(n))
return 0;
if (n == -EXFULL) {
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"Got message with truncated control data (too many fds sent?), ignoring.");
return 0;
}
- return log_ratelimit_error_errno(n, JOURNALD_LOG_RATELIMIT, "recvmsg() failed: %m");
+ return log_ratelimit_error_errno(n, JOURNAL_LOG_RATELIMIT, "recvmsg() failed: %m");
}
CMSG_FOREACH(cmsg, &msghdr)
@@ -1424,7 +1432,7 @@ int server_process_datagram(
if (n > 0 && n_fds == 0)
server_process_syslog_message(s, s->buffer, n, ucred, tv, label, label_len);
else if (n_fds > 0)
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"Got file descriptors via syslog socket. Ignoring.");
} else if (fd == s->native_fd) {
@@ -1433,7 +1441,7 @@ int server_process_datagram(
else if (n == 0 && n_fds == 1)
server_process_native_file(s, fds[0], ucred, tv, label, label_len);
else if (n_fds > 0)
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"Got too many file descriptors via native socket. Ignoring.");
} else {
@@ -1442,7 +1450,7 @@ int server_process_datagram(
if (n > 0 && n_fds == 0)
server_process_audit_message(s, s->buffer, n, ucred, &sa, msghdr.msg_namelen);
else if (n_fds > 0)
- log_ratelimit_warning(JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
"Got file descriptors via audit socket. Ignoring.");
}
@@ -1496,7 +1504,7 @@ static void server_full_rotate(Server *s) {
fn = strjoina(s->runtime_directory, "/rotated");
r = write_timestamp_file_atomic(fn, now(CLOCK_MONOTONIC));
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to write %s, ignoring: %m", fn);
}
@@ -1600,7 +1608,7 @@ static void server_full_sync(Server *s) {
fn = strjoina(s->runtime_directory, "/synced");
r = write_timestamp_file_atomic(fn, now(CLOCK_MONOTONIC));
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to write %s, ignoring: %m", fn);
return;
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index fb512dcfeb..ee8f374190 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -20,8 +20,6 @@ typedef struct Server Server;
#include "time-util.h"
#include "varlink.h"
-#define JOURNALD_LOG_RATELIMIT ((const RateLimit) { .interval = 60 * USEC_PER_SEC, .burst = 3 })
-
typedef enum Storage {
STORAGE_AUTO,
STORAGE_VOLATILE,
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index abfd046837..49f28972ea 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -19,6 +19,7 @@
#include "fileio.h"
#include "fs-util.h"
#include "io-util.h"
+#include "journal-internal.h"
#include "journald-console.h"
#include "journald-context.h"
#include "journald-kmsg.h"
@@ -160,7 +161,7 @@ static int stdout_stream_save(StdoutStream *s) {
r = fstat(s->fd, &st);
if (r < 0)
- return log_ratelimit_warning_errno(errno, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to stat connected stream: %m");
/* We use device and inode numbers as identifier for the stream */
@@ -232,7 +233,7 @@ static int stdout_stream_save(StdoutStream *s) {
if (s->server->notify_event_source) {
r = sd_event_source_set_enabled(s->server->notify_event_source, SD_EVENT_ON);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to enable notify event source: %m");
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to enable notify event source: %m");
}
}
@@ -240,7 +241,7 @@ static int stdout_stream_save(StdoutStream *s) {
fail:
(void) unlink(s->state_file);
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to save stream data %s: %m", s->state_file);
}
@@ -268,7 +269,7 @@ static int stdout_stream_log(
else if (pid_is_valid(s->ucred.pid)) {
r = client_context_acquire(s->server, s->ucred.pid, &s->ucred, s->label, strlen_ptr(s->label), s->unit_id, &s->context);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to acquire client context, ignoring: %m");
}
@@ -366,7 +367,7 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) {
/* line breaks by NUL, line max length or EOF are not permissible during the negotiation part of the protocol */
if (line_break != LINE_BREAK_NEWLINE && s->state != STDOUT_STREAM_RUNNING)
- return log_ratelimit_warning_errno(SYNTHETIC_ERRNO(EINVAL), JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(SYNTHETIC_ERRNO(EINVAL), JOURNAL_LOG_RATELIMIT,
"Control protocol line not properly terminated.");
switch (s->state) {
@@ -398,7 +399,7 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) {
priority = syslog_parse_priority_and_facility(p);
if (priority < 0)
- return log_ratelimit_warning_errno(priority, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(priority, JOURNAL_LOG_RATELIMIT,
"Failed to parse log priority line: %m");
s->priority = priority;
@@ -409,7 +410,7 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) {
case STDOUT_STREAM_LEVEL_PREFIX:
r = parse_boolean(p);
if (r < 0)
- return log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to parse level prefix line: %m");
s->level_prefix = r;
@@ -419,7 +420,7 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) {
case STDOUT_STREAM_FORWARD_TO_SYSLOG:
r = parse_boolean(p);
if (r < 0)
- return log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to parse forward to syslog line: %m");
s->forward_to_syslog = r;
@@ -429,7 +430,7 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) {
case STDOUT_STREAM_FORWARD_TO_KMSG:
r = parse_boolean(p);
if (r < 0)
- return log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to parse copy to kmsg line: %m");
s->forward_to_kmsg = r;
@@ -439,7 +440,7 @@ static int stdout_stream_line(StdoutStream *s, char *p, LineBreak line_break) {
case STDOUT_STREAM_FORWARD_TO_CONSOLE:
r = parse_boolean(p);
if (r < 0)
- return log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ return log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to parse copy to console line.");
s->forward_to_console = r;
@@ -597,7 +598,7 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
if (ERRNO_IS_TRANSIENT(errno))
return 0;
- log_ratelimit_warning_errno(errno, JOURNALD_LOG_RATELIMIT, "Failed to read from stream: %m");
+ log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT, "Failed to read from stream: %m");
goto terminate;
}
cmsg_close_all(&msghdr);
@@ -656,7 +657,7 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
r = sd_id128_randomize(&id);
if (r < 0)
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to generate stream ID: %m");
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to generate stream ID: %m");
stream = new(StdoutStream, 1);
if (!stream)
@@ -672,7 +673,7 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
r = getpeercred(fd, &stream->ucred);
if (r < 0)
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to determine peer credentials: %m");
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to determine peer credentials: %m");
r = setsockopt_int(fd, SOL_SOCKET, SO_PASSCRED, true);
if (r < 0)
@@ -681,18 +682,18 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
if (mac_selinux_use()) {
r = getpeersec(fd, &stream->label);
if (r < 0 && r != -EOPNOTSUPP)
- (void) log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to determine peer security context: %m");
+ (void) log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to determine peer security context: %m");
}
(void) shutdown(fd, SHUT_WR);
r = sd_event_add_io(s->event, &stream->event_source, fd, EPOLLIN, stdout_stream_process, stream);
if (r < 0)
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to add stream to event loop: %m");
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to add stream to event loop: %m");
r = sd_event_source_set_priority(stream->event_source, SD_EVENT_PRIORITY_NORMAL+5);
if (r < 0)
- return log_ratelimit_error_errno(r, JOURNALD_LOG_RATELIMIT, "Failed to adjust stdout event source priority: %m");
+ return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to adjust stdout event source priority: %m");
stream->fd = fd;
@@ -724,7 +725,7 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
if (ERRNO_IS_ACCEPT_AGAIN(errno))
return 0;
- return log_ratelimit_error_errno(errno, JOURNALD_LOG_RATELIMIT, "Failed to accept stdout connection: %m");
+ return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT, "Failed to accept stdout connection: %m");
}
if (s->n_stdout_streams >= STDOUT_STREAMS_MAX) {
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 6394adfdfd..d8708b0775 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -10,6 +10,7 @@
#include "fd-util.h"
#include "format-util.h"
#include "io-util.h"
+#include "journal-internal.h"
#include "journald-console.h"
#include "journald-kmsg.h"
#include "journald-server.h"
@@ -334,7 +335,7 @@ void server_process_syslog_message(
if (ucred && pid_is_valid(ucred->pid)) {
r = client_context_get(s, ucred->pid, ucred, label, label_len, NULL, &context);
if (r < 0)
- log_ratelimit_warning_errno(r, JOURNALD_LOG_RATELIMIT,
+ log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to retrieve credentials for PID " PID_FMT ", ignoring: %m",
ucred->pid);
}