Commit Graph

329 Commits

Author SHA1 Message Date
Lennart Poettering 39cf0351c5 tree-wide: make use of new relative time events in sd-event.h 2020-07-28 11:24:55 +02:00
Lennart Poettering 4f9ff96a55 conf-parser: return mtime in config_parse() and friends
This is a follow-up for 9f83091e3c.

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.
2020-06-02 19:32:20 +02:00
Lennart Poettering fb29cdbef2 tree-wide: make sure our control buffers are properly aligned
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.
2020-05-07 14:39:44 +02:00
Lennart Poettering 0f4a141744
Merge pull request #15504 from poettering/cmsg-find-pure
just the recvmsg_safe() stuff from #15457
2020-04-23 17:28:19 +02:00
Lennart Poettering 3691bcf3c5 tree-wide: use recvmsg_safe() at various places
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)
2020-04-23 09:41:47 +02:00
Zbigniew Jędrzejewski-Szmek 38b38500c6 tree-wide: use "hostname" spelling everywhere
It's not that I think that "hostname" is vastly superior to "host name". Quite
the opposite — the difference is small, and in some context the two-word version
does fit better. But in the tree, there are ~200 occurrences of the first, and
>1600 of the other, and consistent spelling is more important than any particular
spelling choice.
2020-04-21 16:58:04 +02:00
Lennart Poettering 511e03a3ee journald: add configuration option for enabling/disabling audit during journald startup
Let's make it optional whether auditing is enabled at journald start-up
or not.

Note that this only controls whether audit is enabled/disabled in the
kernel. Either way we'll still collect the audit data if it is
generated, i.e. if some other tool enables it, we'll collect it.

Fixes: #959
2020-04-17 16:05:22 +02:00
Zbigniew Jędrzejewski-Szmek 162392b75a tree-wide: spellcheck using codespell
Fixes #15436.
2020-04-16 18:00:40 +02:00
Zbigniew Jędrzejewski-Szmek f36a9d5909 tree-wide: use the return value from sockaddr_un_set_path()
It fully initializes the address structure, so no need for pre-initialization,
and also returns the length of the address, so no need to recalculate using
SOCKADDR_UN_LEN().

socklen_t is unsigned, so let's not use an int for it. (It doesn't matter, but
seems cleaner and more portable to not assume anything about the type.)
2020-03-02 15:55:44 +01:00
Lennart Poettering dc5437c78b journald: add ability to activate by varlink socket
If we have exit on idle, then operations such as "journalctl
--namespace=foo --rotate" should work even if the journal daemon is
currently not running.

(Note that we don't do activation by varlink for the main instance of
journald, I am not sure the deadlocks it might introduce are worth it)
2020-01-31 15:03:55 +01:00
Lennart Poettering 65c398c031 journald: add exit on idle 2020-01-31 15:03:44 +01:00
Lennart Poettering b1852c48c1 journald: allow running multiple instances of journald
If we do, we operate on a separate set of logs and runtime objects

The namespace is configured via argv[1].

Fixes: #12123

Fixes: #10230 #9519

(These latter two issues ask for slightly different stuff, but the
usecases generally can be solved by running separate instances of
journald now, hence also declaring that as "Fixes:")
2020-01-31 15:01:18 +01:00
Lennart Poettering d6f46470f5 journald: when create journal directories use calculated paths 2020-01-31 15:01:14 +01:00
Lennart Poettering 4f60310373 journald: minor coding style updates 2020-01-31 15:01:09 +01:00
Lennart Poettering 4e00337b16 journald: let's simplify rotating of offline user journals
Let's just use the path that is already stored in JournalStorage,
instead of generating our own. While we are at it, split out the loop
into its own function.
2020-01-31 15:01:05 +01:00
Lennart Poettering 46e2348a58 journald: simplify find_journal() a bit
Let's use the already precalculated persistent storage path instead of
deriving it again from the machine ID.
2020-01-31 15:01:01 +01:00
Lennart Poettering b42b9479a8 journald: hide current storage determination in helper call 2020-01-31 15:00:57 +01:00
Lennart Poettering 99d0d05a10 journald: use free_and_replace() where appropriate 2020-01-31 15:00:25 +01:00
Lennart Poettering 659a77bec6 journald: add missing logging for some errors 2020-01-31 15:00:21 +01:00
Lennart Poettering d83f7e4c92 journald: why bitwise XOR when boolean != is easier to read? 2020-01-31 14:59:41 +01:00
Lennart Poettering 806c6a5b97 journald: don't ask for the machine ID if we don't need it 2019-11-28 15:46:01 +01:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Zbigniew Jędrzejewski-Szmek 5ac1530eca tree-wide: say "ratelimit" not "rate_limit"
"ratelimit" is a real word, so we don't need to use the other form anywhere.
We had both forms in various places, let's standarize on the shorter and more
correct one.
2019-09-20 16:05:53 +02:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00
Yu Watanabe 4bbccb02ea tree-wide: introduce strerror_safe() 2019-07-05 02:43:56 +09:00
Yu Watanabe 657ee2d82b tree-wide: replace strjoin() with path_join() 2019-06-21 03:26:16 +09:00
Yu Watanabe 627df1dc42 journal: use cleanup attribute at one more place 2019-05-28 18:07:18 +09:00
Yu Watanabe c377a6f3ad journal: do not trigger assertion when journal_file_close() get NULL
We generally expect destructors to not complain if a NULL argument is passed.

