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

systemd / systemd / 21846209963

09 Feb 2026 03:52PM UTC coverage: 72.697% (-0.02%) from 72.716%
21846209963

push

github

daandemeyer
meson: guard symlinks in sysconfdir behind install_sysconfidr

Symlinks to files inside sysconfdir are now only installed if
ìnstall_sysconfdir=true (which is the default).

If sshconfdir,sshdconfdir,shellprofiledir are not inside sysconfdir and
install_sysconfidr=false, these symlinks are still installed to the
configured directory.

311951 of 429113 relevant lines covered (72.7%)

1156102.48 hits per line

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

73.85
/src/bootctl/bootctl-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <stdlib.h>
4
#include <sys/mman.h>
5

6
#include "alloc-util.h"
7
#include "boot-entry.h"
8
#include "bootctl.h"
9
#include "bootctl-util.h"
10
#include "errno-util.h"
11
#include "fileio.h"
12
#include "log.h"
13
#include "stat-util.h"
14
#include "string-util.h"
15
#include "sync-util.h"
16

17
int sync_everything(void) {
147✔
18
        int r = 0, k;
147✔
19

20
        if (arg_esp_path) {
147✔
21
                k = syncfs_path(AT_FDCWD, arg_esp_path);
147✔
22
                if (k < 0)
147✔
23
                        RET_GATHER(r, log_error_errno(k, "Failed to synchronize the ESP '%s': %m", arg_esp_path));
×
24
        }
25

26
        if (arg_xbootldr_path) {
147✔
27
                k = syncfs_path(AT_FDCWD, arg_xbootldr_path);
73✔
28
                if (k < 0)
73✔
29
                        RET_GATHER(r, log_error_errno(k, "Failed to synchronize $BOOT '%s': %m", arg_xbootldr_path));
×
30
        }
31

32
        return r;
147✔
33
}
34

35
const char* get_efi_arch(void) {
146✔
36
        /* Detect EFI firmware architecture of the running system. On mixed mode systems, it could be 32-bit
37
         * while the kernel is running in 64-bit. */
38

39
#ifdef __x86_64__
40
        _cleanup_free_ char *platform_size = NULL;
146✔
41
        int r;
146✔
42

43
        r = read_one_line_file("/sys/firmware/efi/fw_platform_size", &platform_size);
146✔
44
        if (r == -ENOENT)
146✔
45
                return EFI_MACHINE_TYPE_NAME;
46
        if (r < 0) {
37✔
47
                log_warning_errno(r,
×
48
                        "Error reading EFI firmware word size, assuming machine type '%s': %m",
49
                        EFI_MACHINE_TYPE_NAME);
50
                return EFI_MACHINE_TYPE_NAME;
×
51
        }
52

53
        if (streq(platform_size, "64"))
37✔
54
                return EFI_MACHINE_TYPE_NAME;
55
        if (streq(platform_size, "32"))
×
56
                return "ia32";
57

58
        log_warning(
×
59
                "Unknown EFI firmware word size '%s', using machine type '%s'.",
60
                platform_size,
61
                EFI_MACHINE_TYPE_NAME);
62
#endif
63

64
        return EFI_MACHINE_TYPE_NAME;
65
}
66

67
/* search for "#### LoaderInfo: systemd-boot 218 ####" string inside the binary */
68
int get_file_version(int fd, char **ret) {
572✔
69
        struct stat st;
572✔
70
        char *buf;
572✔
71
        const char *s, *e;
572✔
72
        char *marker = NULL;
572✔
73
        int r;
572✔
74

75
        assert(fd >= 0);
572✔
76
        assert(ret);
572✔
77

78
        /* Does not reposition file offset (as it uses mmap()) */
79

80
        if (fstat(fd, &st) < 0)
572✔
81
                return log_error_errno(errno, "Failed to stat EFI binary: %m");
×
82

83
        r = stat_verify_regular(&st);
572✔
84
        if (r < 0) {
572✔
85
                log_debug_errno(r, "EFI binary is not a regular file, assuming no version information: %m");
×
86
                return -ESRCH;
×
87
        }
88

89
        if (st.st_size < 27 || file_offset_beyond_memory_size(st.st_size))
572✔
90
                return log_debug_errno(SYNTHETIC_ERRNO(ESRCH),
×
91
                                       "EFI binary size too %s: %"PRIi64,
92
                                       st.st_size < 27 ? "small" : "large", st.st_size);
93

94
        buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
572✔
95
        if (buf == MAP_FAILED)
572✔
96
                return log_error_errno(errno, "Failed to mmap EFI binary: %m");
×
97

98
        s = mempmem_safe(buf, st.st_size - 8, "#### LoaderInfo: ", 17);
572✔
99
        if (!s) {
572✔
100
                r = log_debug_errno(SYNTHETIC_ERRNO(ESRCH), "EFI binary has no LoaderInfo marker.");
×
101
                goto finish;
×
102
        }
103

104
        e = memmem_safe(s, st.st_size - (s - buf), " ####", 5);
572✔
105
        if (!e || e - s < 3) {
572✔
106
                r = log_error_errno(SYNTHETIC_ERRNO(EINVAL), "EFI binary has malformed LoaderInfo marker.");
×
107
                goto finish;
×
108
        }
109

110
        marker = strndup(s, e - s);
572✔
111
        if (!marker) {
572✔
112
                r = log_oom();
×
113
                goto finish;
×
114
        }
115

116
        log_debug("EFI binary LoaderInfo marker: \"%s\"", marker);
572✔
117
        r = 0;
572✔
118
        *ret = marker;
572✔
119
finish:
572✔
120
        (void) munmap(buf, st.st_size);
572✔
121
        return r;
572✔
122
}
123

124
int settle_entry_token(void) {
18✔
125
        int r;
18✔
126

127
        r = boot_entry_token_ensure(
18✔
128
                        arg_root,
129
                        secure_getenv("KERNEL_INSTALL_CONF_ROOT"),
18✔
130
                        arg_machine_id,
131
                        /* machine_id_is_random= */ false,
132
                        &arg_entry_token_type,
133
                        &arg_entry_token);
134
        if (r < 0)
18✔
135
                return r;
136

137
        log_debug("Using entry token: %s", arg_entry_token);
18✔
138
        return 0;
139
}
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