Commit Graph

3882 Commits

Author SHA1 Message Date
Yu Watanabe
ae8e3c2b25 ether-addr-util: introduce ether_addr_to_string_alloc() 2021-04-30 05:39:10 +09:00
Zbigniew Jędrzejewski-Szmek
e7702c20aa basic/missing-syscall: add regen instructions 2021-04-28 15:41:34 +02:00
Lennart Poettering
84e8edec30 missing: add syscall wrappers for new mount API 2021-04-28 15:41:34 +02:00
Zbigniew Jędrzejewski-Szmek
9899580a58 basic/missing-syscall: sort syscalls alphabetically and add numbers for mount_setattr, move_mount, open_tree 2021-04-28 15:41:34 +02:00
Zbigniew Jędrzejewski-Szmek
302beee342 basic/missing-syscall: add numbers for riscv (64-bit) 2021-04-28 15:41:34 +02:00
Zbigniew Jędrzejewski-Szmek
94dfd85b0c basic/missing-syscalls: only emit one warning about missing numbers
The ifdef pattern is the same for all syscalls, so most of the time, if one is
not defined, all others will too. So let's reduce the noise a bit and emit one
warning in case the support for the architecture is fully missing. (Current
template was copied over from before when we added numbers for each syscall by
hand and stopped making sense when we started generating the header from a
table that is expected to have all syscall numbers.)
2021-04-28 15:41:34 +02:00
Julia Kartseva
a8e5eb1788 core: add socket-bind cgroup mask harness
Standard cgroup harness for bpf feature.
2021-04-26 16:21:59 -07:00
Lennart Poettering
7bdbafc261 homectl: don't use password cache if we operate on other user 2021-04-23 23:22:37 +02:00
Igor Zhbanov
4c54768c97 journald: Retry if posix_fallocate returned -1 (EINTR)
On some conditions (particularly when mobile CPUs are going to sleep),
the posix_fallocate(), which is called when a new journal file is allocated,
can return -1 (EINTR). This is counted as a fatal error. So the journald
closes both old and journals, and simply throwing away further incoming
events, because of no log files open.

Introduce posix_fallocate_loop() that restarts the function in the case
of EINTR. Also let's make code base more uniform by returning negative
values on error.

Fix assert in test-sigbus.c that incorrectly counted positive values as
success. After changing the function return values, that will actually work.

Fixes: #19041

Signed-off-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
2021-04-21 23:08:35 +02:00
Lennart Poettering
2b66f48e4e generator: write out special systemd-fsck-usr.service
So far all file systems where checked by instances of
systemd-fsck@.service, with the exception of the root fs which was
covered by systemd-fsck-root.service. The special handling is necessary
to deal with ordering issues: we typically want the root fs to be
checked before all others, and — weirdly — allow mounting it before the
fsck done (for compat with initrd-less boots).

This adds similar special handling for /usr: if the hierarchy is placed
on a separate file system check it with a special
systemd-fsck-usr.service instead of a regular sysemd-fsck@.service
instance. Reason is again ordering: we want to allow mounting of /usr
without the root fs already being around in the initrd, to cover for
cases where the root fs is created on first boot and thus cannot be
mounted/checked before /usr.
2021-04-21 18:32:29 +02:00
Zbigniew Jędrzejewski-Szmek
1f2a7ca7ac Merge pull request #19362 from yuwata/network-dhcp6-pd-log-19354
network: dhcp6: add logs about delegated prefix
2021-04-21 18:20:49 +02:00
Zbigniew Jędrzejewski-Szmek
59ab650fc5 Merge pull request #19370 from mrc0mmand/shellcheck-pt4
More shellcheck shenanigans
2021-04-21 18:14:32 +02:00
Yu Watanabe
eccdc68771 in-addr-util: introduce 'struct in_addr_prefix' and hash ops for it 2021-04-21 13:57:47 +09:00
Yu Watanabe
93e44aa92f in-addr-util: add assertions 2021-04-21 13:57:47 +09:00
Frantisek Sumsal
437e889b18 src: shellcheck-ify shell scripts 2021-04-20 18:39:36 +02:00
Lennart Poettering
29a24ab28e fstab-generator: if usr= is specified, mount it to /sysusr/usr/ first
This changes the fstab-generator to handle mounting of /usr/ a bit
differently than before. Instead of immediately mounting the fs to
/sysroot/usr/ we'll first mount it to /sysusr/usr/ and then add a
separate bind mount that mounts it from /sysusr/usr/ to /sysroot/usr/.

