Commit Graph

88 Commits

Author SHA1 Message Date
Michal Fabik a2be8be2cf coredumpctl: Add --debugger-args= option
This commit adds the possibility to pass command line options to the
debugger invoked with coredumpctl debug.

Resolves: #9905
2020-12-16 12:42:53 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Frantisek Sumsal d7a0f1f4f9 tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
Lennart Poettering 3afe5c00a5 coredump: use log_error_errno() where appropriate 2020-06-25 15:03:13 +02:00
Lennart Poettering d80b051cea tree-wide: add new HAVE_COMPRESSION compile time flag
let's simplify the checks for ZSTD/LZ4/XZ

As suggested:

https://github.com/systemd/systemd/pull/16096#discussion_r440705585
2020-06-25 15:02:45 +02:00
Filipe Brandenburger 41d1f469cf log: introduce log_parse_environment_cli() and log_setup_cli()
Presently, CLI utilities such as systemctl will check whether they have a tty
attached or not to decide whether to parse /proc/cmdline or EFI variable
SystemdOptions looking for systemd.log_* entries.

But this check will be misleading if these tools are being launched by a
daemon, such as a monitoring daemon or automation service that runs in
background.

Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI
variables to determine the logging level.

Furthermore, introduce a new log_setup_cli() shortcut to set up common options
used by most command-line utilities.
2020-06-24 16:49:26 +02:00
Lennart Poettering 544e146b0e journalctl,elsewhere: make sure --file=foo fails with sane error msg if foo is not readable
It annoyed me for quite a while that running "journalctl --file=…" on a
file that is not readable failed with a "File not found" error instead
of a permission error. Let's fix that.

We make this work by using the GLOB_NOCHECK flag for glob() which means
that files are not accessible will be returned in the array as they are
instead of being filtered away. This then means that our later attemps
to open the files will fail cleanly with a good error message.
2020-05-19 15:26:51 +02:00
Norbert Lange ef5924aa31 coredump: add zstandard support for coredumps
this will hook libzstd into coredump,
using this format as default.
2020-05-04 10:59:43 +02:00
Frantisek Sumsal aeb5645082 coredumpctl: support --file=PATH
Let's match journalctl's functionality by throwing --file for
coredumpctl into the mix, so we can work on a single journal file
as well.
2020-04-13 17:10:27 +02:00
Lennart Poettering 353b2baa20 tree-wide: clean up --help texts a bit
This cleans up and unifies the outut of --help texts a bit:

1. Highlight the human friendly description string, not the command
   line via ANSI sequences. Previously both this description string and
   the brief command line summary was marked with the same ANSI
   highlight sequence, but given we auto-page to less and less does not
   honour multi-line highlights only the command line summary was
   affectively highlighted. Rationale: for highlighting the description
   instead of the command line: the command line summary is relatively
   boring, and mostly the same for out tools, the description on the
   other hand is pregnant, important and captions the whole thing and
   hence deserves highlighting.

2. Always suffix "Options" with ":" in the help text

3. Rename "Flags" →  "Options" in one case

4. Move commands to the top in a few cases

5. add coloring to many more help pages

6. Unify on COMMAND instead of {COMMAND} in the command line summary.
   Some tools did it one way, others the other way. I am not sure what
   precisely {} is supposed to mean, that uppercasing doesn't, hence
   let's simplify and stick to the {}-less syntax

