Commit Graph

3597 Commits

Author SHA1 Message Date
Lennart Poettering 15308e5083 stat-util: don't try to open path on path_is_temporary_fs()
I mean, the old code at least used O_PATH, but still, we shouldn't
allocate/close an fd if we don't have to.
2021-01-06 23:26:08 +00:00
Lennart Poettering 2a4e1fd0d4 string-util: use GREEDY_ALLOC_ROUND_UP() in strextend()
This uses GREEDY_ALLOC_ROUND_UP() to grow the allocation size
exponentially. This should speed allocation loops up a bit, given
that we often call strextend() repeatedly in a loop on the same
buffer.
2021-01-06 17:25:12 +01:00
Lennart Poettering c2bc710b24 string-util: imply NULL termination of strextend() argument list
The trailing NULL in the argument list is now implied (similar to
what we already have in place in strjoin()).
2021-01-06 17:24:46 +01:00
Yu Watanabe 0b71a7e01d siphash: introduce siphash24_compress_safe() 2020-12-30 04:14:18 +09:00
Luca Boccassi 8bab802910 basic: add make_mount_point_inode helper
Creates a file or a directory depending on the source path, useful
for creating mount points.
2020-12-21 21:48:13 +01:00
Yu Watanabe 9f62de5762
Merge pull request #18011 from yuwata/trivial-fixes
Trivial fixes for recently merged PRs
2020-12-18 20:12:02 +09:00
Yu Watanabe fd4835bdf8
Merge pull request #17693 from yuwata/tmpfiles-compress-nocow-on-btrfs
tmpfiles: try to set file attributes one by one
2020-12-18 16:52:29 +09:00
Yu Watanabe ee672fd30b
Merge pull request #18009 from poettering/time-set-sync-target
tweaks for time-sync.target and time-set.target
2020-12-18 16:02:56 +09:00
Yu Watanabe ec87f63c0e meson: add missing headers 2020-12-18 13:05:19 +09:00
Yu Watanabe 459631a0f9 chattr-util: introduce fallback mode to set file attributes one by one 2020-12-18 12:33:43 +09:00
Lennart Poettering fe934b42e4 core: order timer units after both time-sync.target and time-set.target
If users do not enable a service like systemd-time-wait-sync.target
(because they don't want to delay boot for external events, such as an
NTP sync), then timers should still take the the weaker time-set.target
feature into account, so that the clock is at least monotonic.

Hence, order timer units after both of the targets: time-sync.target
*and* time-set.target. That way, the right thing will happen regardless
if people have no NTP server (and thus also no
systemd-time-wait-sync.service or equivalent) or, only have an NTP
server (and no systemd-time-wait-sync.service), or have both.

Ordering after time-set.target is basically "free". The logic it is
backed by should be instant, without communication with the outside
going on. It's useful still so that time servers that implement the
timestamp from /var/ logic can run in later boot.
2020-12-17 20:21:46 +01:00
Lennart Poettering 5f0ab16198 string-table: add private version of lookup macro with boolean fallback 2020-12-17 20:02:14 +01:00
Lennart Poettering 1403d48d61 sort-util: make cmp_int() generic, so that we can reuse it elsewhere 2020-12-17 20:01:02 +01:00
Lennart Poettering 73d874bacd homed: move homectl's recovery key generation/modhex code to src/shared/
This allows us to later reuse the code to generate recovery keys for
traditional LUKS volumes, too and share the code.
2020-12-17 19:57:18 +01:00
Lennart Poettering 95231c7215 test: fix fd_is_mount_point() check
So the currentl and only fd_is_mount_point() check is actually entirely
bogus: it passes "/" as filename argument, but that's not actually a
a valid filename, but an absolute path.

fd_is_mount_point() is written in a way tha the fd refers to a directory
and the specified path is a file directly below it that shall be
checked. The test call actually violated that rule, but still expected
success.

Let's fix this, and check for this explicitly, and refuse it.

