X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournald.c;h=164e1087d108879b70d9e7f59dfbc852e0120a1c;hb=f2cc3753ce0e85960f0299855c3b98ba60efa580;hp=a1deceabdf2bef696239a695b2c37538c42e7177;hpb=99add6fd0b8f4307ed79256e25f38da318e795c4;p=elogind.git diff --git a/src/journal/journald.c b/src/journal/journald.c index a1deceabd..164e1087d 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -87,6 +87,15 @@ static const char* const storage_table[] = { DEFINE_STRING_TABLE_LOOKUP(storage, Storage); DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting"); +static const char* const split_mode_table[] = { + [SPLIT_NONE] = "none", + [SPLIT_UID] = "uid", + [SPLIT_LOGIN] = "login" +}; + +DEFINE_STRING_TABLE_LOOKUP(split_mode, SplitMode); +DEFINE_CONFIG_PARSE_ENUM(config_parse_split_mode, split_mode, SplitMode, "Failed to parse split mode setting"); + static uint64_t available_space(Server *s) { char ids[33], *p; const char *f; @@ -132,9 +141,10 @@ static uint64_t available_space(Server *s) { for (;;) { struct stat st; - struct dirent buf, *de; + struct dirent *de; + union dirent_storage buf; - r = readdir_r(d, &buf, &de); + r = readdir_r(d, &buf.de, &de); if (r != 0) break; @@ -304,7 +314,7 @@ static void server_rotate(Server *s) { Iterator i; int r; - log_info("Rotating..."); + log_debug("Rotating..."); if (s->runtime_journal) { r = journal_file_rotate(&s->runtime_journal, s->compress, false); @@ -338,7 +348,7 @@ static void server_rotate(Server *s) { 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)); + server_fix_perms(s, f, PTR_TO_UINT32(k)); } } } @@ -349,7 +359,7 @@ static void server_vacuum(Server *s) { sd_id128_t machine; int r; - log_info("Vacuuming..."); + log_debug("Vacuuming..."); r = sd_id128_get_machine(&machine); if (r < 0) { @@ -444,7 +454,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned return; if (journal_file_rotate_suggested(f)) { - log_info("Journal header limits reached or header out-of-date, rotating."); + log_debug("Journal header limits reached or header out-of-date, rotating."); server_rotate(s); server_vacuum(s); vacuumed = true; @@ -475,11 +485,11 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned } if (r == -E2BIG || r == -EFBIG || r == EDQUOT || r == ENOSPC) - log_info("Allocation limit reached, rotating."); + log_debug("Allocation limit reached, rotating."); else if (r == -EHOSTDOWN) log_info("Journal file from other machine, rotating."); else if (r == -EBUSY) - log_info("Unlcean shutdown, rotating."); + log_info("Unclean shutdown, rotating."); else log_warning("Journal file corrupted, rotating."); @@ -491,7 +501,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned if (!f) return; - log_info("Retrying write."); + log_debug("Retrying write."); } } @@ -659,7 +669,10 @@ static void dispatch_message_real( assert(n <= m); - write_to_journal(s, realuid == 0 ? 0 : loginuid, iovec, n); + write_to_journal(s, + s->split_mode == SPLIT_NONE ? 0 : + (s->split_mode == SPLIT_UID ? realuid : + (realuid == 0 ? 0 : loginuid)), iovec, n); free(pid); free(uid); @@ -890,7 +903,7 @@ static int server_flush_to_var(Server *s) { if (!s->system_journal) return 0; - log_info("Flushing to /var..."); + log_debug("Flushing to /var..."); r = sd_id128_get_machine(&machine); if (r < 0) { @@ -918,7 +931,7 @@ static int server_flush_to_var(Server *s) { r = journal_file_copy_entry(f, s->system_journal, o, f->current_offset, NULL, NULL, NULL); if (r == -E2BIG) { - log_info("Allocation limit reached."); + log_debug("Allocation limit reached."); journal_file_post_change(s->system_journal); server_rotate(s); @@ -954,7 +967,7 @@ static int process_event(Server *s, struct epoll_event *ev) { ssize_t n; if (ev->events != EPOLLIN) { - log_info("Got invalid event from epoll."); + log_error("Got invalid event from epoll."); return -EIO; } @@ -990,7 +1003,7 @@ static int process_event(Server *s, struct epoll_event *ev) { int r; if (ev->events != EPOLLIN) { - log_info("Got invalid event from epoll."); + log_error("Got invalid event from epoll."); return -EIO; } @@ -1004,7 +1017,7 @@ static int process_event(Server *s, struct epoll_event *ev) { ev->data.fd == s->syslog_fd) { if (ev->events != EPOLLIN) { - log_info("Got invalid event from epoll."); + log_error("Got invalid event from epoll."); return -EIO; } @@ -1132,7 +1145,7 @@ static int process_event(Server *s, struct epoll_event *ev) { } else if (ev->data.fd == s->stdout_fd) { if (ev->events != EPOLLIN) { - log_info("Got invalid event from epoll."); + log_error("Got invalid event from epoll."); return -EIO; } @@ -1143,7 +1156,7 @@ static int process_event(Server *s, struct epoll_event *ev) { StdoutStream *stream; if ((ev->events|EPOLLIN|EPOLLHUP) != (EPOLLIN|EPOLLHUP)) { - log_info("Got invalid event from epoll."); + log_error("Got invalid event from epoll."); return -EIO; } @@ -1480,7 +1493,6 @@ int main(int argc, char *argv[]) { log_set_target(LOG_TARGET_SAFE); log_set_facility(LOG_SYSLOG); - log_set_max_level(LOG_DEBUG); log_parse_environment(); log_open(); @@ -1542,6 +1554,7 @@ int main(int argc, char *argv[]) { } server_maybe_append_tags(&server); + server_maybe_warn_forward_syslog_missed(&server); } log_debug("systemd-journald stopped as pid %lu", (unsigned long) getpid());