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

systemd / systemd / 24809677062

22 Apr 2026 10:05PM UTC coverage: 71.989% (-0.2%) from 72.23%
24809677062

push

github

bluca
ukify: fix default path for hwids

The documentation and commit that added this seem to suggest this should
be under /usr/lib/systemd

fixes 117ec9db7

321862 of 447097 relevant lines covered (71.99%)

1201427.36 hits per line

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

92.31
/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 "hexdecoct.h"
8
#include "string-table.h"
9
#include "string-util.h"
10
#include "syslog-util.h"
11
#include "unit-name.h"
12

13
int syslog_parse_priority(const char **p, int *priority, bool with_facility) {
1,045,285✔
14
        int a = 0, b = 0, c = 0;
1,045,285✔
15
        const char *end;
1,045,285✔
16
        size_t k;
1,045,285✔
17

18
        assert(p);
1,045,285✔
19
        assert(*p);
1,045,285✔
20
        assert(priority);
1,045,285✔
21

22
        if ((*p)[0] != '<')
1,045,285✔
23
                return 0;
24

25
        end = strchr(*p, '>');
405✔
26
        if (!end)
405✔
27
                return 0;
28

29
        k = end - *p;
405✔
30
        assert(k > 0);
405✔
31

32
        if (k == 2)
405✔
33
                c = undecchar((*p)[1]);
9✔
34
        else if (k == 3) {
396✔
35
                b = undecchar((*p)[1]);
390✔
36
                c = undecchar((*p)[2]);
390✔
37
        } else if (k == 4) {
6✔
38
                a = undecchar((*p)[1]);
2✔
39
                b = undecchar((*p)[2]);
2✔
40
                c = undecchar((*p)[3]);
2✔
41
        } else
42
                return 0;
43

44
        if (a < 0 || b < 0 || c < 0 ||
401✔
45
            (!with_facility && (a || b || c > 7)))
9✔
46
                return 0;
47

48
        if (with_facility)
7✔
49
                *priority = a*100 + b*10 + c;
392✔
50
        else
51
                *priority = (*priority & LOG_FACMASK) | c;
7✔
52

53
        *p += k + 1;
399✔
54
        return 1;
399✔
55
}
56

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

80
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_facility_unshifted, int, LOG_FAC(~0));
540✔
81

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

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

97
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(log_level, int, LOG_DEBUG);
54,055✔
98

99
bool log_level_is_valid(int level) {
811,863✔
100
        return level >= 0 && level <= LOG_DEBUG;
811,863✔
101
}
102

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

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

112
        /* Let's avoid globbing for now */
113
        if (!string_is_safe(s, STRING_FILENAME))
752✔
114
                return false;
115

116
        if (strlen(s) > LOG_NAMESPACE_MAX)
752✔
117
                return false;
118

119
        if (!unit_instance_is_valid(s))
752✔
120
                return false;
×
121

122
        return true;
123
}
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