Commit graph

3645 commits

Author SHA1 Message Date
Zach Smith 28ca9c2499 systemd-sleep: refactor sleep config parsing
remove verb from parse

refactor required fields checks

refactor allow settings
2019-05-30 06:06:16 -07:00
Zach Smith 1bbbefe7a6 systemd-sleep: replace rtc wakealarm with CLOCK_BOOTTIME_ALARM s2h
refactor to use timerfd in place of rtc wakealarm

confirm CLOCK_BOOTTIME_ALARM support in can_s2h

Remove CLOCK_BOOTTIME_ALARM task from TODO

remove unnecessary check on clock_supported return
2019-05-28 17:02:36 +02:00
Lennart Poettering 46fcf95dbe seccomp: add new 5.1 syscall pidfd_send_signal() to filter set list 2019-05-28 17:01:05 +02:00
Lennart Poettering 1c99d2e0c5
Merge pull request #12597 from keszybz/analyze-timestamp
Analyze timestamps
2019-05-28 14:34:53 +02:00
Lennart Poettering 2570578d90 machine-image: openat() doesn't operate on the cwd if the first argument is specified
A fix-up for bcb846f30f.
2019-05-24 14:39:19 +02:00
Lennart Poettering 915fb32438 seccomp: add scmp_act_kill_process() helper that returns SCMP_ACT_KILL_PROCESS if supported 2019-05-24 10:48:28 +02:00
Lennart Poettering d631a760e0
Merge pull request #12601 from keszybz/two-log-color-adjustments
Two log color adjustments
2019-05-24 10:43:07 +02:00
Lennart Poettering 05332e243c
Merge pull request #12590 from keszybz/unicode-cmdlines
Use unicode for cmdline printing
2019-05-24 10:41:30 +02:00
Mike Gilbert bcb846f30f shared/machine-image: avoid passing NULL to log_debug_errno
Fixes: https://github.com/systemd/systemd/issues/12534
2019-05-23 09:36:50 +02:00
Lennart Poettering 0f6519d43c loop-util: invoke LOOP_CTL_GET_FREE in a loop
if we don't call it in a loop the device it tells us to open might
already be gone, taken by somebody else racing against us. Hence try a
few times.
2019-05-22 13:04:26 +02:00
Zbigniew Jędrzejewski-Szmek e3b4efd28f Add 8bit-version of get_process_cmdline() and use in cgroup-show.c
This restores show_pid_array() output in legacy locales on the console.
Only one call to get_process_cmdline() is changed, all others retain
utf8-only mode. This affects systemd-cgls, systemctl status, etc, when
working locally.

Calls to get_process_cmdline() that cross a process boundary always use
utf8. It's the callers responsibility to convert this to some encoding that
they use. This means that we always pass utf8 over the bus.
2019-05-22 10:16:00 +02:00
Zbigniew Jędrzejewski-Szmek 09c1dceef1 basic/process-util: convert bool arg to flags
In preparation for the next commit…
2019-05-22 10:15:49 +02:00
Zbigniew Jędrzejewski-Szmek bc28751ed2 Rework cmdline printing to use unicode
The functions to retrieve and print process cmdlines were based on the
assumption that they contain printable ASCII, and everything else
should be filtered out. That assumption doesn't hold in today's world,
where people are free to use unicode everywhere.

This replaces the custom cmdline reading code with a more generic approach
using utf8_escape_non_printable_full().
For kernel threads, truncation is done on the parenthesized name, so we'll
get "[worker]", "[worker…]", …, "[w…]", "[…", "…" as we reduce the number of
available columns.

This implementation is most likely slower for very long cmdlines, but I don't
think this is very important. The common case is to have short commandlines,
and should print those properly. Absurdly long cmdlines are the exception,
which needs to be handled correctly and safely, but speed is not too important.

Fixes #12532.

v2:
- use size_t for the number of columns. This change propagates into various
  other functions that call get_process_cmdline(), increasing the size of the
  patch, but the changes are rather trivial.
