summaryrefslogtreecommitdiffstats
path: root/src/journal-remote (follow)
Commit message (Collapse)AuthorAgeFilesLines
* shared/microhttp-util: silence gcc warningZbigniew Jędrzejewski-Szmek2022-06-051-1/+1
| | | | | | | | | | ../src/journal-remote/microhttpd-util.c: In function ‘check_permissions’: ../src/journal-remote/microhttpd-util.c:301:5: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn] 301 | int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) { | ^~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Fixes #23630.
* fuzzers: ignore size limits when compiled standaloneZbigniew Jędrzejewski-Szmek2022-05-121-1/+1
| | | | | This way we can still call fuzzers on old samples, but oss-fuzz will not waste its and our time finding overly large inputs.
* fuzzers: add input size limits, always configure limits in two waysYu Watanabe2022-05-121-1/+1
| | | | | | | | | | | | | | | | | Without the size limits, oss-fuzz creates huge samples that time out. Usually this is because some of our code has bad algorithmic complexity. For data like configuration samples we don't need to care about this: non-rogue configs are rarely more than a few items, and a bit of a slowdown with a few hundred items is acceptable. This wouldn't be OK for processing of untrusted data though. We need to set the limit in two ways: through .options and in the code. The first because it nicely allows libFuzzer to avoid wasting time, and the second because fuzzers like hongfuzz and afl don't support .options. While at it, let's fix an off-by-one (65535 is the largest offset for a power-of-two size, but we're checking the size here). Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
* fuzz-journal-remote: allow -ENODATA tooZbigniew Jędrzejewski-Szmek2022-05-081-1/+1
| | | | | | | | | | | | | | | | | | It seems that we try to create a new file, which fails with -ENOSPC, and we later fail when reading a file with ENODATA. journal_file_open() will return -ENODATA if the file is too short or if journal_file_verify_header() fails. We'll unlink a file we newly created if we fail to initialize it immediately after creation. I'm not sure if the file we fail to open is the one we newly created and e.g. failed to create the arena and such, or if it's the file we were trying to rotate away from. Either way, I think we should be OK with with a non-fully-initialized journal file. Failed to create rotated journal: No space left on device Failed to write entry of 2 bytes: No space left on device sd_journal_open_files(["/tmp/fuzz-journal-remote.vELRpI.journal"]) failed: No data available Assertion 'IN_SET(r, -ENOMEM, -EMFILE, -ENFILE)' failed at src/journal-remote/fuzz-journal-remote.c:70, function int LLVMFuzzerTestOneInput(const uint8_t *, size_t)(). Aborting. oss-fuzz-39238: https://oss-fuzz.com/issue/4609851129462784
* Move path_simplify_and_warn() to new shared/parse-helpers.cZbigniew Jędrzejewski-Szmek2022-04-071-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a high-level function, and it belongs in libsystemd-shared. This way we don't end up linking a separate copy into various binaries. It would even end up in libsystemd, where it is not needed. (Maybe it'd be removed in some optimization phase, but it's better to not rely on that.) $ grep -l -r -a 'path is not absolute%s' build/ build/libnss_systemd.so.2 build/pam_systemd_home.so build/test-dlopen build/src/basic/libbasic.a.p/path-util.c.o build/src/basic/libbasic.a build/src/shared/libsystemd-shared-249.so build/test-bus-error build/libnss_mymachines.so.2 build/pam_systemd.so build/libnss_resolve.so.2 build/libnss_myhostname.so.2 build/libsystemd.so.0.32.0 build/libudev.so.1.7.2 $ grep -l -r -a 'path is not absolute%s' build/ build/src/shared/libsystemd-shared-251.a.p/parse-helpers.c.o build/src/shared/libsystemd-shared-251.a build/src/shared/libsystemd-shared-251.so No functional change.
* meson: also allow setting GIT_VERSION via templatesZbigniew Jędrzejewski-Szmek2022-04-051-1/+1
| | | | | | | | | GIT_VERSION is not available as a config.h variable, because it's rendered into version.h during builds. Let's rework jinja2 rendering to also parse version.h. No functional change, the new variable is so far unused. I guess this will make partial rebuilds a bit slower, but it's useful to be able to use the full version string.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-015-6/+6
|
* journal-file: merge compress/seal bool args into a single flags paramLennart Poettering2022-03-258-31/+35
| | | | | | | Just some modernization/refactoring. No change in behaviour, just let's do how we do things these days: use flags param instead of list of bools.
* journal-remote: constify a few parametersLennart Poettering2022-03-252-6/+6
|
* journal-remote: refuse to specify --trust option when gnutls is disabledYu Watanabe2022-03-242-6/+9
| | | | | | and check_permission() should not be called in that case. Replaces #22847.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-192-4/+2
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* conf-parser: merge config_parse_string() and config_parse_safe_string()Yu Watanabe2022-03-101-5/+5
| | | | | This also makes unsafe strings escaped when logged. Otherwise, journalctl may not show the log message unless '--all' is specified.
* meson: move files' closing brace to separate lineZbigniew Jędrzejewski-Szmek2022-03-031-4/+8
|
* meson: do not use split() in file listsZbigniew Jędrzejewski-Szmek2022-03-021-21/+16
| | | | | | | | | | | 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.
* tree-wide: use config_parse_safe_string() at various placesLennart Poettering2022-02-091-1/+1
|
* journal: Rename JournaldFile to ManagedJournalFileDaan De Meyer2022-02-023-7/+7
| | | | | JournalFile and JournaldFile are hard to distinguish from each other. Let's use ManagedJournalFile instead to make the distinction more clear.
* tests: make fuzz-journal-remote less flakyEvgeny Vereshchagin2022-01-201-2/+1
| | | | | | | | | | | | | | | by always calling journal_remote_server_destroy, which resets global variables like journal_remote_server_global. It should prevent crashes like ``` Assertion 'journal_remote_server_global == NULL' failed at src/journal-remote/journal-remote.c:312, function int journal_remote_server_init(RemoteServer *, const char *, JournalWriteSplitMode, _Bool, _Bool)(). Aborting. AddressSanitizer:DEADLYSIGNAL ================================================================= ==24769==ERROR: AddressSanitizer: ABRT on unknown address 0x0539000060c1 (pc 0x7f23b4d5818b bp 0x7ffcbc4080c0 sp 0x7ffcbc407e70 T0) SCARINESS: 10 (signal) #0 0x7f23b4d5818b in raise /build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c:51:1 #1 0x7f23b4d37858 in abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:79:7 #2 0x7f23b5731809 in log_assert_failed systemd/src/basic/log.c:866:9 ```
* meson: Use files() for fuzzersJan Janssen2022-01-111-1/+1
| | | | | | 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.
* journal-remote: use MHD_HTTP_CONTENT_TOO_LARGE as MHD_HTTP_PAYLOAD_TOO_LARGE ↵Yu Watanabe2021-12-202-4/+8
| | | | is deprecated since 0.9.74
* meson: stop building out convenience libraries by defaultZbigniew Jędrzejewski-Szmek2021-12-161-1/+1
| | | | | | | | | | | | | | | | | The meson default for static_library() are: build_by_default=true, install=false. We never interact with the static libraries, and we only care about them as a stepping-stone towards the installable executables or libraries. Thus let's only build them if they are a dependency of something else we are building. While at it, let's drop install:false, since this appears to be the default. This change would have fixed the issue with lib_import_common failing to build too: we wouldn't attempt to build it. In practice this changes very little, because we generally only declare static libraries where there's something in the default target that will make use of them. But it seems to be a better pattern to set build_by_default to false.
* journal: stop using JournalFile.mmap everywhereVito Caputo2021-12-071-4/+4
| | | | | | | | | | | | | | | | | | | | | | | Preparatory commit; before JournalFile can stop hanging onto its copy of MMapCache, all these users need to find another way. Most of the time these callers already have the MMapCache onhand, so it's no big deal for them to just supply it. journal_file_rotate() in particular needed to change, and it seemed wise to not use the mmap_cache_fd_cache() accessor on f->cache_fd, instead requiring the caller supply the cache to use. This was done with an eye towards a potential future where the journal_file_archive() isolates the cache_fd to a private cache, which the newly rotated-to file wouldn't be allowed to use. It's no biggie for the existing callers to just provide the appropriate surviving cache. Basically the mmap_cache_fd_cache() accessor was added just for journal-verify.c's (ab)use of the mmap-cache. Which, if the ugly singleton MMapCache assumption ever goes away, can be cleaned up to simply use a separate MMapCache for those search arrays.
* journal: Introduce journald-file.c for journal file write related logicDaan De Meyer2021-12-064-22/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, all the logic related to writing journal files lives in journal-file.c which is part of libsystemd (sd-journal). Because it's part of libsystemd, we can't depend on any code from src/shared. To allow using code from src/shared when writing journal files, let's gradually move the write related logic from journal-file.c to journald-file.c in src/journal. This directory is not part of libsystemd and as such can use code from src/shared. We can safely remove any journal write related logic from libsystemd as it's not used by any public APIs in libsystemd. This commit introduces the new file along with the JournaldFile struct which wraps an instance of JournalFile. The goal is to gradually move more functions from journal-file.c and fields from JournalFile to journald-file.c and JournaldFile respectively. This commit also modifies all call sites that write journal files to use JournaldFile instead of JournalFile. All sd-journal tests that write journal files are moved to src/journal so they can make use of journald-file.c. Because the deferred closes logic is only used by journald, we move it out of journal-file.c as well. In journal_file_open(), we would wait for any remaining deferred closes for the file we're about to open to complete before continuing if the file was not newly created. In journald_file_open(), we call this logic unconditionally since it stands that if a file is newly created, it can't have any outstanding deferred closes. No changes in behavior are introduced aside from the earlier execution of waiting for any deferred closes to complete when opening a new journal file.
* journal-remote: more handling of sd_event_source_set_enabled failuresLuca Boccassi2021-11-131-4/+14
| | | | | | | But avoid clobbering the return value if it works CID#1465793 CID#1465794
* tree-wide: don't ignore return code from sd_event_source_set_enabled()Luca Boccassi2021-11-121-2/+2
| | | | | | CID#1465793 CID#1465794 CID#1465795
* build: preserve correct mode when generating files via jinja2Christian Brauner2021-11-081-2/+1
| | | | | | | | | When using "capture : true" in custom_target()s the mode of the source file is not preserved when the generated file is not installed and so needs to be tweaked manually. Switch from output capture to creating the target file and copy the permissions from the input file. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
* tree-wide: always use TAKE_FD() when calling rearrange_stdio()Lennart Poettering2021-11-041-2/+2
| | | | | | | | | | | | rearrange_stdio() invalidates specified fds even on failure, which means we should always invalidate the fds we pass in no matter what. Let's make this explicit by using TAKE_FD() for that everywhere. Note that in many places we such invalidation doesnt get us much behaviour-wise, since we don't use the variables anymore later. But TAKE_FD() in a way is also documentation, it encodes explicitly that the fds are invalidated here, so I think it's a good thing to always make this explicit here.
* Merge pull request #20988 from DaanDeMeyer/rotate-reasonZbigniew Jędrzejewski-Szmek2021-10-191-1/+1
|\ | | | | journal: Improve rotation logging
| * journal: Add log level argument to journal_file_rotate_suggested()Daan De Meyer2021-10-181-1/+1
| | | | | | | | | | | | | | | | When journald is rotating a file, we'd like to log the reason at LOG_INFO or higher instead of LOG_DEBUG. For journalctl --header, logging the reason at a level higher than LOG_DEBUG doesn't really make sense. To accomodate both use cases, make the log level used by journal_file_rotate_suggested() configurable.
* | alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhereLennart Poettering2021-10-142-3/+3
|/ | | | | | | | | | | | | 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.
* variuos: add missing includesZbigniew Jędrzejewski-Szmek2021-09-221-0/+1
|
* tree-wide: mark set-but-not-used variables as unused to make LLVM happyFrantisek Sumsal2021-09-153-3/+3
| | | | | | | | | | | | | | LLVM 13 introduced `-Wunused-but-set-variable` diagnostic flag, which trips over some intentionally set-but-not-used variables or variables attached to cleanup handlers with side effects (`_cleanup_umask_`, `_cleanup_(notify_on_cleanup)`, `_cleanup_(restore_sigsetp)`, etc.): ``` ../src/basic/process-util.c:1257:46: error: variable 'saved_ssp' set but not used [-Werror,-Wunused-but-set-variable] _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL; ^ 1 error generated. ```
* tree-wide: port everything over to new sd-id128 compund literal blissLennart Poettering2021-08-201-2/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-035-8/+8
| | | | | | | | | | | | | | | | | 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.
* meson: use a/b instead of join_paths(a,b)Zbigniew Jędrzejewski-Szmek2021-07-271-1/+1
| | | | It is nicer and shorter.
* log-generator: count arguments as offset from an iteratormonosans2021-07-191-12/+4
|
* Add a network timeout option to journal-uploadJayanth Ananthapadmanaban2021-06-141-4/+12
|
* fuzz-journal-remote: print some kinds of errorsZbigniew Jędrzejewski-Szmek2021-05-311-1/+2
| | | | | | | | | | | In https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34803, we fail with: Assertion 'IN_SET(r, -ENOMEM, -EMFILE, -ENFILE)' failed at src/journal-remote/fuzz-journal-remote.c:69, function int LLVMFuzzerTestOneInput(const uint8_t *, size_t)(). Aborting. AddressSanitizer:DEADLYSIGNAL Let's try to print the error, so maybe we can see what is going on. With the previous commit we shouldn't print out anything.
* journal-remote: downgrade messages about input data to warningsZbigniew Jędrzejewski-Szmek2021-05-311-1/+1
| | | | | | Those are unexpected, so a user-visible message seems appropriate. But they are not our errors, and to some extent we can recover from them, so "warning" seems more appropriate than "error".
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-192-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* meson: use jinja2 in src/journal-remoteZbigniew Jędrzejewski-Szmek2021-05-193-25/+23
| | | | | | One stanza had "if install_sysconfdir_samples", while the other "if install_sysconfdir", which looks like a mistake. install_sysconfdir_samples is now used for both.
* tree-wide: use af_to_ipv4_ipv6() + af_from_ipv4_ipv6() helpers at various placesLennart Poettering2021-05-111-1/+2
|
* Wider range of options for selecting entries for systemd-journal-gatewaydSamuel BF2021-05-102-3/+40
| | | | | Introducing --user, --system, --merge and --file flags, like for journalctl and systemd-journal-upload.
* fix: point to the correct drop-ins subdirectory for confsJóhann B. Guðmundsson2021-04-222-2/+2
|
* meson: simplify the BUILD_MODE conditionalZbigniew Jędrzejewski-Szmek2021-04-141-1/+1
| | | | | | | Using a enum is all nice and generic, but at this point it seems unlikely that we'll add further build modes. But having an enum means that we need to include the header file with the enumeration whenerever the conditional is used. I want to use the conditional in log.h, which makes it hard to avoid circular imports.
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-142-2/+2
| | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further.
* journal-upload: use _cleanup_ for curl_slistDavid Tardon2021-03-181-8/+6
|
* journal-upload: make the curl_slist cleanup actually workDavid Tardon2021-03-181-5/+7
| | | | If h is NULL, it is pointless to call curl_slist_free_all() on it...
* journal-upload: cleanup CURL* on errorDavid Tardon2021-03-181-2/+4
|
* journal-gatewayd: use automatic cleanupDavid Tardon2021-03-181-4/+3
|
* journal-remote: check return value from MHD_add_response_headerZbigniew Jędrzejewski-Szmek2021-03-072-7/+18
| | | | | | | Sadly, the API does not allow us to distinguish oom from invalid settings. If the call fails, let's assume oom happened. Coverity CID#1444714.