Commit graph

33516 commits

Author SHA1 Message Date
Lennart Poettering c818eef1cd nspawn: properly handle and log about hostname setting errors 2018-05-17 20:47:21 +02:00
Lennart Poettering 9f8168eb23 process-util: add new helper call for adjusting the OOM score
And let's make use of it in execute.c
2018-05-17 20:47:21 +02:00
Lennart Poettering e9eb2c02f0 basic: split parsing of the OOM score adjust value into its own function in parse-util.c
And port config_parse_exec_oom_score_adjust() over to use it.

While we are at it, let's also fix config_parse_exec_oom_score_adjust()
to accept an empty string for turning off OOM score adjustments set
earlier.
2018-05-17 20:47:21 +02:00
Lennart Poettering 66edd96310 nspawn: add a new --no-new-privileges= cmdline option to nspawn
This simply controls the PR_SET_NO_NEW_PRIVS flag for the container.
This too is primarily relevant to provide OCI runtime compaitiblity, but
might have other uses too, in particular as it nicely complements the
existing --capability= and --drop-capability= flags.
2018-05-17 20:47:20 +02:00
Lennart Poettering 3a9530e5f1 nspawn: make the hostname of the container explicitly configurable with a new --hostname= switch
Previously, the container's hostname was exclusively initialized from
the machine name configured with --machine=, i.e. the internal name and
the external name used for and by the container was synchronized. This
adds a new option --hostname= that optionally allows the internal name
to deviate from the external name.

This new option is mainly useful to ultimately implement the OCI runtime
spec directly in nspawn, but it might be useful on its own for some
other usecases too.
2018-05-17 20:46:45 +02:00
Lennart Poettering 5a4ff98840 conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null() 2018-05-17 20:45:57 +02:00
Lennart Poettering bf428efb07 nspawn: add new --rlimit= switch, and always set resource limits explicitly for our container payloads
This ensures we set the various resource limits of our container
explicitly on each invocation so that we inherit less from our callers
into the payload.

By default resource limits are now set to the same values Linux
generally passes to the host PID 1, thus minimizing needless differences
between host and container environments.

The limits are now also configurable using a new --rlimit= switch. This
is preparation for teaching nspawn native OCI runtime support as OCI
permits setting resource limits for container payloads, and it hence
probably makes sense if we do too.
2018-05-17 20:45:54 +02:00
Lennart Poettering 114c55f2d5 rlimit-util: tweak setrlimit_closest() a bit
POSIX doesn't declare too clearly how RLIM_INFINITY is set. Let's hence
filter it out explicitly early on, just as safety precaution should it
be defined weirdly on some arch, for example negative or below the
maximum value of the rlim_t type.
2018-05-17 20:40:04 +02:00
Lennart Poettering 37bc14de5b basic: be more careful when closing fds based on RLIMIT_NOFILE
Let's make sure we properly handle cases where RLIMIT_NOFILE is set to
infinity, zero or values outside of the "int" range.
2018-05-17 20:40:04 +02:00
Lennart Poettering 1752d69a8b man: document what happens if --kill-signal= is not used in nspawn and --boot neither 2018-05-17 20:40:04 +02:00
Lennart Poettering c7fc3c4cfe man: don't claim systemd-analyze was documented as part of the man-pages project
It's our own command, we document it in our own set of man pages.
2018-05-17 20:40:04 +02:00
Lennart Poettering 34a5df58da rlimit-util: introduce setrlimit_closest_all()
This new call applies all configured resource limits in one.
2018-05-17 20:40:04 +02:00
Lennart Poettering 31ce987c2b rlimit-util: add a common destructor call for arrays of struct rlimit 2018-05-17 20:36:52 +02:00
Lennart Poettering 4f424df760 core: move config_parse_limit() to the generic conf-parser.[ch]
That way we can use it in nspawn.

