• 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

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

3
#include <syslog.h>
4

5
#include "sd-id128.h"
6

7
#include "glob-util.h"
8
#include "hexdecoct.h"
9
#include "path-util.h"
10
#include "string-table.h"
11
#include "string-util.h"
12
#include "syslog-util.h"
13
#include "unit-name.h"
14

15
int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
950,358✔
16
        int a = 0, b = 0, c = 0;
950,358✔
17
        const char *end;
950,358✔
18
        size_t k;
950,358✔
19

20
        assert(p);
950,358✔
21
        assert(*p);
950,358✔
22
        assert(priority);
950,358✔
23

24
        if ((*p)[0] != '<')
950,358✔
25
                return 0;
26

27
        end = strchr(*p, '>');
423✔
28
        if (!end)
423✔
29
                return 0;
30

31
        k = end - *p;
423✔
32
        assert(k > 0);
423✔
33

34
        if (k == 2)
423✔
35
                c = undecchar((*p)[1]);
9✔
36
        else if (k == 3) {
414✔
37
                b = undecchar((*p)[1]);
408✔
38
                c = undecchar((*p)[2]);
408✔
39
        } else if (k == 4) {
6✔
40
                a = undecchar((*p)[1]);
2✔
41
                b = undecchar((*p)[2]);
2✔
42
                c = undecchar((*p)[3]);
2✔
43
        } else
44
                return 0;
45

46
        if (a < 0 || b < 0 || c < 0 ||
419✔
47
            (!with_facility && (a || b || c > 7)))
9✔
48
                return 0;
49

50
        if (with_facility)
7✔
51
                *priority = a*100 + b*10 + c;
410✔
52
        else
53
                *priority = (*priority & LOG_FACMASK) | c;
7✔
54

55
        *p += k + 1;
417✔
56
        return 1;
417✔
57
}
58

59
static const char *const log_facility_unshifted_table[LOG_NFACILITIES] = {
60
        [LOG_FAC(LOG_KERN)]     = "kern",
61
        [LOG_FAC(LOG_USER)]     = "user",
62
        [LOG_FAC(LOG_MAIL)]     = "mail",
63
        [LOG_FAC(LOG_DAEMON)]   = "daemon",
64
        [LOG_FAC(LOG_AUTH)]     = "auth",
65
        [LOG_FAC(LOG_SYSLOG)]   = "syslog",
66
        [LOG_FAC(LOG_LPR)]      = "lpr",
67
        [LOG_FAC(LOG_NEWS)]     = "news",
68
        [LOG_FAC(LOG_UUCP)]     = "uucp",
69
        [LOG_FAC(LOG_CRON)]     = "cron",
70
        [LOG_FAC(LOG_AUTHPRIV)] = "authpriv",
71
        [LOG_FAC(LOG_FTP)]      = "ftp",
72
        [LOG_FAC(LOG_LOCAL0)]   = "local0",
73
        [LOG_FAC(LOG_LOCAL1)]   = "local1",
74
        [LOG_FAC(LOG_LOCAL2)]   = "local2",
75
        [LOG_FAC(LOG_LOCAL3)]   = "local3",
76
        [LOG_FAC(LOG_LOCAL4)]   = "local4",
77
        [LOG_FAC(LOG_LOCAL5)]   = "local5",
78
        [LOG_FAC(LOG_LOCAL6)]   = "local6",
79
        [LOG_FAC(LOG_LOCAL7)]   = "local7",
80
};
81

82
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int, LOG_FAC(~0));
291✔
83

UNCOV
84
bool log_facility_unshifted_is_valid(int facility) {
×
85
        return facility >= 0 && facility <= LOG_FAC(~0);
×
86
}
87

88
static const char *const log_level_table[] = {
89
        [LOG_EMERG]   = "emerg",
90
        [LOG_ALERT]   = "alert",
91
        [LOG_CRIT]    = "crit",
92
        [LOG_ERR]     = "err",
93
        [LOG_WARNING] = "warning",
94
        [LOG_NOTICE]  = "notice",
95
        [LOG_INFO]    = "info",
96
        [LOG_DEBUG]   = "debug",
97
};
98

99
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int, LOG_DEBUG);
51,251✔
100

101
bool log_level_is_valid(int level) {
700,778✔
102
        return level >= 0 && level <= LOG_DEBUG;
700,778✔
103
}
104

105
/* The maximum size for a log namespace length. This is the file name size limit 255 minus the size of a
106
 * formatted machine ID minus a separator char */
107
#define LOG_NAMESPACE_MAX (NAME_MAX - (SD_ID128_STRING_MAX - 1) - 1)
108

109
bool log_namespace_name_valid(const char *s) {
712✔
110
        /* Let's make sure the namespace fits in a filename that is prefixed with the machine ID and a dot
111
         * (so that /var/log/journal/<machine-id>.<namespace> can be created based on it). Also make sure it
112
         * is suitable as unit instance name, and does not contain fishy characters. */
113

114
        if (!filename_is_valid(s))
712✔
115
                return false;
116

117
        if (strlen(s) > LOG_NAMESPACE_MAX)
712✔
118
                return false;
119

120
        if (!unit_instance_is_valid(s))
712✔
121
                return false;
122

123
        if (!string_is_safe(s))
712✔
124
                return false;
125

126
        /* Let's avoid globbing for now */
127
        if (string_is_glob(s))
712✔
UNCOV
128
                return false;
×
129

130
        return true;
131
}
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