Commit graph

30075 commits

Author SHA1 Message Date
Lennart Poettering 5895a9d600
Merge pull request #16874 from poettering/analyze-cap
introduce "systemd-analyze capability" command for dumping locally defined caps
2020-08-28 21:01:56 +02:00
Daniel Mack 5170afbc55 clock-util: read timestamp from /usr/lib/clock-epoch
On systems without an RTC, systemd currently sets the clock to a
compile-time epoch value, derived from the NEWS file in the
repository. This is not ideal as the initial clock hence depends
on the last time systemd was built, not when the image was compiled.

Let's provide a different way here and look at `/usr/lib/clock-epoch`.
If that file exists, it's timestamp for the last modification will be
used instead of the compile-time default.
2020-08-28 18:58:22 +02:00
Lennart Poettering b2af819b22 analyze: add 'capability' verb for dumping all known and unknown caps 2020-08-28 18:52:48 +02:00
Lennart Poettering 0f849d0af9 analyze: fix error handling in one case 2020-08-28 18:14:53 +02:00
Lennart Poettering 524bdc95e7 basic: make sure we include inttypes.h when we use its types 2020-08-28 18:14:35 +02:00
fangxiuning c53aafb7b5
tree-wide: drop pointless zero initialization (#16884)
tree-wide: drop pointless zero initialization
2020-08-28 17:45:54 +02:00
Lennart Poettering cd17bb6e71 networkd: consider any uevent other than "remove" sufficient for the network device to be ready 2020-08-28 17:45:05 +02:00
Ikey Doherty 97207ac85c login/logind: Include sys/stat.h for struct stat usage
We need to include `<sys/stat.h>` for usage of the `struct stat` in
the Manager struct, much as we already include `<stdbool.h>` for C99
booleans.

This helps alleviate another minor build failure on non-glibc systems.
2020-08-28 17:44:39 +02:00
Plan C b23728ec9f
Add simple usage message to systemd-backlight (#16709) 2020-08-28 13:50:35 +02:00
Ikey Doherty 677bb0555a partition/makefs: Include missing sys/file.h header
This file must be included on non-glibc systems to ensure
the `LOCK_EX` definition is available.

Signed-off-by: Ikey Doherty <ikey.doherty@lispysnake.com>
2020-08-28 13:32:09 +02:00
Lennart Poettering ae6ad21e0b device: propagate reload events from devices on everything but "add", and "remove"
Any uevent other then the initial and the last uevent we see for a
device (which is "add" and "remove") should result in a reload being
triggered, including "bind" and "unbind". Hence, let's fix up the check.

("move" is kinda a combined "remove" + "add", hence cover that too)
2020-08-28 13:30:13 +02:00
Zbigniew Jędrzejewski-Szmek c1afa2ed39
Merge pull request #16879 from keszybz/test-last-cap-and-dbus-docs
Add "developer mode" and test last cap and dbus docs
2020-08-28 08:30:00 +02:00
Yu Watanabe 876dc2b014 network: dhcp6: logs only new address
Closes #16731.
2020-08-27 21:24:07 +02:00
Zbigniew Jędrzejewski-Szmek b7be416f55 basic/missing_capability: clean up our defines and check that our fallback is up-to-date
There is little point in #defining and #undefining CAP_LAST_CAP multiple times.

The check is only done in developer mode. After all, it's not an error to
compile on a newer kernel, and we shouldn't even warn in that case.
2020-08-27 20:20:23 +02:00
Zbigniew Jędrzejewski-Szmek c87d0661a0 test-path: remove unnecessary check
test points to an array, so it canont be NULL at this point.
2020-08-27 20:20:23 +02:00
Daan De Meyer f17bdf8264 Don't run test-repart when loop devices are not available 2020-08-27 17:14:58 +02:00
Lennart Poettering df92f4fa8d
Merge pull request #16864 from yuwata/coverity-fixes
Two coverity fixes
2020-08-27 16:36:40 +02:00
Lennart Poettering 4fc14c345f
Merge pull request #16866 from yuwata/networkctl-tiny-cleanups
networkctl: tiny cleanups
2020-08-27 16:34:43 +02:00
Michal Koutný 94d21c2ef6 missing: Add new Linux capability
Yet another new capability coming in Linux kernel v5.9.
Make sure we can recongize them even when built with older kernel headers.
2020-08-27 16:13:09 +02:00
Yu Watanabe 89d36ce8f7 journal: fix divide-by-zero warning
Fixes CID#1430209.
2020-08-27 18:20:34 +09:00
Yu Watanabe 8062e643e6 core: clear bind mounts on error
Follow-up for bbb4e7f39f.

Fixes CID#1431998.
2020-08-27 18:20:34 +09:00
Zbigniew Jędrzejewski-Szmek 67165f7630
Merge pull request #16860 from poettering/tty-ask-pw-agent-list-fix
tty-ask-password-agent: three fixes
2020-08-27 10:58:13 +02:00
Yu Watanabe df696b1413 networkctl: label command does not take any argument 2020-08-27 16:32:13 +09:00
Lennart Poettering 25f3b27270 udev: use path_startswith() instead of startswith() in two more cases 2020-08-27 16:16:43 +09:00
PhoenixDiscord e8607daf7d
Replace gendered pronouns with gender neutral ones. (#16844) 2020-08-27 11:52:48 +09:00
Chris Down 33e1a5d8d3 path: Improve $PATH search directory case
Previously:

1. last_error wouldn't be updated with errors from is_dir;
2. We'd always issue a stat(), even for binaries without execute;
3. We used stat() instead of access(), which is cheaper.

This change avoids all of those, by only checking inside X_OK-positive
case whether access() works on the path with an extra slash appended.
Thanks to Lennart for the suggestion.
2020-08-27 00:52:20 +01:00
Lennart Poettering a4fd6cd3f5 tty-ask-pw-agent: properly propagate error 2020-08-26 23:10:50 +02:00
Lennart Poettering 66bff73b4f tty-ask-pw-agent: the message string might not be set 2020-08-26 23:10:05 +02:00
Lennart Poettering 4c4a018cab tty-ask-pw-agent: make sure "--list" works correctly
Fixes: #16836
2020-08-26 23:02:13 +02:00
Lennart Poettering 0c73f4f075 nss-resolve: port over to new varlink interface 2020-08-26 16:48:16 +02:00
Lennart Poettering 9581bb8424 resolved: add minimal varlink api for resolving hostnames/addresses
This allows us to later port nss-resolve to use Varlink rather than
D-Bus for resolution. This has the benefit that nss-resolve based
resoluton works even without D-Bus being up. And it's faster too.
2020-08-26 16:48:06 +02:00
Lennart Poettering c17b5ce739 resolved: minor clean-ups for resolved-bus.c 2020-08-26 16:48:02 +02:00
Lennart Poettering 65a01e8242 resolved: move query bus tracking to resolved-bus.c
It's strictly bus-specific, hence let's move this to resolved-bus.c like
the rest of the bus specific logic.

This is also in preparation for adding an alternative varlink transport,
which needs similar functionality, but varlink instead of bus-specific.
2020-08-26 16:47:57 +02:00
Lennart Poettering c9de4e0f5b resolved: rename request → bus_request
Let's prepare for adding a new varlink interface, and thus rename the
"request" field to "bus_request", so that we can later add a
varlink_request field too.
2020-08-26 16:47:53 +02:00
Lennart Poettering d4f72f0d21 resolved: drop suppress_unroutable_family field
It's unused since 90bdc8be66.
2020-08-26 16:47:49 +02:00
Lennart Poettering b97e3e3d7a json: also add explicit dispatchers for 'int' and 'unsigned' 2020-08-26 16:47:32 +02:00
Lennart Poettering 0710343ce7 json: add support for byte arrays to json builder 2020-08-26 16:47:16 +02:00
Lennart Poettering 7466e94f13 varlink: add helper for generating errno errors 2020-08-26 16:46:57 +02:00
Lennart Poettering c7dfa1df8b in-addr-util: add byte accessor array to union in_addr_union
It's pretty useful to be able to access the bytes generically, without
acknowledging a specific family, hence let's a third way to access an
in_addr_union.
2020-08-26 16:46:12 +02:00
Zbigniew Jędrzejewski-Szmek b6abc2acb4
Merge pull request #16568 from poettering/creds-store
credentials logic to pass privileged data to services
2020-08-26 10:32:30 +02:00
Chris Down 8b5cb69bc8 path: Skip directories when finalising $PATH search
Imagine $PATH /a:/b. There is an echo command at /b/echo. Under this
configuration, this works fine:

    % systemd-run --user --scope echo .
    Running scope as unit: run-rfe98e0574b424d63a641644af511ff30.scope
    .

However, if I do `mkdir /a/echo`, this happens:

    % systemd-run --user --scope echo .
    Running scope as unit: run-rcbe9369537ed47f282ee12ce9f692046.scope
    Failed to execute: Permission denied

We check whether the resulting file is executable for the performing
user, but of course, most directories are anyway, since that's needed to
list within it. As such, another is_dir() check is needed prior to
considering the search result final.

Another approach might be to check S_ISREG, but there may be more gnarly
edge cases there than just eliminating this obviously pathological
example, so let's just do this for now.
2020-08-26 10:22:02 +02:00
Vito Caputo d4739bc4d3 sd-journal: narrow scope of boot id variable
Something trivial I noticed during some unrelated code spelunking
2020-08-25 22:41:35 +02:00
Lennart Poettering 3652872add nspawn: add --set-credential= and --load-credential=
Let's allow passing in creds to containers, so that PID 1 inside the
container can pick them up.
2020-08-25 19:45:47 +02:00
Lennart Poettering bbb4e7f39f core: hide /run/credentials whenever namespacing is requested
Ideally we would like to hide all other service's credentials for all
services. That would imply for us to enable mount namespacing for all
services, which is something we cannot do, both due to compatibility
with the status quo ante, and because a number of services legitimately
should be able to install mounts in the host hierarchy.

Hence we do the second best thing, we hide the credentials automatically
for all services that opt into mount namespacing otherwise. This is
quite different from other mount sandboxing options: usually you have to
explicitly opt into each. However, given that the credentials logic is a
brand new concept we invented right here and now, and particularly
security sensitive it's OK to reverse this, and by default hide
credentials whenever we can (i.e. whenever mount namespacing is
otherwise opt-ed in to).

Long story short: if you want to hide other service's credentials, the
most basic options is to just turn on PrivateMounts= and there you go,
they should all be gone.
2020-08-25 19:45:38 +02:00
Lennart Poettering bb0c0d6f29 core: add credentials logic
Fixes: #15778 #16060
2020-08-25 19:45:35 +02:00
Lennart Poettering 9db59d9283 acl-util: beef up add_acls_for_user()
Let's add support for controlling r/w/x bits separetely. This is useful
for using it to control access to directories, where r + x shall be
enabled.
2020-08-25 18:39:45 +02:00
Lennart Poettering 71281a7655 acl-util: make sure acl_find_uid() initializes return parameters on success
Let's follow our usual coding style and initialize return parameters on
success in all cases.
2020-08-25 18:39:45 +02:00
Lennart Poettering 2899fb024f rm-rf: add new flag REMOVE_CHMOD
When removing a directory tree as unprivileged user we might encounter
files owned by us but not deletable since the containing directory might
have the "r" bit missing in its access mode. Let's try to deal with
this: optionally if we get EACCES try to set the bit and see if it works
then.
2020-08-25 18:39:45 +02:00
Lennart Poettering 9be99f81a7 homed: report a home directory as "dirty" if image file has dirty flag 2020-08-25 18:18:56 +02:00
Lennart Poettering 565ac8b1c8 homed: mark LUKS loopback file as "dirty" via xattr when in use
Let's track the "dirty" state of a home directory backed by a LUKS
volume by setting a new xattr "home.home-dirty" on the backing file
whenever it is in use.

This allows us to later user this information to show a home directory
as "dirty". This is useful because we trim/allocate on log-out, and
if we don't do that a home directory will be larger than necessary. This
fact is something we should communicate to the admin.

The idea is that when an admin sees a user with a "dirty" home directory
they can ask them to log in, to clean up the dirty state, and thus trim
everything again.
2020-08-25 18:18:46 +02:00