summaryrefslogtreecommitdiff
path: root/src/coredump/coredump.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-051-2/+2
|
* coredump: indent commentZbigniew Jędrzejewski-Szmek2021-03-011-5/+5
|
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* treewide: tighten variable scope in loops (#18372)Susant Sahani2021-01-271-13/+10
| | | | Also use _cleanup_free_ in one more place.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: assorted coccinelle fixesFrantisek Sumsal2020-10-091-2/+1
|
* coredump: use uid_is_system() when appropriateZbigniew Jędrzejewski-Szmek2020-09-251-1/+1
|
* Move {uid,gid}_is_*() from basic to sharedZbigniew Jędrzejewski-Szmek2020-09-251-0/+1
| | | | | Those are functions that express policy, and nothing in basic/ uses (or should use) them.
* coredump: don't convert s → µs twiceLennart Poettering2020-09-021-4/+10
| | | | | | | We already append 000000 early on when parsing the cmdline args, let's not do that a second time. Fixes: #16919
* Merge pull request #16841 from keszybz/acl-util-bitmaskLennart Poettering2020-08-311-2/+2
|\ | | | | Use a bitmask in fd_add_uid_acl_permission()
| * shared/acl-util: convert rd,wr,ex to a bitmaskZbigniew Jędrzejewski-Szmek2020-08-271-2/+2
| | | | | | | | | | | | | | | | | | I find this version much more readable. Add replacement defines so that when acl/libacl.h is not available, the ACL_{READ,WRITE,EXECUTE} constants are also defined. Those constants were declared in the kernel headers already in 1da177e4c3f41524e886b7f1b8a0c1f, so they should be the same pretty much everywhere.
* | tree-wide: drop pointless zero initialization (#16884)fangxiuning2020-08-281-1/+1
|/ | | tree-wide: drop pointless zero initialization
* acl-util: beef up add_acls_for_user()Lennart Poettering2020-08-251-1/+1
| | | | | | Let's add support for controlling r/w/x bits separetely. This is useful for using it to control access to directories, where r + x shall be enabled.
* coredump: port to use common add_acls_for_user()Lennart Poettering2020-07-211-24/+4
| | | | It's line-by-line the same logic, hence use the common implementation.
* tree-wide: add new HAVE_COMPRESSION compile time flagLennart Poettering2020-06-251-1/+1
| | | | | | | | let's simplify the checks for ZSTD/LZ4/XZ As suggested: https://github.com/systemd/systemd/pull/16096#discussion_r440705585
* conf-parser: return mtime in config_parse() and friendsLennart Poettering2020-06-021-5/+8
| | | | | | | | | | | | | This is a follow-up for 9f83091e3cceb646a66fa9df89de6d9a77c21d86. Instead of reading the mtime off the configuration files after reading, let's do so before reading, but with the fd we read the data from. This is not only cleaner (as it allows us to save one stat()), but also has the benefit that we'll detect changes that happen while we read the files. This also reworks unit file drop-ins to use the common code for determining drop-in mtime, instead of reading system clock for that.
* tree-wide: make sure our control buffers are properly alignedLennart Poettering2020-05-071-4/+1
| | | | | | | | | | | | | We always need to make them unions with a "struct cmsghdr" in them, so that things properly aligned. Otherwise we might end up at an unaligned address and the counting goes all wrong, possibly making the kernel refuse our buffers. Also, let's make sure we initialize the control buffers to zero when sending, but leave them uninitialized when reading. Both the alignment and the initialization thing is mentioned in the cmsg(3) man page.
* coredump: add zstandard support for coredumpsNorbert Lange2020-05-041-1/+1
| | | | | this will hook libzstd into coredump, using this format as default.
* tree-wide: use cmsg_find() helper at various places where appropriateLennart Poettering2020-04-231-10/+2
|
* tree-wide: use recvmsg_safe() at various placesLennart Poettering2020-04-231-7/+7
| | | | | | | | | | | | | | | | | Let's be extra careful whenever we return from recvmsg() and see MSG_CTRUNC set. This generally means we ran into a programming error, as we didn't size the control buffer large enough. It's an error condition we should at least log about, or propagate up. Hence do that. This is particularly important when receiving fds, since for those the control data can be of any size. In particular on stream sockets that's nasty, because if we miss an fd because of control data truncation we cannot recover, we might not even realize that we are one off. (Also, when failing early, if there's any chance the socket might be AF_UNIX let's close all received fds, all the time. We got this right most of the time, but there were a few cases missing. God, UNIX is hard to use)
* *: use _cleanup_close_ with fdopen() where trivialVito Caputo2020-03-311-5/+3
| | | | Also convert these to use take_fdopen().
* tree-wide: drop missing.hYu Watanabe2019-10-311-1/+0
|
* coredump: (void)ify all calls of iovw_put_string_field() where we ignore ↵Franck Bui2019-07-161-27/+28
| | | | | | failure on purpose All those calls are dealing with optional metadata.
* coredump: gather all process metadata in iovecs first and then cache themFranck Bui2019-07-161-247/+260
| | | | | | | | | | | | Now we first gather all process metadata and populate the process info cache with them. In this way, the cache only references metadata recorded in iovecs[] so there's no need to bother freeing (part of) cached metadata later. The other advantage is that the coredump handler mode and the service mode are more similar as the cache is populated in the same way for both cases. It also renames the array indexes so it becomes clear which metadata are passed by the kernel and which ones are retrieved from the runtime environment.
* coredump: use 'input_fd' name for the pipe fd passed by the kernel everywhereFranck Bui2019-07-161-5/+5
| | | | | | | | | | | 'input_fd' variable name is used mostly everywhere except in process_socket() where it's named 'coredump_fd', which is pretty confusing since 'coredump_fd' is used for the coredump filename in submit_coredump(). So let's use 'input_fd' consistently as name for the pipe fd passed by the kernel. No functional changes.
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-1/+1
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* coredump: make use of the iovec-array helpersFranck Bui2019-06-281-145/+129
| | | | | | | | | | | | | | | | | Previous code was allocating an array of iovecs big enough to store all the fields added later by various functions. This forced us to calculate the size of the array in advance which is too error prone if for example one wants to add new fields or simply rework the code. Various assertions were added to make sure there's no overflow but it's still more code for no good reasons. Instead, this patch switches to the new iovec array handling interface so the array is grown dynamically when needed. The other contraint was that some iovecs were supposed to be freed whereas some others were not. This makes the code hard to (re)organize. The new code always allocates fields so it becomes easier to rework the code.
* journal-import: extract helpers for handling arrays of iovec and make them ↵Franck Bui2019-06-271-3/+1
| | | | available for others
* coredump: drop 2 useless assertionsFranck Bui2019-06-271-3/+0
|
* coredump: slighlty simplify stack trace generation logicFranck Bui2019-06-271-29/+21
| | | | | | | The main advantage is to avoid the code duplication used to build MESSAGE= field. No functional changes.
* coredump: fix the check on the number of passed args in backtrace modeFranck Bui2019-06-271-2/+2
| | | | In backtrace mode, '--backtrace' option should also be counted.
* coredump: gather_pid_metadata() doesn't return 1 anymoreFranck Bui2019-06-271-5/+1
| | | | | Since commit 92e92d71faea0f107312f296b7756cc04281ba99, gather_pid_metadata() returns only 0 or a negative value.
* coredump: rename set_iovec_field_free() into set_iovec_string_field_free()Franck Bui2019-06-271-23/+15
| | | | | | It's more in line with its counterpart set_iovec_string_field(). Also move the definition to io-util next to set_iovec_string_field().
* coredump: rely on /proc exclusively to get the name of the crashing processFranck Bui2019-06-261-28/+14
| | | | | | | | | | | | | | | | | | I couldn't see any reason why the kernel could provide COMM to the coredump handler via the core_pattern command line but could not make it available in /proc. So let's assume that this info is always available in /proc. For "backtrace" mode (when --backtrace option is passed), I assumed that the crashing process still exists at the time systemd-coredump is called. Also changing the core_pattern line is an API breakage for any users of the backtrace mode but given that systemd-coredump is installed in /usr/lib/systemd, it's a private tool which has no internal users. At least no one complained when the hostname was added to the core_pattern line (f45b8015513)... Indeed it's much easier to get it from /proc since the kernel substitutes '%e' specifier with multiple strings if the process name contains spaces (!).
* coredump: fix one memleak in backtrace modeFranck Bui2019-06-261-1/+1
| | | | Journal importer internal structures need to be freed.
* coredump: make use of STRINGIFYFranck Bui2019-06-261-5/+2
|
* basic/process-util: convert bool arg to flagsZbigniew Jędrzejewski-Szmek2019-05-221-2/+2
| | | | In preparation for the next commit…
* Rework cmdline printing to use unicodeZbigniew Jędrzejewski-Szmek2019-05-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The functions to retrieve and print process cmdlines were based on the assumption that they contain printable ASCII, and everything else should be filtered out. That assumption doesn't hold in today's world, where people are free to use unicode everywhere. This replaces the custom cmdline reading code with a more generic approach using utf8_escape_non_printable_full(). For kernel threads, truncation is done on the parenthesized name, so we'll get "[worker]", "[worker…]", …, "[w…]", "[…", "…" as we reduce the number of available columns. This implementation is most likely slower for very long cmdlines, but I don't think this is very important. The common case is to have short commandlines, and should print those properly. Absurdly long cmdlines are the exception, which needs to be handled correctly and safely, but speed is not too important. Fixes #12532. v2: - use size_t for the number of columns. This change propagates into various other functions that call get_process_cmdline(), increasing the size of the patch, but the changes are rather trivial.
* Merge pull request #12420 from mrc0mmand/coccinelle-tweaksLennart Poettering2019-04-301-4/+1
|\ | | | | Coccinelle improvements
| * tree-wide: code improvements suggested by CoccinelleFrantisek Sumsal2019-04-301-4/+1
| |
* | codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|/
* Add open_memstream_unlocked() wrapperZbigniew Jędrzejewski-Szmek2019-04-121-4/+1
|
* Voidify more mkdir_p callsZbigniew Jędrzejewski-Szmek2019-03-271-1/+1
|
* util: split out memcmp()/memset() related calls into memory-util.[ch]Lennart Poettering2019-03-131-1/+1
| | | | Just some source rearranging.
* Remove 'inline' attributes from static functions in .c files (#11426)Topi Miettinen2019-01-151-2/+2
| | | Let the compiler perform inlining (see #11397).
* coredump: fix message when we fail to save a journald coredumpZbigniew Jędrzejewski-Szmek2019-01-091-2/+2
| | | | | | | If creation of the message failed, we'd write a bogus entry: systemd-coredump[1400]: Cannot store coredump of 416 (systemd-journal): No space left on device systemd-coredump[1400]: MESSAGE=Process 416 (systemd-journal) of user 0 dumped core. systemd-coredump[1400]: Coredump diverted to
* journald: do not store the iovec entry for process commandline on stackZbigniew Jędrzejewski-Szmek2019-01-091-20/+11
| | | | | | | | | | | | This fixes a crash where we would read the commandline, whose length is under control of the sending program, and then crash when trying to create a stack allocation for it. CVE-2018-16864 https://bugzilla.redhat.com/show_bug.cgi?id=1653855 The message actually doesn't get written to disk, because journal_file_append_entry() returns -E2BIG.
* coredump: remove duplicate MESSAGE= prefix from messageZbigniew Jędrzejewski-Szmek2019-01-091-2/+3
| | | | | | | | systemd-coredump[9982]: MESSAGE=Process 771 (systemd-journal) of user 0 dumped core. systemd-coredump[9982]: Coredump diverted to /var/lib/systemd/coredump/core... log_dispatch() calls log_dispatch_internal() which calls write_to_journal() which appends MESSAGE= on its own.
* tree-wide: Remove O_CLOEXEC from fdopenChris Down2018-12-121-1/+1
| | | | | | | | | | | | fdopen doesn't accept "e", it's ignored. Let's not mislead people into believing that it actually sets O_CLOEXEC. From `man 3 fdopen`: > e (since glibc 2.7): > Open the file with the O_CLOEXEC flag. See open(2) for more information. This flag is ignored for fdopen() As mentioned by @jlebon in #11131.