Let's extend the test and move it to test-mountpoint-util.c where the
rest of the tests for related calls are placed.

Replaces: #18004
Fixes: #17950
2020-12-17 19:29:24 +01:00
Lennart Poettering ddbf960574 terminal-util: use 256 color mode for PID 1 output, too
Follow-up for: #17702

Alsoe, see earlier review comment: https://github.com/systemd/systemd/pull/17702#pullrequestreview-552329600
2020-12-17 09:15:26 +01:00
Lennart Poettering e4dde4e87d
Merge pull request #17702 from rnhmjoj/master
Extend $SYSTEMD_COLORS to switch colors mode
2020-12-16 19:26:40 +01:00
Lennart Poettering a8af734e75
Merge pull request #17026 from fw-strlen/nft_16
add networkd/nspawn nftables backend
2020-12-16 19:18:22 +01:00
Zbigniew Jędrzejewski-Szmek 60e4fb4240 hostnamed,shared/hostname-setup: expose the origin of the current hostname
In hostnamed this is exposed as a dbus property, and in the logs in both
places.

This is of interest to network management software and such: if the fallback
hostname is used, it's not as useful as the real configured thing. Right now
various programs try to guess the source of hostname by looking at the string.
E.g. "localhost" is assumed to be not the real hostname, but "fedora" is. Any
such attempts are bound to fail, because we cannot distinguish "fedora" (a
fallback value set by a distro), from "fedora" (received from reverse dns),
from "fedora" read from /etc/hostname.

/run/systemd/fallback-hostname is written with the fallback hostname when
either pid1 or hostnamed sets the kernel hostname to the fallback value. Why
remember the fallback value and not the transient hostname in /run/hostname
instead?
We have three hostname types: "static", "transient", fallback".
– Distinguishing "static" is easy: the hostname that is set matches what
  is in /etc/hostname.
– Distingiushing "transient" and "fallback" is not easy. And the
  "transient" hostname may be set outside of pid1+hostnamed. In particular,
  it may be set by container manager, some non-systemd tool in the initramfs,
  or even by a direct call. All those mechanisms count as "transient". Trying
  to get those cases to write /run/hostname is futile. It is much easier to
  isolate the "fallback" case which is mostly under our control.
And since the file is only used as a flag to mark the hostname as fallback,
it can be hidden inside of our /run/systemd directory.

For https://bugzilla.redhat.com/show_bug.cgi?id=1892235.
2020-12-16 11:03:36 +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
Florian Westphal bcd1a2bb5c linux: import nf_tables and nfnetlink headers from Linux 5.8
Will be used/needed in the upcoming nfnetlink/nftables support.
This follows existing model where kernel uapi headers are cached
locally.
2020-12-16 00:35:56 +01:00
rnhmjoj dcdd9030ba
basic/term-util: inline colors_enabled function
There is no need to cache colors_enabled because the function
is now simply calling get_color_mode, which is already cached.
2020-12-15 19:40:30 +01:00
rnhmjoj 25e4608b8b
tree-wide: avoid direct use of color macros 2020-12-15 19:29:42 +01:00
rnhmjoj c4fea19abb
basic/term-util: extend $SYSTEMD_COLORS
This commit extends $SYSTEMD_COLORS to an enum variable (compared to
a simple boolean) which specifies the "colors mode". This means that, in
addition to disabling colors altogether, it's now possible to restrict
the console output to 16 or 256 colors only.
2020-12-15 19:29:42 +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
Yu Watanabe 7843706caf
Merge pull request #17936 from keszybz/more-nss-logging
Add debug logging for varlink
2020-12-15 12:05:45 +09:00
Yu Watanabe 23d8003bb6 time-util: fix typo 2020-12-14 17:56:01 +01:00
Yu Watanabe 8d80f27530 sd-device: make TAGS= property prefixed and suffixed with ":"
The commit 6f3ac0d517 drops the prefix and
suffix in TAGS= property. But there exists several rules that have like
`TAGS=="*:tag:*"`. So, the property must be always prefixed and suffixed
with ":".

