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

systemd / systemd / 15789897806

20 Jun 2025 05:25PM UTC coverage: 72.105% (+0.06%) from 72.045%
15789897806

push

github

web-flow
bootctl: honour architecture when updating boot loaders (#37913)

Fixes: #33413
Follow-up for: #30418

21 of 29 new or added lines in 2 files covered. (72.41%)

1701 existing lines in 55 files now uncovered.

300497 of 416750 relevant lines covered (72.1%)

721912.12 hits per line

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

96.04
/src/basic/env-file.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <unistd.h>
4

5
#include "alloc-util.h"
6
#include "env-file.h"
7
#include "env-util.h"
8
#include "errno-util.h"
9
#include "escape.h"
10
#include "fd-util.h"
11
#include "fileio.h"
12
#include "fs-util.h"
13
#include "label.h"
14
#include "log.h"
15
#include "string-util.h"
16
#include "strv.h"
17
#include "tmpfile-util.h"
18
#include "utf8.h"
19

20
typedef int (*push_env_func_t)(
21
                const char *filename,
22
                unsigned line,
23
                const char *key,
24
                char *value,
25
                void *userdata);
26

27
static int parse_env_file_internal(
205,508✔
28
                FILE *f,
29
                const char *fname,
30
                push_env_func_t push,
31
                void *userdata) {
32

33
        size_t n_key = 0, n_value = 0, last_value_whitespace = SIZE_MAX, last_key_whitespace = SIZE_MAX;
205,508✔
34
        _cleanup_free_ char *contents = NULL, *key = NULL, *value = NULL;
205,508✔
35
        unsigned line = 1;
205,508✔
36
        int r;
205,508✔
37

38
        enum {
205,508✔
39
                PRE_KEY,
40
                KEY,
41
                PRE_VALUE,
42
                VALUE,
43
                VALUE_ESCAPE,
44
                SINGLE_QUOTE_VALUE,
45
                DOUBLE_QUOTE_VALUE,
46
                DOUBLE_QUOTE_VALUE_ESCAPE,
47
                COMMENT,
48
                COMMENT_ESCAPE
49
        } state = PRE_KEY;
205,508✔
50

51
        assert(f || fname);
205,508✔
52
        assert(push);
205,508✔
53

54
        if (f)
205,508✔
55
                r = read_full_stream(f, &contents, NULL);
9,049✔
56
        else
57
                r = read_full_file(fname, &contents, NULL);
196,459✔
58
        if (r < 0)
205,508✔
59
                return r;
60

61
        for (char *p = contents; *p; p++) {
70,222,841✔
62
                char c = *p;
70,024,695✔
63

64
                switch (state) {
70,024,695✔
65

66
                case PRE_KEY:
2,893,927✔
67
                        if (strchr(COMMENTS, c))
2,893,927✔
68
                                state = COMMENT;
69
                        else if (!strchr(WHITESPACE, c)) {
2,703,219✔
70
                                state = KEY;
2,697,925✔
71
                                last_key_whitespace = SIZE_MAX;
2,697,925✔
72

73
                                if (!GREEDY_REALLOC(key, n_key+2))
2,697,925✔
74
                                        return -ENOMEM;
75

76
                                key[n_key++] = c;
2,697,925✔
77
                        }
78
                        break;
79

80
                case KEY:
35,511,850✔
81
                        if (strchr(NEWLINE, c)) {
35,511,850✔
82
                                state = PRE_KEY;
25✔
83
                                line++;
25✔
84
                                n_key = 0;
25✔
85
                        } else if (c == '=') {
35,511,825✔
86
                                state = PRE_VALUE;
87
                                last_value_whitespace = SIZE_MAX;
88
                        } else {
89
                                if (!strchr(WHITESPACE, c))
32,813,925✔
90
                                        last_key_whitespace = SIZE_MAX;
91
                                else if (last_key_whitespace == SIZE_MAX)
86✔
92
                                         last_key_whitespace = n_key;
40✔
93

94
                                if (!GREEDY_REALLOC(key, n_key+2))
32,813,925✔
95
                                        return -ENOMEM;
96

97
                                key[n_key++] = c;
32,813,925✔
98
                        }
99

100
                        break;
101

102
                case PRE_VALUE:
2,912,123✔
103
                        if (strchr(NEWLINE, c)) {
2,912,123✔
104
                                state = PRE_KEY;
676,688✔
105
                                line++;
676,688✔
106
                                key[n_key] = 0;
676,688✔
107

108
                                if (value)
676,688✔
109
                                        value[n_value] = 0;
40,402✔
110

111
                                /* strip trailing whitespace from key */
112
                                if (last_key_whitespace != SIZE_MAX)
676,688✔
113
                                        key[last_key_whitespace] = 0;
6✔
114

115
                                r = push(fname, line, key, value, userdata);
676,688✔
116
                                if (r < 0)
676,688✔
117
                                        return r;
118

119
                                n_key = 0;
676,688✔
120
                                value = NULL;
676,688✔
121
                                n_value = 0;
676,688✔
122

123
                        } else if (c == '\'')
2,235,435✔
124
                                state = SINGLE_QUOTE_VALUE;
125
                        else if (c == '"')
2,235,425✔
126
                                state = DOUBLE_QUOTE_VALUE;
127
                        else if (c == '\\')
2,021,258✔
128
                                state = VALUE_ESCAPE;
129
                        else if (!strchr(WHITESPACE, c)) {
2,021,254✔
130
                                state = VALUE;
2,021,202✔
131

132
                                if (!GREEDY_REALLOC(value, n_value+2))
2,021,202✔
133
                                        return -ENOMEM;
134

135
                                value[n_value++] = c;
2,021,202✔
136
                        }
137

138
                        break;
139

140
                case VALUE:
19,201,401✔
141
                        if (strchr(NEWLINE, c)) {
19,201,401✔
142
                                state = PRE_KEY;
2,021,185✔
143
                                line++;
2,021,185✔
144

145
                                key[n_key] = 0;
2,021,185✔
146

147
                                if (value)
2,021,185✔
148
                                        value[n_value] = 0;
2,021,185✔
149

150
                                /* Chomp off trailing whitespace from value */
151
                                if (last_value_whitespace != SIZE_MAX)
2,021,185✔
152
                                        value[last_value_whitespace] = 0;
16✔
153

154
                                /* strip trailing whitespace from key */
155
                                if (last_key_whitespace != SIZE_MAX)
2,021,185✔
156
                                        key[last_key_whitespace] = 0;
6✔
157

158
                                r = push(fname, line, key, value, userdata);
2,021,185✔
159
                                if (r < 0)
2,021,185✔
160
                                        return r;
161

162
                                n_key = 0;
2,021,185✔
163
                                value = NULL;
2,021,185✔
164
                                n_value = 0;
2,021,185✔
165

166
                        } else if (c == '\\') {
17,180,216✔
167
                                state = VALUE_ESCAPE;
168
                                last_value_whitespace = SIZE_MAX;
169
                        } else {
170
                                if (!strchr(WHITESPACE, c))
17,180,194✔
171
                                        last_value_whitespace = SIZE_MAX;
172
                                else if (last_value_whitespace == SIZE_MAX)
15,913✔
173
                                        last_value_whitespace = n_value;
15,871✔
174

175
                                if (!GREEDY_REALLOC(value, n_value+2))
17,180,194✔
176
                                        return -ENOMEM;
177

178
                                value[n_value++] = c;
17,180,194✔
179
                        }
180

181
                        break;
182

183
                case VALUE_ESCAPE:
25✔
184
                        state = VALUE;
25✔
185

186
                        if (!strchr(NEWLINE, c)) {
25✔
187
                                /* Escaped newlines we eat up entirely */
188
                                if (!GREEDY_REALLOC(value, n_value+2))
16✔
189
                                        return -ENOMEM;
190

191
                                value[n_value++] = c;
16✔
192
                        }
193
                        break;
194

195
                case SINGLE_QUOTE_VALUE:
98✔
196
                        if (c == '\'')
98✔
197
                                state = PRE_VALUE;
198
                        else {
199
                                if (!GREEDY_REALLOC(value, n_value+2))
88✔
200
                                        return -ENOMEM;
201

202
                                value[n_value++] = c;
88✔
203
                        }
204

205
                        break;
206

207
                case DOUBLE_QUOTE_VALUE:
2,432,479✔
208
                        if (c == '"')
2,432,479✔
209
                                state = PRE_VALUE;
210
                        else if (c == '\\')
2,218,312✔
211
                                state = DOUBLE_QUOTE_VALUE_ESCAPE;
212
                        else {
213
                                if (!GREEDY_REALLOC(value, n_value+2))
2,218,280✔
214
                                        return -ENOMEM;
215

216
                                value[n_value++] = c;
2,218,280✔
217
                        }
218

219
                        break;
220

221
                case DOUBLE_QUOTE_VALUE_ESCAPE:
32✔
222
                        state = DOUBLE_QUOTE_VALUE;
32✔
223

224
                        if (strchr(SHELL_NEED_ESCAPE, c)) {
32✔
225
                                /* If this is a char that needs escaping, just unescape it. */
226
                                if (!GREEDY_REALLOC(value, n_value+2))
24✔
227
                                        return -ENOMEM;
228
                                value[n_value++] = c;
24✔
229
                        } else if (c != '\n') {
8✔
230
                                /* If other char than what needs escaping, keep the "\" in place, like the
231
                                 * real shell does. */
232
                                if (!GREEDY_REALLOC(value, n_value+3))
4✔
233
                                        return -ENOMEM;
234
                                value[n_value++] = '\\';
4✔
235
                                value[n_value++] = c;
4✔
236
                        }
237

238
                        /* Escaped newlines (aka "continuation lines") are eaten up entirely */
239
                        break;
240

241
                case COMMENT:
7,072,757✔
242
                        if (c == '\\')
7,072,757✔
243
                                state = COMMENT_ESCAPE;
244
                        else if (strchr(NEWLINE, c)) {
7,072,754✔
245
                                state = PRE_KEY;
190,705✔
246
                                line++;
190,705✔
247
                        }
248
                        break;
249

250
                case COMMENT_ESCAPE:
251
                        log_debug("The line which doesn't begin with \";\" or \"#\", but follows a comment" \
3✔
252
                                  " line trailing with escape is now treated as a non comment line since v254.");
253
                        if (strchr(NEWLINE, c)) {
3✔
254
                                state = PRE_KEY;
3✔
255
                                line++;
3✔
256
                        } else
257
                                state = COMMENT;
258
                        break;
259
                }
260
        }
261

262
        if (IN_SET(state,
198,146✔
263
                   PRE_VALUE,
264
                   VALUE,
265
                   VALUE_ESCAPE,
266
                   SINGLE_QUOTE_VALUE,
267
                   DOUBLE_QUOTE_VALUE,
268
                   DOUBLE_QUOTE_VALUE_ESCAPE)) {
269

270
                key[n_key] = 0;
27✔
271

272
                if (value)
27✔
273
                        value[n_value] = 0;
26✔
274

275
                if (state == VALUE)
27✔
276
                        if (last_value_whitespace != SIZE_MAX)
20✔
UNCOV
277
                                value[last_value_whitespace] = 0;
×
278

279
                /* strip trailing whitespace from key */
280
                if (last_key_whitespace != SIZE_MAX)
27✔
UNCOV
281
                        key[last_key_whitespace] = 0;
×
282

283
                r = push(fname, line, key, value, userdata);
27✔
284
                if (r < 0)
27✔
285
                        return r;
286

287
                value = NULL;
24✔
288
        }
289

290
        return 0;
291
}
292

293
static int check_utf8ness_and_warn(
2,697,887✔
294
                const char *filename, unsigned line,
295
                const char *key, char *value) {
296

297
        assert(key);
2,697,887✔
298

299
        if (!utf8_is_valid(key)) {
2,697,887✔
300
                _cleanup_free_ char *p = NULL;
1✔
301

302
                p = utf8_escape_invalid(key);
1✔
303
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
1✔
304
                                       "%s:%u: invalid UTF-8 in key '%s', ignoring.",
305
                                       strna(filename), line, p);
306
        }
307

308
        if (value && !utf8_is_valid(value)) {
4,759,495✔
309
                _cleanup_free_ char *p = NULL;
2✔
310

311
                p = utf8_escape_invalid(value);
2✔
312
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
2✔
313
                                       "%s:%u: invalid UTF-8 value for key %s: '%s', ignoring.",
314
                                       strna(filename), line, key, p);
315
        }
