Commit Graph
59562 Commits
Author SHA1 Message Date
Lennart Poettering da8f277c09 bootspec: let's actually use the result of strstrip() for further parsing
Also, given we are looking for whitespace as separators, just pass NULL
as separators, extract_first_word() defaults to whitespace after all.
2022-09-02 14:25:48 +02:00
Lennart Poettering bb9133bb46 bootspec: simplify paths + insist they are normalized
Inspired by #23913, let's complain if people use paths with ".."
in Type #1 bootspec entries.

Let's prefix all paths with "/" if it is missing.

Let's simplify all paths.

let's refuse paths/warn with "..".

Fixes: #23913
2022-09-02 14:25:46 +02:00
Lennart Poettering 81e327c42c Merge pull request #24491 from poettering/compare-order
condition: unify operator parsing handling
2022-09-02 07:18:10 +02:00
Johannes Schauer Marin Rodrigues 3fa8a1148a sysusers: make sp_lstchg shadow field reproducible
If the environment variable SOURCE_DATE_EPOCH is set, use its value
instead of the current time.
2022-09-02 07:17:25 +02:00
Luca Boccassi dddec402de Merge pull request #24530 from poettering/loop-with-more-lock
a variety of loopback block device fixes
2022-09-02 00:04:32 +01:00
Lennart Poettering 10736074b4 mention ConditionKernelVersion= compat break in NEWS 2022-09-01 23:20:11 +02:00
Lennart Poettering 71a3ff036b condition: change operator logic to use $= instead of =$ for glob comparisons
So this is a bit of a bikeshedding thing. But I think we should do this
nonetheless, before this is released.

Playing around with the glob matches I realized that "=$" is really hard
to grep for, since in shell code it's an often seen construct. Also,
when reading code I often found myself thinking first that the "$"
belongs to the rvalue instead of the operator, in a variable expansion
scheme.

If we move the $ character to the left hand, I think we are on the safer
side, since usually lvalues are much more restricted in character sets
than rvalues (at least most programming languages do enforce limits on
the character set for identifiers).

It makes it much easier to grep for the new operator, and easier to read
too. Example:

before:
    ConditionOSRelease=ID=$fedora-*
after:
    ConditionOSRelease=ID$=fedora-*
2022-09-01 23:16:13 +02:00
Lennart Poettering 06219747f5 condition: change ConditionKernelVersion= so that =/!= mean literal string comparison, and ==/<> version comparison
The only reason to do this is to ensure uniformity with the other
options, that work like this, i.e. ConditionOSRelease= or
ConditionSecurity=.

This is a compatibility break, but a minor one, given that string
comparison and version comparison is mostly the same for equality and
inequality.
2022-09-01 23:16:13 +02:00
Lennart Poettering 666d314a74 condition: allow literal string compares in SMBIOS condition
This ensures that "=" and "!=" are now interpreted as literal string
compares, and "==" and "<>" are for version compares.

This is not a compat break, since the SMBIOS stuff has not been included
in any release yet.

Main reason to do this, is to be systematic with the other conditions
that check for text stuff.
2022-09-01 23:16:13 +02:00
Lennart Poettering c990742523 condition: allow fnmatch() matches in ConditionKernelVersion=
This is mostly to make things systematic, and brings no new
functionality, as not specifying any operator is identical to prefixing
with =$ anyway.
2022-09-01 23:16:13 +02:00
Lennart Poettering 4803b0bcaa compare: add macro for operator charset 2022-09-01 23:16:13 +02:00
Lennart Poettering 5f6b2d394b compare: propagate errors of fnmatch() as errors 2022-09-01 23:16:13 +02:00
Lennart Poettering 2e8fa6274d compare: support textual operators, and port analyze over to it 2022-09-01 23:16:13 +02:00
Lennart Poettering 6061c86693 compare: add two new operators "==" and "<>"
These two operators always indicate ordering comparisons, as opposed to
"=" and "!=" which depending on context mean literal string compares.

This is useful for ConditionOSRelease= for example, as this means
there's now always a way to do version compares.
2022-09-01 23:16:13 +02:00
Lennart Poettering 38c09fa008 compare: rework table in parse_compare_operator() to be array of structs
Let's change the lookup table to contain pairs of operator/strings,
instead of being indexed by operator.

