summaryrefslogtreecommitdiffstats
path: root/src/journal (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #28365 from DaanDeMeyer/udevadm-queryDaan De Meyer2023-07-121-2/+2
|\ | | | | Various fixes and improvements
| * device-util: Declare iterator variables inlineDaan De Meyer2023-07-121-2/+2
| |
* | tree-wide: fix typos reported by Fossies Codespell reportYu Watanabe2023-07-121-1/+1
|/
* Cast st_dev to dev_t when printingLuca Boccassi2023-07-101-1/+1
| | | | | | | | | | | | | | | | | | st_dev is not the same as dev_t, and on O32 architectures like mipsel it's an unsigned long, but dev_t is still unsigned long long, so they don't match and compilation fails: ../src/journal/cat.c: In function ‘run’: ../src/basic/format-util.h:46:19: error: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘long unsigned int’ [-Werror=format=] 46 | # define DEV_FMT "%" PRIu64 | ^~~ ../src/journal/cat.c:168:34: note: in expansion of macro ‘DEV_FMT’ 168 | if (asprintf(&s, DEV_FMT ":" INO_FMT, st.st_dev, st.st_ino) < 0) | ^~~~~~~ In file included from ../src/systemd/sd-journal.h:20, from ../src/journal/cat.c:11: /usr/include/inttypes.h:105:41: note: format string is defined here 105 | # define PRIu64 __PRI64_PREFIX "u"
* Merge pull request #28233 from mrc0mmand/append-to-corrupted-journalsYu Watanabe2023-07-072-0/+277
|\ | | | | test: append to corrupted journals
| * test: append to corrupted journalsFrantisek Sumsal2023-07-062-0/+277
| | | | | | | | | | | | | | Introduce a manual test tool that creates a journal, corrupts it by flipping bits at given offsets, and then attempts to write to the journal. In ideal case we should handle this gracefully without any crash or memory corruption.
* | journal-util: extract journal_open_machine() from journalctlYu Watanabe2023-07-051-30/+3
|/
* journalctl: read env vars that override compiled catalog database and source ↵Lennart Poettering2023-06-271-2/+9
| | | | | | | files This makes it a bit easier to test catalog files without installing systemd.
* journalctl: add --truncate-newline optionzhmylove2023-06-161-0/+9
|
* tree-wide: fix a couple of typosFrantisek Sumsal2023-06-151-1/+1
| | | | As reported by Fossies.org.
* socket: bump listen() backlog to INT_MAX everywhereLennart Poettering2023-06-131-1/+1
| | | | | | | This is a rework of #24764 by Cristian Rodríguez <crodriguez@owncloud.com>, which stalled. Instead of assigning -1 we'll use a macro defined to INT_MAX however.
* journald: move uid_for_system_journal() to uid-alloc-range.hLennart Poettering2023-06-081-7/+0
| | | | | | | | | | | Let's move this helper call from journald specific code to src/basic/, so that we can use it from sd-journal. While we are at it, slightly extend it to also cover container uids, which are also routed to the system journal now. This places the call in uid-alloc-range.[ch] which contains similar functions that match UID ranges for specific purposes.
* tree-wide: use memstream-utilYu Watanabe2023-05-311-16/+6
|
* journalctl: fix --follow with non-matching filterYu Watanabe2023-05-281-4/+1
| | | | | | | | | | | When there is no matching entry stored in journal, then initial call of `sd_journal_previous()` following `sd_journal_seek_tail()` returns zero, and does not move the read pointer. In the main loop, on every journal event, we call `sd_journal_next()`, even though the current location is tail, and it takes no effect. In such a case, we need to call `sd_journal_previous()` instead of `sd_journal_next()`.
* journalctl: also update cursor with --followYu Watanabe2023-05-281-1/+31
| | | | Fixes #26746.
* journalctl: replace ppoll() loop with sd_event_loop()Yu Watanabe2023-05-281-51/+71
| | | | No functional change, just refactoring.
* journalctl: split out show()Yu Watanabe2023-05-281-137/+176
| | | | No functional changes, just refactoring.
* journalctl: split out update_cursor()Yu Watanabe2023-05-281-20/+30
| | | | No functional change, just refactoring.
* journalctl: split out action_list_fields()Yu Watanabe2023-05-281-31/+35
| | | | No functional change, just refactoring.
* journalctl: fix --no-tail handlingYu Watanabe2023-05-281-1/+4
| | | | Fixes a bug introduced by 62f21ec91ad8e7e24079962f4df066b0094fe68d.
* journalctl: use correct variable to check if --since is specifiedYu Watanabe2023-05-281-1/+1
|
* journalctl: always initialize global variablesYu Watanabe2023-05-281-1/+1
| | | | | That's not necessary, as they are initialized with zero, but for safety and readability.
* journalctl: split get_boots() into threeYu Watanabe2023-05-261-155/+140
| | | | | | | | | Previously, get_boots() used for three ways; finding boot entry by boot ID, finding boot entry by offset, listing up all boot IDs. Let's split it into three for each usecase. No functional change, just refactoring.
* logs-show: introduce add_match_boot_id() helper functionYu Watanabe2023-05-261-11/+3
|
* Merge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigansYu Watanabe2023-05-251-0/+4
|\ | | | | A couple of fixes for potential issues during OOM situations
| * tree-wide: check memstream buffer after closing the handleFrantisek Sumsal2023-05-241-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When closing the FILE handle attached to a memstream, it may attempt to do a realloc() that may fail during OOM situations, in which case we are left with the buffer pointer pointing to NULL and buffer size > 0. For example: ``` #include <errno.h> #include <stdio.h> #include <stdlib.h> void *realloc(void *ptr, size_t size) { return NULL; } int main(int argc, char *argv[]) { FILE *f; char *buf; size_t sz = 0; f = open_memstream(&buf, &sz); if (!f) return -ENOMEM; fputs("Hello", f); fflush(f); printf("buf: 0x%lx, sz: %lu, errno: %d\n", (unsigned long) buf, sz, errno); fclose(f); printf("buf: 0x%lx, sz: %lu, errno: %d\n", (unsigned long) buf, sz, errno); return 0; } ``` ``` $ gcc -o main main.c $ ./main buf: 0x74d4a0, sz: 5, errno: 0 buf: 0x0, sz: 5, errno: 0 ``` This might do unexpected things if the underlying code expects a valid pointer to the memstream buffer after closing the handle. Found by Nallocfuzz.
* | Merge pull request #27774 from dtardon/free-cleanupYu Watanabe2023-05-241-8/+4
|\ \ | |/ |/| Use free_and_*() more
| * tree-wide: use free_and_replace() moreDavid Tardon2023-05-241-8/+4
| |
* | journalctl: convert a machine1.Manager call to BusLocatorDavid Tardon2023-05-241-9/+2
|/
* tree-wide: Fix false positives on newer gccDaan De Meyer2023-05-231-1/+1
| | | | | | Recent gcc versions have started to trigger false positive maybe-uninitialized warnings. Let's make sure we initialize variables annotated with _cleanup_ to avoid these.
* Revert "Revert "journal: Make sd_journal_previous/next() return 0 at HEAD/TAIL""Chen Qi2023-05-211-26/+16
| | | | | | | | | | | | | | | This reverts commit 1db6dbb1dcdacfd7d2b4c84562fc6e77bc8c43a5. The original patch was reverted because of issue #25369. The issue was created because it wrongly assumed that sd_journal_seek_tail() seeks to 'current' tail. But in fact, only when a subsequent sd_journal_previous() is called that it's pointing to the tail at that time. The concept of 'tail' in sd_journal_seek_tail() only has a logical meaning, and a sd_journal_previous is needed. In fact, if we look at the codes in journalctl, we can see sd_journal_seek_tail() is followed by sd_journal_previous(). By contrary, a sd_journal_next() after a 'logical' tail does not make much sense. So the original patch is correct, and projects that are using 'sd_journal_next()' right after 'sd_journal_seek_tail()' should do fixes as in https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2823#note_1637715.
* test-journal-interleaving: extend tests to clarify the issue in ↵Yu Watanabe2023-05-211-33/+151
| | | | | | | | | sd_journal_next() or friends This illustrates bug in sd_journal_next() or friends; calling sd_jounral_next() followed by sd_journal_seek_tail() makes the location saved in sd-journal something corrupted, and subsequent sd_journal_previous() or friends may fail or provides unexpected result.
* journalctl: make --follow work with --merge againFrantisek Sumsal2023-05-191-5/+6
| | | | | | | | Set --boot with --follow only if it's not already set and if --merge is not used, since it's not compatible with --boot. Follow-up to 2dd9285bac. Resolves: #24565
* dissect-image: port mount_image_privately_interactively() to use ↵Lennart Poettering2023-05-161-3/+3
| | | | | | | | | | /run/systemd/mount-rootfs/ too Let's use the same common directory as the unit logic uses. This means we have less to clean up, and opens the door to eventually allow unprivileged operation of the mount_image_privately_interactively() logic.
* test-journal-verify: Use a more thorough machine ID checkDaan De Meyer2023-05-081-2/+2
| | | | | Let's not only check if the file exists but also check if it contains a valid machine ID.
* journal: handle EADDRNOTAVAIL in two more cases gracefullyLennart Poettering2023-05-022-0/+2
| | | | Follow-up for #27488.
* Drop log level of header limits log messageDaan De Meyer2023-04-251-4/+3
| | | | | Especially when using in-memory logging, these are too noisy so let's drop them back to debug level.
* tree-wide: convert more cases do DEVNUM_FORMAT_STR()/DEVNUM_FORMAT_VAL()Lennart Poettering2023-04-211-2/+3
| | | | | | Let's use our nice macros a bit more. (Not comprehensive)
* tree-wide: copy timestamp data from cmsgYu Watanabe2023-04-161-3/+3
| | | | | | | On RISCV32, time_t is 64bit and size_t is 32bit, hence the timestamp data in message header may not be aligned. Fixes #27241.
* Merge pull request #27254 from poettering/cmsg-align-checkYu Watanabe2023-04-141-4/+4
|\ | | | | socket-util: tighten CMSG_TYPED_DATA() alignment checks
| * tree-wide: port more code over to CMSG_TYPED_DATA()Lennart Poettering2023-04-131-4/+4
| |
* | image-policy: introduce parse_image_policy_argument() helperYu Watanabe2023-04-131-13/+8
|/ | | | | | | | | Addresses https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312, https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416. Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
* Merge pull request #25608 from poettering/dissect-moarLennart Poettering2023-04-121-2/+18
|\ | | | | dissect: add dissection policies
| * tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-051-2/+18
| |
* | Merge pull request #26887 from yuwata/proc-cmdline-filter-argumentsZbigniew Jędrzejewski-Szmek2023-04-071-0/+3
|\ \ | | | | | | proc-cmdline: filter PID1 arguments on container
| * | tree-wide: reset optind to 0 when GNU extensions in optstring are usedYu Watanabe2023-03-291-0/+3
| |/ | | | | | | | | | | | | | | | | | | Otherwise, if getopt() and friends are used before parse_argv(), then the GNU extensions may be ignored. This should not change any behavior at least now, as we usually use getopt_long() only once per invocation. But in the next commit, getopt_long() will be used for other arrays, hence this change will become necessary.
* / journald: fix log messageYu Watanabe2023-04-041-1/+1
|/
* test: verify the journal with and without a sealing keyFrantisek Sumsal2023-03-272-36/+96
| | | | | | | | | The bit flips during journal verification cause various types of journal corruptions, so it's useful to go through it even without a sealing key to see how we handle corrupted stuff. Also, provide a sealing key if running in "CI mode" (i.e. arguments), to check the FSS-related codepaths in CIs as well.
* journalctl: fix when --grep is used with --followMike Yuan2023-03-271-2/+4
| | | | | | | | Follow-up for #25147 (db4691961ca52759fe6645d0fddb659ee4299ac2) --follow sets arg_lines to 10, which breaks --grep as the latter implies --reverse. So let's not set --reverse if --follow is used.
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-2/+2
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.