316

317
        return 0;
318
}
319

320
static int parse_env_file_push(
2,659,354✔
321
                const char *filename, unsigned line,
322
                const char *key, char *value,
323
                void *userdata) {
324

325
        const char *k;
2,659,354✔
326
        va_list aq, *ap = userdata;
2,659,354✔
327
        int r;
2,659,354✔
328

329
        assert(key);
2,659,354✔
330

331
        r = check_utf8ness_and_warn(filename, line, key, value);
2,659,354✔
332
        if (r < 0)
2,659,354✔
333
                return r;
2,659,354✔
334

335
        va_copy(aq, *ap);
2,659,354✔
336

337
        while ((k = va_arg(aq, const char *))) {
5,278,823✔
338
                char **v;
2,752,793✔
339

340
                v = va_arg(aq, char **);
2,752,793✔
341

342
                if (streq(key, k)) {
2,752,793✔
343
                        va_end(aq);
133,324✔
344
                        free_and_replace(*v, value);
133,324✔
345

346
                        return 1;
133,324✔
347
                }
348
        }
349

350
        va_end(aq);
2,526,030✔
351
        free(value);
2,526,030✔
352

353
        return 0;
2,526,030✔
354
}
355

356
int parse_env_filev(
196,064✔
357
                FILE *f,
358
                const char *fname,
359
                va_list ap) {
360

361
        int r;
196,064✔
362
        va_list aq;
196,064✔
363

364
        assert(f || fname);
196,064✔
365

366
        va_copy(aq, ap);
196,064✔
367
        r = parse_env_file_internal(f, fname, parse_env_file_push, &aq);
196,064✔
368
        va_end(aq);
196,064✔
369
        return r;
196,064✔
370
}
371