This way we can access /usr independently of the root fs, without for
waiting to be mounted via the /sysusr/ hierarchy. This is useful for
invoking systemd-repart while a root fs doesn't exist yet and for
creating it, with partition data read from the /usr/ hierarchy.

This introduces a new generic target initrd-usr-fs.target that may be
used to generically order services against /sysusr/ to become available.
2021-04-20 18:26:17 +02:00
Zbigniew Jędrzejewski-Szmek
59e8042ecd basic/log: change error for unset errno to ESTRPIPE
EIO is used in other contexts, so change ot something otherwise unused.
ENOTRECOVERABLE was also suggested, but it's used in various other places
in the code.

https://github.com/systemd/systemd/pull/19317#discussion_r614887661
2021-04-19 08:46:19 +02:00
Yu Watanabe
6604fb0207 fileio: use take_fdopen_unlocked()
This fixes maybe-uninitialized warning:
```
../src/basic/fileio.c: In function ‘chase_symlinks_and_fopen_unlocked’:
../src/basic/fileio.c:1026:19: warning: ‘f’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1026 |         *ret_file = f;
      |         ~~~~~~~~~~^~~

```
2021-04-17 00:22:12 +09:00
Luca Boccassi
2969369130 Merge pull request #19318 from yuwata/udev-ignore-additional-newline-on-verify-19314
udev: ignore additional newline at the end on verify
2021-04-15 20:36:55 +01:00
Luca Boccassi
2d8c8549ab Merge pull request #19317 from keszybz/check-return-values-from-log_errno-functions
Check return values from log_errno functions
2021-04-15 20:33:54 +01: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
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
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
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
Yu Watanabe
c68ede3952 util: shorten allow_listed_char_for_devnode() 2021-04-14 11:04:46 +01:00
Yu Watanabe
050f05c2eb tree-wide: update comment about unnecessary initialization 2021-04-13 12:53:32 +09:00
Julia Kartseva
506ea51b48 core: add bpf-foreign cgroup mask and harness
Add CGROUP_MASK_BPF_FOREIGN to CGROUP_MASK_BPF and standard cgroup
context harness.
2021-04-09 20:28:47 -07:00
Zbigniew Jędrzejewski-Szmek
22344fcfb9 Merge pull request #19243 from bluca/lgtm
Fix various issues reported by LGTM
2021-04-09 13:12:41 +02:00
Lennart Poettering
eeb6923d5a core: rework unit_active_state_to_glyph() to use a translation table
Let's make this a bit more readable by implementing this via a
translation table, indexed by the state.
2021-04-08 23:01:25 +02:00
Lennart Poettering
eff60d8cea locale-util: make SpecialGlyph more like our usual enums
Let's define both an enum and a typedef named SpecialGlyph, the way we
usually do it.

