summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2022-03-14 13:54:06 +0100
committerFranck Bui <fbui@suse.com>2023-01-16 15:04:29 +0100
commit596c3c7f1be85ea21ac4fccc25e3899ba4bf5141 (patch)
treeee441703661860e806831b12029b0fde88cbe7fb /src/journal
parent43d287ec8c5ea803dfb1d98c43aa39b229d51efa (diff)
downloadsystemd-596c3c7f1be85ea21ac4fccc25e3899ba4bf5141.tar.gz
journald: introduce journal_file_parse_uid_from_filename() helper
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/journald-server.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 92205cca0e..e3ce6aaea8 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -559,9 +559,8 @@ static int server_archive_offline_user_journals(Server *s) {
}
for (;;) {
- _cleanup_free_ char *u = NULL, *full = NULL;
+ _cleanup_free_ char *full = NULL;
_cleanup_close_ int fd = -EBADF;
- const char *a, *b;
struct dirent *de;
ManagedJournalFile *f;
uid_t uid;
@@ -573,24 +572,14 @@ static int server_archive_offline_user_journals(Server *s) {
log_ratelimit_warning_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to enumerate %s, ignoring: %m",
s->system_storage.path);
-
break;
}
- a = startswith(de->d_name, "user-");
- if (!a)
- continue;
- b = endswith(de->d_name, ".journal");
- if (!b)
- continue;
-
- u = strndup(a, b-a);
- if (!u)
- return log_oom();
-
- r = parse_uid(u, &uid);
+ r = journal_file_parse_uid_from_filename(de->d_name, &uid);
if (r < 0) {
- log_debug_errno(r, "Failed to parse UID from file name '%s', ignoring: %m", de->d_name);
+ /* Don't warn if the file is not an online or offline user journal. */
+ if (r != -EREMOTE)
+ log_warning_errno(r, "Failed to parse UID from file name '%s', ignoring: %m", de->d_name);
continue;
}