Also, while we are at it, let's rename the call config_parse_rlimit(),
i.e. insert the "r", to clarify what kind of limit this is about.
2018-05-17 20:36:52 +02:00
Lennart Poettering 6550c24c7f rlimit-util: rework rlimit_{from|to}_string() to work without "Limit" prefix
let's make the call more generic, so that we can also easily use it for
parsing "RLIMIT_xyz" style constants.
2018-05-17 20:36:52 +02:00
Lennart Poettering 0e960f9b5c
Merge pull request #9017 from keszybz/man-coredump
coredump documention enhancement
2018-05-17 10:45:22 -07:00
Lennart Poettering b391a5f5d5
Merge pull request #9002 from yuwata/fix-timedate
Fixes timedated and cleanups hostnamed
2018-05-17 10:38:37 -07:00
Lennart Poettering 94e05c9a09
Merge pull request #9016 from yuwata/fix-policy
polkit policy related fixes
2018-05-17 10:07:56 -07:00
Zbigniew Jędrzejewski-Szmek d18cb3937b Turn VALGRIND variable into a meson configuration switch
Configuration through environment variable is inconvenient with meson, because
they cannot be convieniently changed and/or are not preserved during
reconfiguration (https://github.com/mesonbuild/meson/issues/1503).
This adds -Dvalgrind=true/false, which has the advantage that it can be set
at any time with meson configure -Dvalgrind=... and ninja will rebuild targets
as necessary. Additional minor advantages are better consistency with the
options for hashmap debugging, and typo avoidance with '#if' instead of '#ifdef'.
2018-05-17 09:54:36 -07:00
Zbigniew Jędrzejewski-Szmek c8e053fbe4 man: fix ProcessSizeMax= description, describe how to disable coredumps
What the man page said was different than what the code did.
save_external_coredump() will store the core temporarily for backtrace
generation, and will delete if afterwards if it is too large. So to disable
processing, it's necessary to both set
Storage=none/Storage=journal+JournalSizeMax=0/Storage=external+ExternalSizeMax=0
and ProcessSizeMax=0. This updates the man page to reflect the code.

The man pages are extended to describe that Storage=none + ProcessSizeMax=0 is
the simplest way to disable coredump processing. All the storage and processing
options make this quite complicated, so let's add a copy-and-pasteable example
of how to disable coredump. Doing it through coredump.conf has the advantage
that we still log, and the effect is immediate, unlike masking the sysconf
file.

Fixes #8788.
2018-05-17 17:15:03 +02:00
Yu Watanabe e610ac3d50 timedatectl: do not wrap polkit policy message
If messages are wrapped, then only the last line is shown in the
dialog, at least polkit gui for Xfce. It may be a bug of polkit or
Xfce. But it is not necessary to wrap the message in the policy
file. So, let's fix them.
2018-05-18 00:03:15 +09:00
Yu Watanabe a8f2b6912e core: systemd1.manage-unit-files policy implies systemd1.manage-units
This makes e.g. `systemctl enable --now` ask password only once.

Follow-up for b07abe63d3abf03df559f7cb2c9863943df22274.
2018-05-18 00:02:58 +09:00
Zbigniew Jędrzejewski-Szmek ee0449fd7a coredump: properly treat Storage=none as disabled storage
Also don't attempt to create /var/lib/systemd/coredump if storage
limit is set to 0 and coredump processing is disabled.
2018-05-17 17:00:11 +02:00
Yu Watanabe 51b66c7a8a core: systemd1.manage-unit-files policy implies systemd1.reload-daemon
Closes #5013.
2018-05-15 15:01:05 -07:00
Zbigniew Jędrzejewski-Szmek 5300857701
Merge pull request #9005 from fsateler/circular-deps
core: Fix some header dependencies
2018-05-15 21:56:50 +02:00
Felipe Sateler 57b7a260c2 core: undo the dependency inversion between unit.h and all unit types 2018-05-15 14:24:34 -04:00
Felipe Sateler 90a8f0b9a9 core: Break circular dependency between unit.h and cgroup.h 2018-05-15 14:23:32 -04:00
Milan Broz f2bd752215 udev: create /dev/disk/by-label symlink for LUKS2 (#8998)
LUKS2 header supports to device label and blkid since 2.32 version
already supports this option.

Persistent udev storage rules should create symlink for this label.

For older devices this value is not set so changed rule should be compatible.
2018-05-15 16:51:07 +02:00
Yu Watanabe 14f7edb094 core/dbus-unit: do not pass whole Unit object 2018-05-15 23:11:26 +09:00
Yu Watanabe 874bd264a0 core/dbus-unit: introduce unit_can_{start,stop,isolate}_refuse_manual() functions 2018-05-15 23:11:20 +09:00
Yu Watanabe 92c23c5a70 core: use BUS_DEFINE_PROPERTY_GET* macros 2018-05-15 23:11:16 +09:00
Yu Watanabe 74c308ae44 machine: use BUS_DEFINE_PROPERTY_GET* macros 2018-05-15 23:10:49 +09:00
Yu Watanabe acd380c450 resolve: use BUS_DEFINE_PROPERTY_GET* macros 2018-05-15 23:07:02 +09:00
Yu Watanabe 6cc379b573 timedate: use BUS_DEFINE_PROPERTY_GET* macros 2018-05-15 23:07:02 +09:00
Yu Watanabe 62cf085143 timesync: use NULL instead of empty string 2018-05-15 23:07:02 +09:00
Yu Watanabe 01adcd691d login: use BUS_DEFINE_PROPERTY_GET* macros 2018-05-15 23:07:02 +09:00
Yu Watanabe c321885489 bus-util: add more macros for defining functions of getting dbus properties 2018-05-15 23:07:02 +09:00
Yu Watanabe 539a68e0fb timedate: do not copy input string before bus_verify_polkit_async()
This fixes the commit 2c3def6214 which
breaks `timedatectl set-timezone` called by non-privileged user.
2018-05-15 22:53:42 +09:00
Yu Watanabe c650f20721 hostname: use free_and_strdup()
Also, this makes hostnamed check the input strings before
bus_verify_polkit_async().
2018-05-15 22:51:57 +09:00
Yu Watanabe 5ed29cab4a sysusers: drop an unused variable
Follow-up for ec0327d69c.
2018-05-15 14:04:43 +02:00
Alan Jenkins 4330dc03a0 service: FileDescriptorStoreMax should also imply NotifyAccess
Commenting out "WatchdogTimeout=3min" in systemd-logind.service causes
NotifyAccess to go from "main" to "none", breaking support for logind
restart.  Let's fix that.
2018-05-15 12:33:56 +02:00
Zbigniew Jędrzejewski-Szmek 38dad44332 sd-resolve: fix check for packet size
The protocol is that a string is serialized with the nul byte at the end, and
the terminator is included in length. We'd call strndup with offset 0, length
len1-1, and then a second time with offset len1, length len2-1, so in the end
the check was off by one. But let's require the terminating nul too, even if
we don't access it.

CID #1383035.
2018-05-15 12:31:42 +02:00
Zbigniew Jędrzejewski-Szmek 2da063370a sd-resolve: use structured initializers and _cleanup_
Also remove a break that cannot be reached and a resolve->dead check
that duplicates the loop condition.
2018-05-15 12:31:39 +02:00
Zbigniew Jędrzejewski-Szmek e8bce4fad3 sd-resolve: trivial indentation fixes 2018-05-15 12:27:02 +02:00
Zbigniew Jędrzejewski-Szmek f6ddae40ab sd-resolve: do not assert on packet size received over a socket
This is external data, even if trusted. We should not assert on it, but verify
and return proper error instead, which assert_return does. In particular,
write(2) says that a partial write could occur when interupted by a signal.
When compiled with asserts disabled, we could access memory outside of the
allocated buffer.

CID #1237671.
Follow-up for 1a96c8e1cc.
2018-05-15 12:25:44 +02:00
Yu Watanabe d231d569d8 bash-completion: add missing options and commands of timedatectl
Follow-up for 6129ec852e.
2018-05-15 10:52:45 +02:00
Zbigniew Jędrzejewski-Szmek b330320278
Merge pull request #8947 from yuwata/meson-0.44
meson: bump minimum required version to 0.44
2018-05-15 08:58:33 +02:00
Zbigniew Jędrzejewski-Szmek 0b45ff5278 sd-resolve: add helper macro for setting of ret/_errno/_h_errno
Just to make things a bit shorter. This fixes an error where errno==-EIO would be set
(negative value), introduced in 1a96c8e1cc.
2018-05-14 17:22:22 +02:00
Zbigniew Jędrzejewski-Szmek 9421cab6db test-copy: remove unnecessary initialization
Initializing just some of the values doesn't make sense. We should handle them
all in the same way. In those tests there are no jumps, all steps are covered
with assert_se(), so we know everything will be set if we get to the end of the
function. And _not_ initializing those variables has the advantage that it
allows valgrind to catch potential initalization errors in the function being
tested.
2018-05-14 17:22:22 +02:00
Zbigniew Jędrzejewski-Szmek dcd6361ea1 tree-wide: do not wrap assert_se in extra parentheses
We were inconsitently using them in some cases, but in majority not.
Using assignment in assert_se is very common, not an exception like in
'if', so let's drop the extra parens everywhere.
2018-05-14 17:22:22 +02:00