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

systemd / systemd / 15263807472

26 May 2025 08:53PM UTC coverage: 72.046% (-0.002%) from 72.048%
15263807472

push

github

yuwata
src/core/manager.c: log preset activity on first boot

This gives us a little more information about what units were enabled
or disabled on that first boot and will be useful for OS developers
tracking down the source of unit state.

An example with this enabled looks like:

```
NET: Registered PF_VSOCK protocol family
systemd[1]: Applying preset policy.
systemd[1]: Unit /etc/systemd/system/dnsmasq.service is masked, ignoring.
systemd[1]: Unit /etc/systemd/system/systemd-repart.service is masked, ignoring.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket'.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir.mount' → '/etc/systemd/system/var-mnt-workdir.mount'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir\x2dtmp.mount' → '/etc/systemd/system/var-mnt-workdir\x2dtmp.mount'.
systemd[1]: Created symlink '/etc/systemd/system/afterburn-sshkeys.target.requires/afterburn-sshkeys@core.service' → '/usr/lib/systemd/system/afterburn-sshkeys@.service'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket' → '/usr/lib/systemd/system/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket' → '/usr/lib/systemd/system/systemd-resolved-monitor.socket'.
systemd[1]: Populated /etc with preset unit settings.
```

Considering it only happens on first boot and not on every boot I think
the extra information is worth the extra verbosity in the logs just for
that boot.

5 of 6 new or added lines in 1 file covered. (83.33%)

5463 existing lines in 165 files now uncovered.

299151 of 415222 relevant lines covered (72.05%)

702386.45 hits per line

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

94.74
/src/basic/glob-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <dirent.h>
4
#include <sys/stat.h>
5

6
#include "dirent-util.h"
7
#include "errno-util.h"
8
#include "glob-util.h"
9
#include "log.h"
10
#include "string-util.h"
11
#include "strv.h"
12

13
static void closedir_wrapper(void* v) {
11,189✔
14
        (void) closedir(v);
11,189✔
15
}
11,189✔
16

17
int safe_glob(const char *path, int flags, glob_t *pglob) {
42,855✔
18
        int k;
42,855✔
19

20
        /* We want to set GLOB_ALTDIRFUNC ourselves, don't allow it to be set. */
21
        assert(!(flags & GLOB_ALTDIRFUNC));
42,855✔
22

23
        if (!pglob->gl_closedir)
42,855✔
24
                pglob->gl_closedir = closedir_wrapper;
42,852✔
25
        if (!pglob->gl_readdir)
42,855✔
26
                pglob->gl_readdir = (struct dirent *(*)(void *)) readdir_no_dot;
42,852✔
27
        if (!pglob->gl_opendir)
42,855✔
28
                pglob->gl_opendir = (void *(*)(const char *)) opendir;
36,351✔
29
        if (!pglob->gl_lstat)
42,855✔
30
                pglob->gl_lstat = lstat;
42,852✔
31
        if (!pglob->gl_stat)
42,855✔
32
                pglob->gl_stat = stat;
42,852✔
33

34
        errno = 0;
42,855✔
35
        k = glob(path, flags | GLOB_ALTDIRFUNC, NULL, pglob);
42,855✔
36
        if (k == GLOB_NOMATCH)
42,855✔
37
                return -ENOENT;
38
        if (k == GLOB_NOSPACE)
8,279✔
39
                return -ENOMEM;
40
        if (k != 0)
8,279✔
UNCOV
41
                return errno_or_else(EIO);
×
42
        if (strv_isempty(pglob->gl_pathv))
8,279✔
UNCOV
43
                return -ENOENT;
×
44

45
        return 0;
46
}
47

48
int glob_first(const char *path, char **ret_first) {
12✔
49
        _cleanup_globfree_ glob_t g = {};
12✔
50
        int k;
12✔
51

52
        assert(path);
12✔
53

54
        k = safe_glob(path, GLOB_NOSORT|GLOB_BRACE, &g);
12✔
55
        if (k == -ENOENT) {
12✔
56
                if (ret_first)
6✔
57
                        *ret_first = NULL;
5✔
58
                return false;
6✔
59
        }
60
        if (k < 0)
6✔
61
                return k;
62

63
        if (ret_first) {
6✔
64
                assert(g.gl_pathv && g.gl_pathv[0]);
3✔
65

66
                char *first = strdup(g.gl_pathv[0]);
3✔
67
                if (!first)
3✔
UNCOV
68
                        return log_oom_debug();
×
69
                *ret_first = first;
3✔
70
        }
71

72
        return true;
73
}
74

75
int glob_extend(char ***strv, const char *path, int flags) {
4,137✔
76
        _cleanup_globfree_ glob_t g = {};
4,137✔
77
        int k;
4,137✔
78

79
        k = safe_glob(path, GLOB_NOSORT|GLOB_BRACE|flags, &g);
4,137✔
80
        if (k < 0)
4,137✔
81
                return k;
82

83
        return strv_extend_strv(strv, g.gl_pathv, false);
4,137✔
84
}
85

86
int glob_non_glob_prefix(const char *path, char **ret) {
3,648✔
87
        /* Return the path of the path that has no glob characters. */
88

89
        size_t n = strcspn(path, GLOB_CHARS);
3,648✔
90

91
        if (path[n] != '\0')
3,648✔
92
                while (n > 0 && path[n-1] != '/')
66,778✔
93
                        n--;
94

95
        if (n == 0)
3,648✔
96
                return -ENOENT;
97

98
        char *ans = strndup(path, n);
3,647✔
99
        if (!ans)
3,647✔
100
                return -ENOMEM;
101
        *ret = ans;
3,647✔
102
        return 0;
3,647✔
103
}
104

105
bool string_is_glob(const char *p) {
226,002✔
106
        /* Check if a string contains any glob patterns. */
107
        return !!strpbrk(p, GLOB_CHARS);
226,002✔
108
}
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