Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates-src > by-pkgid > ab4b662b9827b6375ffd451bf4abd615 > files > 340

systemd-44-24.fc17.src.rpm

From 319abb7aa9997de34c815759f8d102d2fac4471d Mon Sep 17 00:00:00 2001
From: Sjoerd Simons <sjoerd@luon.net>
Date: Sat, 14 Apr 2012 14:11:08 +0200
Subject: [PATCH] journal: crash when filesystem is low on space

When space is getting too low on a file system rotating the journal file
will fail after the rotation, as opening the new logfile will fail.

Recognize this when logging the error and don't try to dereference a
NULL JournalFile pointer.
(cherry picked from commit 499fb2152f8518796607dd0406698cb6ce4c7098)
---
 src/journal/journald.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/journal/journald.c b/src/journal/journald.c
index da683d6..4d8e1ba 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -330,7 +330,10 @@ static void server_rotate(Server *s) {
         if (s->runtime_journal) {
                 r = journal_file_rotate(&s->runtime_journal);
                 if (r < 0)
-                        log_error("Failed to rotate %s: %s", s->runtime_journal->path, strerror(-r));
+                        if (s->runtime_journal)
+                                log_error("Failed to rotate %s: %s", s->runtime_journal->path, strerror(-r));
+                        else
+                                log_error("Failed to create new runtime journal: %s", strerror(-r));
                 else
                         server_fix_perms(s, s->runtime_journal, 0);
         }
@@ -338,7 +341,11 @@ static void server_rotate(Server *s) {
         if (s->system_journal) {
                 r = journal_file_rotate(&s->system_journal);
                 if (r < 0)
-                        log_error("Failed to rotate %s: %s", s->system_journal->path, strerror(-r));
+                        if (s->system_journal)
+                                log_error("Failed to rotate %s: %s", s->system_journal->path, strerror(-r));
+                        else
+                                log_error("Failed to create new system journal: %s", strerror(-r));
+
                 else
                         server_fix_perms(s, s->system_journal, 0);
         }
@@ -346,7 +353,10 @@ static void server_rotate(Server *s) {
         HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
                 r = journal_file_rotate(&f);
                 if (r < 0)
-                        log_error("Failed to rotate %s: %s", f->path, strerror(-r));
+                        if (f->path)
+                                log_error("Failed to rotate %s: %s", f->path, strerror(-r));
+                        else
+                                log_error("Failed to create user journal: %s", strerror(-r));
                 else {
                         hashmap_replace(s->user_journals, k, f);
                         server_fix_perms(s, s->system_journal, PTR_TO_UINT32(k));