network: find DHCP server address only on loading .network file
Previously, we periodically search suitable address for DHCP server,
1. when .network file is loaded,
2. when checking if we can configure sd_dhcp_server object,
3. when configuring sd_dhcp_server.
Especially, the step 2 may be triggered several times.
This makes, when .network file is loaded, find a corresponding Address
object, add a new Address object if not found, then save the found or
added Address object. So, it is not necessary to find address again on
configuring sd_dhcp_server object.
network: call network_adjust_dhcp_server() from network_drop_invalid_addresses()
We need to find a suitable static address for the DHCP server.
So, all static addresses must be verified before network_adjust_dhcp_server()
is called. For safety, let's call it from network_drop_invalid_addresses().
No functional change, just refactoring and preparation for later
commits.
tpm2-util: drop support for creating TPM2 trial sessions
This is unused these days, we instead calculate policy hashes ourselves
and do not need trial sessions for that anymore. Given how unreliable
they are in actual TPMs, we don't want to use them anyway, so I don't
think we ever want to readd this.
parse_timestamp: accept RFC3339-style timezone and %FT%R[:%S[.%N]]
We basically parsed the RFC3339 format already, except with a space:
NOTE: ISO 8601 defines date and time separated by "T".
Applications using this syntax may choose, for the sake of
readability, to specify a full-date and full-time separated by
(say) a space character.
so now we handle both
2012-11-23 11:12:13.456
2012-11-23T11:12:13.456
as equivalent.
Parse directly-suffixed Z and +05:30 timezones as well:
2012-11-23T11:12:13.456Z
2012-11-23T11:12:13.456+02:00
as they're both defined by RFC3339.
We do /not/ allow z or t; the RFC says
NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this
syntax may alternatively be lower case "t" or "z" respectively.
This date/time format may be used in some environments or contexts
that distinguish between the upper- and lower-case letters 'A'-'Z'
and 'a'-'z' (e.g. XML). Specifications that use this format in
such environments MAY further limit the date/time syntax so that
the letters 'T' and 'Z' used in the date/time syntax must always
be upper case. Applications that generate this format SHOULD use
upper case letters.
We /are/ in a case-sensitive environment, neither are in wide-spread
use, and "z" poses an issue of whether "todayz" should be the same
as "todayZ" ("today UTC") or an error (it should be an error).
Fractional seconds are limited to six digits (they're nominally
time-secfrac = "." 1*DIGIT
), since we only support 1µs-resolution timestamps, and limit to six
digits in our other sub-second formats.
Parsing
2012-11-23T11:12
is an extension two ways (no seconds, no timezone),
mirroring our "canonical" format.
Mike Yuan [Tue, 5 Sep 2023 13:50:04 +0000 (21:50 +0800)]
hibernate-resume: split out the logic of finding hibernate location
Before this commit, the hibernate location logic only exists in
the generator. Also, we compare device nodes (devnode_same()) and
clear EFI variable HibernateLocation in the generator too. This is
not ideal though: when the generator gets to run, udev hasn't yet
started, so effectively devnode_same() always fails. Moreover, if
the boot process is interrupted by e.g. battery-check, the hibernate
information is lost.
Therefore, let's split out the logic of finding hibernate location.
The generator only does the initial validation of system info and
enables systemd-hibernate-resume.service, and when the service
actually runs we validate everything again, which includes comparing
the device nodes and clearing the EFI variable. This should make
things more robust, plus systems that don't utilize a systemd-enabled
initrd can use the exact same logic to resume using the EFI variable.
I.e., systemd-hibernate-resume can be used standalone.
In general, it's better to avoid a negation. And "!" is special, because it is
used for history expansion, i.e. the same command would behave differently if
pasted on the command line.
Map Fn+Tab to fn_esc as is FnLock toggle in this keyboard. Still doesn't behave as expected because work in ideapad_laptop kernel module could be required but now at least we report the same mapping in others keyboards with Fn+ESC for FnLock and not unknown.
Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
Yu Watanabe [Thu, 24 Aug 2023 14:41:05 +0000 (23:41 +0900)]
core/credential,mount: re-read /proc/self/mountinfo before invoking umount command
When a unit has credentials, stopping the service unmounts the credentials
directory. On shutdown, stopping the service and the corresponding mount
unit may be done mostly simultaneously, and if we invoke umount command soon
after umount() being called on stopping the service, the mount unit will
fail.
This makes Mount.invalidated_state flag set when umount() is called for a path,
and re-read /proc/self/mouninfo before invoking umount command if the flag is set.
Before the commits, credentials directory set up on ExecStart= was kept
on e.g. ExecStop=. But, with the changes, if a service requests a
private mount namespace, the credentials directory is discarded after
ExecStart= is finished.
Let's revert the change, and find better way later.
Addresses the post-merge comment
https://github.com/systemd/systemd/pull/28787#issuecomment-1690614202.
The example was supposed to show how
machine-id/new/machine-id --app-specific/show --app-specific tie together, but
the verb was ommitted.
I also extended the explanation a bit and used long option form in the first
example for more clarity. In the second, more complicated example, the
one-letter form is used for brevity.
Having USB enabled seems useful enough, this wasn't doing anything
regardless because we already enable CONFIG_USB earlier in the kconfig
file so this just gets rid of warning.
Jan Janssen [Tue, 5 Sep 2023 10:07:01 +0000 (12:07 +0200)]
ci: Do not run build test as root
Although, this is CI, we can still do better. It also ensures that any
env var changes make it into the script, as things like PATH would not
survive a `sudo -E`.
The TEX Shinobi keyboard with trackpoint incorrectly identifies as a mouse instead of a pointing stick. This corrects it as suggested at https://gitlab.freedesktop.org/libinput/libinput/-/issues/932#note_2069967
Following the example of the Lite-On keyboard entry, this modalias specifies the mouse unit without tagging the device's other entries.
Also, this introduce sd_dhcp_lease_get_lifetime_timestamp() and friends,
which provides timestamp of the lifetime and so on, while
sd_dhcp_lease_get_lifetime() provides timestamp.
logind: give better error messages when failing to attach devices to seats
When the user tries to attach a device lacking ID_FOR_SEAT they
currently get a very cryptic error message. Let's improve the situation
a bit. Still a bit cryptic maybe, but much less so.
Configuration now takes priority over CLI options so we have to
configure the defaults for settings that we want to allow overriding
from the CLI. We also explicitly set some other settings so that they
can't be overridden from the CLI anymore. For example the base and
initrd image should never be made bootable so we set Bootable=no
explicitly for both.
Otherwise we'll get stuck waiting indefinitely if the test socket unit
fails to fail due the trigger limit, i.e.:
[ 111.104906] testsuite-07.sh[743]: + systemctl start issue2467.socket
[ OK ] Listening on issue2467.socket.
[ 111.746465] testsuite-07.sh[743]: + nc -w20 -U /run/test.ctl
Starting systemd-tmpfiles-clean.service...
[ OK ] Finished systemd-tmpfiles-clean.service.
qemu-system-x86_64: terminating on signal 15 from pid 565814 (timeout)
E: Test timed out after 1800s
With the idle timeout we should give up after 20 seconds, allowing the next
statement to properly fail:
In file included from ../src/basic/macro.h:455,
from ../src/basic/alloc-util.h:10,
from ../src/basic/hash-funcs.h:4,
from ../src/basic/hashmap.h:8,
from ../src/shared/dns-domain.h:10,
from ../src/network/networkd-radv.c:9:
../src/network/networkd-radv.c: In function ‘config_parse_router_home_agent_lifetime’:
../src/network/networkd-radv.c:1626:28: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 11 has type ‘long long unsigned int’ [-Werror=format=]
1626 | "Invalid %s= must be in the range 1...%lu seconds, ignoring: %s", lvalue,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/basic/log.h:361:125: note: in definition of macro ‘log_syntax’
361 | ? log_syntax_internal(unit, _level, config_file, config_line, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
| ^~~~~~~~~~~
../src/network/networkd-radv.c:1626:68: note: format string is defined here
1626 | "Invalid %s= must be in the range 1...%lu seconds, ignoring: %s", lvalue,
| ~~^
| |
| long unsigned int
| %llu
cc1: all warnings being treated as errors
Addresses: https://github.com/systemd/systemd/pull/28964#issuecomment-1705550404
Follow-up to 6a6d27bc5b0.
- Rename the argument for storing the sender address,
- allow to call it with NULL for ret_xyz,
- reduce needless copy of timestamp when the message does not have
timestamp.