Commit Graph

2013 Commits

Author SHA1 Message Date
Frantisek Sumsal 15dd451535 tree-wide: codespell fixes
Another batch of codespell fixes as reported by Fossies.org
2020-05-25 10:29:28 +02:00
Anita Zhang b10ceb4783
Merge pull request #15557 from poettering/journal-zero-fix
journal: deal better with reading from zeroed out journal mmaps
2020-05-20 18:14:51 -07:00
Lennart Poettering 544e146b0e journalctl,elsewhere: make sure --file=foo fails with sane error msg if foo is not readable
It annoyed me for quite a while that running "journalctl --file=…" on a
file that is not readable failed with a "File not found" error instead
of a permission error. Let's fix that.

We make this work by using the GLOB_NOCHECK flag for glob() which means
that files are not accessible will be returned in the array as they are
instead of being filtered away. This then means that our later attemps
to open the files will fail cleanly with a good error message.
2020-05-19 15:26:51 +02:00
Ankit Jain 2eaf435a16 journal-send: Fix the limitation of LINE_MAX
- If length of formatted string >= LONG_LINE_MAX then return -ENOBUFS
- Normal Case:
  - length of formatted string < POSIX defined LINE_MAX
  - Allocate sbuf to accomodate the message
- Rare case:
  - LINE_MAX < length of formatted string < LONG_LINE_MAX
  - Allocate the required length using alloca()
2020-05-14 17:15:34 +00:00
Zbigniew Jędrzejewski-Szmek 969d329490 test-journal-send: send printing of long lines 2020-05-14 17:15:14 +00:00
Lennart Poettering 2b8c2fbb2d
Merge pull request #15765 from benjarobin/fix_kw
Various bug fixes
2020-05-14 09:08:47 +02:00
Benjamin Robin 243945e95e test: Add return 0 to main() function (even it is not strictly necessary) 2020-05-13 22:56:42 +02:00
Lennart Poettering 45ba1ea5e9 journald: rework pid change handling
Let's introduce an explicit line ending marker for line endings due to
pid change.

Let's also make sure we don't get confused with buffer management.

Fixes: #15654
2020-05-13 21:32:38 +02:00
Lennart Poettering 020b4a023c journald: use the fact that client_context_release() returns NULL 2020-05-13 21:32:34 +02:00
Lennart Poettering 549b7379ba journald: rework end of line marker handling to use a field table 2020-05-13 21:32:30 +02:00
Lennart Poettering 5fe7fb0bf6 journald: use log_warning_errno() where appropriate 2020-05-13 21:32:25 +02:00
Benjamin Robin 034e9719ac journald: Increase stdout buffer size sooner, when almost full
If the previous received buffer length is almost equal to the allocated
buffer size, before this change the next read can only receive a couple
of bytes (in the worst case only 1 byte), which is not efficient.
2020-05-13 21:31:58 +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
Benjamin Robin 0a0e594a26 tree-wide: Mark as _unused_ variables that are only used in assert()
Allow to build without any warning with NDEBUG defined
2020-05-06 23:03:25 +02:00
Norbert Lange ef5924aa31 coredump: add zstandard support for coredumps
this will hook libzstd into coredump,
using this format as default.
2020-05-04 10:59:43 +02:00
Michal Koutný 2e4086060b test: Fix build with !HAVE_LZ4 && HAVE_XZ
HUGE_SIZE was defined inconsistently.

> In file included from ../src/basic/alloc-util.h:9,
>                  from ../src/journal/test-compress.c:9:
> ../src/journal/test-compress.c: In function ‘main’:
> ../src/journal/test-compress.c:280:33: error: ‘HUGE_SIZE’ undeclared (first use in this function)
>   280 |         assert_se(huge = malloc(HUGE_SIZE));
2020-05-02 20:04:36 +00:00
Topi Miettinen 3c14dc61f7 tests: various small fixes for strict systems
Don't assume that 4MB can be allocated from stack since there could be smaller
DefaultLimitSTACK= in force, so let's use malloc(). NUL terminate the huge
strings by hand, also ensure termination in test_lz4_decompress_partial() and
optimize the memset() for the string.

Some items in /proc and /etc may not be accessible to poor unprivileged users
due to e.g. SELinux, BOFH or both, so check for EACCES and EPERM.

/var/tmp may be a symlink to /tmp and then path_compare() will always fail, so
let's stick to /tmp like elsewhere.

/tmp may be mounted with noexec option and then trying to execute scripts from
there would fail.

Detect and warn if seccomp is already in use, which could make seccomp test
fail if the syscalls are already blocked.

