Commit Graph

48319 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 536970d4f9 hostnamed: minor style cleanups 2020-12-16 11:02:18 +01:00
Zbigniew Jędrzejewski-Szmek efda832d4f hostnamed: when hostname is set to existing value, suppress notifications
When the hostname is set through network config or such, let's
optimize things a bit by suppressing the logs and dbus notifications.
2020-12-16 11:02:17 +01:00
Zbigniew Jędrzejewski-Szmek 39ede7cc37 shared/hostname-setup: leave the terminator byte alone
gethostname(3) says it's unspecified whether the string is properly terminated
when the hostname is too long. We created a buffer with one extra byte, and it
seems the intent was to let that byte serve as terminator even if we get an
unterminated string from gethostname().
2020-12-16 11:02:17 +01:00
Zbigniew Jędrzejewski-Szmek b6fad30665 shared/hostname-setup: add mode where we check what would be set, without doing
This allows the 'unsafe' mark to be removed from the test.
2020-12-16 11:02:17 +01:00
Zbigniew Jędrzejewski-Szmek e2054217d5 Move hostname setup logic to new shared/hostname-setup.[ch]
No functional change, just moving a bunch of things around. Before
we needed a rather complicated setup to test hostname_setup(), because
the code was in src/core/. When things are moved to src/shared/
we can just test it as any function.

The test is still "unsafe" because hostname_setup() may modify the
hostname.
2020-12-16 11:02:15 +01:00
Zbigniew Jędrzejewski-Szmek 7d9ec60990 hostnamed: fix return value 2020-12-16 10:54:57 +01:00
Zbigniew Jędrzejewski-Szmek ce6b138c75 hostnamed: expose the fallback-hostname setting as a const dbus property
Various users want to know what the fallback hostname is. Since it was made
configurable in 8146c32b92, we didn't expose this
nicely.
2020-12-16 10:54:57 +01:00
Zbigniew Jędrzejewski-Szmek de31bbc6b1 man/hostnamectl,hostaned,hostname1: adjust the docs to match reality
The semantics were significantly changed in c779a44222
("hostnamed: Fix the way that static and transient host names interact", Feb. 2014),
but when the dbus api documentation was imported much later, it wasn't properly
adjusted to describe those new semantics.

34293dfafd which added systemd.hostname= also
added new behaviour.

Let's ove various bits and pieces around so that they are in more appropriate
places. Drop recommendations to set the hostname for DHCP or mDNS purposes.
Nowadays we expect tools that want to expose some different hostname to the
outside to manage that internally without affecting visible state. Also drop
mentions of DHCP or mDNS directly setting the hostname, since nowadays network
management software is expected to (and does) go through hostnamed.

Also, add a high-level description of semantics. It glosses over the details of
handling of localhost-style names. Later commits will remove this special handling
anyway.
2020-12-16 10:54:57 +01:00
Michal Fabik a2be8be2cf coredumpctl: Add --debugger-args= option
This commit adds the possibility to pass command line options to the
debugger invoked with coredumpctl debug.

Resolves: #9905
2020-12-16 12:42:53 +09:00
Yu Watanabe a7c52e1ee1
Merge pull request #17968 from yuwata/purge-libudev
udev: do not link with libudev
2020-12-16 12:07:46 +09:00
Susant Sahani 937e305e93 network: Allow to configure interface promiscuous mode 2020-12-15 20:25:08 +00:00
Christian Ehrhardt 43b49470d1 test: use modern qemu numa arguments
Upgrading to qemu 5.2 breaks TEST-36-NUMAPOLICY like:
  qemu-system-x86_64: total memory for NUMA nodes (0x0) should
  equal RAM size (0x20000000)

Use the new (as in >=2014) form of memdev in test 36:
 -object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0

Since some target systems are as old as qemu 1.5.3 (CentOS7) but the new
kind to specify was added in qemu 2.1 this needs to add version parsing and
add the argument only when qemu is >=5.2.

