X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournalctl.c;h=92e828633458012f88ba9e73faaa56070ecdd911;hb=eacbb4d33e2bb5c54311544851140efe3dd0f774;hp=a328ba11b0d3193daae39d1e18be28fb309ffd57;hpb=39883f622f392d8579f4428fc5a789a102efbb10;p=elogind.git diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index a328ba11b..92e828633 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -167,8 +167,8 @@ static int help(void) { printf("%s [OPTIONS...] [MATCHES...]\n\n" "Query the journal.\n\n" "Flags:\n" - " --system Show only the system journal\n" - " --user Show only the user journal for the current user\n" + " --system Show the system journal\n" + " --user Show the user journal for the current user\n" " -M --machine=CONTAINER Operate on local container\n" " --since=DATE Start showing entries on or newer than the specified date\n" " --until=DATE Stop showing entries on or older than the specified date\n" @@ -658,6 +658,11 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; } + if (arg_action != ACTION_SHOW && optind < argc) { + log_error("Extraneous arguments starting with '%s'", argv[optind]); + return -EINVAL; + } + return 1; } @@ -1285,7 +1290,7 @@ static int setup_keys(void) { n = now(CLOCK_REALTIME); n /= arg_interval; - close_nointr_nofail(fd); + safe_close(fd); fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC); if (fd < 0) { log_error("Failed to open %s: %m", k); @@ -1384,8 +1389,7 @@ static int setup_keys(void) { r = 0; finish: - if (fd >= 0) - close_nointr_nofail(fd); + safe_close(fd); if (k) { unlink(k); @@ -1748,7 +1752,7 @@ int main(int argc, char *argv[]) { } if (arg_cursor || arg_after_cursor) { - r = sd_journal_seek_cursor(j, arg_cursor ? arg_cursor : arg_after_cursor); + r = sd_journal_seek_cursor(j, arg_cursor ?: arg_after_cursor); if (r < 0) { log_error("Failed to seek to cursor: %s", strerror(-r)); return EXIT_FAILURE; @@ -1933,5 +1937,7 @@ int main(int argc, char *argv[]) { finish: pager_close(); + strv_free(arg_file); + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }