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

systemd / systemd / 29132483780

10 Jul 2026 08:43PM UTC coverage: 72.912% (+0.2%) from 72.702%
29132483780

push

github

bluca
man: run forgotten 'update-man-rules'

344600 of 472622 relevant lines covered (72.91%)

1365091.83 hits per line

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

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

3
#include "sd-bus.h"
4

5
#include "bus-error.h"
6
#include "bus-locator.h"
7
#include "conf-files.h"
8
#include "constants.h"
9
#include "log.h"
10
#include "login-util.h"
11
#include "path-util.h"
12
#include "set.h"
13
#include "string-util.h"
14
#include "strv.h"
15
#include "sysupdate-util.h"
16

17
int reboot_now(void) {
×
18
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
×
19
        _cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
×
20
        int r;
×
21

22
        r = sd_bus_open_system(&bus);
×
23
        if (r < 0)
×
24
                return log_error_errno(r, "Failed to open bus connection: %m");
×
25

26
        r = bus_call_method(bus, bus_login_mgr, "RebootWithFlags", &error, NULL, "t",
×
27
                            (uint64_t) SD_LOGIND_ROOT_CHECK_INHIBITORS);
28
        if (r < 0)
×
29
                return log_error_errno(r, "Failed to issue reboot request: %s", bus_error_message(&error, r));
×
30

31
        return 0;
32
}
33

34
bool feature_name_valid(const char *c) {
×
35

36
        if (!string_is_safe(c, STRING_FILENAME_PART))
×
37
                return false;
38

39
        /* Stack allocation is safe, since STRING_FILENAME_PART includes a length check */
40
        const char *j = strjoina(c, ".feature.d");
×
41

42
        return filename_is_valid(j);
×
43
}
44

45
bool component_name_valid(const char *c) {
145✔
46
        /* See if the specified string enclosed in the directory prefix+suffix would be a valid file name */
47

48
        if (!string_is_safe(c, STRING_FILENAME_PART))
145✔
49
                return false;
50

51
        if (endswith(c, ".component")) /* don't allow ambiguity around sysupdate.<foobar>.component.d/ */
121✔
52
                return false;
53

54
        /* Stack allocation is safe, since STRING_FILENAME_PART includes a length check */
55
        const char *j = strjoina("sysupdate.", c, ".component.d");
847✔
56

57
        return filename_is_valid(j);
121✔
58
}
59

60
int get_component_list(const char *root, char ***ret) {
182✔
61
        int r;
182✔
62

63
        assert(ret);
182✔
64

65
        ConfFile **directories = NULL;
182✔
66
        size_t n_directories = 0;
182✔
67
        CLEANUP_ARRAY(directories, n_directories, conf_file_free_array);
182✔
68

69
        r = conf_files_list_strv_full(
364✔
70
                        ".d",
71
                        root,
72
                        CONF_FILES_DIRECTORY|CONF_FILES_WARN,
73
                        (const char * const *) CONF_PATHS_STRV(""),
182✔
74
                        &directories,
75
                        &n_directories);
76
        if (r < 0)
182✔
77
                return r;
78

79
        _cleanup_set_free_ Set *names = NULL;
182✔
80

81
        FOREACH_ARRAY(i, directories, n_directories) {
4,615✔
82
                ConfFile *e = *i;
4,433✔
83

84
                const char *s = startswith(e->filename, "sysupdate.");
4,433✔
85
                if (!s)
4,433✔
86
                        continue;
4,186✔
87

88
                const char *a = endswith(s, ".d");
247✔
89
                if (!a)
247✔
90
                        continue;
181✔
91

92
                if (a == s)
66✔
93
                        continue;
×
94

95
                _cleanup_free_ char *n = strndup(s, a - s);
×
96
                if (!n)
66✔
97
                        return log_oom();
×
98

99
                if (!component_name_valid(n))
66✔
100
                        continue;
×
101

102
                r = set_ensure_consume(&names, &string_hash_ops_free, TAKE_PTR(n));
66✔
103
                if (r < 0 && r != -EEXIST)
66✔
104
                        return r;
105
        }
106

107
        _cleanup_strv_free_ char **z = set_to_strv(&names);
364✔
108
        if (!z)
182✔
109
                return -ENOMEM;
110

111
        strv_sort(z);
182✔
112

113
        *ret = TAKE_PTR(z);
182✔
114
        return 0;
182✔
115
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc