Commit graph

2072 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 98dcb8f4c7 Move {uid,gid}_is_*() from basic to shared
Those are functions that express policy, and nothing in basic/ uses
(or should use) them.
2020-09-25 17:18:56 +02:00
Zbigniew Jędrzejewski-Szmek f7bc0c324a Rename find_binary to find_executable
"executable" is more correct than "binary", since scripts are OK too.
2020-09-18 15:28:48 +02:00
Yu Watanabe adb5848706 journal: downgrade log level 2020-09-10 15:20:35 +09:00
Lennart Poettering 12ce0f4173
Merge pull request #16635 from keszybz/do-not-for-each-word
Drop FOREACH_WORD
2020-09-09 17:43:38 +02:00
Zbigniew Jędrzejewski-Szmek da277e90a4 sd-journal: use extract_first_word() 2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Lennart Poettering b519529104
Merge pull request #16841 from keszybz/acl-util-bitmask
Use a bitmask in fd_add_uid_acl_permission()
2020-08-31 16:45:13 +02:00
Yu Watanabe 89d36ce8f7 journal: fix divide-by-zero warning
Fixes CID#1430209.
2020-08-27 18:20:34 +09:00
Zbigniew Jędrzejewski-Szmek 567aeb5801 shared/acl-util: convert rd,wr,ex to a bitmask
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.
2020-08-27 10:20:12 +02:00
Zbigniew Jędrzejewski-Szmek b6abc2acb4
Merge pull request #16568 from poettering/creds-store
credentials logic to pass privileged data to services
2020-08-26 10:32:30 +02:00
Vito Caputo d4739bc4d3 sd-journal: narrow scope of boot id variable
Something trivial I noticed during some unrelated code spelunking
2020-08-25 22:41:35 +02:00
Lennart Poettering 9db59d9283 acl-util: beef up add_acls_for_user()
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.
2020-08-25 18:39:45 +02:00
Lennart Poettering da3920c3a4 journal: move qrcode printing code to src/shared/
That way we can make use of it in homctl, too.
2020-08-25 17:58:02 +02:00
Luca Boccassi 7b3eb5c97e basic/time-util: add function to format timestamps with different styles
Instead of a multiple fixed format helper functions, add an enum and
a single helper, so that it's easier to extend in the future.
2020-08-19 15:30:13 +01:00
Lennart Poettering b0073a017b
Merge pull request #16640 from keszybz/various-patches
Improve systemd-analyze security a bit and other assorted bits
2020-08-19 10:30:45 +02:00
Zbigniew Jędrzejewski-Szmek b91ae210e6 journal: adjust line about when the journal begins and ends
This comes up occasionally with new users. The phrase "Logs begin ..." is
ambiguous because it can be taken to mean the logs being displayed or all logs
(the intended meaning). Let's rephrase this as "Journal begins ..." to make
this clearer.
2020-08-17 19:48:32 +02:00
Lennart Poettering 721bb6ed08
Merge pull request #16684 from keszybz/assorted-cleanups
Assorted cleanups
2020-08-10 19:28:05 +02:00
Lennart Poettering cc171228d4 journalctl: add --image= switch 2020-08-05 20:34:58 +02:00
Zbigniew Jędrzejewski-Szmek da012db02d journalctl: reshuffle console message about fss keys
We talked about the verification key, then about sealing keys, and then
about the verification key again. Let's shorten things a bit, and divide
the output in three paragraphs: one about the machine, one about the sealing
keys, and one about verification keys and the qr code with them.
2020-08-05 10:49:46 +02:00
Zbigniew Jędrzejewski-Szmek d06bd2e785 Merge pull request #16596 from poettering/event-time-rel
Conflict in src/libsystemd-network/test-ndisc-rs.c fixed manually.
2020-08-04 16:07:03 +02:00
Zbigniew Jędrzejewski-Szmek 1472b58835
Merge pull request #16260 from poettering/pcre2-dlopen
turn pcre2 dependency into dlopen() dependency
2020-08-04 15:37:48 +02:00
Zbigniew Jędrzejewski-Szmek 3a4378cb9e
Merge pull request #16145 from poettering/qrcode-dlopen
journalctl: make libqrencode a weak (dlopen() style) dependency
2020-08-04 15:25:50 +02:00
Lennart Poettering 39cf0351c5 tree-wide: make use of new relative time events in sd-event.h 2020-07-28 11:24:55 +02:00
Yu Watanabe f281fc1e95 tree-wide: use siphash24_compress_string() where it is applicable 2020-07-22 19:55:14 +09:00
Zbigniew Jędrzejewski-Szmek e4a321fc08 journal/compress: remove loop in decompress_startswith_zstd()
This should be more efficient with no downsides. Same considerations as in the
previous commit hold.
2020-07-21 17:42:15 +02:00
Zbigniew Jędrzejewski-Szmek a24153279e journal/compress: fix zstd decompression with capped output size
decompress_blob_zstd() would allocate ever bigger buffers in a loop trying to
get a buffer big enough to decompress the input data. This is wasteful, since
we can just query the size of the decompressed data from the compressed header.
Worse, it doesn't work when the output size is capped, i.e. when dst_max != 0.
If the decompressed blob happened to be bigger than dst_max, decompression
would fail with -ENOBUFS. We need to use "stream decompression" instead, and
only get min(uncompressed size, dst_max) bytes of output.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856037 in a second way.
2020-07-21 17:42:15 +02:00
Zbigniew Jędrzejewski-Szmek b4a11ca3f2 journal: use -EPROTONOSUPPORT for unknown compression
We might add more compression types in the future, and we should treat that
as unsupported, and not a format error.
2020-07-21 17:42:15 +02:00
Zbigniew Jędrzejewski-Szmek 76cbafcdd4 sd-journal: when enumerating, continue even after an inaccessible field
SD_JOURNAL_FOREACH_DATA() and SD_JOURNAL_FOREACH_UNIQUE() would immediately
terminate when a field couldn't be accessed. This can happen for example when a
field is compressed with an unavailable compression format. But it's likely
that this is the wrong thing to do: the caller for example might want to
iterate over the fields but isn't interested in all of them. coredumpctl is
like this: it uses SD_JOURNAL_FOREACH_DATA() but only uses a subset of the
fields.