2019-05-22 10:08:17 +02:00
Zbigniew Jędrzejewski-Szmek 31c294dc41 shared/cgroup-show: fix off-by-one in column counting
We'd get one column too many, and the trailing ellipsis would end up in
the next row.
2019-05-21 10:57:23 +02:00
Lennart Poettering 6980b04fb6 json: fix minor memory leak on error path 2019-05-20 18:12:48 +02:00
Yu Watanabe 030a5d78ed efivars: allow plus in the entry name
Closes #12572.
2019-05-19 16:00:27 +02:00
Zbigniew Jędrzejewski-Szmek be44e09162 shared/varlink: add missing setting of output_buffer_allocated
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14708,
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14735,
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14725,
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14720,
and probably others.
2019-05-17 15:09:32 +02:00
Zbigniew Jędrzejewski-Szmek 194da5ca51 shared/logs-show: show audit logs in blue
Audit logs always have _TRANSPORT=audit and no PRIORITY= field set.  This means
that they are shown in the default foreground color. There can be quite a lot
of them, and they often repeat the same information that is already logged by
applications, leading to a "wall of text" effect. Let's mark them with a
different color. This splits the logs visually into "normal logs" and "audit
logs".
2019-05-17 15:06:59 +02:00
Zbigniew Jędrzejewski-Szmek 9a2b3d3df1 shared/calendarspec: make output arg optional 2019-05-17 10:09:32 +02:00
Yu Watanabe 8688c29b5a varlink: initialize Varlink with 0
Closes oss-fuzz#14688.
2019-05-16 18:51:33 +02:00
Lennart Poettering 73130b0bcf
Merge pull request #12565 from zachsmith/fix-log-message-typos
systemd-sleep: Fix typos in log messages
2019-05-15 10:50:03 +02:00
Thadeu Lima de Souza Cascardo 59c55e73ea ask-password: prevent buffer overrow when reading from keyring
When we read from keyring, a temporary buffer is allocated in order to
determine the size needed for the entire data. However, when zeroing that area,
we use the data size returned by the read instead of the lesser size allocate
for the buffer.

