Commit Graph

57162 Commits

Author SHA1 Message Date
Yu Watanabe
cf708d803e Merge pull request #22867 from poettering/lockdev-util
add small "udevadm lock" tool for locking a block device
2022-04-05 03:04:23 +09:00
Luca Boccassi
4e9a7022c5 Merge pull request #22960 from mrc0mmand/use-udevadm-wait
test: use the new `udevadm wait` verb to wait for the loop device
2022-04-04 18:39:59 +01:00
Lennart Poettering
6b41a7b281 tree-wide: use 'Architecture' type consistently across the tree
Some parts of our tree used 'Architecture' for storing architectures,
others used ints. Let's unify on the former.

Inspired by #22952's rework of the 'Virtualization' enum.
2022-04-05 02:19:37 +09:00
Lennart Poettering
9858e6d2e7 man: properly conditionalize kernel-install man page
Change f887eab1da conditionalized the
building of ther kenel-install man page in the generated meson output,
instead of the source in the XML markup. Thus, whenever the rules file
is updated the conditionalization is lost. Correct that.

Follow-up for: f887eab1da
2022-04-05 01:20:35 +09:00
Franck Bui
6d7afa3b58 journald: make use of CLAMP() in cache_space_refresh() 2022-04-04 17:51:34 +02:00
Franck Bui
4bb37be07b journald: make sure journal_file_open() doesn't leave a corrupted file around after failing
This can be problematic especially when there's no more free disk
space. Consider the following:.

When disk space becomes sparse, writting to the system journal can lead to
error. In this case journald attempts to make room by rotating the journals,
which consists in archiving online journals and opening new ones.

However opening new files is likely to fail too and in this case
journal_file_open() leaves half initialized file around but in online
state. Then the error is propagated and journald switches into volatile mode.

Next time a new message is received by journald, it tries to open the
persistent system journal file to switch automatically back to persistent
mode.

When opening the system journal, journal_file_open(), called by
managed_journal_file_open_reliably(), finds the persistent system journal left
previously and assumes that it was uncleanly closed and considers it as
corrupted. The error is reported to managed_journal_file_open_reliably(), which
backs the file up and attempts to create a new system file, which fails and
leaves a corrupted system file again.

Since this is done for each message received by journald, /var/log/message can
be filled with backup files pretty quickly.

To prevent this, the patch makes sure to delete the newly created file in case
of error.
2022-04-04 17:51:10 +02:00
Lennart Poettering
ae61c53c3b man: document new udevadm lock tool 2022-04-04 17:19:51 +02:00
Lennart Poettering
8b12a516e9 udevadm: add new "lock" verb for locking block devices 2022-04-04 17:19:51 +02:00
Lennart Poettering
1748853700 hash-funcs: tweak odering in devt_compare_func()
Let's order dev_t's by their major first, minor secondary. The binary
encoding of the two fields is weirdly interleaved and different in
kernel and glibc, hence let's focus on the generic part that works like
users would expect it.

So far the function is only used to compare for equality, not for
sorting, hence this has no immediate effect.
2022-04-04 17:04:14 +02:00
Lennart Poettering
666efe94c9 TODO 2022-04-04 16:07:26 +02:00
Frantisek Sumsal
9b264c1dfa partition: use udevadm wait 2022-04-04 15:59:40 +02:00
Frantisek Sumsal
c189d3bd78 test: use the new udevadm wait verb to wait for the loop device
The original workaround didn't work, as `systemd-repart` kept failing
 even when the `/dev/loopX` device was present:

 ```
 [   13.959419] H testsuite-58.sh[280]: + LOOP=/dev/loop1
 [   13.959636] H testsuite-58.sh[280]: + :
 [   13.959764] H testsuite-58.sh[280]: + test -e /dev/loop1
 [   13.959895] H testsuite-58.sh[280]: + break
 [   13.960023] H testsuite-58.sh[280]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1
 [   13.970538] H testsuite-58.sh[363]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device.
 [   13.970538] H testsuite-58.sh[363]: Failed to determine canonical path for '/dev/loop1': No such file or directory
 [   13.970538] H testsuite-58.sh[363]: Failed to open file or determine backing device of /dev/loop1: No such file or directory
 ```