Fixes #17930.
2020-12-14 14:04:53 +09:00
Yu Watanabe ba9385d91f
Merge pull request #17928 from keszybz/nss-logging
Enable logging in nss modules
2020-12-14 09:48:23 +09:00
Zbigniew Jędrzejewski-Szmek b3a7915805 basic/log: add debug-level log_oom() variant
This is useful for contexts where only debug-level messages are allowed.
2020-12-11 08:22:41 +01:00
Zbigniew Jędrzejewski-Szmek 3c94f71472 Drop compat "gateway" name
Back in 5248e7e1f1 (July 2017) we moved over to
"_gateway", with the old name declared to be temporary measure. Since we're
doing a bunch of changes to resolved now, it seems to be a good moment to make
this simplification and not add support for the compat name in new code.
2020-12-10 20:44:41 +01:00
Zbigniew Jędrzejewski-Szmek 1f568ba13f basic/static-destruct: fix grammar in comment 2020-12-10 13:00:14 +01:00
Yu Watanabe 44cc6bfef0
Merge pull request #17877 from yuwata/missing-syscall-sort
missing: sort architectures in missing_syscall.h
2020-12-10 12:42:35 +09:00
Lennart Poettering 5e3effb1f3 virt: drop /proc/1/sched hack
On really old kernels (< 4.14+) a bug in /proc/1/sched handling in the
kernel could be used to determine whether we are running in a PID
namespace. This hasn't worked for a long time, and there's little point
in making things work on old kernels we can't make work on current
kernels, hence let's drop that old cruft.

See: #8153
2020-12-09 21:07:46 +01:00
Lennart Poettering 1c36b8bf53 log: add helper set sets log level in all realms
Prompted-by: #17903
2020-12-09 18:26:17 +01:00
Luca Boccassi 0727a75a3b
Merge pull request #17911 from yuwata/log-cli-program-use-journal
log: open journal when cli program run in a service unit
2020-12-09 14:30:32 +00:00
Lennart Poettering 1d9aa4d572 async: add trivial cleanup wrapper for asynchronous_close() 2020-12-09 10:07:52 +01:00
Yu Watanabe 13ee939784 log: open journal when cli program run in a service unit
Previously, cli programs like networkctl always use console for logging.
2020-12-09 14:44:02 +09:00
Yu Watanabe db987463fe log: make show_color variable tristate
Should not change any behavior.
2020-12-09 14:44:02 +09:00
Yu Watanabe 5941112e7e log: merge conditions to reduce indentation 2020-12-09 14:44:02 +09:00
Yu Watanabe 105bfc9e72 missing: update warning messages 2020-12-08 15:35:57 +09:00
Yu Watanabe 6451baba82 missing: add missing syscalls for ia64, m68k, sparc, arc, and tilegx
These are not tested, but several syscalls are defined for these
architectures. Let's add syscalls comprehensively.
2020-12-08 15:32:25 +09:00
Yu Watanabe ae32a94efe missing: drop redundant condition 2020-12-08 14:54:20 +09:00
Yu Watanabe 86b8637435 missing: support 32bit powerpc 2020-12-08 14:51:58 +09:00
Yu Watanabe b8bcd4c69f missing: sort architectures in missing_syscall.h 2020-12-08 14:50:23 +09:00
Yu Watanabe 4dbce71787 set: introduce set_strjoin() 2020-12-08 12:28:54 +09:00
Lennart Poettering 52975f8672 socket-util: add common API for querying socket MTU 2020-12-07 13:46:35 +01:00
Lennart Poettering 4e25d4cf0f socket-util: add getsockopt_int() helper 2020-12-07 13:46:35 +01:00
Lennart Poettering 00ed2fff1a socket-util: add sockopt helper for controlling IP_RECVFRAGSIZE 2020-12-07 13:46:35 +01:00