Commit Graph

30872 Commits

Author SHA1 Message Date
Lennart Poettering e7266e98f9 test: fix UDEV-WANTS testcase for non-bash shells
testsuite.sh uses "set -o pipefile", which is a bashism, hence use bash
to invoke the script.
2017-11-21 11:54:08 +01:00
Lennart Poettering 99f3baa983 man: clarify that the controllers listed on Delegate= might not be the only ones 2017-11-21 11:54:08 +01:00
Lennart Poettering b961baf1ce test: add a test case that validates cgroup delegation
This test runs on the unified hierarchy, and ensures that cgroup
delegation works properly, i.e. writ access is granted and the requested
controllers are enabled.
2017-11-21 11:54:08 +01:00
Lennart Poettering 64e844e5ca cgroup: fix delegation on the unified hierarchy
Make sure to add the delegation mask to the mask of controllers we have
to enable on our own unit. Do not claim it was a members mask, as such
a logic would mean we'd collide with cgroupv2's "no processes on inner
nodes policy".

This change does the right thing: it means any controller enabled
through Controllers= will be made available to subcrgoups of our unit,
but the unit itself has to still enable it through
cgroup.subtree_control (which it can since that file is delegated too)
to be inherited further down.

Or to say this differently: we only should manipulate
cgroup.subtree_control ourselves for inner nodes (i.e. slices), and
for leaves we need to provide a way to enable controllers in the slices
above, but stay away from the cgroup's own cgroup.subtree_control —
which is what this patch ensures.

Fixes: #7355
2017-11-21 11:54:08 +01:00
Lennart Poettering 5e20b0a452 cgroup: properly determine cgroups zombie processes belong to
When a process becomes a zombie its cgroup might be deleted. Let's add
some minimal code to detect cases like this, so that we can still
attribute this back to the original cgroup.
2017-11-21 11:54:08 +01:00
Lennart Poettering 77fa610b22 cgroup-util: optimization — open subtree_control file only once for all controllers 2017-11-21 11:54:08 +01:00
Lennart Poettering 5962e9db5e update TODO 2017-11-21 11:54:08 +01:00
Lennart Poettering 3c7416b6ca core: unify common code for preparing for forking off unit processes
This introduces a new function unit_prepare_exec() that encapsulates a
number of calls we do in preparation for spawning off some processes in
all our unit types that do so.

This allows us to neatly unify a bit of code between unit types and
shorten our code.
2017-11-21 11:54:08 +01:00
Lennart Poettering 6925a0de4e cgroup-util: move Set* allocation into cg_kernel_controllers()
Previously, callers had to do this on their own. Let's make the call do
that instead, making the caller code a bit shorter.
2017-11-21 11:54:08 +01:00
Lennart Poettering bf516294c8 nspawn: minor optimization
no need to prepare the target path if we quite the loop anyway one step
later.
2017-11-21 11:54:08 +01:00
Lennart Poettering d7c9693a3e nspawn-mount: rework get_controllers() a bit
Let's rename get_controllers() → get_process_controllers(), in order to
underline the difference to cg_kernel_controllers(). After all, one
returns the controllers available to the process, the other the
controllers enabled in the kernel at all).

Let's also update the code to use read_line() and set_put_strdup() to
shorten the code a bit, and make it more robust.
2017-11-21 11:54:08 +01:00
Lennart Poettering ea9053c5f8 nspawn: rework mount_systemd_cgroup_writable() a bit
We shouldn't call alloca() as part of function calls, that's not really
defined in C. Hence, let's first do our stack allocations, and then
invoke functions.

Also, some coding style fixes, and minor shuffling around.