2022-04-04 15:58:03 +02:00
Yu Watanabe
f3e5c781f3 Merge pull request #22943 from yuwata/dhcp6-client-requet-options
sd-dhcp6-client: requet options
2022-04-04 22:55:02 +09:00
Yu Watanabe
d315b47e2d Merge pull request #22952 from poettering/rework-kvm-hyperv
virt: tweak kvm with hyperv enlightenments
2022-04-04 22:53:56 +09:00
Lennart Poettering
cc97a3a5e8 gpt: introduce common implementation of type uuid search loop 2022-04-04 22:50:48 +09:00
Lennart Poettering
e4f92a62a8 update TODO 2022-04-04 13:14:42 +02:00
Lennart Poettering
0ee2d5b2a9 virt: move array iterators to smaller scope, and use right type 2022-04-04 11:36:26 +02:00
Lennart Poettering
1b86c7c59e virt: make virtualization enum a named type
These days we have a mechanism for safely returning errnos in enum
types, via definining -ERRNO_MAX as one special enu value. Let's use
that for Virtualization.

No change in behaviour, just some typesafety improvement.
2022-04-04 11:36:26 +02:00
Lennart Poettering
0f534758d1 virt: rework kvm with hyperv enlightenment checks a bit
Let's avoid extending the virtualization with an "alias" entry that has
the same string assigned as another.

The only reason this was done was to make the patch small that added a
second CPUID vendor string for kvm to the vm_table[] array. Let's
instead rework the array to use struct elements that match up strings
with ids. Given the array was previously mostly sparse this should be a
general improvement.

Fixes: #22950
Follow-up for: #22945
2022-04-04 11:28:56 +02:00
Yu Watanabe
822883b3e7 sd-dhcp6-client: request several options
Even though these options are not currently used by sd-dhcp6-client,
RFC 8415 states these options MUST be requested.
2022-04-04 01:22:02 +09:00
Yu Watanabe
612caa2626 network: dhcp6: request DNS servers or friends only when they will be used 2022-04-03 19:55:25 +09:00
Yu Watanabe
f697ab358a dhcp: make option names singular 2022-04-03 19:50:02 +09:00
Yu Watanabe
0e0c4daea6 sd-dhcp6-client: sort requesting options 2022-04-03 19:23:03 +09:00
Yu Watanabe
2f53b311c3 sd-dhcp6-client: rename req_opts_len -> n_req_opts
As 'len' is confusing and we may misunderstand it as the size of
the buffer instead of the number of options.
2022-04-03 19:23:03 +09:00
Brett Holman
fbe0430015 Identify kvm + hv_passthrough as "kvm" 2022-04-03 19:21:24 +09:00
dependabot[bot]
64c843d12d build(deps): bump meson from 0.61.2 to 0.62.0 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 0.61.2 to 0.62.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/0.61.2...0.62.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 21:41:37 +00:00
dependabot[bot]
b6ab9d7ade build(deps): bump actions/labeler from 3.1.0 to 4
Bumps [actions/labeler](https://github.com/actions/labeler) from 3.1.0 to 4.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](3d612d72e6...9fd24f1f9d)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 21:41:06 +00:00
dependabot[bot]
a2b107c86c build(deps): bump actions/checkout from 2.4.0 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](ec3a7ce113...a12a3943b4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 21:40:52 +00:00
dependabot[bot]
a1a1e0b79f build(deps): bump github/codeql-action from 1.1.3 to 2.1.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 1.1.3 to 2.1.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](75f07e7ab2...28eead2408)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 21:39:20 +00:00
dependabot[bot]
5f82d58bb0 build(deps): bump github/super-linter from 4.8.5 to 4.9.1
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.8.5 to 4.9.1.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](b8641364ca...3792fe5373)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 21:37:14 +00:00
Lennart Poettering
bd4dea76de veritysetup: fix memory corruption
We must copy the option string, since in one case we are called with a
pointer into dynamic memory that will be freed by the caller.

As discussed here: https://github.com/systemd/systemd/pull/22908/files#r839394490

Follow-up for: #22908
2022-04-02 02:22:39 +09:00
Yu Watanabe
95cd21928f Merge pull request #22939 from yuwata/tree-wide-space
tree-wide: add space after if, switch, for, and while
2022-04-02 01:32:26 +09:00
Yu Watanabe
b17a681be5 tree-wide: fix typo 2022-04-02 00:34:39 +09:00
Lennart Poettering
0d08db7f89 udev: add /dev/disk/by-diskseq symlink for block devices
This adds another symlink for block devices:

    /dev/disk/by-diskseq/<number>

