[gnome-logs] util: Improve the check for reading system journal
- From: Jonathan Kang <jonathankang src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-logs] util: Improve the check for reading system journal
- Date: Tue, 12 May 2020 08:47:28 +0000 (UTC)
commit b42defceefc775220b525f665a3b662ab9593b81
Author: Jonathan Kang <jonathankang gnome org>
Date: Mon May 11 16:08:58 2020 +0800
util: Improve the check for reading system journal
Previously, the existence of "/run/log/journal/" is used to determine
whether journal storage is persistent or volatile. For most systems using
persistent journal storage, that directory doesn’t exist. Therefore,
no issues occur due to it.
In some systems, that directory exists somehow, even with persistent
journal storage. The old checking confuses Logs that journal files are
stored at "/run/log/journal/$machine-id/". While those journal files
doesn’t exist at all.
Fix that by checking the existence of "/run/log/journal/$machine-id/"
directory.
https://gitlab.gnome.org/GNOME/gnome-logs/-/issues/52
src/gl-util.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/gl-util.c b/src/gl-util.c
index eabacf6..50993f7 100644
--- a/src/gl-util.c
+++ b/src/gl-util.c
@@ -335,16 +335,31 @@ gl_util_boot_time_to_display (guint64 realtime_first,
GlJournalStorage
gl_util_journal_storage_type (void)
{
- if (g_file_test ("/run/log/journal", G_FILE_TEST_EXISTS))
+ g_autofree gchar *run_path = NULL;
+ g_autofree gchar *var_path = NULL;
+ gchar ids[33];
+ gint ret;
+ sd_id128_t machine_id;
+
+ ret = sd_id128_get_machine (&machine_id);
+ if (ret < 0)
+ {
+ g_critical ("Error getting machine id: %s", g_strerror (-ret));
+ }
+ sd_id128_to_string (machine_id, ids);
+
+ run_path = g_build_filename ("/run/log/journal/", ids, NULL);
+ var_path = g_build_filename ("/var/log/journal/", ids, NULL);
+
+ if (g_file_test (run_path, G_FILE_TEST_EXISTS))
{
return GL_JOURNAL_STORAGE_VOLATILE;
}
- else
+ else if (g_file_test (var_path, G_FILE_TEST_EXISTS))
{
return GL_JOURNAL_STORAGE_PERSISTENT;
}
-
- if ((!g_file_test ("/run/log/journal", G_FILE_TEST_EXISTS)) && (!g_file_test ("/var/log/journal",
G_FILE_TEST_EXISTS)))
+ else
{
return GL_JOURNAL_STORAGE_NONE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]