Add two new functions sd_journal_enumerate_good_data() and
sd_journal_enumerate_good_unique() that retry sd_journal_enumerate_data() and
sd_journal_enumerate_unique() if the return value is something that applies to
a single field: ENOBUS, E2BIG, EOPNOTSUPP.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856037.

An alternative would be to make the macros themselves smarter instead of adding
new symbols, and do the looping internally in the macro. I don't like that
approach for two reasons. First, it would embed the logic in the macro, so
recompilation would be required if we decide to update the logic. With the
current version of the patch, recompilation is required to use the new symbols,
but after that, library upgrades are enough. So the current approach is safer
in case further updates are needed. Second, our headers use primitive C, and it
is hard to do the macros without using newer features.
2020-07-21 17:42:11 +02:00
Lennart Poettering 9200bb30d0 journalctl: make pcre2 a dlopen() dependency
Let's make use of the library if it is installed, but otherwise just
generate a nice error and provide all other functionality.
2020-07-21 10:37:54 +02:00
Zbigniew Jędrzejewski-Szmek a53f024d71 journald: minor wording tweak in message
For a user "from the kernel" might be rather unclear.
2020-07-07 12:14:41 +02:00
Zbigniew Jędrzejewski-Szmek 8ab0f03266 journal/compress: drop "future" code in zstd compression
We generally don't include stuff that is not used. This can be
easily ressurected if ever needed.

Fixes CID#1430210.
2020-07-07 12:06:26 +02:00
Zbigniew Jędrzejewski-Szmek e9dd698407 tree-wide: fixes for assorted grammar and spelling issues
Fixes #16363. Also includes some changes where I generalized the pattern.
2020-07-06 11:29:05 +02:00
Lennart Poettering c85cf04fa3 compress: do something roughly reasonable when building without compressor 2020-06-25 15:03:18 +02:00
Lennart Poettering d80b051cea tree-wide: add new HAVE_COMPRESSION compile time flag
let's simplify the checks for ZSTD/LZ4/XZ

As suggested:

https://github.com/systemd/systemd/pull/16096#discussion_r440705585
2020-06-25 15:02:45 +02:00
Lennart Poettering bbcd38e41e docs: import journal file format docs from fdo wiki
Just an import, with no textual changes (some fixed URLs however)
2020-06-25 15:02:34 +02:00
Lennart Poettering 8653185a9e journal: support zstd compression for large objects in journal files 2020-06-25 15:02:18 +02:00
Lennart Poettering 0dbe57ee86 journal-file: when individual hash chains grow too large, rotate
Even with the new keyed hash table journal feature: if an attacker
manages to get access to the journal file id it could synthesize records
that result in hash collisions. Let's rotate automatically when we
notice that, so that a new journal file ID is generated, our performance
is restored and the attacker has to guess a new file ID before being
able to trigger the issue again.