Also, introduce an "invalid" special glyph, assigned to -EINVAL, also
like we always do it. (And handle it somewhat sanely in special_glyph()
2021-04-08 23:00:43 +02:00
Zbigniew Jędrzejewski-Szmek
d0b3039837 Merge pull request #19226 from keszybz/reenable-maybe-unitialized-warning
meson: re-enable -Wmaybe-uninitialized
2021-04-08 20:29:05 +02:00
Luca Boccassi
a0cc411724 in-addr-util: suppress LGTM warning about htobe32
We are not calling it directly, it's coming from a standard library
macro, so just suppress it.
2021-04-08 13:08:38 +01:00
Luca Boccassi
82cdb75b8d errno-util: suppress LGTM warning about strerror 2021-04-08 13:08:38 +01:00
Zbigniew Jędrzejewski-Szmek
3b9e6fb490 basic/strbuf: use _cleanup_ 2021-04-08 13:00:50 +02:00
Luca Boccassi
7f8225d21b Merge pull request #19231 from bluca/coredump_decode
coredump: follow-ups for #19135
2021-04-07 22:06:26 +01:00
Lennart Poettering
d997861ea7 proc-cmdline: allow backslash escapes when parsing /proc/cmdline
So far when parsing /proc/cmdline we'd consider backslashes as
mechanisms for escaping whitepace or quotes. This changes things so that
they are retained as they are instead. The kernel itself doesn't allow such
escaping, and hence we shouldn't do so either (see lib/cmdline.c in the
kernel sources; it does support "" quotes btw).

This fix is useful to allow specifying backslash escapes in the "root="
cmdline option to be passed through to systemd-fstab-generator. Example:

    root=/dev/disk/by-partlabel/Root\x20Partition

Previously we'd eat up the "\" so that we'd then look for a device
/dev/disk/by-partlabel/Rootx20Partition which never shows up.
2021-04-07 16:19:35 +02:00
Zbigniew Jędrzejewski-Szmek
7756528e9b tree-wide: use the same comment for work-around initializations
This should make it easier to remove those warnings when the compiler
gets smarter. Not sure if I got them all...

Double space before the comment start to make it easier to separate from the
preceding line.
2021-04-07 16:04:22 +02:00
Luca Boccassi
727e63e33e basic: add path_equal_filename helper 2021-04-07 14:03:49 +01:00
Lennart Poettering
ff2cf6f8fe recovery-key: add some extra asserts
Let's ensure our key sizes calculations are correct.

This doesn't actually change anything, just adds more safety checks.
Inspired by #19203, but not a fix.
2021-04-06 18:42:30 +02:00
Zbigniew Jędrzejewski-Szmek
aff81b1851 various: silence gcc warnings
AFAICT, gcc is just being stupid in all those cases.
2021-04-01 12:02:25 +02:00
Luca Boccassi
bd506dfb5e Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warning
Fix a bunch of maybe-unitialized warnings but don't enable the warning yet
2021-04-01 09:36:46 +01:00
Deepak Rawat
1d8a16f1f4 logind: Rename kexec reboot flag
Also change error message to be more meanigful. No change in
functionality.

Fixes: 0d96caa5c0
2021-03-31 21:43:45 +02:00
Zbigniew Jędrzejewski-Szmek
1dbd0bdb3a basic/env-util: silence two gcc warnings 2021-03-31 18:24:54 +02:00
Zbigniew Jędrzejewski-Szmek
bc20c31bbc basic/cgroup-util: silence gcc warning about unitialized variable 2021-03-31 18:24:53 +02:00
Zbigniew Jędrzejewski-Szmek
55e2cfc938 basic/fileio: silence gcc's maybe-unitialized warning
[11/657] Compiling C object src/basic/libbasic.a.p/fileio.c.o
../src/basic/fileio.c: In function ‘write_string_stream_ts’:
../src/basic/fileio.c:167:21: warning: ‘fd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  167 |                 if (futimens(fd, twice) < 0)
      |                     ^~~~~~~~~~~~~~~~~~~
2021-03-31 18:22:53 +02:00
Zbigniew Jędrzejewski-Szmek
befab2c40c basic/socket-util: add hint to silence gcc's maybe-unitialized warning
[59/1551] Compiling C object src/basic/libbasic.a.p/socket-util.c.o
../src/basic/socket-util.c: In function ‘socket_get_mtu’:
../src/basic/socket-util.c:1393:16: warning: ‘mtu’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1393 |         *ret = (size_t) mtu;
      |                ^~~~~~~~~~~~
2021-03-31 18:22:53 +02:00