372
int parse_env_file_fdv(int fd, const char *fname, va_list ap) {
2,020✔
373
        _cleanup_fclose_ FILE *f = NULL;
2,020✔
374
        va_list aq;
2,020✔
375
        int r;
2,020✔
376

377
        assert(fd >= 0);
2,020✔
378

379
        r = fdopen_independent(fd, "re", &f);
2,020✔
380
        if (r < 0)
2,020✔
381
                return r;
382

383
        va_copy(aq, ap);
2,020✔
384
        r = parse_env_file_internal(f, fname, parse_env_file_push, &aq);
2,020✔
385
        va_end(aq);
2,020✔
386
        return r;
2,020✔
387
}
388

389
int parse_env_file_sentinel(
196,064✔
390
                FILE *f,
391
                const char *fname,
392
                ...) {
393

394
        va_list ap;
196,064✔
395
        int r;
196,064✔
396

397
        assert(f || fname);
196,064✔
398

399
        va_start(ap, fname);
196,064✔
400
        r = parse_env_filev(f, fname, ap);
196,064✔
401
        va_end(ap);
196,064✔
402

403
        return r;
196,064✔
404
}
405

406
int parse_env_file_fd_sentinel(
1,716✔
407
                int fd,
408
                const char *fname, /* only used for logging */
409
                ...) {
410

411
        va_list ap;
1,716✔
412
        int r;
1,716✔
413

414
        assert(fd >= 0);
1,716✔
415

416
        va_start(ap, fname);
1,716✔
417
        r = parse_env_file_fdv(fd, fname, ap);
1,716✔
418
        va_end(ap);
1,716✔
419

420
        return r;
1,716✔
421
}
422