And minor other tweaks.
2019-11-18 15:14:43 +01:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Zbigniew Jędrzejewski-Szmek ce2529b4a2 Highlight the synopsis and summary in --help
This doesn't cover all the binaries, but I don't know how to script
this, and I run out of steam ;)
2019-10-08 18:21:27 +02:00
Zbigniew Jędrzejewski-Szmek e1fac8a68a Move the Commands section above Options section
For executables which take a verb, we should list the verbs first, and
then options which modify those verbs second. The general layout of
the man page is from general description to specific details, usually
Overview, Commands, Options, Return Value, Examples, References.
2019-10-08 18:21:26 +02:00
Zbigniew Jędrzejewski-Szmek 2d0a880fea coredumpctl: check return value
retrieve() allocates memory, so it may fail.
Coverity CID#1402338.
2019-07-17 11:35:04 +02:00
Zbigniew Jędrzejewski-Szmek eba048bb6e coredumpctl: use free_and_replace in one more place 2019-07-17 11:35:04 +02:00
Yu Watanabe 657ee2d82b tree-wide: replace strjoin() with path_join() 2019-06-21 03:26:16 +09:00
Yu Watanabe 3f0d8b2dbd coredumpctl: fix --debugger option
Closes #12660.
2019-05-28 08:22:07 +02:00
Lennart Poettering e95be7def2
Merge pull request #12411 from keszybz/pr/12394
run: when emitting the calendarspec warning, use red
2019-05-08 10:11:32 -04:00
Zbigniew Jędrzejewski-Szmek 1a04395959 Enable log colors for most of tools in /usr/bin
When emitting the calendarspec warning we want to see some color.
Follow-up for 04220fda5c.

Exceptions:
- systemctl, because it has a lot hand-crafted coloring
- tmpfiles, sysusers, stdio-bridge, etc, because they are also used in
  services and I'm not sure if this wouldn't mess up something.
2019-05-08 09:50:21 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Lennart Poettering 6990fb6bc6 tree-wide: (void)ify a few unlink() and rmdir()
Let's be helpful to static analyzers which care about whether we
knowingly ignore return values. We do in these cases, since they are
usually part of error paths.
2019-03-27 18:09:56 +01:00
Zbigniew Jędrzejewski-Szmek 871fa294ff Merge pull request #10935 from poettering/rlimit-nofile-safe
Merged by hand to resolve a trivial conflict in TODO.
2018-12-06 17:19:21 +01:00
Lennart Poettering e4de72876e util-lib: split out all temporary file related calls into tmpfiles-util.c
This splits out a bunch of functions from fileio.c that have to do with
temporary files. Simply to make the header files a bit shorter, and to
group things more nicely.

