}
}
+ /* We do not recalculate the mask unconditionally here,
+ * so that the fchmod() mask above stays intact. */
if (acl_get_permset(entry, &permset) < 0 ||
acl_add_perm(permset, ACL_READ) < 0 ||
- acl_calc_mask(&acl) < 0) {
+ calc_acl_mask_if_needed(&acl) < 0) {
log_warning("Failed to patch ACL on %s, ignoring: %m", f->path);
goto finish;
}
}
static JournalFile* find_journal(Server *s, uid_t uid) {
- char *p;
+ _cleanup_free_ char *p = NULL;
int r;
JournalFile *f;
sd_id128_t machine;
journal_file_close(f);
}
- r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, s->system_journal, &f);
- free(p);
-
+ r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &f);
if (r < 0)
return s->system_journal;
}
void server_vacuum(Server *s) {
- char *p;
char ids[33];
sd_id128_t machine;
int r;
sd_id128_to_string(machine, ids);
if (s->system_journal) {
- p = strappend("/var/log/journal/", ids);
- if (!p) {
- log_oom();
- return;
- }
+ char *p = strappenda("/var/log/journal/", ids);
r = journal_directory_vacuum(p, s->system_metrics.max_use, s->system_metrics.keep_free, s->max_retention_usec, &s->oldest_file_usec);
if (r < 0 && r != -ENOENT)
log_error("Failed to vacuum %s: %s", p, strerror(-r));
- free(p);
}
if (s->runtime_journal) {
- p = strappend("/run/log/journal/", ids);
- if (!p) {
- log_oom();
- return;
- }
+ char *p = strappenda("/run/log/journal/", ids);
r = journal_directory_vacuum(p, s->runtime_metrics.max_use, s->runtime_metrics.keep_free, s->max_retention_usec, &s->oldest_file_usec);
if (r < 0 && r != -ENOENT)
log_error("Failed to vacuum %s: %s", p, strerror(-r));
- free(p);
}
s->cached_available_space_timestamp = 0;
char *fn;
sd_id128_t machine;
char ids[33];
+ uint64_t avail;
+
+ avail = available_space(s);
r = sd_id128_get_machine(&machine);
if (r < 0)
server_driver_message(s, SD_ID128_NULL, "Allowing system journal files to grow to %s.",
format_bytes(fb, sizeof(fb), s->system_metrics.max_use));
+ if (s->system_metrics.max_use > avail)
+ server_driver_message(s, SD_ID128_NULL, "Journal size currently limited to %s due to SystemKeepFree.",
+ format_bytes(fb, sizeof(fb), avail));
+
} else if (r < 0) {
if (r != -ENOENT && r != -EROFS)
server_fix_perms(s, s->runtime_journal, 0);
server_driver_message(s, SD_ID128_NULL, "Allowing runtime journal files to grow to %s.",
format_bytes(fb, sizeof(fb), s->runtime_metrics.max_use));
+
+ if (s->system_metrics.max_use > avail)
+ server_driver_message(s, SD_ID128_NULL, "Journal size currently limited to %s due to RuntimeKeepFree.",
+ format_bytes(fb, sizeof(fb), avail));
}
}
server_rotate(s);
server_vacuum(s);
+ if (!s->system_journal) {
+ log_notice("Didn't flush runtime journal since rotation of system journal wasn't successful.");
+ r = -EIO;
+ goto finish;
+ }
+
log_debug("Retrying write.");
r = journal_file_copy_entry(f, s->system_journal, o, f->current_offset, NULL, NULL, NULL);
if (r < 0) {
}
static int server_parse_config_file(Server *s) {
- static const char *fn = "/etc/systemd/journald.conf";
+ static const char fn[] = "/etc/systemd/journald.conf";
_cleanup_fclose_ FILE *f = NULL;
int r;
}
r = config_parse(NULL, fn, f, "Journal\0", config_item_perf_lookup,
- (void*) journald_gperf_lookup, false, s);
+ (void*) journald_gperf_lookup, false, false, s);
if (r < 0)
log_warning("Failed to parse configuration file: %s", strerror(-r));
return 0;
if (s->sync_interval_usec) {
- struct itimerspec sync_timer_enable = {
- .it_value.tv_sec = s->sync_interval_usec / USEC_PER_SEC,
- .it_value.tv_nsec = s->sync_interval_usec % MSEC_PER_SEC,
- };
+ struct itimerspec sync_timer_enable = {};
+
+ timespec_store(&sync_timer_enable.it_value, s->sync_interval_usec);
r = timerfd_settime(s->sync_timer_fd, 0, &sync_timer_enable, NULL);
if (r < 0)