• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 21419361949

27 Jan 2026 02:53PM UTC coverage: 72.793% (-0.03%) from 72.821%
21419361949

push

github

keszybz
kernel-install: handle removal unsuccessful UKIs and loader entries separately

When a tries file exists, 90-uki-copy.install removes a previous UKI of the
same kernel version and all it's unbooted variants. This removal is guarded
behind a check for the existence of the already booted UKI, i.e. if uki.efi
already exists, uki.efi and uki+*.efi will be removed.

This leaves the edge case that if uki.efi does not exist, but only an unbooted,
e.g. uki+3.efi, it will not be removed. This is not a problem, if the number of
tries is constant between both builds, since a new uki+3.efi would overwrite
the existing one, but if the number of tries is changed to, e.g. uki+5.efi, we
are left with both uki+3.efi and uki+5.efi.

The same is done for loader entries.

311334 of 427698 relevant lines covered (72.79%)

1157141.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.69
/src/shared/kernel-config.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "alloc-util.h"
4
#include "conf-parser.h"
5
#include "fd-util.h"
6
#include "kernel-config.h"
7
#include "path-util.h"
8

9
int load_kernel_install_conf_at(
155✔
10
                const char *root,
11
                int root_fd,
12
                const char *conf_root,
13
                char **ret_machine_id,
14
                char **ret_boot_root,
15
                char **ret_layout,
16
                char **ret_initrd_generator,
17
                char **ret_uki_generator) {
18

19
        _cleanup_free_ char *machine_id = NULL, *boot_root = NULL, *layout = NULL,
×
20
                            *initrd_generator = NULL, *uki_generator = NULL;
155✔
21
        const ConfigTableItem items[] = {
155✔
22
                { NULL, "MACHINE_ID",       config_parse_string, 0, &machine_id       },
23
                { NULL, "BOOT_ROOT",        config_parse_string, 0, &boot_root        },
24
                { NULL, "layout",           config_parse_string, 0, &layout           },
25
                { NULL, "initrd_generator", config_parse_string, 0, &initrd_generator },
26
                { NULL, "uki_generator",    config_parse_string, 0, &uki_generator    },
27
                {}
28
        };
29
        int r;
155✔
30

31
        assert(root_fd >= 0 || IN_SET(root_fd, AT_FDCWD, XAT_FDROOT));
155✔
32

33
        if (conf_root) {
155✔
34
                _cleanup_free_ char *conf = path_join(conf_root, "install.conf");
×
35
                if (!conf)
×
36
                        return log_oom();
×
37

38
                r = config_parse_many_full(
×
39
                                STRV_MAKE_CONST(conf),
×
40
                                STRV_MAKE_CONST(conf_root),
×
41
                                "install.conf.d",
42
                                root,
43
                                root_fd,
44
                                /* sections= */ NULL,
45
                                config_item_table_lookup, items,
46
                                CONFIG_PARSE_WARN,
47
                                /* userdata= */ NULL,
48
                                /* ret_stats_by_path= */ NULL,
49
                                /* ret_dropin_files= */ NULL);
50
        } else
51
                r = config_parse_standard_file_with_dropins_full(
155✔
52
                                root,
53
                                root_fd,
54
                                "kernel/install.conf",
55
                                /* sections= */ NULL,
56
                                config_item_table_lookup, items,
57
                                CONFIG_PARSE_WARN,
58
                                /* userdata= */ NULL,
59
                                /* ret_stats_by_path= */ NULL,
60
                                /* ret_dropin_files= */ NULL);
61
        if (r < 0 && r != -ENOENT)
155✔
62
                return r;
63

64
        if (ret_machine_id)
155✔
65
                *ret_machine_id = TAKE_PTR(machine_id);
×
66
        if (ret_boot_root)
155✔
67
                *ret_boot_root = TAKE_PTR(boot_root);
×
68
        if (ret_layout)
155✔
69
                *ret_layout = TAKE_PTR(layout);
155✔
70
        if (ret_initrd_generator)
155✔
71
                *ret_initrd_generator = TAKE_PTR(initrd_generator);
×
72
        if (ret_uki_generator)
155✔
73
                *ret_uki_generator = TAKE_PTR(uki_generator);
×
74
        return r >= 0;  /* Return 0 if we got -ENOENT above, 1 otherwise. */
155✔
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc