1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00
Commit Graph

50711 Commits

Author SHA1 Message Date
Sevan Janiyan
d5b3e51044 meson.build: typo 2021-04-15 13:23:13 +09:00
Zbigniew Jędrzejewski-Szmek
00dd6d7770 libsystemd-network: check that errno==0 is not passed to log functions 2021-04-14 23:32:10 +02:00
Zbigniew Jędrzejewski-Szmek
a0c2541b6b libsystemd-network: use macro for definitions of log_{lldp,dhcp,…}_errno
No functional change.
2021-04-14 23:32:07 +02:00
Zbigniew Jędrzejewski-Szmek
f407219cd1 Check that errno passed log_{interface,link}_*_errno() is non-zero 2021-04-14 22:53:49 +02:00
Yu Watanabe
22bbba8444 sd-dhcp-client: introduce sd_dhcp_client_is_running() 2021-04-14 22:31:28 +02:00
Zbigniew Jędrzejewski-Szmek
e89f6ed476 Voidify log_link_debug
See analogous change for log_debug() for discussion.
2021-04-14 22:20:20 +02:00
Luca Boccassi
9264fb47d9
Merge pull request #19315 from yuwata/network-wait-online-address-family-follow-ups
network: several follow-ups for #19069
2021-04-14 21:17:00 +01:00
Zbigniew Jędrzejewski-Szmek
cf5a2ee825 journald: fix %m usage 2021-04-14 22:06:02 +02:00
Yu Watanabe
6fb61918cc udev: ignore additional newline in sysfs attribute on verify
Some driver may automatically add additional newline at the end.
E.g., portno attribute for qeth driver.

Fixes #19314.
2021-04-15 01:46:58 +09:00
Yu Watanabe
6873d20392 fileio: introduce a new flag to make write_string_file() ignore trailing newline
When writing a sysfs attribute, kernel may automatically append newline
at the end, e.g., 'portno' attribute for qeth driver.
2021-04-15 01:40:52 +09:00
Zbigniew Jędrzejewski-Szmek
75029e150b Do not try to return 0 from log_debug()
As @yuwata correctly points out, this became broken when log_debug()
started returning -EIO. I wanted to preserve this pattern, but it turns
out it is not very widely used, and preserving it would make the whole
thing, already quite complicated, even more complex.

log_debug() is made like log_info() and friends, and returns void.
2021-04-14 17:45:11 +02:00
Zbigniew Jędrzejewski-Szmek
a2eb2267e4 shared/module-util: fix errno value passed to log function
If r == 0, no harm done. But if r > 0, this would be interpreted as an
errno value, wrongly.
2021-04-14 17:10:36 +02:00
Zbigniew Jędrzejewski-Szmek
a626cb15c0 basic/log: assert that 0 is not passed as errno, except in test code
Let's assert if we ever happen to pass 0 to one of the log functions.
With the preceding commit to return -EIO from log_*(), passing 0 wouldn't
affect the return value any more, but it is still most likely an error.
The unit test code is an exception: we fairly often pass the return value
to print it, before checking what it is. So let's assert that we're not
passing 0 in non-test code. As with the previous check for %m, this is only
done in developer mode. We are depending on external code setting
errno correctly for us, which might not always be true, and which we can't
test, so we shouldn't assert, but just handle this gracefully.

I did a bunch of greps to try to figure out if there are any places where
we're passing 0 on purpose, and couldn't find any.
The one place that failed in tests is adjusted.

About "zerook" in the name: I wanted the suffix to be unambiguous. It's a
single "word" because each of the words in log_full_errno is also meaningful,
and having one term use two words would be confusing.
2021-04-14 17:07:06 +02:00
Zbigniew Jędrzejewski-Szmek
c5cb37d95e
Merge pull request #19302 from bluca/uninit
tree-wide: avoid uninitialized warning on _cleanup_ variables
2021-04-14 16:25:35 +02:00
Zbigniew Jędrzejewski-Szmek
63275a7032 basic/log: assert that %m is not used when error is not set
This is only done in developer mode. It is a pretty rare occurence that we
make this kind of mistake. And even if it happens, the result is just a misleading
error message. So let's only do the check in non-release builds.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
cbe97b9c92 basic/log: force log_*_errno() to return negative
This silences some warnigns where gcc thinks that some variables are
unitialized. One particular case:

../src/journal/journald-server.c: In function 'ache_space_refresh':
../src/journal/journald-server.c:136:28: error: 'vfs_avail' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  136 |         uint64_t vfs_used, vfs_avail, avail;
      |                            ^~~~~~~~~
../src/journal/journald-server.c:136:18: error: 'vfs_used' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  136 |         uint64_t vfs_used, vfs_avail, avail;
      |                  ^~~~~~~~
cc1: all warnings being treated as errors

which is caused by

   d = opendir(path);
   if (!d)
           return log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_ERR,
                                 errno, "Failed to open %s: %m", path);
   if (fstatvfs(dirfd(d), &ss) < 0)
           return log_error_errno(errno, "Failed to fstatvfs(%s): %m", path);