That will cause memory corruption that causes systemd-cryptsetup to crash
either when a single large password is used or when multiple passwords have
already been pushed to the keyring.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
2019-05-15 10:49:46 +02:00
Zach Smith 45733c9d21 fix typo in wakealarm message 2019-05-13 20:01:36 -07:00
Zbigniew Jędrzejewski-Szmek 77740b5993 journalctl: improve error messages
Follow-up for #12230.
2019-05-10 16:55:37 +02:00
Zbigniew Jędrzejewski-Szmek 1d3fe304fd Use sd_event_source_disable_unref() 2019-05-10 16:55:37 +02:00
Lennart Poettering d41bd96f54 shared: add minimal varlink implementation
This adds a minimal Varlink (https://varlink.org/) implementation to our
tree. Given that we already have a JSON logic it's an easy thing to add.

Why bother?

We currently have major problems with IPC before dbus-daemon is up, and
in all components that dbus-daemon itself makes use of (such as various
NSS modules to resolve users as well as the journal which dbus-daemon
logs to). Because of that we so far ended up creating various (usually
crappy) work-arounds either coming up with secondary IPC systems or
sharing data statelessly in /run or similar. Let's clean this up, and
instead use a clean, well-defined, broker-less IPC for cases like that.

This is a minimal implementation of Varlink, i.e. the most basic logic
only. Stuff that's missing is left out on purpose: there's no
introspection/validation and there's no name service. It might make
sense to add that later, but for now let's only do the minimum buy-in we
can get away with. In particular as I'd assume that at least initially
we only use this IPC for our internal communication avoiding
introspection and the name service should be fine.

Specifically, I'd expect that we add IPC interfaces to the following
concepts with this scheme:

1. nss-resolve (so that hostname lookups with resolved work before
   resolved is up)
2. journald (so that IPC calls to journald don't have to go through
   dbus-daemon thus creating a cyclic dependency between journald and
   dbus-daemon)
3. nss-systemd (so that dynamic user lookups via PID 1 work sanely even
   inside of dbus-daemon, because otherwise we'd want to use dbus to run
   dbus which causes deadlocks)
4. networkd (to make sure one can talk to it in the initrd already,
   long before dbus is around)

And there might be other cases similar to this.
2019-05-09 14:14:20 -04:00
Zbigniew Jędrzejewski-Szmek 180f1e3359
Merge pull request #12445 from cdown/dmm_docs
cgroup: Some memory protection fixes
2019-05-08 18:09:45 +02:00
Lennart Poettering e95be7def2
Merge pull request #12411 from keszybz/pr/12394
run: when emitting the calendarspec warning, use red
2019-05-08 10:11:32 -04:00
Chris Down 7e7223b3d5 cgroup: Readd some plumbing for DefaultMemoryMin
Somehow these got lost in the previous PR, rendering DefaultMemoryMin
not very useful.
2019-05-08 12:06:32 +01:00
Lennart Poettering a1c7a1f057 format-table: correct prototype 2019-05-08 06:33:36 -04:00
Zbigniew Jędrzejewski-Szmek 37b8d2f699 basic/log: use colors to highlight messages like journalctl 2019-05-08 09:45:38 +02:00
Zbigniew Jędrzejewski-Szmek 6695c200bd shared/utmp-wtmp: silence gcc warning about strncpy truncation
Unfortunately the warning must be known, or otherwise the pragma generates a
warning or an error. So let's do a meson check for it.

Is it worth doing this to silence the warning? I think so, because apparently
the warning was already emitted by gcc-8.1, and with the recent push in gcc to
catch more such cases, we'll most likely only get more of those.
2019-05-07 21:05:26 +02:00
Zbigniew Jędrzejewski-Szmek f1d553e9df shared/utmp-wtmp: avoid gcc warning about strncpy truncation
The fact that strncpy does the truncation is the whole point here, and gcc
shouldn't warn about this. We can avoid the warning and simplify the
whole procedure by directly copying the interesting part.
2019-05-07 14:15:46 +02:00
Lennart Poettering adb7b782f8
Merge pull request #12218 from keszybz/use-libmount-more
Use libmount more
2019-04-30 19:44:17 +02:00
Lennart Poettering 0892f3f999
Merge pull request #12420 from mrc0mmand/coccinelle-tweaks
Coccinelle improvements
2019-04-30 11:37:19 +02:00
Frantisek Sumsal ed0cb34682 tree-wide: code improvements suggested by Coccinelle 2019-04-30 09:39:07 +02:00
Zbigniew Jędrzejewski-Szmek cb9ff7532b
Merge pull request #12434 from poettering/rm-rf-children-take-ptr
minor rm_rf_children() modernizations
2019-04-30 08:23:13 +02:00
Ben Boeckel 5238e95759 codespell: fix spelling errors 2019-04-29 16:47:18 +02:00
Lennart Poettering c0ba6b9286 switch-root: modernize rm_rf_children() invocation a bit 2019-04-29 16:17:29 +02:00
Frantisek Sumsal 55033662f9 tree-wide: drop !! casts to booleans
Done by coccinelle/bool-cast.cocci
2019-04-28 14:32:19 +02:00
Frantisek Sumsal 4e361acc06 tree-wide: replace explicit NULL checks with their shorter variants
Done by coccinelle/equals-null.cocci
2019-04-28 14:28:49 +02:00
Zbigniew Jędrzejewski-Szmek a6d04b1a17
Merge pull request #12394 from poettering/oncalendar-tweak
systemd-run --on-calendar= follow-up
2019-04-26 08:48:28 +02:00
Lennart Poettering cbb3092ce6 json: let's not accept embedded NUL bytes when allocating JSON strings
Let's add an additional paranoia check, and not accept embedded NUL
bytes in strings, just in case.
2019-04-26 08:24:41 +02:00
Lennart Poettering b2bdf6e456 json: make log message more focussed 2019-04-26 08:22:22 +02:00
Lennart Poettering 9bb656bd0c calendarspec: make return time value of calendar_spec_next_usec() optional
If noone is interested, there's no reason to return it.

(Also document the ENOENT error code in a comment)
2019-04-25 13:21:54 +02:00
Zbigniew Jędrzejewski-Szmek 2f2d81d957 shared/mount-util: make sure utab is ignored in umount_recursive()
See https://github.com/systemd/systemd/pull/12218#pullrequestreview-226029985.
2019-04-23 23:52:15 +02:00
Zbigniew Jędrzejewski-Szmek e2857b3d87 Add helper function for mnt_table_parse_{stream,mtab}
This wraps a few common steps. It is defined as inline function instead of in a
.c file to avoid having a .c file. With a .c file, we would have three choices:
- either link it into libshared, but then then libshared would have to be
  linked to libmount.
- or compile the .c file into each target separately. This has the disdvantage
  that configuration of every target has to be updated and stuff will be compiled
  multiple times anyway, which is not too different from keeping this in the
  header file.
- or create a new convenience library just for this. This also has the disadvantage
  that the every target would have to be updated, and a separate library for a
  10 line function seems overkill.

By keeping everything in a header file, we compile this a few times, but
otherwise it's the least painful option. The compiler can optimize most of the
function away, because it knows if 'source' is set or not.
2019-04-23 23:29:29 +02:00
Zbigniew Jędrzejewski-Szmek 13dcfe4661 shared/mount-util: convert to libmount
It seems better to use just a single parsing algorithm for /proc/self/mountinfo.

Also, unify the naming of variables in all places that use mnt_table_next_fs().
It makes it easier to compare the different call sites.
2019-04-23 23:29:29 +02:00
Chris Down 6610200d29
Merge pull request #12336 from anitazha/disablecontroller
core: support DisableControllers= for transient units
2019-04-23 10:42:37 +02:00
Anita Zhang 25cc30c4c8 core: support DisableControllers= for transient units 2019-04-22 11:52:08 -07:00