Unset $TMPDIR so it will not break specifier tests where %T is assumed to be
/tmp and %V /var/tmp.
2020-04-26 20:18:48 +02:00
Zbigniew Jędrzejewski-Szmek 11f9379866
Merge pull request #15570 from poettering/cmsg-find
CMSG_FIND_DATA() and cmsg_find() work
2020-04-24 07:45:07 +02:00
Lennart Poettering 41ab8c67eb tree-wide: use structured initialization at various places 2020-04-24 07:44:42 +02:00
Lennart Poettering 371d72e05b socket-util: introduce type-safe, dereferencing wrapper CMSG_FIND_DATA around cmsg_find()
let's take this once step further, and add type-safety to cmsg_find(),
and imply the CMSG_DATA() macro for finding the cmsg payload.
2020-04-23 19:41:15 +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 a9ab5cdb50
Merge pull request #15472 from keszybz/dbus-api-docs
A few more dbus api documentation updates
2020-04-23 17:01:11 +02:00
Lennart Poettering bfbd5be02a journal: no need to check offset twice, journal_file_move_to_object() does it again 2020-04-23 12:13:21 +02:00
Lennart Poettering 893e0f8fb6 journal: make sure to explicitly copy out values of mmap before doing arithmetics on them
Our journal code is generally supposed to be written in a fashion that
the underlying file can be deallocated any time, i.e. our mmap of it
suddenly becomes all zeroes. The idea is that we catch that when parsing
everything. For that to work safely we need to make sure that when doing
arithmetics or comparisons on values read from the map we don't run into
TTOCTTOU issues when determining validity. Hence we need to copy out the
values before use and operate on the copies. This requires some special
care since the C compiler could suppress our copies as optimization.
Hence use the new READ_NOW() macro to force a copy by using memcpy(),
and use it whenever we start doing an arithmetic operation on it, or
validity checking of multiple steps.

Fixes: #14943
2020-04-23 12:13:10 +02:00
Lennart Poettering 711398986e journal: several minor coding style fixes/clean-ups 2020-04-23 12:12:58 +02:00
Lennart Poettering 0600ff0e66 journal: don't assert on mmap'ed object type
Mappings canbe replaced by all zeroes under our feet if vacuuming
decides to unallocate some file. Hence let's not check for this kind of
stuff in an assert.

(Typically, we should genreate runtime errors in this case, in
particular EBADMSG, which the callers generally look for. But in this
case this is just an extra precaution check anyway, so let's just remove
it.)
2020-04-23 12:12:55 +02:00
Lennart Poettering bba6e4aeec journal: use structured initialization for Location structure 2020-04-23 12:12:33 +02:00
Lennart Poettering e6fea3063b journal: use a bitfield where appropriate 2020-04-23 12:12:20 +02:00
Lennart Poettering 20ee282bb7 journal-file: avoid risky subtraction when validity checking object
The value might change beneath what we do, and hence let's avoid any
chance of underflow.
2020-04-23 12:12:17 +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
Lennart Poettering 2b6df46d21 sd-journal: don't check namespaces if we have no namespace to go by
Fixes: #15528
2020-04-23 09:23:53 +02:00
Frantisek Sumsal 86b52a3958 tree-wide: fix spelling errors
Based on a report from Fossies.org using Codespell.

Followup to #15436
2020-04-21 23:21:08 +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 0648f9beb9 errno-util: let's beef up ERRNO_IS_NOT_SUPPORTED() with socket not supported errors 2020-04-17 16:05:56 +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 38cd55b007 Remove unneded {}s
$ perl -i -0pe 's|\s+{\n([^\n]*;)\n\s+}\n|\n\1\n|gms' **/*.c

Inspired by ea7cbf5bdd.
2020-04-13 09:31:49 +02:00
Vito Caputo 8e06af804b *: use _cleanup_close_ with fdopendir() where trivial
Also convert these to use take_fdopendir().
2020-03-31 06:48:03 -07:00
Michal Sekletár 8581b9f973 sd-journal: remove the dead code and actually fix #14695
journal_file_fstat() returns an error if we call it on already unlinked
journal file and hence we never reach remove_file_real() which is the
entire point.

I must have made some mistake while testing the fix that got me thinking
the issue is gone while opposite was true.

Fixes #14695
2020-03-28 09:39:33 +01:00
Georg Müller 8d0726fcd7 fix journalctl regression (#15099)
This regression was introduced in #14913.

The current_file variable can be NULL, as, for example, with the
following commands:

* journalctl --list-boots
* journalctl -b -1 --no-pager

Since current_file is only checked for pointer equality with f, removing
the assertion is safe here.
2020-03-13 12:31:01 +09:00
Georg Müller b6849042d6 journalctl: show duplicate entries if they are from the same file (#14898)
When having a service which intentionally outputs multiple equal lines,
all these messages might be inserted with the same timestamp.

journalctl has a mechanism to avoid duplicate lines, which might be in
different journal files.

This patch allows duplicate lines, if they are from the same file.
2020-03-11 09:12:00 +01: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
Zbigniew Jędrzejewski-Szmek 64177e9e4e journald: fix forwarding to syslog
.msg_namelen was set to a bogus value before we actually stored the path in the
the structure. sockaddr_un_set_path() returns the length, so just use that.

Fixes #14799.
2020-03-02 15:47:41 +01:00
Zbigniew Jędrzejewski-Szmek 196dedd503 journalctl: implement --facility=foo
Fixes #9716.
2020-02-29 18:07:37 +01:00
Yu Watanabe 74deaff118 journal: fix log message 2020-02-07 15:27:43 +01:00
Michal Sekletár 28ca867abd sd-journal: close journal files that were deleted by journald before we've setup inotify watch
Fixes #14695
2020-02-05 18:34:52 +01:00
Yu Watanabe 4c1dea42b5 journal: drop unreachable path 2020-02-03 10:00:50 +01:00
Lennart Poettering 23d8c56046 journalctl: underline sections in --help 2020-01-31 15:10:40 +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