chiark / gitweb /
log: make sure generators never log into the journal to avoid activation deadlocks
[elogind.git] / src / journal / journald.c
index a6f27f6ef4cc86c765adfddc4a9b844db754c5ba..c429896ac40cbd4aa9cb8530da247fe853743fbb 100644 (file)
@@ -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));
@@ -1234,11 +1244,11 @@ static void process_native_message(
                                          p[17] >= '0' && p[17] <= '9')
                                         priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
 
-                                else if (l >= 12 &&
-                                         memcmp(p, "SYSLOG_IDENTIFIER=", 11) == 0) {
+                                else if (l >= 19 &&
+                                         memcmp(p, "SYSLOG_IDENTIFIER=", 18) == 0) {
                                         char *t;
 
-                                        t = strndup(p + 11, l - 11);
+                                        t = strndup(p + 18, l - 18);
                                         if (t) {
                                                 free(identifier);
                                                 identifier = t;
@@ -2764,7 +2774,7 @@ int main(int argc, char *argv[]) {
                 return EXIT_FAILURE;
         }
 
-        log_set_target(LOG_TARGET_CONSOLE);
+        log_set_target(LOG_TARGET_SAFE);
         log_set_facility(LOG_SYSLOG);
         log_parse_environment();
         log_open();