423
static int load_env_file_push(
559✔
424
                const char *filename, unsigned line,
425
                const char *key, char *value,
426
                void *userdata) {
427

428
        char ***m = userdata;
559✔
429
        char *p;
559✔
430
        int r;
559✔
431

432
        assert(key);
559✔
433

434
        r = check_utf8ness_and_warn(filename, line, key, value);
559✔
435
        if (r < 0)
559✔
436
                return r;
437

438
        p = strjoin(key, "=", value);
556✔
439
        if (!p)
556✔
440
                return -ENOMEM;
441

442
        r = strv_env_replace_consume(m, p);
556✔
443
        if (r < 0)
556✔
444
                return r;
445

446
        free(value);
556✔
447
        return 0;
556✔
448
}
449

450
int load_env_file(FILE *f, const char *fname, char ***ret) {
280✔
451
        _cleanup_strv_free_ char **m = NULL;
280✔
452
        int r;
280✔
453

454
        assert(f || fname);
280✔
455
        assert(ret);
280✔
456

457
        r = parse_env_file_internal(f, fname, load_env_file_push, &m);
280✔
458
        if (r < 0)
280✔
459
                return r;
460

461
        *ret = TAKE_PTR(m);
276✔
462
        return 0;
276✔
463
}
464

465
static int load_env_file_push_pairs(
37,974✔
466
                const char *filename, unsigned line,
467
                const char *key, char *value,
468
                void *userdata) {
469

470
        char ***m = ASSERT_PTR(userdata);
37,974✔
471
        int r;
37,974✔
472

473
        assert(key);
37,974✔
474

475
        r = check_utf8ness_and_warn(filename, line, key, value);
37,974✔
476
        if (r < 0)
37,974✔
477
                return r;
478

479
        /* Check if the key is present */
480
        for (char **t = *m; t && *t; t += 2)
206,473✔
481
                if (streq(t[0], key)) {
168,504✔
482
                        if (value)
5✔
483
                                return free_and_replace(t[1], value);
5✔
484
                        else
UNCOV
485
                                return free_and_strdup(t+1, "");
×
486
                }
487

488
        r = strv_extend(m, key);
37,969✔
489
        if (r < 0)
37,969✔
490
                return r;
491

492
        if (value)
37,969✔
493
                return strv_push(m, value);
37,966✔
494
        else
495
                return strv_extend(m, "");
3✔
496
}
497

498
int load_env_file_pairs(FILE *f, const char *fname, char ***ret) {
6,961✔
499
        _cleanup_strv_free_ char **m = NULL;
6,961✔
500
        int r;
6,961✔
501

502
        assert(f || fname);
6,961✔
503
        assert(ret);
6,961✔
504

505
        r = parse_env_file_internal(f, fname, load_env_file_push_pairs, &m);
6,961✔
506
        if (r < 0)
6,961✔
507
                return r;
508

509
        *ret = TAKE_PTR(m);
6,941✔
510
        return 0;
6,941✔
511
}
512

513
int load_env_file_pairs_fd(int fd, const char *fname, char ***ret) {
5,388✔
514
        _cleanup_fclose_ FILE *f = NULL;
5,388✔
515
        int r;
5,388✔
516

517
        assert(fd >= 0);
5,388✔
518

519
        r = fdopen_independent(fd, "re", &f);
5,388✔
520
        if (r < 0)
5,388✔
521
                return r;
522

523
        return load_env_file_pairs(f, fname, ret);
5,388✔
524
}
525

526
static int merge_env_file_push(
53✔
527
                const char *filename, unsigned line,
528
                const char *key, char *value,
529
                void *userdata) {
530

531
        char ***env = ASSERT_PTR(userdata);
53✔
532
        char *expanded_value;
53✔
533
        int r;
53✔
534

535
        assert(key);
53✔
536

537
        if (!value) {
53✔
538
                log_error("%s:%u: invalid syntax (around \"%s\"), ignoring.", strna(filename), line, key);
20✔
539
                return 0;
10✔
540
        }
541

542
        if (!env_name_is_valid(key)) {
43✔
543
                log_error("%s:%u: invalid variable name \"%s\", ignoring.", strna(filename), line, key);
6✔
544
                free(value);
3✔
545
                return 0;
3✔
546
        }
547

548
        r = replace_env(value,
40✔
549
                        *env,
550
                        REPLACE_ENV_USE_ENVIRONMENT|REPLACE_ENV_ALLOW_BRACELESS|REPLACE_ENV_ALLOW_EXTENDED,
551
                        &expanded_value);
552
        if (r < 0)
40✔
UNCOV
553
                return log_error_errno(r, "%s:%u: Failed to expand variable '%s': %m", strna(filename), line, value);
×
554

555
        free_and_replace(value, expanded_value);
40✔
556

557
        log_debug("%s:%u: setting %s=%s", filename, line, key, value);
40✔
558

559
        return load_env_file_push(filename, line, key, value, env);
40✔
560
}
561

562
int merge_env_file(
183✔
563
                char ***env,
564
                FILE *f,
565
                const char *fname) {
566

567
        assert(env);
183✔
568
        assert(f || fname);
183✔
569

570
        /* NOTE: this function supports braceful and braceless variable expansions,
571
         * plus "extended" substitutions, unlike other exported parsing functions.
572
         */
573

574
        return parse_env_file_internal(f, fname, merge_env_file_push, env);
183✔
575
}
576