Fixes #17986.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
2020-12-16 05:16:41 +09:00
Lennart Poettering 94b78105c6
Merge pull request #17967 from poettering/connect-user-bus
add support for "systemctl --user --machine=foobar@.host" for connecting to user bus of user "foobar"
2020-12-15 21:14:01 +01:00
d032747 6fe2a70b91 busctl: add a timestamp to the output of the busctl monitor command 2020-12-16 05:06:56 +09:00
Yu Watanabe 3a23834d6b
Merge pull request #17908 from ddstreet/dhcpv4_rfc2131_intervals
Fix dhcpv4 renew/rebind intervals to match rfc2131
2020-12-16 05:05:06 +09:00
Yu Watanabe ebd04379cd udev: drop license boilerplate 2020-12-16 02:31:44 +09:00
Yu Watanabe 90ac73eb1b rules: drop broken links 2020-12-16 02:31:44 +09:00
Yu Watanabe e4b127e2cc meson: do not link with libudev 2020-12-16 02:31:44 +09:00
Yu Watanabe 1403fe26d6 udev: drop unnecessary libudev-util.h inclusions 2020-12-16 02:31:44 +09:00
Yu Watanabe b653abbb1a udevadm: drop udev_queue 2020-12-16 02:31:30 +09:00
Yu Watanabe bee33d0527 udev: introduce udev_queue_is_empty() and udev_queue_init() 2020-12-16 02:28:08 +09:00
Yu Watanabe 0746a5ee4c libudev: fix indentation 2020-12-16 02:23:13 +09:00
Yu Watanabe dae28211b7 libudev: drop unnecessary headers from libudev-util.c 2020-12-16 02:23:13 +09:00
Yu Watanabe 2b0f5113b4 udev: use encode_devnode_name() instead of udev_util_encode_string()
As udev_util_encode_string() is a simple wrapper of
encode_devnode_name().
2020-12-16 02:23:13 +09:00
Yu Watanabe c8eaaf69ac udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friends
This also moves them to udev-util.h
2020-12-16 02:22:58 +09:00
Yu Watanabe 1223227f95 udev: move util_resolve_subsys_kernel() to udev-util.c 2020-12-16 02:14:47 +09:00
Yu Watanabe 393fcaf733 udev: move util_replace_chars() to udev-util.c 2020-12-16 02:14:47 +09:00
Yu Watanabe 9a56b87717 udev: move util_path_encode() and rename it to escape_path() 2020-12-16 02:14:47 +09:00
Yu Watanabe 5953d8b910 udev: move util_replace_whitespace() to udev-util.c 2020-12-16 02:14:47 +09:00
shenyangyang4 b17f651a17 journalctl: don't skip the entries that have the same seqnum
These two judgement can't judge that two entries are repeating fully.
So i think seqnum is needed to make full judgement.
2020-12-15 18:07:11 +01:00
Lennart Poettering 1ecb46724c bus-util: improve logging when we can't connect to the bus
Previously, we'd already have explicit logging for the case where
$XDG_RUNTIME_DIR is not set. Let's also add some explicit logging for
the EPERM/ACCESS case. Let's also in both cases suggest the
--machine=<user>@.host syntax.

And while we are at it, let's remove side-effects from the macro.

By checking for both the EPERM/EACCES case and the $XDG_RUNTIME_DIR case
we will now catch both the cases where people use "su" to issue a
"systemctl --user" operation, and those where they (more correctly, but
still not good enough) call "su -".

Fixes: #17901
2020-12-15 18:01:23 +01:00
Lennart Poettering cedfd142de stdio-bridge: add support for --system and --user
So far, the bridge always acted as if "--system" was used, i.e. would
unconditionally connect to the system bus. Let's add "--user" too, to
connect to the users session bus.

This is mostly for completeness' sake.