where the number is the diskseq number as exposed by the kernel. It's
useful for apps because they can use it to open a device by diskseq, in
a way that is safe against device node reuse. I.e. if a device node path
like this is passed to an app it could open the device node via the
symlink and also parse the diskseq from the path. Once the device is
opened it could compare the parsed diskseq with the one returned by
BLKGETDISKSEQ on the open node, and if it matches they know they are
talking to the right device.

Fixes: #22906
2022-04-01 23:44:37 +09:00
Yu Watanabe
37ebfe49de Merge pull request #22926 from bluca/analyze_offline_filter
analyze: fix offline checks for syscall filter and 'native' architecture
2022-04-01 23:43:18 +09:00
Lennart Poettering
356ad32dc2 Merge pull request #22921 from poettering/uid-range-tweaks
userns uid range tweaks: taint systemd if assigned userns uid range too short, and show userns uid range in userdbctl output
2022-04-01 15:58:55 +02:00
Yu Watanabe
798931160e tree-wide: add a space after if, switch, for, and while 2022-04-01 22:48:42 +09:00
Yu Watanabe
72dce85a60 test: add space between arguments 2022-04-01 22:28:13 +09:00
Lennart Poettering
fdf02a4f26 path-util: use STR_IN_SET() where appropriate 2022-04-01 15:23:43 +02:00
Lennart Poettering
6cdd6d1acc notify: remove spurious whitespace 2022-04-01 15:23:43 +02:00
Lennart Poettering
ca782b85fc Merge pull request #22934 from poettering/tls-test-fix-root
tests: make test-resolved-stream suceed even when run as root with restrictive access mode on build tree dir
2022-04-01 15:22:43 +02:00
Lennart Poettering
aed3c5eca3 process-util: refactor APIs for reading /proc/self/xyz symlinks
The three functions for reading cwd, exe and root symlinks of processes
already share a common core: get_process_link_contents(). Let's refactor
that a bit, and move formatting of the /proc/self/ path into this helper
function instead of doing that in the caller, thus sharing more code.

While we are at it, make the return parameters optional, in case the
information if the links are readable is interesting, but the contents
is not. (This also means safe_getcwd() and readlinkat_malloc() are
updated to make the return parameter optional, as these are called by
the relevant three functions)
2022-04-01 15:22:27 +02:00
Luca Boccassi
dd51e725df analyze: fix offline check for syscal filter
The deny/allow list check was inverted, if we are deny listing and the
hashmap contains the syscall then that's good

Fixes https://github.com/systemd/systemd/issues/22914
2022-04-01 10:42:48 +01:00
Luca Boccassi
1449b0f8a9 analyze: fix offline check for 'native' syscall architecture
Enum values are stored in the set, not strings
2022-04-01 10:42:48 +01:00
Yu Watanabe
b8529cf376 Merge pull request #22872 from yuwata/udevadm-wait
udevadm: introduce 'wait' command
2022-04-01 18:41:03 +09:00
Lennart Poettering
9cce7fb193 userdbctl: also show available UID range in current userns
Containers generally have a smaller UID range assigned than host
systems. Let's visualize this in the user/group tables. We insert
markers for unavailable regions. This way display is identical to status
quo ante on host systems, but in containers unavailable ranges will be
shown as that.

And while we are at it, also hide well-known UID ranges when they are
outside of userns uid_map range. This is mostly about the "container"
range. It's pointless showing the cotnainer range (i.e. a range UID >
65535) if that range isn#t available in the container anyway.
2022-04-01 11:21:44 +02:00
Lennart Poettering
49888d31b6 update TODO 2022-04-01 11:21:44 +02:00
Lennart Poettering
63e8df046b pid1: add taint flag if uid/gid userns range too small
This will taint systemd if invoked in containers that do not have the
full 16bit range of UIDs defined.

we pretty much need uid root…nobody to be defined for a variety of
purposes, hence let's add this taint flag. Of course taints are
graceful, but it at least communicates the mess in some way...
2022-04-01 11:21:44 +02:00
Lennart Poettering
556560495e uid-range: replace uid_range_contains() by more generalized uid_range_covers()
The former checks if one UID is inside the uid range set. The latter
checks if a full UID range is inside the uid range set. The former is
hence a special case of the latter.
2022-04-01 11:20:12 +02:00
Lennart Poettering
0a5c6a57c6 uid-range: add some overflow checks 2022-04-01 11:20:12 +02:00