]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysupdate: handle slashes after pattern fields
authordongshengyuan <545258830@qq.com>
Mon, 6 Jul 2026 05:40:26 +0000 (13:40 +0800)
committerKai Lüke <pothos@users.noreply.github.com>
Thu, 9 Jul 2026 12:36:36 +0000 (14:36 +0200)
Patterns such as foo_@v/bar.efi are documented to
match files in versioned subdirectories,
but pattern_match() assumed that a field is
always followed by a literal when another element exists.

Handle a following slash as a delimiter too,
and request another recursion step
when the current path ends before that slash.

Fixes #42895.
Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
src/sysupdate/sysupdate-pattern.c

index f06265c698fa124dad265af9128f8c3ac2f04934..c859bd111cdfbe3a3e2ac2162e8fe75fe84d359e 100644 (file)
@@ -248,12 +248,14 @@ int pattern_match(const char *pattern, const char *s, InstanceMetadata *ret) {
                 }
 
                 if (e->elements_next) {
-                        /* The next element must be literal, as we use it to determine where to split */
-                        assert(e->elements_next->type == PATTERN_LITERAL);
-
-                        n = strstr(p, e->elements_next->literal);
-                        if (!n)
-                                goto nope;
+                        if (e->elements_next->type == PATTERN_LITERAL) {
+                                n = strstr(p, e->elements_next->literal);
+                                if (!n)
+                                        goto nope;
+                        } else if (e->elements_next->type == PATTERN_SLASH)
+                                n = strchrnul(p, '/');
+                        else
+                                assert_not_reached();
 
                 } else
                         /* End of the string */