Compare commits

..

6 Commits

Author SHA1 Message Date
Anita Zhang 96100b8a04
Merge pull request #14964 from yuwata/conf-parser-fix-line-number
conf-parser: fix line number in error message
2020-02-27 17:16:35 -08:00
Anita Zhang 9c7179bbfa
Merge pull request #14965 from keszybz/journal-rotation-hint
systemctl: be more specific when emitting warning about rotated journal
2020-02-27 17:16:02 -08:00
Anita Zhang 8f7d2c89c5
Merge pull request #14960 from yuwata/udevadm-info-export-db-error-message
udevadm: show more error message during exporting database
2020-02-27 17:10:19 -08:00
Zbigniew Jędrzejewski-Szmek 1a8f0ce64f systemctl: be more specific when emitting warning about rotated journal
See inline comment for disucssion.
Fixes #14281.
2020-02-27 19:52:08 +01:00
Yu Watanabe 68c1ac1568 conf-parser: fix line number in error message
Fixes #14929.
2020-02-28 02:37:15 +09:00
Yu Watanabe df5a4889fe udevadm: show more error message during exporting database
Closes #14959.
2020-02-27 22:27:16 +09:00
5 changed files with 29 additions and 8 deletions

View File

@ -334,6 +334,8 @@ int config_parse(const char *unit,
return r; return r;
} }
line++;
l = skip_leading_chars(buf, WHITESPACE); l = skip_leading_chars(buf, WHITESPACE);
if (*l != '\0' && strchr(COMMENTS, *l)) if (*l != '\0' && strchr(COMMENTS, *l))
continue; continue;
@ -390,7 +392,7 @@ int config_parse(const char *unit,
r = parse_line(unit, r = parse_line(unit,
filename, filename,
++line, line,
sections, sections,
lookup, lookup,
table, table,

View File

@ -80,6 +80,10 @@ static int access_check_var_log_journal(sd_journal *j, bool want_other_users) {
return 1; return 1;
} }
int journal_access_blocked(sd_journal *j) {
return hashmap_contains(j->errors, INT_TO_PTR(-EACCES));
}
int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users) { int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users) {
Iterator it; Iterator it;
void *code; void *code;
@ -95,7 +99,7 @@ int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_use
return 0; return 0;
} }
if (hashmap_contains(j->errors, INT_TO_PTR(-EACCES))) { if (journal_access_blocked(j)) {
if (!quiet) if (!quiet)
(void) access_check_var_log_journal(j, want_other_users); (void) access_check_var_log_journal(j, want_other_users);

View File

@ -7,5 +7,5 @@
#include "sd-journal.h" #include "sd-journal.h"
bool journal_field_valid(const char *p, size_t l, bool allow_protected); bool journal_field_valid(const char *p, size_t l, bool allow_protected);
int journal_access_blocked(sd_journal *j);
int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users); int journal_access_check_and_warn(sd_journal *j, bool quiet, bool want_other_users);

View File

@ -20,6 +20,7 @@
#include "id128-util.h" #include "id128-util.h"
#include "io-util.h" #include "io-util.h"
#include "journal-internal.h" #include "journal-internal.h"
#include "journal-util.h"
#include "json.h" #include "json.h"
#include "log.h" #include "log.h"
#include "logs-show.h" #include "logs-show.h"
@ -1232,7 +1233,21 @@ int show_journal(
if (r > 0 && not_before < cutoff) { if (r > 0 && not_before < cutoff) {
maybe_print_begin_newline(f, &flags); maybe_print_begin_newline(f, &flags);
fprintf(f, "Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.\n");
/* If we logged *something* and no permission error happened, than we can
* reliably emit the warning about rotation. If we didn't log anything and
* access errors happened, emit hint about permissions. Otherwise, give a
* generic message, since we can't diagnose the issue. */
bool noaccess = journal_access_blocked(j);
if (line == 0 && noaccess)
fprintf(f, "Warning: some journal files were not opened due to insufficient permissions.");
else if (!noaccess)
fprintf(f, "Warning: journal has been rotated since unit was started, output may be incomplete.\n");
else
fprintf(f, "Warning: journal has been rotated since unit was started and some journal "
"files were not opened due to insufficient permissions, output may be incomplete.\n");
} }
warn_cutoff = false; warn_cutoff = false;

View File

@ -177,18 +177,18 @@ static int export_devices(void) {
r = sd_device_enumerator_new(&e); r = sd_device_enumerator_new(&e);
if (r < 0) if (r < 0)
return r; return log_oom();
r = sd_device_enumerator_allow_uninitialized(e); r = sd_device_enumerator_allow_uninitialized(e);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to set allowing uninitialized flag: %m");
r = device_enumerator_scan_devices(e); r = device_enumerator_scan_devices(e);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to scan devices: %m");
FOREACH_DEVICE_AND_SUBSYSTEM(e, d) FOREACH_DEVICE_AND_SUBSYSTEM(e, d)
print_record(d); (void) print_record(d);
return 0; return 0;
} }