577
static void env_file_fputs_escaped(FILE *f, const char *p) {
10,240✔
578
        assert(f);
10,240✔
579
        assert(p);
10,240✔
580

581
        flockfile(f);
10,240✔
582

583
        if (string_has_cc(p, NULL) || chars_intersect(p, WHITESPACE SHELL_NEED_QUOTES)) {
10,240✔
584
                fputc_unlocked('"', f);
258✔
585

586
                for (; *p; p++) {
12,048✔
587
                        if (strchr(SHELL_NEED_ESCAPE, *p))
11,790✔
588
                                fputc_unlocked('\\', f);
553✔
589

590
                        fputc_unlocked(*p, f);
23,580✔
591
                }
592

593
                fputc_unlocked('"', f);
258✔
594
        } else
595
                fputs_unlocked(p, f);
9,982✔
596

597
        funlockfile(f);
10,240✔
598
}
10,240✔
599

600
void env_file_fputs_assignment(FILE *f, const char *k, const char *v) {
22,310✔
601
        assert(f);
22,310✔
602
        assert(k);
22,310✔
603

604
        if (!v)
22,310✔
605
                return;
606

607
        fputs(k, f);
9,738✔
608
        env_file_fputs_escaped(f, v);
9,738✔
609
        fputc('\n', f);
9,738✔
610
}
611

612
static void write_env_var(FILE *f, const char *v) {
502✔
613
        const char *p;
502✔
614

615
        assert(f);
502✔
616
        assert(v);
502✔
617

618
        p = strchr(v, '=');
502✔
619
        if (!p) {
502✔
620
                /* Fallback */
621
                fputs_unlocked(v, f);
×
UNCOV
622
                fputc_unlocked('\n', f);
×
UNCOV
623
                return;
×
624
        }
625

626
        p++;
502✔
627
        fwrite_unlocked(v, 1, p-v, f);
502✔
628

629
        env_file_fputs_escaped(f, p);
502✔
630

631
        fputc_unlocked('\n', f);
502✔
632
}
633

634
int write_env_file(int dir_fd, const char *fname, char **headers, char **l, WriteEnvFileFlags flags) {
286✔
635
        _cleanup_fclose_ FILE *f = NULL;
286✔
636
        _cleanup_free_ char *p = NULL;
286✔
637
        int r;
286✔
638

639
        assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
286✔
640
        assert(fname);
286✔
641

642
        bool call_label_ops_post = false;
286✔
643
        if (FLAGS_SET(flags, WRITE_ENV_FILE_LABEL)) {
286✔
644
                r = label_ops_pre(dir_fd, fname, S_IFREG);
275✔
645
                if (r < 0)
275✔
646
                        return r;
647

648
                call_label_ops_post = true;
649
        }
650

651
        r = fopen_tmpfile_linkable_at(dir_fd, fname, O_WRONLY|O_CLOEXEC, &p, &f);
286✔
652
        if (call_label_ops_post)
286✔
653
                RET_GATHER(r, label_ops_post(f ? fileno(f) : dir_fd, f ? NULL : fname, /* created= */ !!f));
550✔
654
        if (r < 0)
286✔
UNCOV
655
                return r;
×
656

657
        r = fchmod_umask(fileno(f), 0644);
286✔
658
        if (r < 0)
286✔
659
                goto fail;
×
660

661
        STRV_FOREACH(i, headers) {
815✔
662
                assert(isempty(*i) || startswith(*i, "#"));
529✔
663
                fputs_unlocked(*i, f);
529✔
664
                fputc_unlocked('\n', f);
1,058✔
665
        }
666

667
        STRV_FOREACH(i, l)
788✔
668
                write_env_var(f, *i);
502✔
669

670
        r = flink_tmpfile_at(f, dir_fd, p, fname, LINK_TMPFILE_REPLACE|LINK_TMPFILE_SYNC);
286✔
671
        if (r < 0)
286✔
UNCOV
672
                goto fail;
×
673

674
        return 0;
675

UNCOV
676
fail:
×
UNCOV
677
        if (p)
×
UNCOV
678
                (void) unlinkat(dir_fd, p, 0);
×
679

680
        return r;
681
}
682

683
int write_vconsole_conf(int dir_fd, const char *fname, char **l) {
251✔
684
        char **headers = STRV_MAKE(
251✔
685
                "# Written by systemd-localed(8) or systemd-firstboot(1), read by systemd-localed",
686
                "# and systemd-vconsole-setup(8). Use localectl(1) to update this file.");
687

688
        return write_env_file(dir_fd, fname, headers, l, WRITE_ENV_FILE_LABEL);
251✔
689
}
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