Closes #12400.
2019-05-28 18:07:18 +09:00
Lennart Poettering 5087825ea7 journald: output a proper error message when the journal is used on fs that doesn't do mmap() properly
Prompted by:

https://lists.freedesktop.org/archives/systemd-devel/2019-May/042708.html
2019-05-22 18:56:24 +02:00
Lennart Poettering b4e26d1d8e journald: add API to move logging from /var to /run again
We now have this nice little Varlink API, let's beef it up a bit.
2019-05-09 14:26:42 -04:00
Lennart Poettering 4f413af2a0 journalctl: port --flush/--sync/--rotate to use varlink method calls 2019-05-09 14:26:40 -04:00
Lennart Poettering 1ec23479e1 journald: also offer flush/rotate/sync as varlink method calls
This makes the operations previously available via asynchronous signals
also available as regular varlink method calls, i.e. with sane
completion.
2019-05-09 14:14:20 -04:00
Lennart Poettering e3d36a8da3 journald: modernize config_parse_compress() a bit 2019-04-12 14:23:12 +02:00
Lennart Poettering 337fabf749 journald: rebreak a few comments 2019-04-12 14:23:12 +02:00
Lennart Poettering e3d78cb160 journald: no need to check ptr for non-NULL before _unref(), as function does that anyway 2019-04-12 14:23:12 +02:00
Lennart Poettering e4d9c98512 journald: use structure initialization 2019-04-12 14:23:08 +02:00
Zbigniew Jędrzejewski-Szmek 084eeb865c journald: do not store the iovec entry for process commandline on stack
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.
2019-01-09 23:41:53 +01:00
Zbigniew Jędrzejewski-Szmek bc2762a309 journald: remove unnecessary {} 2019-01-09 23:41:53 +01:00
Lennart Poettering 5cfa2c3dc0 tree-wide: use IOVEC_MAKE() at many places 2018-11-27 10:12:27 +01:00
Lennart Poettering 30acbadc6a journald: don't try to rotate user journals in /var/log/journal/ if we are still in log-to-runtime-journal mode
Fixes: #10879
2018-11-27 11:09:15 +09:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Lennart Poettering a33687b792 journald: when we are asked to rotate all files, let's also look at closed files
Before this when asked for rotation we'd only rotate files we have open
anyway. However there might be a number of other files on disk that are
active (i.e. not archived yet) but not open. Let's take care of those
too, so that rotation is always comprehensive, and the user gets the
guarantee that afterthe rotation all stored data is in archived files.

Fixes: #1017
2018-10-25 21:44:48 +02:00
Lennart Poettering d03077759e journald: log about an OOM condition 2018-10-25 21:44:48 +02:00
Lennart Poettering e859154447 journald: debug log when we cannot read the machine ID 2018-10-25 21:44:48 +02:00
Lennart Poettering f760d8a858 journal: refactor out loop that processes deferred closes into its own function 2018-10-25 21:43:09 +02:00
Anita Zhang 90fc172e19 core: implement per unit journal rate limiting
Add LogRateLimitIntervalSec= and LogRateLimitBurst= options for
services. If provided, these values get passed to the journald
client context, and those values are used in the rate limiting
function in the journal over the the journald.conf values.

Part of #10230
2018-10-18 09:56:20 +02:00
Lennart Poettering 15a3e96f92 tree-wide: port various users over to sockaddr_un_set_path()
CID 1396140
CID 1396141
2018-10-15 19:40:51 +02:00
Renaud Métrich fd790d6f09 journald: fixed assertion failure when system journal rotation fails (#9893) 2018-09-03 12:42:39 +09:00
Yu Watanabe 8bebb09ce7 journal: replace udev_device by sd_device 2018-08-23 04:57:39 +09:00
Yu Watanabe 29bfb683a8 journal: drop redundant condition 2018-06-25 13:36:49 +09:00