For some reason on aarch64 gcc thinks we might return non-negative here. In
principle errno must be set in both cases, but it's hard to say for certain.
So let's make sure that our code flow is correct, even if somebody forgot to
set the global variable somewhere.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
111a3aae71 partition, random-seed, logind: fix log messages with %m
We would print "...: Success", which is not too terrible, but not pretty
either.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
aca591ac55 sd-device: improve log message and tweak style
We shouldn't say the attribute is missing right after ruling out ENOENT.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
2d359acda5 libsystemd-network: fix dhcp option buffer confusion
We were writing to the wrong buffer with a wrong offset :(
Bug present since the original introduction of the code in
04b28be1a3.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
47350c5fb6 meson: simplify the BUILD_MODE conditional
Using a enum is all nice and generic, but at this point it seems unlikely that
we'll add further build modes. But having an enum means that we need to include
the header file with the enumeration whenerever the conditional is used. I want
to use the conditional in log.h, which makes it hard to avoid circular imports.
2021-04-14 16:19:54 +02:00
Zbigniew Jędrzejewski-Szmek
5600a26114 bpf-devices: update comment 2021-04-14 15:29:41 +02:00
Yu Watanabe
f11bee0cb9 wait-online: update debug log messages 2021-04-14 22:17:44 +09:00
Yu Watanabe
90afec1834 network: shorten code a bit 2021-04-14 22:13:46 +09:00
Zbigniew Jędrzejewski-Szmek
6634a39469
Merge pull request #19266 from mrc0mmand/testsuite-shellcheck
test: make the test scripts shellcheck-compliant
2021-04-14 13:58:01 +02:00
Luca Boccassi
c2b2df604b tree-wide: avoid uninitialized warning on _cleanup_ variables
With some versions of the compiler, the _cleanup_ attr makes it think
the variable might be freed/closed when uninitialized, even though it
cannot happen. The added cost is small enough to be worth the benefit,
and optimized builds will help reduce it even further.
2021-04-14 12:25:06 +01:00
Luca Boccassi
be084c0dd1 meson: build tests with -Wno-maybe-uninitialized if -O2/-flto are used
We intentionally do not inline initializations with definitions for
a bunch of _cleanup_ variables in tests, to ensure valgrind is triggered.
This triggers a lot of maybe-uninitialized false positives when -O2 and
-flto are used. Suppress them.
2021-04-14 11:31:50 +01:00
Yu Watanabe
c68ede3952 util: shorten allow_listed_char_for_devnode() 2021-04-14 11:04:46 +01:00
Yu Watanabe
a2b1572ce4
Merge pull request #19287 from yuwata/network-manage-foreign-routing-policy-rule-19106
network: add ManageForeignRoutingPolicyRules= boolean setting
2021-04-14 19:01:41 +09:00
Yu Watanabe
c7cbe25d11
Merge pull request #19069 from LetzteInstanz/waiting_for_address_family
systemd-networkd-wait-online: wait for specific address family
2021-04-14 18:57:39 +09:00
Luca Boccassi
ab1aa6368a rfkill: add some casts to silence -Werror=sign-compare 2021-04-14 10:26:31 +01:00
Yu Watanabe
86d58c8625 man: update explanation for Anonymize= 2021-04-14 14:15:15 +09:00
Yu Watanabe
f90635f14f network: dhcp4: warn when Anonymize=yes and ClientIdentifier= is not mac 2021-04-14 14:15:11 +09:00
Yu Watanabe
0078195835 network: drop unnecessary explicit initializations 2021-04-14 13:06:54 +09:00
Yu Watanabe
a83bda058c network: dhcp4: do not request any additional options when Anonymize=yes
This makes networkd can use recieved options we do not request.
2021-04-14 13:06:54 +09:00
Yu Watanabe
ae7ea5a7ba network: move and rename network_apply_anonymize_if_set() 2021-04-14 13:06:50 +09:00
LetzteInstanz
70448bb1c1 test-network: test waiting for address family 2021-04-14 09:00:12 +09:00
LetzteInstanz
6dc4531d16 wait-online: wait for address family
This introduce -4 and -6 commandline options.
2021-04-14 09:00:08 +09:00
LetzteInstanz
bbea881312 sd-network: read IPv4/IPv6 address states from state files 2021-04-14 08:51:08 +09:00
LetzteInstanz
8430841b5e network: save IPv4/IPv6 address states into state file
This also introduces RequiredFamilyForOnline= setting to .network file,
and IPv4AddressState/IPv6AddressState DBus properties.
2021-04-14 08:51:02 +09:00
LetzteInstanz
86ae2d69a3 network: move AddressFamily into network-util for the use by wait-online later 2021-04-14 08:30:18 +09:00
gaoyi
993eb00016 udev: delete useless codes
It seems no one will touch queue.bin
2021-04-14 08:07:40 +09:00
Yegor Alexeyev
21b6b87eb3 dhcp: Implemented BindToInterface= configuration option 2021-04-14 07:30:40 +09:00
Frantisek Sumsal
84031b5d6e test: bunch of assorted tweaks to make shellcheck happy 2021-04-13 19:14:35 +02:00
Frantisek Sumsal
4544002cae test: use arrays to make things a bit cleaner 2021-04-13 13:20:22 +02:00
Frantisek Sumsal
ea539ad297 test: replace the obsolete `` syntax with $() 2021-04-13 12:08:01 +02:00
Frantisek Sumsal
70ad107bdf test: use an explicit no-op for file truncation 2021-04-13 12:08:01 +02:00
Frantisek Sumsal
f794098356 test: tidy up arithmetic expressions 2021-04-13 12:08:01 +02:00
Frantisek Sumsal
3882526798 test: use quotes where necessary
to avoid possible word splitting.
2021-04-13 12:08:01 +02:00
Frantisek Sumsal
084575ff91 test: use set -eux and set -o pipefail everywhere
This should make the scripts more robust.
2021-04-13 12:08:01 +02:00
Luca Boccassi
bcaf24cd77
Merge pull request #19303 from yuwata/fix-typo
tree-wide: fix typo
2021-04-13 09:44:33 +01:00