summaryrefslogtreecommitdiffstats
path: root/src/coredump (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
|
* basic,shared: move disable_coredumps() to coredump-util.[ch]Zbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* coredumpctl: add --root= + --image= to --help textLennart Poettering2022-10-251-0/+2
|
* coredumpctl: Add support for the --root option (after merge fixes)Richard Phibel2022-10-101-10/+9
|
* coredumpctl: Add support for the --image optionRichard Phibel2022-10-031-2/+34
|
* coredumpctl: Add support for the --root optionRichard Phibel2022-10-031-4/+76
| | | | | With this option, coredumpctl looks for journal files under the specified root directory
* shared/format-table: use enum instead of Table.empty_stringZbigniew Jędrzejewski-Szmek2022-09-221-1/+1
| | | | | | | | | | | | All users were setting this to some static string (usually "-"), so let's simplify things by not doing strdup, but instead limiting callers to a fixed set of values. In preparation for the next commit, the function is renamed from "empty" to "replacement", because it'll be used for more than empty fields. I didn't do the whole string-table setup, because it's all used internally in one file and this way we can immediately assert if an invalid value is passed in. Some callers were (void)ing the error, others were ignoring it, and others propagating. It's nicer to remove the boilerplate.
* coredumpctl: rename table entryZbigniew Jędrzejewski-Szmek2022-09-171-1/+1
| | | | "Disk Size" could be mistaken for "Size of the Disk".
* coredump: drop an unused variableFrantisek Sumsal2022-08-201-2/+0
|
* coredumpctl: Use BusLocator functionsAlexander Wilson2022-07-211-7/+2
|
* coredump: Try to write journald coredump metadata to the journalDaan De Meyer2022-07-151-6/+26
| | | | | | | | | | | | | | | | | Currently, if journald coredumps, the coredump is written to /var/lib/systemd/coredump but the coredump metadata is not written to the journal meaning we can't find out about the coredump's existence via the journal. This means that coredumpctl can't be used to work with journald coredumps, as well as any other tools that rely on journald to know about coredumps. To solve the issue, let's have systemd-coredump try to write systemd-journald coredump metadata to the journal. We have to be careful though, since if journald coredumps, there's no active reader on the receive end of the journal socket, so we have to make sure we don't deadlock trying to write to the socket. To avoid the deadlock, we put the socket in nonblocking mode before trying to write to it.
* coredump: Connect stdout/stderr to /dev/null before doing anythingDaan De Meyer2022-07-151-0/+7
| | | | | | | | | | When invoked as the coredump handler by the kernel, systemd-coredump's stdout and stderr streams are closed. This is dangerous as this means the fd's can get reallocated, leading to hard to debug errors such as log messages ending up being appended to a compressed coredump file. To avoid such issues in the future, let's bind stdout/stderr to /dev/null so the file descriptors can't get used for anything else.
* coredump: Fix format string type mismatchDaan De Meyer2022-05-221-2/+2
| | | | Fixes #23471
* tree-wide: port various users over to connect_unix_path()Lennart Poettering2022-05-131-7/+3
| | | | Let's make use of our new helper, and thus allow longer paths.
* meson: use a single constant for default compression settingZbigniew Jędrzejewski-Szmek2022-04-221-1/+1
| | | | | | | | | | Suggested by Daniele Nicolodi: https://github.com/systemd/systemd/pull/23160#discussion_r855853716 This is possible only if the macro is never used in #if, but only in C code. This means that all places that use #if have to be refactored into C, but we reduce the duplication a bit, and C is nicer to read than preprocessor conditionals.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-1/+0
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* meson: do not use split() in file listsZbigniew Jędrzejewski-Szmek2022-03-021-5/+4
| | | | | | | | | | | The approach to use '''…'''.split() instead of a list of strings was initially used when converting from automake because it allowed identical blocks of lines to be used for both, making the conversion easier. But over the years we have been using normal lists more and more, especially when there were just a few filenames listed. This converts the rest. No functional change.
* coredump: fix inode checkLennart Poettering2022-02-141-1/+1
| | | | | | When checking if we look at the root directory we actually need to compare both st_dev *and* st_ino. The existing check only checked the latter. Fix that.
* tree-wide: port various places over to new stat_inode_same() helperLennart Poettering2022-02-141-3/+2
|
* coredump: raise the coredump save size on 64bit systems to 32G (and lower it ↵Lennart Poettering2022-02-081-2/+8
| | | | | | | | | | | | | | | | | to 1G on 32bit systems) Apparently 2G is too low for various real-life systems. But raising it universally above 2^32 sounds wrong to me, since that makes no sense on 32bit systems, that we still support. Hence, let's raise the limit to 32G on 64bit systems, and *lower* it to 1G on 32bit systems. 32G is 4 orders of magnitude higher then the old settings. Let's hope that's enough for now. Should this not be enough we can raise it further. Fixes: #22076
* meson: Use files() for testsJan Janssen2022-01-111-3/+3
| | | | | | Not having to provide the full path in the source tree is much nicer and the produced lists can also be used anywhere in the source tree.
* coredump: drop unnecessary initializationYu Watanabe2022-01-051-1/+2
|
* coredump: do not crash if we failed to acquire exe pathZbigniew Jędrzejewski-Szmek2022-01-031-17/+22
| | | | | | | | | | | | | | | | | | The COREDUMP_EXE attribute is "optional", i.e. we continue to process the crash even if we didn't acquire it. The coredump generation code assumed that it is always available: #5 endswith at ../src/fundamental/string-util-fundamental.c:41 [ endswith() is called with NULL here, and an assertion fails. ] #6 submit_coredump at ../src/coredump/coredump.c:823 #7 process_socket at ../src/coredump/coredump.c:1038 #8 run at ../src/coredump/coredump.c:1413 We use the exe path for loop detection, and also (ultimately) pass it to dwfl_core_file_report(). The latter seems to be fine will NULL, so let's just change our code to look at COMM, which should be more reliable anyway. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2036517.
* coredump: drop unnecessary parenthesesYu Watanabe2022-01-031-3/+2
|
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-152-6/+4
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* elf-util: add stub for builds without libdwLuca Boccassi2021-11-301-2/+0
|
* coredump: move elf parsing utilities to src/shared/elf-utilLuca Boccassi2021-11-304-556/+1
|
* coredump: always log on failure in parse_core()Luca Boccassi2021-11-301-2/+2
|
* coredump: make the buffer optional when analyzing a core fileLuca Boccassi2021-11-301-21/+31
| | | | Allow later usage when we only want to fetch the JSON packaging metadata
* coredump: analyze object with libdwelf in forked processLuca Boccassi2021-11-303-16/+139
| | | | | | | Parsing objects is risky as data could be malformed or malicious, so avoid doing that from the main systemd-coredump process and instead fork another process, and set it to avoid generating core files itself.
* coredump: use _cleanup_ patternLuca Boccassi2021-11-301-51/+47
| | | | | Note that c.f needs to be closed _before_ taking or freeing the buf pointer, as it might be invalidated
* coredump: flush accumulating buffer after parsing core fileLuca Boccassi2021-11-301-3/+4
|
* coredump: check return of dwarf_getscopesLuca Boccassi2021-11-301-15/+16
|
* coredump: fix parsing metadata without access to executableLuca Boccassi2021-11-291-35/+33
| | | | | | | This was broken in a subtle way: we'd get an ELF ref, but not the right one, so no metadata note would be found. Change the parsing function to return 1 when it finds something, so that we can return early only when that happens.
* systemd-coredump: allow setting external core size to infinityThomas Blume2021-11-191-7/+7
| | | | Make it compatible to the ulimit setting: unlimited
* Merge pull request #21326 from poettering/mkdir-tweaksLennart Poettering2021-11-161-1/+1
|\ | | | | various tweaks to mkdir code
| * shared: clean up mkdir.h/label.h situationLennart Poettering2021-11-161-1/+1
| | | | | | | | | | | | | | | | | | | | Previously the mkdir_label() family of calls was implemented in src/shared/mkdir-label.c but its functions partly declared ins src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird (and wrong). Let's clean this up, and add a proper mkdir-label.h matching the .c file.
* | coredump: tweak which dir we createLennart Poettering2021-11-161-1/+1
|/
* shared: split out UID allocation range stuff from user-record.hLennart Poettering2021-11-131-1/+1
| | | | | | | | user-record.[ch] are about the UserRecord JSON stuff, and the UID allocation range stuff (i.e. login.defs handling) is a very different thing, and complex enough on its own, let's give it its own c/h files. No code changes, just some splitting out of code.
* coredump: fix filename in journal when not compressedxdavidwu2021-11-051-0/+1
| | | | | | | | Since 587f2a5e564cf434c2e0a653f52b8f73e86092d8, filename for not-compressed coredump is missing from save_external_coredump, making it write COREDUMP_FILENAME= (empty) in journal, making `coredumpctl` report it missing but it is actually saved. This fixes it.
* Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-031-1/+1
|
* alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhereLennart Poettering2021-10-141-1/+1
| | | | | | | | | | | | | Let's define two helpers strdupa_safe() + strndupa_safe() which do the same as their non-safe counterparts, except that they abort if called with allocations larger than ALLOCA_MAX. This should ensure that all our alloca() based allocations are subject to this limit. afaics glibc offers three alloca() based APIs: alloca() itself, strndupa() + strdupa(). With this we have now replacements for all of them, that take the limit into account.
* coredumpctl: stop truncating information about coredumpZbigniew Jędrzejewski-Szmek2021-10-121-0/+2
| | | | | | | With the changes to limit that print 'Found module …' over and over, we were hitting the journal field message limit, effectively truncating the info output. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1998488.
* coredump: Add --all optionDaan De Meyer2021-10-071-1/+9
| | | | | | | | | | | This option has coredumpctl look at all journals instead of only the local ones. This allows coredumpctl to show information about remote coredumps if the coredumps are made available in /var/lib/systemd/coredump and the corresponding journals are made available in /var/log/journal. This is already possible using the --directory option but --all makes it more user friendly since users don't have to enter the journal directory anymore as long as it's available under /var/log/journal.
* coredump: Don't log an error if D-Bus isn't runningDaan De Meyer2021-10-061-0/+4
| | | | | | | coredumpctl could be used in a chroot where D-Bus isn't running. If that's the case, we shouldn't consider it an error if we can't connect to the D-Bus daemon so let's reduce the severity of the error we log when we can't connect to D-Bus because the socket doesn't exist.
* basic: split out sync() family of calls from fs-util.[ch] into new c/h fileLennart Poettering2021-10-051-4/+4
| | | | No changes in code, just some splitting out.
* Fix another crash due to missing NHDRKevin Orr2021-08-271-0/+2
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.