I wanted to use this when making sd-bus's ability to connect to other
user's D-Bus busses work, but it didn't exist so far. In the interest of
keeping things compatible the implementation in sd-bus will not use the
new "--user" switch, and instead manually construct the right bus path
via "--path=", but we still should add the proper switches, as
preparation for a brighter future, one day.
2020-12-15 18:01:20 +01:00
Lennart Poettering ba4a31b7a6 man: document new ability to connect to user of container 2020-12-15 18:01:01 +01:00
Lennart Poettering 1b630835df sd-bus: add API for connecting to a specific user's user bus of a specific container
This is unfortunately harder to implement than it sounds. The user's bus
is bound a to the user's lifecycle after all (i.e. only exists as long
as the user has at least one PAM session), and the path dynamically (at
least theoretically, in practice it's going to be the same always)
generated via $XDG_RUNTIME_DIR in /run/.

To fix this properly, we'll thus go through PAM before connecting to a
user bus. Which is hard since we cannot just link against libpam in the
container, since the container might have been compiled entirely
differently. So our way out is to use systemd-run from outside, which
invokes a transient unit that does PAM from outside, doing so via D-Bus.
Inside the transient unit we then invoke systemd-stdio-bridge which
forwards D-Bus from the user bus to us. The systemd-stdio-bridge makes
up the PAM session and thus we can sure tht the bus exists at least as
long as the bus connection is kept.

Or so say this differently: if you use "systemctl -M lennart@foobar"
now, the bus connection works like this:

        1. sd-bus on the host forks off:

                systemd-run -M foobar -PGq --wait -pUser=lennart -pPAMName=login systemd-stdio-bridge

        2. systemd-run gets a connection to the "foobar" container's
           system bus, and invokes the "systemd-stdio-bridge" binary as
           transient service inside a PAM session for the user "lennart"

        3. The systemd-stdio-bridge then proxies our D-Bus traffic to
           the user bus.

sd-bus (on host) → systemd-run (on host) → systemd-stdio-bridge (in container)

Complicated? Well, to some point yes, but otoh it's actually nice in
various other ways, primarily as it makes the -H and -M codepaths more
alike. In the -H case (i.e. connect to remote host via SSH) a very
similar three steps are used. The only difference is that instead of
"systemd-run" the "ssh" binary is used to invoke the stdio bridge in a
PAM session of some other system. Thus we get similar implementation and
isolation for similar operations.

Fixes: #14580
2020-12-15 18:00:15 +01:00
Lennart Poettering 1ca37419b1 sd-bus: 'ret' parameter to sd_bus_query_sender_creds() is not optional, check for it 2020-12-15 18:00:11 +01:00
Lennart Poettering f8ecc2c00d sd-bus: make credential acquisition more graceful
So far when asked for augmented bus credentials and the process was
already gone we'd fail fatally. Let's make this graceful instead, and
never allow augmenting fail due to PID having vanished — unless the
augmenting is the explicit and only purpose of the requested operation.

This should be safe as clients have to explicitly query the acquired
creds anyway and handle if they couldn't be acquired. Moreover we
already handle permission problems gracefully, thus clients must be
ready to deal with missing creds.

This is useful to make selinux authorization work for short-lived client
proceses. PReviously we'd augment creds to have more info to log about
(the selinux decision would not be based on augmented data however,
because that'd be unsafe), and would fail if we couldn't get it. Now,
we'll try to acquire the data, but if we cannot acquire it, we'll still
do the selinux check, except that logging will be more limited.
2020-12-15 18:00:06 +01:00
Lennart Poettering 79485fc27a firstboot: clean-up the copied hostname, not argv[] directly, as that's ugly 2020-12-15 18:00:02 +01:00
Lennart Poettering d4e9809465 hostname-setup: clarify that failures reading /etc/hostname are ignored 2020-12-15 17:59:58 +01:00
Lennart Poettering 52ef5dd798 hostname-util: flagsify hostname_is_valid(), drop machine_name_is_valid()
Let's clean up hostname_is_valid() a bit: let's turn the second boolean
argument into a more explanatory flags field, and add a flag that
accepts the special name ".host" as valid. This is useful for the
container logic, where the special hostname ".host" refers to the "root
container", i.e. the host system itself, and can be specified at various
places.

let's also get rid of machine_name_is_valid(). It was just an alias,
which is confusing and even more so now that we have the flags param.
2020-12-15 17:59:48 +01:00
Lennart Poettering 9e815cf2c2 hostname-util: explain what 'LDH' is 2020-12-15 17:59:44 +01:00
Lennart Poettering 1feb8eee2d logs-show: drop redundant validation of machine name
The immediately following container_get_leader() call validate the name
anyway, no need to twice exactly the same way twice immediately after
each other.
2020-12-15 17:59:41 +01:00
Lennart Poettering c4dd2d7575 machine: drop really old kdbus left-over
The "x-machine-kernel" dbus address has been removed a long time ago,
hence don't generate it either.
2020-12-15 17:59:37 +01:00
Lennart Poettering 68a3d91538 sd-bus: use SOCK_CLOEXEC on one more socket 2020-12-15 17:58:40 +01:00
Gaurav fa8342228b Fix review comments in added debug log. 2020-12-15 17:47:03 +01:00
Gaurav d66b0ed4cc Fix build warning. 2020-12-15 17:47:03 +01:00
Gaurav 6ef03f7a0d Handle escape characters in interface name
Updated the patch as per review comments.
2020-12-15 17:47:03 +01:00
Gaurav 17f8a21fd0 Detect special character in dbus interface name
Added debug log to detect special character in dbus interface names.
Helps to detect a case mentioned in https://github.com/systemd/systemd/issues/14636
2020-12-15 17:47:03 +01:00
Fabian Affolter 04b2224957 Translated using Weblate (German)
Currently translated at 61.4% (115 of 187 strings)

Co-authored-by: Fabian Affolter <mail@fabian-affolter.ch>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/de/
Translation: systemd/master
2020-12-15 17:40:56 +01:00
Ondrej Mosnacek 7b87bece5d resolved: create stub-resolv.conf symlink with correct security label
Use symlink_atomic_label() instead of symlink_atomic() as the symlink
may need a different label than the parent directory.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
2020-12-15 14:12:08 +01:00
Yu Watanabe fc874bf3bf
Merge pull request #17977 from yuwata/namespace-mount-procfs-follow-up
core/namespace: do not ignore non-EPERM mount error
2020-12-15 12:07:30 +09:00