The table isn't dense anymore, and this allows us to add alias strings
sooner or later.
2022-09-01 23:16:10 +02:00
Lennart Poettering 8daa674090 condition: allow fnmatch compares for ConditionOSRelease=
We support this for smbios matches, hence do so for /etc/os-release
matches too.
2022-09-01 23:15:14 +02:00
Lennart Poettering 57610982f7 compare: add flag for parse_compare_operator() to do equality/inequality comparison via simple string compares
This allows us to switch condition_test_osrelease() to use generic
version_or_fnmatch_compare() for executing the comparison.
2022-09-01 23:15:14 +02:00
Lennart Poettering 69f0a6091b compare: add a proper flags field for parse_compare_operator() 2022-09-01 23:15:14 +02:00
Lennart Poettering 97c7bed90a compare: drop use of FNM_EXTMATCH for now
None of our other fnmatch() calls make use of this, and the concept was
new to me at least. Given that this is only used for the recently added
SMBIOS field matches (and is not included in any release) let's disable
"extended" matches for now. We can certainly revisit this, and enable it
later if there is real demand, but if we do, we should probably add that
all over the place, not just for smbios matches.
2022-09-01 23:15:14 +02:00
Lennart Poettering 8bd2cf6e11 comapre: add generic implementation for comapring with verscmp+fnmatch 2022-09-01 23:15:14 +02:00
Lennart Poettering 650c4c8707 compare: move test_order() → compare-operator.[ch] 2022-09-01 23:15:14 +02:00
Lennart Poettering a8835c1190 condition: split out order operator enum
Let's move the operator enum into its own .c/.h file, so that we can
reuse it elsewhere, in particular systemd-analyze's compare-versions
logic.

Let's rename the concept CompareOperator, since it is nowadays
genericlaly about both order *and* fnmatch comparisons, hence just
naming it "order" is misleading.
2022-09-01 23:12:34 +02:00
Lennart Poettering 7cb349f0ca loop-util: make clearer how LoopDevice objects that do not encapsulate an actual loopback device are set up 2022-09-01 22:06:19 +02:00
Lennart Poettering 4c1d50e65c loop-util: lock the control device around clearing the loopback device and deleting it
This mirrors what we already do during allocation. We lock the control
device first, and then release the block device and then delete it.

This makes things substantially more robust as long all participants do
such locking: we won't attempt to delete a block device somebody else
already is using.
2022-09-01 22:06:19 +02:00
Lennart Poettering 87862cc2b4 loop-util: close lock fd before trying LOOP_CLR_FD in failure path
If the loopback device is open more than once LOOP_CLR_FD will fail,
hence close the lock fd first explicitly, so there's definitely only one
fd left.
2022-09-01 22:06:19 +02:00
Lennart Poettering 247738b4f5 loop-util: drop code to attach empty file
Back when I wrote this code I wasn't aware of BLKPG and what it can do.
Hence I came up with this hack to attach an empty file to delete all
partitions. But today we can do better with BLKPG: let's just explicitly
remove all partitions, and then try again.
2022-09-01 22:06:19 +02:00
Lennart Poettering 7f52206a2b loop-util: rework how we lock loopback block devices
Let's rework how we lock loopback block devices in two ways:

1. Lock a separate fd, instead of the main block device fd. We already
   did that for our internal locking when allocating loopback block
   devices, but do so for the exposed locking (i.e.
   loop_device_flock()), too, so that the lock is independent of the
   main fd we actually use of IO.

2. Instead of locking the device during allocation of the loopback
   device, then unlocking it (which will make udev run), and then
   re-locking things if we need, let's instead just keep the lock the
   whole time, to make things a bit safer and faster, and not have to
   wait for udev at all. This is done by adding a "lock_op" parameter to
   loop device allocation functions that declares the initial state of
   the lock, and is one of LOCK_UN/LOCK_SH/LOCK_EX. This change also
   shortens a lot of code, since we allocate + immediately lock loopback
   devices pretty much everywhere.
2022-09-01 22:05:32 +02:00
Lennart Poettering 234c2e16e5 dissect: drop partition removal code
This reverts a major chunk of 75d7e04eb4

Now that the loopback device code already destroys the partitions we
don't have to do this here anymore.

I am sure the right place to delete the partitions is in the loopback
code, since we really only should do that for loopback devices, see
bug #24431, and not on "real" block devices.

I am also not convinced dropping partitions the dissection logic doesn't
care about is a good idea, after all. The dissection stuff should
probably not consider itself the "owner" of the block devices it
analyzes, but take a more passive role: figure out what is what, but not
modify it.

