summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAgeFilesLines
* core: add socket-bind cgroup mask harnessJulia Kartseva2021-04-262-1/+4
| | | | Standard cgroup harness for bpf feature.
* homectl: don't use password cache if we operate on other userLennart Poettering2021-04-232-0/+15
|
* journald: Retry if posix_fallocate returned -1 (EINTR)Igor Zhbanov2021-04-212-0/+23
| | | | | | | | | | | | | | | | | | | 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>
* generator: write out special systemd-fsck-usr.serviceLennart Poettering2021-04-211-0/+1
| | | | | | | | | | | | | | | | | 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.
* Merge pull request #19362 from yuwata/network-dhcp6-pd-log-19354Zbigniew Jędrzejewski-Szmek2021-04-212-0/+47
|\ | | | | network: dhcp6: add logs about delegated prefix
| * in-addr-util: introduce 'struct in_addr_prefix' and hash ops for itYu Watanabe2021-04-212-0/+37
| |
| * in-addr-util: add assertionsYu Watanabe2021-04-211-0/+10
| |
* | Merge pull request #19370 from mrc0mmand/shellcheck-pt4Zbigniew Jędrzejewski-Szmek2021-04-215-19/+24
|\ \ | |/ |/| More shellcheck shenanigans
| * src: shellcheck-ify shell scriptsFrantisek Sumsal2021-04-205-19/+24
| |
* | fstab-generator: if usr= is specified, mount it to /sysusr/usr/ firstLennart Poettering2021-04-201-0/+1
|/ | | | | | | | | | | | | | | 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.
* basic/log: change error for unset errno to ESTRPIPEZbigniew Jędrzejewski-Szmek2021-04-191-1/+1
| | | | | | | | 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
* fileio: use take_fdopen_unlocked()Yu Watanabe2021-04-171-5/+2
| | | | | | | | | | | 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; | ~~~~~~~~~~^~~ ```
* Merge pull request #19318 from ↵Luca Boccassi2021-04-152-11/+12
|\ | | | | | | | | yuwata/udev-ignore-additional-newline-on-verify-19314 udev: ignore additional newline at the end on verify
| * fileio: introduce a new flag to make write_string_file() ignore trailing newlineYu Watanabe2021-04-152-11/+12
| | | | | | | | | | When writing a sysfs attribute, kernel may automatically append newline at the end, e.g., 'portno' attribute for qeth driver.
* | Merge pull request #19317 from ↵Luca Boccassi2021-04-153-10/+25
|\ \ | |/ |/| | | | | keszybz/check-return-values-from-log_errno-functions Check return values from log_errno functions
| * Do not try to return 0 from log_debug()Zbigniew Jędrzejewski-Szmek2021-04-141-1/+1
| | | | | | | | | | | | | | | | | | 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.
| * basic/log: assert that 0 is not passed as errno, except in test codeZbigniew Jędrzejewski-Szmek2021-04-141-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * basic/log: assert that %m is not used when error is not setZbigniew Jędrzejewski-Szmek2021-04-141-1/+7
| | | | | | | | | | | | 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.
| * basic/log: force log_*_errno() to return negativeZbigniew Jędrzejewski-Szmek2021-04-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * meson: simplify the BUILD_MODE conditionalZbigniew Jędrzejewski-Szmek2021-04-142-6/+1
| | | | | | | | | | | | | | 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.
* | Merge pull request #19302 from bluca/uninitZbigniew Jędrzejewski-Szmek2021-04-144-5/+5
|\ \ | |/ | | tree-wide: avoid uninitialized warning on _cleanup_ variables
| * tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-04-144-5/+5
| | | | | | | | | | | | | | 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.
* | util: shorten allow_listed_char_for_devnode()Yu Watanabe2021-04-141-10/+7
|/
* tree-wide: update comment about unnecessary initializationYu Watanabe2021-04-131-1/+1
|
* core: add bpf-foreign cgroup mask and harnessJulia Kartseva2021-04-092-1/+4
| | | | | Add CGROUP_MASK_BPF_FOREIGN to CGROUP_MASK_BPF and standard cgroup context harness.
* Merge pull request #19243 from bluca/lgtmZbigniew Jędrzejewski-Szmek2021-04-092-3/+3
|\ | | | | Fix various issues reported by LGTM
| * in-addr-util: suppress LGTM warning about htobe32Luca Boccassi2021-04-081-2/+2
| | | | | | | | | | We are not calling it directly, it's coming from a standard library macro, so just suppress it.
| * errno-util: suppress LGTM warning about strerrorLuca Boccassi2021-04-081-1/+1
| |
* | core: rework unit_active_state_to_glyph() to use a translation tableLennart Poettering2021-04-081-18/+15
| | | | | | | | | | Let's make this a bit more readable by implementing this via a translation table, indexed by the state.
* | locale-util: make SpecialGlyph more like our usual enumsLennart Poettering2021-04-082-2/+5
| | | | | | | | | | | | | | | | 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()
* | Merge pull request #19226 from keszybz/reenable-maybe-unitialized-warningZbigniew Jędrzejewski-Szmek2021-04-083-10/+8
|\ \ | |/ |/| meson: re-enable -Wmaybe-uninitialized
| * basic/strbuf: use _cleanup_Zbigniew Jędrzejewski-Szmek2021-04-081-8/+6
| |
| * tree-wide: use the same comment for work-around initializationsZbigniew Jędrzejewski-Szmek2021-04-072-2/+2
| | | | | | | | | | | | | | | | 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.
* | Merge pull request #19231 from bluca/coredump_decodeLuca Boccassi2021-04-072-0/+23
|\ \ | | | | | | coredump: follow-ups for #19135
| * | basic: add path_equal_filename helperLuca Boccassi2021-04-072-0/+23
| |/
* | proc-cmdline: allow backslash escapes when parsing /proc/cmdlineLennart Poettering2021-04-071-1/+1
|/ | | | | | | | | | | | | | | | 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.
* recovery-key: add some extra assertsLennart Poettering2021-04-061-2/+5
| | | | | | | 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.
* various: silence gcc warningsZbigniew Jędrzejewski-Szmek2021-04-011-1/+1
| | | | AFAICT, gcc is just being stupid in all those cases.
* Merge pull request #19169 from keszybz/reenable-maybe-unitialized-warningLuca Boccassi2021-04-014-12/+14
|\ | | | | Fix a bunch of maybe-unitialized warnings but don't enable the warning yet
| * basic/env-util: silence two gcc warningsZbigniew Jędrzejewski-Szmek2021-03-311-7/+6
| |
| * basic/cgroup-util: silence gcc warning about unitialized variableZbigniew Jędrzejewski-Szmek2021-03-311-1/+2
| |
| * basic/fileio: silence gcc's maybe-unitialized warningZbigniew Jędrzejewski-Szmek2021-03-311-3/+4
| | | | | | | | | | | | | | | | [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) | ^~~~~~~~~~~~~~~~~~~
| * basic/socket-util: add hint to silence gcc's maybe-unitialized warningZbigniew Jędrzejewski-Szmek2021-03-311-1/+2
| | | | | | | | | | | | | | | | [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; | ^~~~~~~~~~~~
* | logind: Rename kexec reboot flagDeepak Rawat2021-03-311-2/+2
|/ | | | | | | Also change error message to be more meanigful. No change in functionality. Fixes: 0d96caa5c0
* gcrypt: do not ignore return valuesLuca Boccassi2021-03-311-2/+3
| | | | | | | | | | | | | | Check the return code from gcrypt's functions. In some cases just log, as it shoulnd't really happen. Fixes various Coverity issues: CID #1444702 CID #1444704 CID #1444706 CID #1444711 CID #1444712 CID #1444713
* logind: Add new flag for kexec rebootDeepak Rawat2021-03-311-2/+3
| | | | Add new flag to allow kexec reboot if kernel is already loaded.
* Merge pull request #19101 from poettering/mount-util-fixesLennart Poettering2021-03-311-16/+14
|\ | | | | Make recursive bind remounting handle failures gracefully
| * mountpoint-util: rebreak some commentsLennart Poettering2021-03-261-15/+9
| |
| * mountpoint-util: a symlink is never a mount pointLennart Poettering2021-03-261-1/+5
| | | | | | | | | | | | | | | | The various flavours of stat() basically tell us for free if something is a symlink. If it is, then it's definitely not a mount point. Use that. All other inode types can be mount point, just symlinks cannot.
* | Merge pull request #18989 from yuwata/ordered-set-put-strdupZbigniew Jędrzejewski-Szmek2021-03-312-12/+21
|\ \ | | | | | | ordered-set: make ordered_set_put_strdup() allocate OrderedSet object