summaryrefslogtreecommitdiff
path: root/src/journal/test-journal-verify.c
Commit message (Collapse)AuthorAgeFilesLines
* test-journal-verify: Use a more thorough machine ID checkDaan De Meyer2023-05-091-2/+2
| | | | | Let's not only check if the file exists but also check if it contains a valid machine ID.
* test: verify the journal with and without a sealing keyFrantisek Sumsal2023-03-271-36/+95
| | | | | | | | | 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.
* journald: maintain entry seqnum counter in mmap()ed file in /run/Lennart Poettering2023-02-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Let's ensure that entry seqnums remain stable and monotonic across the entire runtime of the system, even if local storage is turned off. Let's do this by maintainer a counter file in /run/ which we mmap() and wherein we maintain the counter from early-boot on till late shutdown. This takes inspiration of the kernel-seqnum file we already maintain like that that tracks which kmsg messages we already processed. In fact, we reuse the same code for maintaining it. This should allow the behaviour entry seqnums to be more predictable, in particular when journal local storage is turned off. Previously, we'd maintain the seqnum simply by always bumping it to the maximum of the last written entry seqnum plus one, and the biggest seqnum so far written to the journal file on disk. If we'd never write a file on disk, or if no journal file was existing during the initrd→seqnum transition we'd completely lose the current seqnum position during daemon restarts (such as the one happening during the switch-root operation). This also will cause a journal file rotation whenever we try to write to a journal file with multiple sequence number IDs, so that we know that from early boot trhough the entire runtime we'll have stable sequence numbers that do not jump, and thus can be used to determine "lost" messages.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* journal: Run unit tests with and without compact mode enabledDaan De Meyer2022-10-071-1/+11
|
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-1/+1
| | | | gcc will complain about all these with -Wformat-signedness.
* journal-file: merge compress/seal bool args into a single flags paramLennart Poettering2022-03-251-3/+3
| | | | | | | 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: Rename JournaldFile to ManagedJournalFileDaan De Meyer2022-02-021-5/+5
| | | | | JournalFile and JournaldFile are hard to distinguish from each other. Let's use ManagedJournalFile instead to make the distinction more clear.
* journal-file: require MMapCache* for journal_file_open()Vito Caputo2021-12-071-3/+12
| | | | | | | | | | | | | | | Previously the MMapCache* was optionally NULL, which open would handle by creating a new MMapCache* for the occasion. This produced some slightly circuitous refcount-handling code in the function, as well as arguably creating opportunities for weirdness where an MMapCache* was intended to be supplied but happened to be NULL, which this magic would then paper over. In any case, this was basically only being utilized by tests, apparently just to avoid having to create an MMapCache. So update the relevant tests to supply an MMapCache and make journal_file_open() treat a NULL MMapCache* as fatal w/assert.
* journal: Introduce journald-file.c for journal file write related logicDaan De Meyer2021-12-061-0/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sd-journal: move source files for sd-journal to src/libsystemd/sd-journalYu Watanabe2021-01-191-136/+0
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* test-journal: move tests to /var/tmp/ and set FS_NOCOW_FLv242-rc3Lennart Poettering2019-04-041-1/+3
| | | | | | | | The journal files might not be tiny hence let's write them to /var/tmp/ instead of /tmp. Also, let's turn on NOCOW on the files, as these tests might apparently be slow on btrfs. Fixes: #12210
* tree-wide: use IOVEC_MAKE() at many placesLennart Poettering2018-11-271-2/+2
|
* tests: use a helper function to parse environment and open loggingZbigniew Jędrzejewski-Szmek2018-09-141-1/+1
| | | | | The advantages are that we save a few lines, and that we can override logging using environment variables in more test executables.
* tests: add helper to unify skipping a test and exitingZbigniew Jędrzejewski-Szmek2018-09-141-4/+3
|
* test: log when skipping tests in more casesYu Watanabe2018-09-131-1/+3
| | | | Follow-up for the previous commit.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | 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.
* journal: allow boot_id to be passed to journal_append_entry()Zbigniew Jędrzejewski-Szmek2018-05-311-1/+1
| | | | | In this commit, this is done only in testing code, i.e. there is no functional change apart from tests.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | 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.
* journal: provide compress_threshold_bytes parameterAlex Gartrell2018-03-201-3/+3
| | | | | | Previously the compression threshold was hardcoded to 512, which meant that smaller values wouldn't be compressed. This left some storage savings on the table, so instead, we make that number tunable.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* sd-journal: add API for opening journal files or directories by fdLennart Poettering2016-04-251-3/+3
| | | | | | | Also, expose this via the "journalctl --file=-" syntax for STDIN. This feature remains undocumented though, as it is probably not too useful in real-life as this still requires fds that support mmaping and seeking, i.e. does not work for pipes, for which reading from STDIN is most commonly used.
* journal: defer journal closes on rotateVito Caputo2016-02-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | When we rotate journals, we must set offline and close the current one, but don't generally need to wait for this to complete. Instead, we'll initiate an asynchronous offline via journal_file_set_offline(oldfile, false), and add the file to a per-server set of deferred closes to be closed later when they won't block. There's one complication however; journal_file_open() via journal_file_verify_header() assumes that any writable journal in the online state is the product of an unclean shutdown or other form of corruption. Thus there's a need for journal_file_open() to be aware of deferred closes and synchronize with their completion when opening preexisting journals for writing. To facilitate this the deferred closes set is supplied to the journal_file_open() function where the deferred closes may be closed synchronously before verifying the header in such circumstances.
* journal: add void cast to journal_file_close() callsVito Caputo2016-02-191-3/+3
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: sort includesThomas Hindoe Paaboel Andersen2015-11-161-1/+1
| | | | Sort the includes accoding to the new coding style.
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-3/+4
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* cgtop: underline table headerLennart Poettering2015-09-221-1/+1
| | | | | | Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
* tree-wide: drop {} from one-line if blocksLennart Poettering2015-09-091-2/+1
| | | | Patch via coccinelle.
* shared: add terminal-util.[ch]Ronny Chevalier2015-04-111-0/+1
|
* util: rework rm_rf() logicLennart Poettering2015-04-061-1/+2
| | | | | | | | - Move to its own file rm-rf.c - Change parameters into a single flags parameter - Remove "honour sticky" logic, it's unused these days
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-1/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* tests: use assert_se instead of assertRonny Chevalier2014-11-301-3/+3
| | | | Otherwise they can be optimized away with -DNDEBUG
* util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering2014-03-181-1/+1
| | | | | | | | | | | | | | | safe_close() automatically becomes a NOP when a negative fd is passed, and returns -1 unconditionally. This makes it easy to write lines like this: fd = safe_close(fd); Which will close an fd if it is open, and reset the fd variable correctly. By making use of this new scheme we can drop a > 200 lines of code that was required to test for non-negative fds or to reset the closed fd variable afterwards.
* test: Make testing work on systems without or old systemdHolger Hans Peter Freyther2013-08-221-0/+4
| | | | | | | | | | | | | | * Introduce a macro to conditionally execute tests. This avoids skipping the entire test if some parts require systemd * Skip the journal tests when no /etc/machine-id is present * Change test-catalog to load the catalog from the source directory of systemd. * /proc/PID/comm got introduced in v2.6.33 but travis is still using v2.6.32. * Enable make check and make distcheck on the travis build * Use -D"CATALOG_DIR=STR($(abs_top_srcdir)/catalog)" as a STRINGIY would result in the path '/home/ich/source/linux' to be expanded to '/home/ich/source/1' as linux is defined to 1.
* Use stdint.h macros instead of casts to print uint64_t valuesZbigniew Jędrzejewski-Szmek2013-06-101-2/+2
| | | | Casts are visually heavy, and can obscure unwanted truncations.
* util: make time formatting a bit smarterLennart Poettering2013-04-041-1/+1
| | | | | | | | | | | Instead of outputting "5h 55s 50ms 3us" we'll now output "5h 55.050003s". Also, while outputting the accuracy is configurable. Basically we now try use "dot notation" for all time values > 1min. For >= 1s we use 's' as unit, otherwise for >= 1ms we use 'ms' as unit, and finally 'us'. This should give reasonably values in most cases.
* journal: make libgcrypt dependency optionalLennart Poettering2012-08-201-3/+4
|
* journal: fix tag ordering checkLennart Poettering2012-08-201-11/+12
|
* jounral: write bit fiddling testLennart Poettering2012-08-181-9/+62
| | | | | This test goes through every single bit in a journal file, toggles it, and checks if this change is detected by the verification.
* journal: after verification output validated time rangeLennart Poettering2012-08-171-1/+11
|
* journal: show new header fields in header dumpLennart Poettering2012-08-171-0/+3
|
* journal: add FSPRG journal authenticationLennart Poettering2012-08-161-2/+3
|
* journal: split up journal-file.cLennart Poettering2012-08-161-0/+78