No functional changes.
2017-11-21 11:54:08 +01:00
Lennart Poettering 68ac0d05a9 cgroup: move cgroup controller names def.h → cgroup-util.h
These definitions are clearly cgroup specific, hence let's move them out
of def.h
2017-11-21 11:54:08 +01:00
Susant Sahani 762e2659b9 networkd: support incoming/outgoing device for rule matching (#7223)
Closes #7210
2017-11-21 11:51:50 +01:00
Lennart Poettering 190654f44b test: fix UDEV-WANTS testcase for non-bash shells
testsuite.sh uses "set -o pipefile", which is a bashism, hence use bash
to invoke the script.
2017-11-21 11:37:28 +01:00
Lennart Poettering 654c87e0e6 udev: port udev_has_devtmpfs() to use path_get_mnt_id()
This means there's a good chance the code also works on kernels that
lack name_to_handle_at().
2017-11-21 11:37:12 +01:00
Lennart Poettering c2a986d509 mount-util: add new path_get_mnt_id() call that queries the mnt ID of a path
This is a simple wrapper around name_to_handle_at_loop() and
fd_fdinfo_mnt_id() to query the mnt ID of a path. It uses
name_to_handle_at() where it can, and falls back to to
fd_fdinfo_mnt_id() where that doesn't work.

This is a best-effort thing of course, since neither name_to_handle_at()
nor the fdinfo logic work on all kernels.
2017-11-21 11:37:12 +01:00
Lennart Poettering cbfb8679dd mount-util: add name_to_handle_at_loop() wrapper around name_to_handle_at()
As it turns out MAX_HANDLE_SZ is a lie, the handle buffer we pass into
name_to_handle_at() might need to be larger than MAX_HANDLE_SZ, and we
thus need to invoke name_to_handle_at() in a loop, growing the buffer as
needed.

This adds a new wrapper name_to_handle_at_loop() around
name_to_handle_at() that does the necessary looping, and ports over all
users.

Fixes: #7082
2017-11-21 11:37:12 +01:00
Lennart Poettering 213242a36b man: bootup(7) is one of our own man pages 2017-11-21 11:01:34 +01:00
Lennart Poettering e68537f0ba core: make use of unit_active_or_pending() where we can
Let's make use of unit_active_or_pending() where we can. Note that this
change changes beaviour in one specific case: when shutdown.target is
active we'll now also return that the system is in "stopping" state, not
only when we try to get into it. That makes sense as shutdown.target is
ordered before the actually shutdown units such as
"systemd-poweroff.service", and if the state is queried between reaching
those we should also report "stopping".
2017-11-21 11:01:34 +01:00
Lennart Poettering 49d5666cc5 manager: introduce MANAGER_IS_FINISHED() macro
Let's make our finished checks a bit more readable. Checking the
timestamp is not entirely obvious, hence let's abstract that a bit by
adding a macro that shows what we are doing here, not how we doing it.

This is particularly useful if we want to change the definition of
"finished" later on, in particular, when we try to fix #7023.
2017-11-21 11:01:34 +01:00
Lennart Poettering 713f6f901d manager: add manager_get_dump_string()
It's like manager_dump(), but returns a string. This allows us to reduce
some duplicate code. Also, while we are at it, turn off stdio locking
while we write to the memory FILE *f.
2017-11-21 11:01:34 +01:00
Lennart Poettering ad75b9e765 core: add manager_dump() call, and make it output timestamp data
It's a wrapper around manager_dump_units() and manager_dump_jobs(), and
outputs some additional timestamp data.

Also, port two users of this over.
2017-11-21 10:22:28 +01:00
Lennart Poettering 9f9f034271 manager: rework the timestamps logic, so that they are an enum-index array
This makes things quite a bit more systematic I think, as we can
systematically operate on all timestamps, for example for the purpose of
serialization/deserialization.

This rework doesn't necessarily make things shorter in the individual
lines, but it does reduce the line count a bit.

(This is useful particularly when we want to add additional timestamps,
for example to solve #7023)
2017-11-21 10:22:28 +01:00
Shawn Landden 172378e01b shared: silence gcc warning (#7402)
[346/1860] Compiling C object 'src/shared/systemd-shared-235@sha/firewall-util.c.o'.
../src/shared/firewall-util.c: In function ‘entry_fill_basics’:
../src/shared/firewall-util.c:81:79: warning: logical ‘and’ of equal expressions [-Wlogical-op]
[543/1860] Compiling C object 'src/shared/systemd-shared-235@sta/firewall-util.c.o'.
../src/shared/firewall-util.c: In function ‘entry_fill_basics’:
../src/shared/firewall-util.c:81:79: warning: logical ‘and’ of equal expressions [-Wlogical-op]
2017-11-21 08:24:12 +01:00
Shawn Landden 23d37367ed NEWS: fix minor error (#7399) 2017-11-21 11:05:57 +09:00
Shawn Landden 4831981d89 tree-wide: adjust fall through comments so that gcc is happy
Distcc removes comments, making the comment silencing
not work.

I know there was a decision against a macro in commit
ec251fe7d5
2017-11-20 13:06:25 -08:00
lukas d8bd96ab54 hwdb: Add ACCEL_MOUNT_MATRIX for the Acer Aspire Switch 10 convertible
SW5-012 (#7394)
2017-11-20 20:26:38 +01:00
Zbigniew Jędrzejewski-Szmek 7624e721c8 test: fall back to /boot if bootctl -p fails (#7397)
It doesn't really matter why.
2017-11-20 20:08:11 +01:00
Susant Sahani 444b017046 networkd: configure link even if no routes have been received by dhcp (#6886)
Fixes #3752

 networkctl
IDX LINK             TYPE               OPERATIONAL SETUP
  1 lo               loopback           carrier     unmanaged
  2 eth0             ether              no-carrier  configuring
  5 host             ether              routable    configured <==========

5 links listed.
2017-11-20 19:23:34 +01:00
Lennart Poettering 8c6f6a2f91
Merge pull request #6910 from ssahani/issue-6359
networkd: For IPv6 addresses do not treat IFA_F_DEPRECATED as not ready. (Fix #6359)
2017-11-20 19:21:36 +01:00
Lennart Poettering 4ff971ac08
Merge pull request #6918 from ssahani/issue-5625
networkd: ndisc - do not stop ndisc client incase of conf error.
2017-11-20 19:20:23 +01:00
Susant Sahani e87e2b78f7 networkd: address - support for /31 IPv4 addresses (rfc3021) (#6938)
When configuring a network address with /31 using networkd, a /31 without a
broadcast specified should be present.

 A /31 which has neither a network nor a broadcast address. See
https://tools.ietf.org/html/rfc3021

Fixes #4038
2017-11-20 19:16:01 +01:00
Susant Sahani a63e5daaa3 networkd: Do not send requests to create netdevs if they exists. (#6973)
If the netdev already exists we should not send requests to
kernel to create them.

fixes #5448
2017-11-20 18:58:06 +01:00
Susant Sahani 8a9b3a23fd networkd: Set RoutingPolicyRule in link_configure (#7235)
The RoutingPolicyRules are not added when we are calling from set_address
the link->message++ and link->message-- never reaches to zero in the callback function
resulting routes are never gets added.

Closes #7200
2017-11-20 17:50:48 +01:00
Lennart Poettering 6ca7d231ed machinectl: show (some) of the new image metadata bits in "status-image" output
Let's hook it all up, and show the image metadata among the rest of the
output.
2017-11-20 16:43:15 +01:00
Lennart Poettering cf30a8c1ed machined: port machined's bus APIs to use new image metadata API
Let's rework the D-Bus APIs GetImageOSRelease() to use the new internal
metadata API, to query what it needs to know. Augment it with
GetImageHostname(), GetImageMachineID(), GetImageMachineInfo(), that
expose the other new APIS.
2017-11-20 16:43:15 +01:00
Lennart Poettering c7664c071e machine-image: add a generic API to determine metadata of any image
This adds an internal API that permits querying metadata from any type
of image, including both subvol/dir images, and raw/block images. In the
latter case we use the new dissection API we just added.
2017-11-20 16:43:15 +01:00
Lennart Poettering a1edd22e67 dissect: update dissect tool to show image metadata
Pretty straight-forward: just use the new metadata dissection API to
figure out what an image contains.
2017-11-20 16:43:15 +01:00
Lennart Poettering 3b92550417 dissect: add an API that can read various metadata bits out of a dissected image
We focus on four kinds of metadata:

1. /etc/hostname
2. /etc/machine-id
3. /etc/machine-info
4. /etc/os-release or /usr/lib/os-release

This makes dissected images nicely self-contained as we can figure out
what they are just by dissecting them.
2017-11-20 16:43:15 +01:00
Lennart Poettering b302a50d85 strv: introduce strv_free_and_replace()
it's like free_and_replace() but uses strv_free()
2017-11-20 16:43:15 +01:00
Lennart Poettering 7c78959fc2 signal-util: use a slightly less likely to conflict variable name instead of 't' 2017-11-20 16:43:15 +01:00
Lennart Poettering f35cb39ed6 hostname-util: rework read_hostname_config() a bit
First of all, let's rename it to read_etc_hostname(), to make clearer
what kind of configuration it actually reads: the file format defined in
/etc/hostname and nothing else.

Secondly: let's port this to use read_line(), i.e. the new way to read
lines from a file in a safe, bounded way.

Thirdly: let's strip leading/trailing whitespace from what we are
reading. Given that we are already pretty lenient what we read (comments
and empty lines), let's be permissive regarding whitespace too.

Fourthly: let's actually validate the hostname when reading it. So far
we tried to make it valid, but that's not always possible (for example,
we can't make an empty hostname valid, ever).
2017-11-20 16:43:15 +01:00
Lennart Poettering 9a92a97a94 update TODO 2017-11-20 16:37:22 +01:00
Lennart Poettering 24aab7936c test: add testcase for FailureAction=/SuccessAction=
it also ensures that rebooting once gets us back up. Yay!
2017-11-20 16:37:22 +01:00
Lennart Poettering e7dfbb4e74 core: introduce SuccessAction= as unit file property
SuccessAction= is similar to FailureAction= but declares what to do on
success of a unit, rather than on failure. This is useful for running
commands in qemu/nspawn images, that shall power down on completion. We
frequently see "ExecStopPost=/usr/bin/systemctl poweroff" or so in unit
files like this. Offer a simple, more declarative alternative for this.

While we are at it, hook up failure action with unit_dump() and
transient units too.
2017-11-20 16:37:22 +01:00
Lennart Poettering 53c35a766f core: generalize FailureAction= move it from service to unit
All kinds of units can fail, hence it makes sense to offer this as
generic concept for all unit types.
2017-11-20 16:37:22 +01:00
Zbigniew Jędrzejewski-Szmek 9990ea0e59
Merge pull request #7375 from poettering/readme-updates
some README updates
2017-11-20 14:46:02 +01:00
Zbigniew Jędrzejewski-Szmek 5d9adb5b60 man: fix description of --force in halt(8) (#7392)
https://bugzilla.redhat.com/show_bug.cgi?id=1449751
2017-11-20 14:27:46 +01:00
Lennart Poettering 4ff183d419
Merge pull request #7154 from keszybz/bootspec
List bootspec entries in bootctl and use the default for kexec
2017-11-20 13:06:33 +01:00