That said, untrusted peers should never get access to journal files in
the first case...
2020-06-25 15:02:00 +02:00
Lennart Poettering 4ce534f4cd journal: use a different hash function for each journal file
This adds a new (incompatible) feature to journal files: if enabled the
hash function used for the hash tables is no longer jenkins hash with a
zero key, but siphash keyed by the file uuid that is included in the
file header anyway. This should make our hash tables more robust against
collision attacks, as long as the attacker has no read access to the
journal files. We switch from jenkins to siphash simply because it's
more well-known and we standardize for the rest of our codebase onto it.

This is hardening in order to make collision attacks harder for clients
that can forge log messages but have no read access to the logs. It has
no effect on clients that have read access.
2020-06-25 15:01:45 +02:00
Lennart Poettering 7851ec6634 journal: make signature arrays const 2020-06-25 15:01:40 +02:00
Lennart Poettering 20b0acfacd journal: rename hash64() to jenkins_hash64()
Let's prefix this with "jenkins_" since it wraps the jenkins hash. We
want to add support for other hash functions to journald soon, hence
better be clear with what this is. In particular as all other symbols
defined by lookup3.h actually are prefixed "jenkins_".
2020-06-25 15:01:36 +02:00
Lennart Poettering f4474e004d journal-file: rename return parameters to ret_xyz
Let's clean this up a bit, following our usual nomenclature to name
return parameters ret-xyz.

This is mostly a bit of renaming, but there's also some minor other
changes: if we return a pointer to a mmap'ed object plus its offset, in
almost all cases we are happy if either parameter is NULL in case the
caller is not interested in it. Let's fix the remaining case to do this
too, to minimize surprises.
2020-06-25 15:01:22 +02:00
Lennart Poettering 5030c85a3e journal-file: also show field hash table size in debug output 2020-06-25 15:01:17 +02:00
Lennart Poettering e958c05703 journal-file: simplify boot ID acquiring 2020-06-25 15:01:12 +02:00
Lennart Poettering cde8c5f722 journal: store NE hash instead of LE hash in Match object
We keep converting forth and back though we never need it in LE. Let's
stop doing those conversions hence.
2020-06-25 15:00:59 +02:00
Lennart Poettering a76560915f journal-file: use FLAGS_SET where appropriate 2020-06-25 15:00:44 +02:00
Lennart Poettering e9ece6a0e3 journal: fix definition of _OBJECT_COMPRESSED_MAX
The object flags field is a bitmask, hence don't sloppily define
_OBJECT_COMPRESSED_MAX as one mor than the previous flag. That worked OK
as long as we only had two flags, but will fall apart as soon as we have
three. Let's fix this.

(It's kinda sloppy how the string table is built here, as it will be
quite sparse as soon as we have more enum entries, but let's keep it for
now.)
2020-06-25 15:00:37 +02:00
Lennart Poettering e44b500484 journalctl: make libqrencode a weak dependency
This way journalctl can make use of libqrencode if it's there, but will
quietly not use it if it isn't.

This means libqrencode remains a build-time dep, but not a strict
runtime dependency.

I figure we should do something similar for a bunch of other "leaf"
libraries we only use few symbols of. Specifically the following are
probably good candidates:

* pcre2
* libpwquality
* p11kit
* elfutils

and possibly:

* libcryptsetup (only in some parts. i.e. building systemd-cryptsetup
  without it makes no sense. However building the dissect option with
  libcryptsetup as optional dep does make sense)
* possibly the compression libraries (at least the ones we never use for
  compression, but only as alternative ones for decompression)

Already covered like this is:

* libxkcommon
2020-06-25 09:28:27 +02:00
Lennart Poettering a4df1f0b9d journalctl: set and log about all fss file flags individually
Also, don#t complain about unsupported chattr support on backing fs
beyond LOG_DEBUG.
2020-06-25 09:28:22 +02:00
Lennart Poettering 0523022d5b journalctl: don't print QR codes if we can't/shan't use colors
We need them to display things properly, hence treat color-less
terminals the same way as UTF-8-less systems: avoid the QR code.
2020-06-25 09:28:18 +02:00
Lennart Poettering 9bff141052 qrcode: modernize code a bit 2020-06-25 09:28:12 +02:00