No code changes, just some rearranging of source files.
2018-12-02 13:22:29 +01:00
Lennart Poettering 0672e2c6f8 tree-wide: use FORK_RLIMIT_NOFILE_SAFE wherever possible
Similar to the previous commit: in many cases no further fd processing
needs to be done in forked of children before execve() or any of its
flavours are called. In those case we can use FORK_RLIMIT_NOFILE_SAFE
instead.
2018-12-01 12:50:45 +01:00
Zbigniew Jędrzejewski-Szmek 886cf317c4 coccinelle: also mark previous synthetic errnos as such 2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Zbigniew Jędrzejewski-Szmek 7add4883cb coredumpctl: fix "leak" of bus connection
$ valgrind --show-leak-kinds=all --leak-check=full build/coredumpctl dump --output /tmp/ff
...
==16431== HEAP SUMMARY:
==16431==     in use at exit: 3,680 bytes in 13 blocks
==16431==   total heap usage: 831 allocs, 818 frees, 197,776 bytes allocated
==16431==
==16431== 2 bytes in 1 blocks are still reachable in loss record 1 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x49B2387: bus_message_parse_fields (bus-message.c:5300)
==16431==    by 0x49A23AF: bus_message_from_malloc (bus-message.c:560)
==16431==    by 0x49C459B: bus_socket_make_message (bus-socket.c:1099)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 9 bytes in 1 blocks are still reachable in loss record 2 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4939067: malloc_multiply (alloc-util.h:78)
==16431==    by 0x493921D: hexmem (hexdecoct.c:62)
==16431==    by 0x49C2B75: bus_socket_start_auth_client (bus-socket.c:626)
==16431==    by 0x49C2D78: bus_socket_start_auth (bus-socket.c:665)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==
==16431== 9 bytes in 1 blocks are still reachable in loss record 3 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x497364E: free_and_strdup (string-util.c:1013)
==16431==    by 0x49C9FB1: hello_callback (sd-bus.c:547)
==16431==    by 0x49D0A3A: process_reply (sd-bus.c:2498)
==16431==    by 0x49D13E0: process_message (sd-bus.c:2677)
==16431==    by 0x49D165F: process_running (sd-bus.c:2739)
==16431==    by 0x49D20DD: bus_process_internal (sd-bus.c:2957)
==16431==    by 0x49D21E8: sd_bus_process (sd-bus.c:2984)
==16431==    by 0x49CF21E: bus_ensure_running (sd-bus.c:2053)
==16431==    by 0x49CF51F: sd_bus_call (sd-bus.c:2095)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==
==16431== 24 bytes in 1 blocks are still reachable in loss record 4 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x495CB0D: malloc_multiply (alloc-util.h:78)
==16431==    by 0x495CB2A: prioq_new (prioq.c:35)
==16431==    by 0x495CC02: prioq_ensure_allocated (prioq.c:60)
==16431==    by 0x49CEF84: sd_bus_call_async (sd-bus.c:1995)
==16431==    by 0x49CA0E6: bus_send_hello (sd-bus.c:581)
==16431==    by 0x49CC019: sd_bus_start (sd-bus.c:1196)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 38 bytes in 1 blocks are still reachable in loss record 5 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x4C4D5AD: strdup (strdup.c:42)
==16431==    by 0x497364E: free_and_strdup (string-util.c:1013)
==16431==    by 0x49C7F97: sd_bus_set_address (sd-bus.c:269)
==16431==    by 0x49CC314: bus_set_address_system (sd-bus.c:1262)
==16431==    by 0x49CC3E0: sd_bus_open_system_with_description (sd-bus.c:1281)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 64 bytes in 1 blocks are still reachable in loss record 6 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x4902663: greedy_realloc (alloc-util.c:55)
==16431==    by 0x49C7D7D: sd_bus_new (sd-bus.c:255)
==16431==    by 0x49CC398: sd_bus_open_system_with_description (sd-bus.c:1271)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 64 bytes in 1 blocks are still reachable in loss record 7 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x4902663: greedy_realloc (alloc-util.c:55)
==16431==    by 0x49CE54E: bus_rqueue_make_room (sd-bus.c:1786)
==16431==    by 0x49C44FC: bus_socket_make_message (bus-socket.c:1087)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CE6AF: dispatch_rqueue (sd-bus.c:1814)
==16431==    by 0x49D162E: process_running (sd-bus.c:2733)
==16431==    by 0x49D20DD: bus_process_internal (sd-bus.c:2957)
==16431==    by 0x49D21E8: sd_bus_process (sd-bus.c:2984)
==16431==    by 0x49CF21E: bus_ensure_running (sd-bus.c:2053)
==16431==
==16431== 65 bytes in 1 blocks are still reachable in loss record 8 of 13
==16431==    at 0x483AB1A: calloc (vg_replace_malloc.c:752)
==16431==    by 0x496E5D6: getpeersec (socket-util.c:969)
==16431==    by 0x49C291C: bus_get_peercred (bus-socket.c:594)
==16431==    by 0x49C2CB2: bus_socket_start_auth (bus-socket.c:650)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 181 bytes in 1 blocks are still reachable in loss record 9 of 13
==16431==    at 0x483AD19: realloc (vg_replace_malloc.c:826)
==16431==    by 0x49C4791: bus_socket_read_message (bus-socket.c:1143)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 256 bytes in 1 blocks are still reachable in loss record 10 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x496E740: getpeergroups (socket-util.c:998)
==16431==    by 0x49C29BD: bus_get_peercred (bus-socket.c:599)
==16431==    by 0x49C2CB2: bus_socket_start_auth (bus-socket.c:650)
==16431==    by 0x49C3B09: bus_socket_connect (bus-socket.c:915)
==16431==    by 0x49CBB08: bus_start_address (sd-bus.c:1103)
==16431==    by 0x49CBFEA: sd_bus_start (sd-bus.c:1187)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==
==16431== 256 bytes in 1 blocks are still reachable in loss record 11 of 13
==16431==    at 0x4838748: malloc (vg_replace_malloc.c:298)
==16431==    by 0x483AD63: realloc (vg_replace_malloc.c:826)
==16431==    by 0x495D1A0: prioq_put (prioq.c:162)
==16431==    by 0x49CF0EA: sd_bus_call_async (sd-bus.c:2023)
==16431==    by 0x49CA0E6: bus_send_hello (sd-bus.c:581)
==16431==    by 0x49CC019: sd_bus_start (sd-bus.c:1196)
==16431==    by 0x49CC452: sd_bus_open_system_with_description (sd-bus.c:1294)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==
==16431== 856 bytes in 1 blocks are still reachable in loss record 12 of 13
==16431==    at 0x483AB1A: calloc (vg_replace_malloc.c:752)
==16431==    by 0x49A1F33: bus_message_from_header (bus-message.c:458)
==16431==    by 0x49A22B1: bus_message_from_malloc (bus-message.c:535)
==16431==    by 0x49C459B: bus_socket_make_message (bus-socket.c:1099)
==16431==    by 0x49C4C5B: bus_socket_read_message (bus-socket.c:1213)
==16431==    by 0x49CE4CE: bus_read_message (sd-bus.c:1777)
==16431==    by 0x49CFA2C: sd_bus_call (sd-bus.c:2176)
==16431==    by 0x1105F3: check_units_active (coredumpctl.c:1029)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== 1,856 bytes in 1 blocks are still reachable in loss record 13 of 13
==16431==    at 0x483880B: malloc (vg_replace_malloc.c:299)
==16431==    by 0x49C6EDF: malloc_multiply (alloc-util.h:78)
==16431==    by 0x49C7C81: sd_bus_new (sd-bus.c:235)
==16431==    by 0x49CC398: sd_bus_open_system_with_description (sd-bus.c:1271)
==16431==    by 0x49CC4C6: sd_bus_open_system (sd-bus.c:1303)
==16431==    by 0x49D4424: bus_default (sd-bus.c:3655)
==16431==    by 0x49D44BC: sd_bus_default_system (sd-bus.c:3668)
==16431==    by 0x110444: check_units_active (coredumpctl.c:1007)
==16431==    by 0x110998: run (coredumpctl.c:1087)
==16431==    by 0x110A45: main (coredumpctl.c:1100)
==16431==
==16431== LEAK SUMMARY:
==16431==    definitely lost: 0 bytes in 0 blocks
==16431==    indirectly lost: 0 bytes in 0 blocks
==16431==      possibly lost: 0 bytes in 0 blocks
==16431==    still reachable: 3,680 bytes in 13 blocks
==16431==         suppressed: 0 bytes in 0 blocks
==16431==
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek c118b577fa coredumpctl: define main through macro
We want to propagate the return value from gdb, hence this commit makes
use of the liberalization of DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE()
in previous commit.
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 158ecef56b coredumpctl: open output file only before writing
We would open the file very early, which is not nice, if we e.g. fail when
parsing later options. Let's do the usual thing and just open it just before
writing, and close immediately after writing.
2018-11-20 16:48:21 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00
Yu Watanabe 9d77ca39e5 coredump: include error cause in log message 2018-10-20 01:43:13 +09:00
Lennart Poettering 1abaf4887d tree-wide: uniformly bump RLIMIT_NOFILE in all our tools that access the journal
This makes use of rlimit_nofile_bump() in all tools that access the
journal. In some cases this replaces older code to achieve this, and
others we add it in where it was missing.
2018-10-16 16:33:55 +02:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Lion Yang 2fafabfdc4 coredumpctl: info shows the last entry by default
Closes #9524.
2018-07-23 17:45:53 +02:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Lennart Poettering abdf29f50d coredumpctl: always output proper english sentence
Let's uppercase the first character, and finish them in a full stop.
2018-05-22 13:14:18 +02:00
Ryan Gonzalez c5896b6a8c coredumpctl: Add debug as a gdb alias, and add lldb support (closes #8722) (#8744) 2018-04-18 21:32:17 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Lennart Poettering f5c4b520ba coccinelle: run safe_fclose.cocci again 2018-03-23 16:32:48 +01:00
Lennart Poettering ae2a15bc14 macro: introduce TAKE_PTR() macro
This macro will read a pointer of any type, return it, and set the
pointer to NULL. This is useful as an explicit concept of passing
ownership of a memory area between pointers.

This takes inspiration from Rust:

https://doc.rust-lang.org/std/option/enum.Option.html#method.take

and was suggested by Alan Jenkins (@sourcejedi).

It drops ~160 lines of code from our codebase, which makes me like it.
Also, I think it clarifies passing of ownership, and thus helps
readability a bit (at least for the initiated who know the new macro)
2018-03-22 20:21:42 +01:00
Lennart Poettering 43bfe75032 coredumpctl: drop unnecessary NULL initialization, and use const where possible (#8515) 2018-03-21 11:46:08 +01:00
Yu Watanabe ee5324aa04 tree-wide: voidify pager_open()
Even if pager_open() fails, in general, we should continue the operations.
All erroneous cases in pager_open() show log message in the function.
So, it is not necessary to check the returned value.
2018-03-19 21:04:02 +09:00
Yu Watanabe 5ce97d33d0 coredumpctl: use dispatch_verb() 2018-03-19 21:03:36 +09:00
Yu Watanabe e8fb0238cd coredump: do not leak memory (#8352)
Fixes #8351.
2018-03-05 08:39:52 +01:00
Lennart Poettering 0b1f3c768c tree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS children
In a number of occasions we use FORK_CLOSE_ALL_FDS when forking off a
child, since we don't want to pass fds to the processes spawned (either
because we later want to execve() some other process there, or because
our child might hang around for longer than expected, in which case it
shouldn't keep our fd pinned). This also closes any logging fds, and
thus means logging is turned off in the child. If we want to do proper
logging, explicitly reopen the logs hence in the child at the right
time.

This is particularly crucial in the umount/remount children we fork off
the shutdown binary, as otherwise the children can't log, which is
why #8155 is harder to debug than necessary: the log messages we
generate about failing mount() system calls aren't actually visible on
screen, as they done in the child processes where the log fds are
closed.
2018-02-22 00:35:00 +01:00
Zbigniew Jędrzejewski-Szmek e79d0b59c8 journalctl: improve hint about lack of access for --user-unit=...
When running journalctl --user-unit=foo as an unprivileged user we could get
the usual hint:
Hint: You are currently not seeing messages from the system and other users.
      Users in groups 'adm', 'systemd-journal', 'wheel' can see all messages.
      ...
But with --user-unit our filter is:
(((_UID=0 OR _UID=1000) AND OBJECT_SYSTEMD_USER_UNIT=foo.service) OR
 ((_UID=0 OR _UID=1000) AND COREDUMP_USER_UNIT=foo.service) OR
 (_UID=1000 AND USER_UNIT=foo.service) OR
 (_UID=1000 AND _SYSTEMD_USER_UNIT=foo.service))
so we would never see messages from other users.

We could still see messages from the system. In fact, on my machine the
only messages with OBJECT_SYSTEMD_USER_UNIT= are from the system:
journalctl  $(journalctl -F OBJECT_SYSTEMD_USER_UNIT|sed 's/.*/OBJECT_SYSTEMD_USER_UNIT=\0/')

Thus, a more correct hint is that we cannot see messages from the system.
Make it so.

Fixes #7887.
2018-02-20 22:36:01 +01:00