Fixes: #24431
2022-09-01 22:05:10 +02:00
Lennart Poettering e8383058b2 dissect: don't remove partitions explicitly on umount anymore
We do that now automatically when releasing the loopback device, hence
we can drop the redundant try entirely.
2022-09-01 20:42:17 +02:00
Lennart Poettering 3a6ed1e19d loop-util: when clearing a loopback device delete partitions first, and take BSD lock
Whenever we release a loopback device, let's first synchronously delete
all partitions, so that we know that's complete and not done
asynchronously in the background. Take a BSD lock on the device while
doing so, so that udev won't make the devices busy while we do this.
2022-09-01 20:41:08 +02:00
Lennart Poettering ff27ef4b59 loop: convert impossibe EBADF cases into asserts 2022-09-01 20:40:01 +02:00
Yu Watanabe 0a3e413516 github: update differential shellcheck to v3.0.1
v3 supports external sources. Yey!
2022-09-01 17:27:09 +00:00
Yu Watanabe 51165cf587 Merge pull request #24531 from poettering/loop-resize-part-modernizations
loopback block device resize partition modernizations
2022-09-02 00:53:38 +09:00
Lennart Poettering ed13feff1e loop-util: use DEVNUM_FORMAT_STR more 2022-09-01 16:00:45 +02:00
Lennart Poettering 91e1ce1a7c loop-util: move resize partition ioctl call to blockdev-util.[ch]
The other BLKPG calls have wrappers in blockdev-util.[ch], let's place
them all there.

No change in behaviour.
2022-09-01 15:59:54 +02:00
Antonio Alvarez Feijoo cf0dc88da6 man: remove reference to mkinitrd 2022-09-01 14:09:30 +01:00
dependabot[bot] c19053e657 build(deps): bump meson from 0.63.0 to 0.63.1 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 0.63.0 to 0.63.1.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/0.63.0...0.63.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 10:31:30 +00:00
dependabot[bot] d1cc2654fd build(deps): bump github/super-linter from 4.9.5 to 4.9.6
Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.5 to 4.9.6.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/2d64ac1c067c34beaf7d24cc12733cd46236f76e...01d3218744765b55c3b5ffbb27e50961e50c33c5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 09:21:53 +00:00
dependabot[bot] 42907767bd build(deps): bump redhat-plumbers-in-action/advanced-issue-labeler
Bumps [redhat-plumbers-in-action/advanced-issue-labeler](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler/releases)
- [Commits](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler/compare/b89eb39b97529bb7596cb4e716485a6d6f7dd74a...d12b782ff92bc9ac535fb09c925aaa5be9e40f69)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/advanced-issue-labeler
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 09:08:19 +00:00
Lennart Poettering b7b7441de4 update TODO 2022-09-01 09:48:40 +02:00
Colin Walters 413e8650b7 tree-wide: Use "unmet" for condition checks, not "failed"
Often I end up debugging a problem on a system, and I
do e.g. `journalctl --grep=failed|error`.  The use of the term
"failed" for condition checks adds a *lot* of unnecessary noise into
this.

Now, I know this regexp search isn't precise, but it has proven
to be useful to me.

I think "failed" is too strong of a term as a baseline, and also
just stands out to e.g. humans watching their servers boot or
whatever.

The term "met condition" is fairly widely used, e.g.
https://stackoverflow.com/questions/63751794/what-does-the-condition-is-met-exactly-mean-in-programming-languages

Use that instead.
2022-09-01 15:03:40 +09:00
Yu Watanabe 133ac84e60 udevadm-settle: improve logs when we cannot access /run/udev/control
Addresses https://github.com/systemd/systemd/pull/24474#discussion_r959696663.
2022-08-31 22:26:06 +01:00
Frantisek Sumsal 47190275cf Merge pull request #24515 from yuwata/dissect-timeout
dissect-image: extend timeout for waiting devlink
2022-08-31 18:03:00 +00:00
Lennart Poettering a9f1bf409f update TODO 2022-08-31 18:29:30 +02:00
Jan Janssen 3a4e4fface tree-wide: Use devnum helpers in a few more places 2022-09-01 00:55:37 +09:00
Lennart Poettering 18f806b8d9 test: don't mistake error for success
Follow-up for acd3c86624
2022-09-01 00:54:28 +09:00
Luca Boccassi df16869660 shellcheck/labeler: disable on systemd-security 2022-09-01 00:53:46 +09:00
Lennart Poettering 7fd0fb02a1 condition: properly handle fnmatch() errors in ConditionHost 2022-08-31 17:31:28 +02:00
Lennart Poettering 6eeadaa141 path-util: return error if fnmatch() fails 2022-08-31 17:31:11 +02:00
Yu Watanabe 39fdc6f82d test-29-portable: enable debugging logs of udevd 2022-08-31 23:33:13 +09:00