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

systemd / systemd / 25705508282

11 May 2026 11:07PM UTC coverage: 72.65% (+0.1%) from 72.511%
25705508282

push

github

bluca
firstboot,sysinstall,hostnamed: always show FANCY_NAME=

This makes sure that whenever we want to show the OS name we can show
the fancy name. Thus this moves the escaping/validation of the fancy
name out of hostnamed into generic code, and then makes use of it in
sysinstall,firstboot,prompt-util.

17 of 36 new or added lines in 6 files covered. (47.22%)

2673 existing lines in 72 files now uncovered.

327104 of 450245 relevant lines covered (72.65%)

1200575.51 hits per line

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

77.39
/src/firstboot/firstboot.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <fcntl.h>
4
#include <unistd.h>
5

6
#include "sd-bus.h"
7
#include "sd-id128.h"
8
#include "sd-varlink.h"
9

10
#include "alloc-util.h"
11
#include "ask-password-api.h"
12
#include "build.h"
13
#include "bus-error.h"
14
#include "bus-locator.h"
15
#include "bus-unit-util.h"
16
#include "bus-util.h"
17
#include "bus-wait-for-jobs.h"
18
#include "chase.h"
19
#include "copy.h"
20
#include "creds-util.h"
21
#include "dissect-image.h"
22
#include "env-file.h"
23
#include "errno-util.h"
24
#include "fd-util.h"
25
#include "fileio.h"
26
#include "format-table.h"
27
#include "fs-util.h"
28
#include "glyph-util.h"
29
#include "hostname-util.h"
30
#include "image-policy.h"
31
#include "kbd-util.h"
32
#include "label-util.h"
33
#include "libcrypt-util.h"
34
#include "locale-setup.h"
35
#include "locale-util.h"
36
#include "lock-util.h"
37
#include "loop-util.h"
38
#include "main-func.h"
39
#include "memory-util.h"
40
#include "mount-util.h"
41
#include "options.h"
42
#include "os-util.h"
43
#include "parse-argument.h"
44
#include "password-quality-util.h"
45
#include "path-util.h"
46
#include "plymouth-util.h"
47
#include "pretty-print.h"
48
#include "proc-cmdline.h"
49
#include "prompt-util.h"
50
#include "runtime-scope.h"
51
#include "smack-util.h"
52
#include "stat-util.h"
53
#include "string-util.h"
54
#include "strv.h"
55
#include "terminal-util.h"
56
#include "time-util.h"
57
#include "tmpfile-util-label.h"
58
#include "user-util.h"
59
#include "vconsole-util.h"
60

61
static char *arg_root = NULL;
62
static char *arg_image = NULL;
63
static char *arg_locale = NULL;  /* $LANG */
64
static char *arg_locale_messages = NULL; /* $LC_MESSAGES */
65
static char *arg_keymap = NULL;
66
static char *arg_timezone = NULL;
67
static char *arg_hostname = NULL;
68
static sd_id128_t arg_machine_id = {};
69
static char *arg_root_password = NULL;
70
static char *arg_root_shell = NULL;
71
static char *arg_kernel_cmdline = NULL;
72
static bool arg_prompt_locale = false;
73
static bool arg_prompt_keymap = false;
74
static bool arg_prompt_keymap_auto = false;
75
static bool arg_prompt_timezone = false;
76
static bool arg_prompt_hostname = false;
77
static bool arg_prompt_root_password = false;
78
static bool arg_prompt_root_shell = false;
79
static bool arg_copy_locale = false;
80
static bool arg_copy_keymap = false;
81
static bool arg_copy_timezone = false;
82
static bool arg_copy_root_password = false;
83
static bool arg_copy_root_shell = false;
84
static bool arg_force = false;
85
static bool arg_delete_root_password = false;
86
static bool arg_root_password_is_hashed = false;
87
static bool arg_welcome = true;
88
static bool arg_reset = false;
89
static ImagePolicy *arg_image_policy = NULL;
90
static bool arg_chrome = true;
91
static bool arg_mute_console = false;
92

93
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
144✔
94
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
144✔
95
STATIC_DESTRUCTOR_REGISTER(arg_locale, freep);
144✔
96
STATIC_DESTRUCTOR_REGISTER(arg_locale_messages, freep);
144✔
97
STATIC_DESTRUCTOR_REGISTER(arg_keymap, freep);
144✔
98
STATIC_DESTRUCTOR_REGISTER(arg_timezone, freep);
144✔
99
STATIC_DESTRUCTOR_REGISTER(arg_hostname, freep);
144✔
100
STATIC_DESTRUCTOR_REGISTER(arg_root_password, erase_and_freep);
144✔
101
STATIC_DESTRUCTOR_REGISTER(arg_root_shell, freep);
144✔
102
STATIC_DESTRUCTOR_REGISTER(arg_kernel_cmdline, freep);
144✔
103
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
144✔
104

105
static void print_welcome(int rfd, sd_varlink **mute_console_link) {
7✔
106
        _cleanup_free_ char *pretty_name = NULL, *os_name = NULL, *ansi_color = NULL, *fancy_name = NULL;
7✔
107
        static bool done = false;
7✔
108
        const char *pn, *ac;
7✔
109
        int r;
7✔
110

111
        assert(rfd >= 0);
7✔
112
        assert(mute_console_link);
7✔
113

114
        /* Needs to be called before mute_console or it will garble the screen */
115
        if (arg_welcome)
7✔
116
                (void) plymouth_hide_splash();
6✔
117

118
        if (!*mute_console_link && arg_mute_console)
7✔
119
                (void) mute_console(mute_console_link);
×
120

121
        if (!arg_welcome)
7✔
122
                return;
123

124
        if (done) {
6✔
125
                putchar('\n'); /* Add some breathing room between multiple prompts */
1✔
126
                return;
127
        }
128

129
        (void) terminal_reset_defensive_locked(STDOUT_FILENO, /* flags= */ 0);
6✔
130

131
        if (arg_chrome)
6✔
132
                chrome_show("Initial Setup", /* bottom= */ NULL);
6✔
133

134
        r = parse_os_release_at(rfd,
6✔
135
                                "PRETTY_NAME", &pretty_name,
136
                                "FANCY_NAME", &fancy_name,
137
                                "NAME", &os_name,
138
                                "ANSI_COLOR", &ansi_color);
139
        if (r < 0)
6✔
140
                log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
6✔
141
                               "Failed to read os-release file, ignoring: %m");
142

143
        pn = os_release_pretty_name(pretty_name, os_name);
6✔
144
        ac = isempty(ansi_color) ? "0" : ansi_color;
6✔
145

146
        if (use_fancy_name(unescape_fancy_name(&fancy_name)))
6✔
NEW
147
                printf(ANSI_HIGHLIGHT "Welcome to " ANSI_NORMAL "%s" ANSI_HIGHLIGHT "!" ANSI_NORMAL "\n", fancy_name);
×
148
        else if (colors_enabled())
6✔
UNCOV
149
                printf(ANSI_HIGHLIGHT "Welcome to " ANSI_NORMAL "\x1B[%sm%s" ANSI_HIGHLIGHT "!" ANSI_NORMAL "\n", ac, pn);
×
150
        else
151
                printf("Welcome to %s!\n", pn);
6✔
152

153
        putchar('\n');
6✔
154
        if (emoji_enabled()) {
6✔
155
                fputs(glyph(GLYPH_SPARKLES), stdout);
×
156
                putchar(' ');
×
157
        }
158
        printf("Please configure the system!\n\n");
6✔
159

160
        done = true;
6✔
161
}
162

163
static int should_configure(int dir_fd, const char *filename) {
1,128✔
164
        _cleanup_fclose_ FILE *passwd = NULL, *shadow = NULL;
1,128✔
165
        int r;
1,128✔
166

167
        assert(dir_fd >= 0);
1,128✔
168
        assert(filename);
1,128✔
169

170
        if (streq(filename, "passwd") && !arg_force)
1,128✔
171
                /* We may need to do additional checks, so open the file. */
172
                r = xfopenat(dir_fd, filename, "re", O_NOFOLLOW, &passwd);
138✔
173
        else
174
                r = RET_NERRNO(faccessat(dir_fd, filename, F_OK, AT_SYMLINK_NOFOLLOW));
990✔
175

176
        if (r == -ENOENT)
605✔
177
                return true; /* missing */
178
        if (r < 0)
636✔
179
                return log_error_errno(r, "Failed to access %s: %m", filename);
×
180
        if (arg_force)
636✔
181
                return true; /* exists, but if --force was given we should still configure the file. */
182

183
        if (!passwd)
619✔
184
                return false;
185

186
        /* In case of /etc/passwd, do an additional check for the root password field.
187
         * We first check that passwd redirects to shadow, and then we check shadow.
188
         */
189
        struct passwd *i;
190
        while ((r = fgetpwent_sane(passwd, &i)) > 0) {
113✔
191
                if (!streq(i->pw_name, "root"))
112✔
192
                        continue;
×
193

194
                if (streq_ptr(i->pw_passwd, PASSWORD_SEE_SHADOW))
112✔
195
                        break;
196
                log_debug("passwd: root account with non-shadow password found, treating root as configured");
×
197
                return false;
198
        }
199
        if (r < 0)
113✔
200
                return log_error_errno(r, "Failed to read %s: %m", filename);
×
201
        if (r == 0) {
113✔
202
                log_debug("No root account found in %s, assuming root is not configured.", filename);
1✔
203
                return true;
204
        }
205

206
        r = xfopenat(dir_fd, "shadow", "re", O_NOFOLLOW, &shadow);
112✔
207
        if (r == -ENOENT) {
112✔
208
                log_debug("No shadow file found, assuming root is not configured.");
×
209
                return true; /* missing */
210
        }
211
        if (r < 0)
112✔
212
                return log_error_errno(r, "Failed to access shadow: %m");
×
213

214
        struct spwd *j;
215
        while ((r = fgetspent_sane(shadow, &j)) > 0) {
112✔
216
                if (!streq(j->sp_namp, "root"))
112✔
217
                        continue;
×
218

219
                bool unprovisioned = streq_ptr(j->sp_pwdp, PASSWORD_UNPROVISIONED);
112✔
220
                log_debug("Root account found, %s.",
218✔
221
                          unprovisioned ? "with unprovisioned password, treating root as not configured" :
222
                                          "treating root as configured");
223
                return unprovisioned;
112✔
224
        }
225
        if (r < 0)
×
226
                return log_error_errno(r, "Failed to read shadow: %m");
×
227
        assert(r == 0);
×
228
        log_debug("No root account found in shadow, assuming root is not configured.");
×
229
        return true;
230
}
231

232
static int locale_is_ok(const char *name, void *userdata) {
11✔
233
        int rfd = ASSERT_FD(PTR_TO_FD(userdata)), r;
11✔
234

235
        r = dir_fd_is_root(rfd);
11✔
236
        if (r < 0)
11✔
237
                log_debug_errno(r, "Unable to determine if operating on host root directory, assuming we are: %m");
×
238

239
        return r != 0 ? locale_is_installed(name) > 0 : locale_is_valid(name);
11✔
240
}
241

242
static int prompt_locale(int rfd, sd_varlink **mute_console_link) {
11✔
243
        _cleanup_strv_free_ char **locales = NULL;
×
244
        bool acquired_from_creds = false;
11✔
245
        int r;
11✔
246

247
        assert(rfd >= 0);
11✔
248

249
        if (arg_locale || arg_locale_messages)
11✔
250
                return 0;
251

252
        r = read_credential("firstboot.locale", (void**) &arg_locale, NULL);
6✔
253
        if (r < 0)
6✔
254
                log_debug_errno(r, "Failed to read credential firstboot.locale, ignoring: %m");
5✔
255
        else
256
                acquired_from_creds = true;
257

258
        r = read_credential("firstboot.locale-messages", (void**) &arg_locale_messages, NULL);
6✔
259
        if (r < 0)
6✔
260
                log_debug_errno(r, "Failed to read credential firstboot.locale-messages, ignoring: %m");
5✔
261
        else
262
                acquired_from_creds = true;
263

264
        if (acquired_from_creds) {
5✔
265
                log_debug("Acquired locale from credentials.");
1✔
266
                return 0;
267
        }
268

269
        if (!arg_prompt_locale) {
5✔
270
                log_debug("Prompting for locale was not requested.");
4✔
271
                return 0;
272
        }
273

274
        r = get_locales(&locales);
1✔
275
        if (r < 0)
1✔
276
                return log_error_errno(r, "Cannot query locales list: %m");
×
277

278
        if (strv_isempty(locales))
1✔
279
                log_debug("No locales found, skipping locale selection.");
×
280
        else if (strv_length(locales) == 1) {
1✔
281

282
                if (streq(locales[0], SYSTEMD_DEFAULT_LOCALE))
×
283
                        log_debug("Only installed locale is default locale anyway, not setting locale explicitly.");
×
284
                else {
285
                        log_debug("Only a single locale available (%s), selecting it as default.", locales[0]);
×
286

287
                        arg_locale = strdup(locales[0]);
×
288
                        if (!arg_locale)
×
289
                                return log_oom();
×
290

291
                        /* Not setting arg_locale_message here, since it defaults to LANG anyway */
292
                }
293
        } else {
294
                print_welcome(rfd, mute_console_link);
1✔
295

296
                r = prompt_loop("Please enter the new system locale name or number",
2✔
297
                                GLYPH_WORLD,
298
                                locales,
299
                                /* accepted= */ NULL,
300
                                /* ellipsize_percentage= */ 60,
301
                                /* n_columns= */ 3,
302
                                /* column_width= */ 20,
303
                                locale_is_ok,
304
                                /* refresh= */ NULL,
305
                                FD_TO_PTR(rfd),
1✔
306
                                PROMPT_MAY_SKIP|PROMPT_SHOW_MENU,
307
                                &arg_locale);
308
                if (r < 0)
1✔
309
                        return r;
310
                if (isempty(arg_locale))
12✔
311
                        return 0;
312

313
                r = prompt_loop("Please enter the new system message locale name or number",
1✔
314
                                GLYPH_WORLD,
315
                                locales,
316
                                /* accepted= */ NULL,
317
                                /* ellipsize_percentage= */ 60,
318
                                /* n_columns= */ 3,
319
                                /* column_width= */ 20,
320
                                locale_is_ok,
321
                                /* refresh= */ NULL,
322
                                FD_TO_PTR(rfd),
323
                                PROMPT_MAY_SKIP|PROMPT_SHOW_MENU,
324
                                &arg_locale_messages);
325
                if (r < 0)
1✔
326
                        return r;
327

328
                /* Suppress the messages setting if it's the same as the main locale anyway */
329
                if (streq_ptr(arg_locale, arg_locale_messages))
1✔
330
                        arg_locale_messages = mfree(arg_locale_messages);
×
331
        }
332

333
        return 0;
334
}
335

336
static int process_locale(int rfd, sd_varlink **mute_console_link) {
141✔
337
        _cleanup_close_ int pfd = -EBADF;
141✔
338
        _cleanup_free_ char *f = NULL;
141✔
339
        char* locales[3];
141✔
340
        unsigned i = 0;
141✔
341
        int r;
141✔
342

343
        assert(rfd >= 0);
141✔
344

345
        pfd = chase_and_open_parent_at(rfd, rfd, etc_locale_conf(),
141✔
346
                                       CHASE_MKDIR_0755|CHASE_WARN|CHASE_NOFOLLOW,
347
                                       &f);
348
        if (pfd < 0)
141✔
349
                return log_error_errno(pfd, "Failed to chase /etc/locale.conf: %m");
×
350

351
        r = should_configure(pfd, f);
141✔
352
        if (r == 0)
141✔
353
                log_debug("Found /etc/locale.conf, assuming locale information has been configured.");
127✔
354
        if (r <= 0)
141✔
355
                return r;
356

357
        r = dir_fd_is_root(rfd);
14✔
358
        if (r < 0)
14✔
359
                return log_error_errno(r, "Failed to check if directory file descriptor is root: %m");
×
360

361
        if (arg_copy_locale && r == 0) {
14✔
362
                r = copy_file_atomic_at(AT_FDCWD, etc_locale_conf(), pfd, f, 0644, COPY_REFLINK);
3✔
363
                if (r != -ENOENT) {
3✔
364
                        if (r < 0)
3✔
365
                                return log_error_errno(r, "Failed to copy host's /etc/locale.conf: %m");
×
366

367
                        log_info("Copied host's /etc/locale.conf.");
3✔
368
                        return 0;
369
                }
370
        }
371

372
        r = prompt_locale(rfd, mute_console_link);
11✔
373
        if (r < 0)
11✔
374
                return r;
375

376
        if (!isempty(arg_locale))
11✔
377
                locales[i++] = strjoina("LANG=", arg_locale);
30✔
378
        if (!isempty(arg_locale_messages) && !streq_ptr(arg_locale_messages, arg_locale))
16✔
379
                locales[i++] = strjoina("LC_MESSAGES=", arg_locale_messages);
25✔
380

381
        if (i == 0)
11✔
382
                return 0;
383

384
        locales[i] = NULL;
7✔
385

386
        r = write_env_file(
7✔
387
                        pfd,
388
                        f,
389
                        /* headers= */ NULL,
390
                        locales,
391
                        WRITE_ENV_FILE_LABEL);
392
        if (r < 0)
7✔
393
                return log_error_errno(r, "Failed to write /etc/locale.conf: %m");
×
394

395
        log_info("/etc/locale.conf written.");
7✔
396
        return 1;
397
}
398

399
static int keymap_is_ok(const char* name, void *userdata) {
5✔
400
        int rfd = ASSERT_FD(PTR_TO_FD(userdata)), r;
5✔
401

402
        r = dir_fd_is_root(rfd);
5✔
403
        if (r < 0)
5✔
404
                log_debug_errno(r, "Unable to determine if operating on host root directory, assuming we are: %m");
×
405

406
        return r != 0 ? keymap_exists(name) > 0 : keymap_is_valid(name);
5✔
407
}
408

409
static int prompt_keymap(int rfd, sd_varlink **mute_console_link) {
19✔
410
        _cleanup_strv_free_ char **kmaps = NULL;
19✔
411
        int r;
19✔
412

413
        assert(rfd >= 0);
19✔
414

415
        if (arg_keymap)
19✔
416
                return 0;
417

418
        _cleanup_free_ char *km = NULL;
16✔
419
        r = read_credential("firstboot.keymap", (void**) &km, NULL);
16✔
420
        if (r < 0)
16✔
421
                log_debug_errno(r, "Failed to read credential firstboot.keymap, ignoring: %m");
15✔
422
        else if (!keymap_is_valid(km))
1✔
423
                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Keymap '%s' supplied via credential is not valid, ignoring.", km);
×
424
        else {
425
                log_debug("Acquired keymap from credential.");
1✔
426
                arg_keymap = TAKE_PTR(km);
1✔
427
                return 0;
1✔
428
        }
429

430
        bool b;
15✔
431
        if (arg_prompt_keymap_auto) {
15✔
432
                _cleanup_free_ char *ttyname = NULL;
1✔
433

434
                r = getttyname_harder(STDOUT_FILENO, &ttyname);
1✔
435
                if (r < 0) {
1✔
436
                        log_debug_errno(r, "Cannot determine TTY we are connected, ignoring: %m");
1✔
437
                        b = false; /* if we can't resolve this, it's probably not a VT */
438
                } else {
439
                        b = tty_is_vc_resolve(ttyname);
×
440
                        log_debug("Detected connection to local console: %s", yes_no(b));
×
441
                }
442
        } else
443
                b = arg_prompt_keymap;
14✔
444
        if (!b) {
15✔
445
                log_debug("Prompting for keymap was not requested.");
14✔
446
                return 0;
447
        }
448

449
        r = get_keymaps(&kmaps);
1✔
450
        if (r == -ENOENT) /* no keymaps installed */
1✔
451
                return log_debug_errno(r, "No keymaps are installed.");
×
452
        if (r < 0)
1✔
453
                return log_error_errno(r, "Failed to read keymaps: %m");
×
454

455
        print_welcome(rfd, mute_console_link);
1✔
456

457
        return prompt_loop(
1✔
458
                        "Please enter the new keymap name or number",
459
                        GLYPH_KEYBOARD,
460
                        kmaps,
461
                        /* accepted= */ NULL,
462
                        /* ellipsize_percentage= */ 60,
463
                        /* n_columns= */ 3,
464
                        /* column_width= */ 20,
465
                        keymap_is_ok,
466
                        /* refresh= */ NULL,
467
                        FD_TO_PTR(rfd),
1✔
468
                        PROMPT_MAY_SKIP|PROMPT_SHOW_MENU,
469
                        &arg_keymap);
470
}
471

472
static int process_keymap(int rfd, sd_varlink **mute_console_link) {
141✔
473
        _cleanup_close_ int pfd = -EBADF;
141✔
474
        _cleanup_free_ char *f = NULL;
141✔
475
        _cleanup_strv_free_ char **keymap = NULL;
×
476
        int r;
141✔
477

478
        assert(rfd >= 0);
141✔
479

480
        pfd = chase_and_open_parent_at(rfd, rfd, etc_vconsole_conf(),
141✔
481
                                       CHASE_MKDIR_0755|CHASE_WARN|CHASE_NOFOLLOW,
482
                                       &f);
483
        if (pfd < 0)
141✔
484
                return log_error_errno(pfd, "Failed to chase /etc/vconsole.conf: %m");
×
485

486
        r = should_configure(pfd, f);
141✔
487
        if (r == 0)
141✔
488
                log_debug("Found /etc/vconsole.conf, assuming console has been configured.");
119✔
489
        if (r <= 0)
141✔
490
                return r;
491

492
        r = dir_fd_is_root(rfd);
22✔
493
        if (r < 0)
22✔
494
                return log_error_errno(r, "Failed to check if directory file descriptor is root: %m");
×
495

496
        if (arg_copy_keymap && r == 0) {
22✔
497
                r = copy_file_atomic_at(AT_FDCWD, etc_vconsole_conf(), pfd, f, 0644, COPY_REFLINK);
3✔
498
                if (r != -ENOENT) {
3✔
499
                        if (r < 0)
3✔
500
                                return log_error_errno(r, "Failed to copy host's /etc/vconsole.conf: %m");
×
501

502
                        log_info("Copied host's /etc/vconsole.conf.");
3✔
503
                        return 0;
504
                }
505
        }
506

507
        r = prompt_keymap(rfd, mute_console_link);
19✔
508
        if (r == -ENOENT)
19✔
509
                return 0; /* don't fail if no keymaps are installed */
510
        if (r < 0)
19✔
511
                return r;
512

513
        if (isempty(arg_keymap))
146✔
514
                return 0;
515

516
        VCContext vc = {
5✔
517
                .keymap = arg_keymap,
518
        };
519
        _cleanup_(x11_context_clear) X11Context xc = {};
5✔
520

521
        r = vconsole_convert_to_x11(&vc, /* verify= */ NULL, &xc);
5✔
522
        if (r < 0)
5✔
523
                return log_error_errno(r, "Failed to convert keymap data: %m");
×
524

525
        r = vconsole_serialize(&vc, &xc, &keymap);
5✔
526
        if (r < 0)
5✔
527
                return log_error_errno(r, "Failed to serialize keymap data: %m");
×
528

529
        r = write_vconsole_conf(pfd, f, keymap);
5✔
530
        if (r < 0)
5✔
531
                return log_error_errno(r, "Failed to write /etc/vconsole.conf: %m");
×
532

533
        log_info("/etc/vconsole.conf written.");
5✔
534
        return 1;
535
}
536

537
static int timezone_is_ok(const char *name, void *userdata) {
1✔
538
        return timezone_is_valid(name, LOG_DEBUG);
1✔
539
}
540

541
static int prompt_timezone(int rfd, sd_varlink **mute_console_link) {
122✔
542
        _cleanup_strv_free_ char **zones = NULL;
122✔
543
        int r;
122✔
544

545
        assert(rfd >= 0);
122✔
546

547
        if (arg_timezone)
122✔
548
                return 0;
549

550
        _cleanup_free_ char *tz = NULL;
119✔
551
        r = read_credential("firstboot.timezone", (void**) &tz, NULL);
119✔
552
        if (r < 0)
119✔
553
                log_debug_errno(r, "Failed to read credential firstboot.timezone, ignoring: %m");
12✔
554
        else if (!timezone_is_valid(tz, LOG_DEBUG))
107✔
555
                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Timezone '%s' supplied via credential is not valid, ignoring.", tz);
×
556
        else {
557
                log_debug("Acquired timezone from credential.");
107✔
558
                arg_timezone = TAKE_PTR(tz);
107✔
559
                return 0;
107✔
560
        }
561

562
        if (!arg_prompt_timezone) {
12✔
563
                log_debug("Prompting for timezone was not requested.");
11✔
564
                return 0;
565
        }
566

567
        r = get_timezones(&zones);
1✔
568
        if (r < 0)
1✔
569
                return log_error_errno(r, "Cannot query timezone list: %m");
×
570

571
        print_welcome(rfd, mute_console_link);
1✔
572

573
        return prompt_loop(
1✔
574
                        "Please enter the new timezone name or number",
575
                        GLYPH_CLOCK,
576
                        zones,
577
                        /* accepted= */ NULL,
578
                        /* ellipsize_percentage= */ 30,
579
                        /* n_columns= */ 3,
580
                        /* column_width= */ 20,
581
                        timezone_is_ok,
582
                        /* refresh= */ NULL,
583
                        FD_TO_PTR(rfd),
1✔
584
                        PROMPT_MAY_SKIP|PROMPT_SHOW_MENU,
585
                        &arg_timezone);
586
}
587

588
static int process_timezone(int rfd, sd_varlink **mute_console_link) {
141✔
589
        _cleanup_close_ int pfd = -EBADF;
141✔
590
        _cleanup_free_ char *f = NULL, *relpath = NULL;
141✔
591
        const char *e;
141✔
592
        int r;
141✔
593

594
        assert(rfd >= 0);
141✔
595

596
        pfd = chase_and_open_parent_at(rfd, rfd, etc_localtime(),
141✔
597
                                       CHASE_MKDIR_0755|CHASE_WARN|CHASE_NOFOLLOW,
598
                                       &f);
599
        if (pfd < 0)
141✔
600
                return log_error_errno(pfd, "Failed to chase /etc/localtime: %m");
×
601

602
        r = should_configure(pfd, f);
141✔
603
        if (r == 0)
141✔
604
                log_debug("Found /etc/localtime, assuming timezone has been configured.");
16✔
605
        if (r <= 0)
141✔
606
                return r;
607

608
        r = dir_fd_is_root(rfd);
125✔
609
        if (r < 0)
125✔
610
                return log_error_errno(r, "Failed to check if directory file descriptor is root: %m");
×
611

612
        if (arg_copy_timezone && r == 0) {
125✔
613
                _cleanup_free_ char *s = NULL;
3✔
614

615
                r = readlink_malloc(etc_localtime(), &s);
3✔
616
                if (r != -ENOENT) {
3✔
617
                        if (r < 0)
3✔
618
                                return log_error_errno(r, "Failed to read host's /etc/localtime: %m");
×
619

620
                        r = symlinkat_atomic_full(s, pfd, f, SYMLINK_LABEL);
3✔
621
                        if (r < 0)
3✔
622
                                return log_error_errno(r, "Failed to create /etc/localtime symlink: %m");
×
623

624
                        log_info("Copied host's /etc/localtime.");
3✔
625
                        return 0;
626
                }
627
        }
628

629
        r = prompt_timezone(rfd, mute_console_link);
122✔
630
        if (r < 0)
122✔
631
                return r;
632

633
        if (isempty(arg_timezone))
252✔
634
                return 0;
635

636
        e = strjoina("/usr/share/zoneinfo/", arg_timezone);
555✔
637
        r = path_make_relative_parent(etc_localtime(), e, &relpath);
111✔
638
        if (r < 0)
111✔
639
                return r;
640

641
        r = symlinkat_atomic_full(relpath, pfd, f, SYMLINK_LABEL);
111✔
642
        if (r < 0)
111✔
643
                return log_error_errno(r, "Failed to create /etc/localtime symlink: %m");
×
644

645
        log_info("/etc/localtime written");
111✔
646
        return 0;
647
}
648

649
static int hostname_is_ok(const char *name, void *userdata) {
1✔
650
        return hostname_is_valid(name, VALID_HOSTNAME_TRAILING_DOT);
1✔
651
}
652

653
static int prompt_hostname(int rfd, sd_varlink **mute_console_link) {
127✔
654
        int r;
127✔
655

656
        assert(rfd >= 0);
127✔
657

658
        if (arg_hostname)
127✔
659
                return 0;
127✔
660

661
        _cleanup_free_ char *hn = NULL;
123✔
662
        r = read_credential("firstboot.hostname", (void**) &hn, NULL);
123✔
663
        if (r < 0)
123✔
664
                log_debug_errno(r, "Failed to read credential firstboot.hostname, ignoring: %m");
123✔
665
        else if (!hostname_is_valid(hn, VALID_HOSTNAME_TRAILING_DOT|VALID_HOSTNAME_QUESTION_MARK))
×
666
                log_warning_errno(SYNTHETIC_ERRNO(EINVAL), "Hostname '%s' supplied via credential is not valid, ignoring.", hn);
×
667
        else {
668
                log_debug("Acquired hostname from credentials.");
×
669
                arg_hostname = TAKE_PTR(hn);
×
670
                hostname_cleanup(arg_hostname);
×
671
                return 0;
672
        }
673

674
        if (!arg_prompt_hostname) {
123✔
675
                log_debug("Prompting for hostname was not requested.");
122✔
676
                return 0;
677
        }
678

679
        print_welcome(rfd, mute_console_link);
1✔
680

681
        r = prompt_loop("Please enter the new hostname",
2✔
682
                        GLYPH_LABEL,
683
                        /* menu= */ NULL,
684
                        /* accepted= */ NULL,
685
                        /* ellipsize_percentage= */ 100,
686
                        /* n_columns= */ 3,
687
                        /* column_width= */ 20,
688
                        hostname_is_ok,
689
                        /* refresh= */ NULL,
690
                        FD_TO_PTR(rfd),
1✔
691
                        PROMPT_MAY_SKIP,
692
                        &arg_hostname);
693
        if (r < 0)
1✔
694
                return r;
695

696
        if (arg_hostname)
1✔
697
                hostname_cleanup(arg_hostname);
1✔
698

699
        return 0;
700
}
701

702
static int process_hostname(int rfd, sd_varlink **mute_console_link) {
141✔
703
        _cleanup_close_ int pfd = -EBADF;
141✔
704
        _cleanup_free_ char *f = NULL;
141✔
705
        int r;
141✔
706

707
        assert(rfd >= 0);
141✔
708

709
        pfd = chase_and_open_parent_at(rfd, rfd, etc_hostname(), CHASE_MKDIR_0755|CHASE_WARN, &f);
141✔
710
        if (pfd < 0)
141✔
711
                return log_error_errno(pfd, "Failed to chase /etc/hostname: %m");
×
712

713
        r = should_configure(pfd, f);
141✔
714
        if (r == 0)
141✔
715
                log_debug("Found /etc/hostname, assuming hostname has been configured.");
14✔
716
        if (r <= 0)
141✔
717
                return r;
718

719
        r = prompt_hostname(rfd, mute_console_link);
127✔
720
        if (r < 0)
127✔
721
                return r;
722

723
        if (isempty(arg_hostname))
146✔
724
                return 0;
725

726
        r = write_string_file_at(pfd, f, arg_hostname,
5✔
727
                                 WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_SYNC|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_LABEL);
728
        if (r < 0)
5✔
729
                return log_error_errno(r, "Failed to write /etc/hostname: %m");
×
730

731
        log_info("/etc/hostname written.");
5✔
732
        return 0;
733
}
734

735
static int process_machine_id(int rfd) {
141✔
736
        _cleanup_close_ int pfd = -EBADF;
141✔
737
        _cleanup_free_ char *f = NULL;
141✔
738
        int r;
141✔
739

740
        assert(rfd >= 0);
141✔
741

742
        pfd = chase_and_open_parent_at(rfd, rfd, "/etc/machine-id",
141✔
743
                                       CHASE_MKDIR_0755|CHASE_WARN|CHASE_NOFOLLOW,
744
                                       &f);
745
        if (pfd < 0)
141✔
746
                return log_error_errno(pfd, "Failed to chase /etc/machine-id: %m");
×
747

748
        r = should_configure(pfd, f);
141✔
749
        if (r == 0)
141✔
750
                log_debug("Found /etc/machine-id, assuming machine-id has been configured.");
116✔
751
        if (r <= 0)
141✔
752
                return r;
753

754
        if (sd_id128_is_null(arg_machine_id)) {
25✔
755
                log_debug("Initialization of machine-id was not requested, skipping.");
22✔
756
                return 0;
757
        }
758

759
        r = write_string_file_at(pfd, "machine-id", SD_ID128_TO_STRING(arg_machine_id),
3✔
760
                                 WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_SYNC|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_LABEL);
761
        if (r < 0)
3✔
762
                return log_error_errno(r, "Failed to write /etc/machine-id: %m");
×
763

764
        log_info("/etc/machine-id written.");
3✔
765
        return 0;
766
}
767

768
static int prompt_root_password(int rfd, sd_varlink **mute_console_link) {
30✔
769
        const char *msg1, *msg2;
30✔
770
        int r;
30✔
771

772
        assert(rfd >= 0);
30✔
773

774
        if (arg_root_password)
30✔
775
                return 0;
776

777
        if (get_credential_user_password("root", &arg_root_password, &arg_root_password_is_hashed) >= 0)
21✔
778
                return 0;
779

780
        if (!arg_prompt_root_password) {
20✔
781
                log_debug("Prompting for root password was not requested.");
19✔
782
                return 0;
783
        }
784

785
        print_welcome(rfd, mute_console_link);
1✔
786

787
        msg1 = "Please enter the new root password (empty to skip):";
1✔
788
        msg2 = "Please enter the new root password again:";
1✔
789

790
        suggest_passwords();
1✔
791

792
        for (;;) {
×
793
                _cleanup_strv_free_erase_ char **a = NULL, **b = NULL;
1✔
794
                _cleanup_free_ char *error = NULL;
1✔
795

796
                AskPasswordRequest req = {
1✔
797
                        .tty_fd = -EBADF,
798
                        .message = msg1,
799
                        .until = USEC_INFINITY,
800
                        .hup_fd = -EBADF,
801
                };
802

803
                r = ask_password_tty(&req, /* flags= */ 0, &a);
1✔
804
                if (r < 0)
1✔
805
                        return log_error_errno(r, "Failed to query root password: %m");
×
806
                if (strv_length(a) != 1)
1✔
807
                        return log_error_errno(SYNTHETIC_ERRNO(EIO),
×
808
                                               "Received multiple passwords, where we expected one.");
809

810
                if (isempty(*a)) {
1✔
811
                        log_info("No password entered, skipping.");
1✔
812
                        break;
813
                }
814

815
                r = check_password_quality(*a, /* old= */ NULL, "root", &error);
×
816
                if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
×
817
                        log_warning("Password quality check is not supported, proceeding anyway.");
×
818
                else if (r < 0)
×
819
                        return log_error_errno(r, "Failed to check password quality: %m");
×
820
                else if (r == 0)
×
821
                        log_warning("Password is weak, accepting anyway: %s", error);
×
822

823
                req.message = msg2;
×
824

825
                r = ask_password_tty(&req, /* flags= */ 0, &b);
×
826
                if (r < 0)
×
827
                        return log_error_errno(r, "Failed to query root password: %m");
×
828
                if (strv_length(b) != 1)
×
829
                        return log_error_errno(SYNTHETIC_ERRNO(EIO),
×
830
                                               "Received multiple passwords, where we expected one.");
831

832
                if (!streq(*a, *b)) {
×
833
                        log_error("Entered passwords did not match, please try again.");
×
834
                        continue;
×
835
                }
836

837
                arg_root_password = TAKE_PTR(*a);
×
838
                break;
×
839
        }
840

841
        return 0;
1✔
842
}
843

844
static int find_shell(int rfd, const char *path) {
7✔
845
        int r;
7✔
846

847
        assert(path);
7✔
848

849
        if (!valid_shell(path))
7✔
850
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "%s is not a valid shell", path);
×
851

852
        r = chaseat(rfd, rfd, path, /* flags= */ 0, /* ret_path= */ NULL, /* ret_fd= */ NULL);
7✔
853
        if (r < 0)
7✔
854
                return log_error_errno(r, "Failed to resolve shell %s: %m", path);
1✔
855

856
        return 0;
857
}
858

859
static int shell_is_ok(const char *path, void *userdata) {
2✔
860
        int rfd = ASSERT_FD(PTR_TO_FD(userdata));
2✔
861

862
        return find_shell(rfd, path) >= 0;
2✔
863
}
864

865
static int prompt_root_shell(int rfd, sd_varlink **mute_console_link) {
30✔
866
        int r;
30✔
867

868
        assert(rfd >= 0);
30✔
869

870
        if (arg_root_shell)
30✔
871
                return 0;
872

873
        r = read_credential("passwd.shell.root", (void**) &arg_root_shell, NULL);
25✔
874
        if (r < 0)
25✔
875
                log_debug_errno(r, "Failed to read credential passwd.shell.root, ignoring: %m");
24✔
876
        else {
877
                log_debug("Acquired root shell from credential.");
1✔
878
                return 0;
879
        }
880

881
        if (!arg_prompt_root_shell) {
24✔
882
                log_debug("Prompting for root shell was not requested.");
22✔
883
                return 0;
884
        }
885

886
        print_welcome(rfd, mute_console_link);
2✔
887

888
        return prompt_loop(
2✔
889
                        "Please enter the new root shell",
890
                        GLYPH_SHELL,
891
                        /* menu= */ NULL,
892
                        /* accepted= */ NULL,
893
                        /* ellipsize_percentage= */ 0,
894
                        /* n_columns= */ 3,
895
                        /* column_width= */ 20,
896
                        shell_is_ok,
897
                        /* refresh= */ NULL,
898
                        FD_TO_PTR(rfd),
2✔
899
                        PROMPT_MAY_SKIP,
900
                        &arg_root_shell);
901
}
902

903
static int write_root_passwd(int rfd, int etc_fd, const char *password, const char *shell) {
15✔
904
        _cleanup_fclose_ FILE *original = NULL, *passwd = NULL;
15✔
905
        _cleanup_(unlink_and_freep) char *passwd_tmp = NULL;
15✔
906
        int r;
15✔
907
        bool found = false;
15✔
908

909
        r = fopen_temporary_at_label(etc_fd, "passwd", "passwd", &passwd, &passwd_tmp);
15✔
910
        if (r < 0)
15✔
911
                return r;
912

913
        r = xfopenat(etc_fd, "passwd", "re", O_NOFOLLOW, &original);
15✔
914
        if (r < 0 && r != -ENOENT)
15✔
915
                return r;
916

917
        if (original) {
15✔
918
                struct passwd *i;
4✔
919

920
                r = copy_rights(fileno(original), fileno(passwd));
4✔
921
                if (r < 0)
4✔
922
                        return r;
×
923

924
                while ((r = fgetpwent_sane(original, &i)) > 0) {
7✔
925

926
                        if (streq(i->pw_name, "root")) {
3✔
927
                                if (password)
3✔
928
                                        i->pw_passwd = (char *) password;
2✔
929
                                if (shell)
3✔
930
                                        i->pw_shell = (char *) shell;
2✔
931
                                found = true;
932
                        }
933

934
                        r = putpwent_sane(i, passwd);
3✔
935
                        if (r < 0)
3✔
936
                                return r;
937
                }
938
                if (r < 0)
4✔
939
                        return r;
940

941
        } else {
942
                r = fchmod(fileno(passwd), 0644);
11✔
943
                if (r < 0)
11✔
944
                        return -errno;
×
945
        }
946

947
        if (!found) {
4✔
948
                struct passwd root = {
12✔
949
                        .pw_name = (char *) "root",
950
                        .pw_passwd = (char *) (password ?: PASSWORD_SEE_SHADOW),
12✔
951
                        .pw_uid = 0,
952
                        .pw_gid = 0,
953
                        .pw_gecos = (char *) "Super User",
954
                        .pw_dir = (char *) "/root",
955
                        .pw_shell = (char *) (shell ?: default_root_shell_at(rfd)),
6✔
956
                };
957

958
                r = putpwent_sane(&root, passwd);
12✔
959
                if (r < 0)
12✔
960
                        return r;
×
961
        }
962

963
        r = fflush_sync_and_check(passwd);
15✔
964
        if (r < 0)
15✔
965
                return r;
966

967
        r = renameat_and_apply_smack_floor_label(etc_fd, passwd_tmp, etc_fd, "passwd");
15✔
968
        if (r < 0)
15✔
969
                return r;
×
970

971
        return 0;
972
}
973

974
static int write_root_shadow(int etc_fd, const char *hashed_password) {
15✔
975
        _cleanup_fclose_ FILE *original = NULL, *shadow = NULL;
15✔
976
        _cleanup_(unlink_and_freep) char *shadow_tmp = NULL;
15✔
977
        int r;
15✔
978
        bool found = false;
15✔
979

980
        r = fopen_temporary_at_label(etc_fd, "shadow", "shadow", &shadow, &shadow_tmp);
15✔
981
        if (r < 0)
15✔
982
                return r;
983

984
        r = xfopenat(etc_fd, "shadow", "re", O_NOFOLLOW, &original);
15✔
985
        if (r < 0 && r != -ENOENT)
15✔
986
                return r;
987

988
        if (original) {
15✔
989
                struct spwd *i;
4✔
990

991
                r = copy_rights(fileno(original), fileno(shadow));
4✔
992
                if (r < 0)
4✔
993
                        return r;
×
994

995
                while ((r = fgetspent_sane(original, &i)) > 0) {
7✔
996

997
                        if (streq(i->sp_namp, "root")) {
3✔
998
                                if (hashed_password) {
3✔
999
                                        i->sp_pwdp = (char *) hashed_password;
2✔
1000
                                        i->sp_lstchg = (long) (now(CLOCK_REALTIME) / USEC_PER_DAY);
2✔
1001
                                }
1002
                                found = true;
1003
                        }
1004

1005
                        r = putspent_sane(i, shadow);
3✔
1006
                        if (r < 0)
3✔
1007
                                return r;
1008
                }
1009
                if (r < 0)
4✔
1010
                        return r;
1011

1012
        } else {
1013
                r = fchmod(fileno(shadow), 0000);
11✔
1014
                if (r < 0)
11✔
1015
                        return -errno;
×
1016
        }
1017

1018
        if (!found) {
4✔
1019
                struct spwd root = {
36✔
1020
                        .sp_namp = (char*) "root",
1021
                        .sp_pwdp = (char *) (hashed_password ?: PASSWORD_LOCKED_AND_INVALID),
12✔
1022
                        .sp_lstchg = (long) (now(CLOCK_REALTIME) / USEC_PER_DAY),
12✔
1023
                        .sp_min = -1,
1024
                        .sp_max = -1,
1025
                        .sp_warn = -1,
1026
                        .sp_inact = -1,
1027
                        .sp_expire = -1,
1028
                        .sp_flag = ULONG_MAX, /* this appears to be what everybody does ... */
1029
                };
1030

1031
                r = putspent_sane(&root, shadow);
12✔
1032
                if (r < 0)
12✔
1033
                        return r;
×
1034
        }
1035

1036
        r = fflush_sync_and_check(shadow);
15✔
1037
        if (r < 0)
15✔
1038
                return r;
1039

1040
        r = renameat_and_apply_smack_floor_label(etc_fd, shadow_tmp, etc_fd, "shadow");
15✔
1041
        if (r < 0)
15✔
1042
                return r;
×
1043

1044
        return 0;
1045
}
1046

1047
static int process_root_account(int rfd, sd_varlink **mute_console_link) {
141✔
1048
        _cleanup_close_ int pfd = -EBADF;
141✔
1049
        _cleanup_(release_lock_file) LockFile lock = LOCK_FILE_INIT;
×
1050
        _cleanup_(erase_and_freep) char *_hashed_password = NULL;
141✔
1051
        const char *password, *hashed_password;
141✔
1052
        int k = 0, r;
141✔
1053

1054
        assert(rfd >= 0);
141✔
1055

1056
        pfd = chase_and_open_parent_at(rfd, rfd, "/etc/passwd",
141✔
1057
                                       CHASE_MKDIR_0755|CHASE_WARN|CHASE_NOFOLLOW,
1058
                                       NULL);
1059
        if (pfd < 0)
141✔
1060
                return log_error_errno(pfd, "Failed to chase /etc/passwd: %m");
×
1061

1062
        /* Ensure that passwd and shadow are in the same directory and are not symlinks. */
1063

1064
        FOREACH_STRING(s, "passwd", "shadow") {
423✔
1065
                r = verify_regular_at(pfd, s, /* follow= */ false);
282✔
1066
                if (r < 0 && r != -ENOENT)
282✔
1067
                        return log_error_errno(r, "Verification of /etc/%s being regular file failed: %m", s);
×
1068

1069
                r = should_configure(pfd, s);
282✔
1070
                if (r < 0)
282✔
1071
                        return r;
1072

1073
                k += r;
282✔
1074
        }
1075

1076
        if (k == 0) {
141✔
1077
                log_debug("Found /etc/passwd and /etc/shadow, assuming root account has been initialized.");
111✔
1078
                return 0;
1079
        }
1080

1081
        r = make_lock_file_at(pfd, ETC_PASSWD_LOCK_FILENAME, LOCK_EX, &lock);
30✔
1082
        if (r < 0)
30✔
1083
                return log_error_errno(r, "Failed to take a lock on /etc/passwd: %m");
×
1084

1085
        k = dir_fd_is_root(rfd);
30✔
1086
        if (k < 0)
30✔
1087
                return log_error_errno(k, "Failed to check if directory file descriptor is root: %m");
×
1088

1089
        if (arg_copy_root_shell && k == 0) {
30✔
1090
                _cleanup_free_ struct passwd *p = NULL;
2✔
1091

1092
                r = getpwnam_malloc("root", &p);
2✔
1093
                if (r < 0)
2✔
1094
                        return log_error_errno(r, "Failed to find passwd entry for root: %m");
×
1095

1096
                r = free_and_strdup(&arg_root_shell, p->pw_shell);
2✔
1097
                if (r < 0)
2✔
1098
                        return log_oom();
×
1099
        }
1100

1101
        r = prompt_root_shell(rfd, mute_console_link);
30✔
1102
        if (r < 0)
30✔
1103
                return r;
1104

1105
        if (arg_copy_root_password && k == 0) {
30✔
1106
                struct spwd *p;
2✔
1107

1108
                errno = 0;
2✔
1109
                p = getspnam("root");
2✔
1110
                if (!p)
2✔
1111
                        return log_error_errno(errno_or_else(EIO), "Failed to find shadow entry for root: %m");
×
1112

1113
                r = free_and_strdup(&arg_root_password, p->sp_pwdp);
2✔
1114
                if (r < 0)
2✔
1115
                        return log_oom();
×
1116

1117
                arg_root_password_is_hashed = true;
2✔
1118
        }
1119

1120
        r = prompt_root_password(rfd, mute_console_link);
30✔
1121
        if (r < 0)
30✔
1122
                return r;
1123

1124
        if (arg_root_password && arg_root_password_is_hashed) {
30✔
1125
                password = PASSWORD_SEE_SHADOW;
1126
                hashed_password = arg_root_password;
1127
        } else if (arg_root_password) {
24✔
1128
                r = hash_password(arg_root_password, &_hashed_password);
4✔
1129
                if (r < 0)
4✔
1130
                        return log_error_errno(r, "Failed to hash password: %m");
×
1131

1132
                password = PASSWORD_SEE_SHADOW;
4✔
1133
                hashed_password = _hashed_password;
4✔
1134

1135
        } else if (arg_delete_root_password) {
20✔
1136
                password = PASSWORD_SEE_SHADOW;
1137
                hashed_password = PASSWORD_NONE;
1138
        } else if (!arg_root_password && arg_prompt_root_password) {
19✔
1139
                /* If the user was prompted, but no password was supplied, lock the account. */
1140
                password = PASSWORD_SEE_SHADOW;
1141
                hashed_password = PASSWORD_LOCKED_AND_INVALID;
1142
        } else
1143
                /* Leave the password as is. */
1144
                password = hashed_password = NULL;
18✔
1145

1146
        /* Don't create/modify passwd and shadow if there's nothing to do. */
1147
        if (!(password || hashed_password || arg_root_shell)) {
30✔
1148
                log_debug("Initialization of root account was not requested, skipping.");
15✔
1149
                return 0;
1150
        }
1151

1152
        r = write_root_passwd(rfd, pfd, password, arg_root_shell);
15✔
1153
        if (r < 0)
15✔
1154
                return log_error_errno(r, "Failed to write /etc/passwd: %m");
×
1155

1156
        log_info("/etc/passwd written.");
15✔
1157

1158
        r = write_root_shadow(pfd, hashed_password);
15✔
1159
        if (r < 0)
15✔
1160
                return log_error_errno(r, "Failed to write /etc/shadow: %m");
×
1161

1162
        log_info("/etc/shadow written.");
15✔
1163
        return 0;
1164
}
1165

1166
static int process_kernel_cmdline(int rfd) {
141✔
1167
        _cleanup_close_ int pfd = -EBADF;
141✔
1168
        _cleanup_free_ char *f = NULL;
141✔
1169
        int r;
141✔
1170

1171
        assert(rfd >= 0);
141✔
1172

1173
        pfd = chase_and_open_parent_at(rfd, rfd, "/etc/kernel/cmdline",
141✔
1174
                                       CHASE_MKDIR_0755|CHASE_WARN|CHASE_NOFOLLOW,
1175
                                       &f);
1176
        if (pfd < 0)
141✔
1177
                return log_error_errno(pfd, "Failed to chase /etc/kernel/cmdline: %m");
×
1178

1179
        r = should_configure(pfd, f);
141✔
1180
        if (r == 0)
141✔
1181
                log_debug("Found /etc/kernel/cmdline, assuming kernel command line has been configured.");
1✔
1182
        if (r <= 0)
141✔
1183
                return r;
1184

1185
        if (!arg_kernel_cmdline) {
140✔
1186
                log_debug("Creation of /etc/kernel/cmdline was not requested, skipping.");
138✔
1187
                return 0;
1188
        }
1189

1190
        r = write_string_file_at(pfd, "cmdline", arg_kernel_cmdline,
2✔
1191
                                 WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_SYNC|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_LABEL);
1192
        if (r < 0)
2✔
1193
                return log_error_errno(r, "Failed to write /etc/kernel/cmdline: %m");
×
1194

1195
        log_info("/etc/kernel/cmdline written.");
2✔
1196
        return 0;
1197
}
1198

1199
static int reset_one(int rfd, const char *path) {
6✔
1200
        _cleanup_close_ int pfd = -EBADF;
6✔
1201
        _cleanup_free_ char *f = NULL;
6✔
1202

1203
        assert(rfd >= 0);
6✔
1204
        assert(path);
6✔
1205

1206
        pfd = chase_and_open_parent_at(rfd, rfd, path, CHASE_WARN|CHASE_NOFOLLOW, &f);
6✔
1207
        if (pfd == -ENOENT)
6✔
1208
                return 0;
1209
        if (pfd < 0)
6✔
1210
                return log_error_errno(pfd, "Failed to resolve %s: %m", path);
×
1211

1212
        if (unlinkat(pfd, f, 0) < 0)
6✔
1213
                return errno == ENOENT ? 0 : log_error_errno(errno, "Failed to remove %s: %m", path);
×
1214

1215
        log_info("Removed %s", path);
6✔
1216
        return 0;
1217
}
1218

1219
static int process_reset(int rfd) {
141✔
1220
        int r;
141✔
1221

1222
        assert(rfd >= 0);
141✔
1223

1224
        if (!arg_reset)
141✔
1225
                return 0;
1226

1227
        FOREACH_STRING(p,
7✔
1228
                       etc_locale_conf(),
1229
                       etc_vconsole_conf(),
1230
                       etc_hostname(),
1231
                       "/etc/machine-id",
1232
                       "/etc/kernel/cmdline",
1233
                       etc_localtime()) {
1234
                r = reset_one(rfd, p);
6✔
1235
                if (r < 0)
6✔
1236
                        return r;
×
1237
        }
1238

1239
        return 0;
1✔
1240
}
1241

1242
static int help(void) {
×
1243
        _cleanup_free_ char *link = NULL;
×
1244
        _cleanup_(table_unrefp) Table *options = NULL;
×
1245
        int r;
×
1246

1247
        r = terminal_urlify_man("systemd-firstboot", "1", &link);
×
1248
        if (r < 0)
×
1249
                return log_oom();
×
1250

1251
        r = option_parser_get_help_table(&options);
×
1252
        if (r < 0)
×
1253
                return r;
1254

1255
        printf("%s [OPTIONS...]\n\n"
×
1256
               "%sConfigures basic settings of the system.%s\n\n",
1257
               program_invocation_short_name,
1258
               ansi_highlight(),
1259
               ansi_normal());
1260

1261
        r = table_print_or_warn(options);
×
1262
        if (r < 0)
×
1263
                return r;
1264

1265
        printf("\nSee the %s for details.\n", link);
×
1266
        return 0;
1267
}
1268

1269
static int parse_argv(int argc, char *argv[]) {
144✔
1270
        assert(argc >= 0);
144✔
1271
        assert(argv);
144✔
1272

1273
        OptionParser opts = { argc, argv };
144✔
1274
        int r;
144✔
1275

1276
        FOREACH_OPTION_OR_RETURN(c, &opts)
928✔
1277
                switch (c) {
642✔
1278

1279
                OPTION_COMMON_HELP:
×
1280
                        return help();
×
1281

1282
                OPTION_COMMON_VERSION:
×
1283
                        return version();
×
1284

1285
                OPTION_LONG("root", "PATH", "Operate on an alternate filesystem root"):
38✔
1286
                        r = parse_path_argument(opts.arg, true, &arg_root);
38✔
1287
                        if (r < 0)
38✔
1288
                                return r;
1289
                        break;
1290

1291
                OPTION_LONG("image", "PATH", "Operate on disk image as filesystem root"):
×
1292
                        r = parse_path_argument(opts.arg, false, &arg_image);
×
1293
                        if (r < 0)
×
1294
                                return r;
1295
                        break;
1296

1297
                OPTION_LONG("image-policy", "POLICY", "Specify disk image dissection policy"):
×
1298
                        r = parse_image_policy_argument(opts.arg, &arg_image_policy);
×
1299
                        if (r < 0)
×
1300
                                return r;
1301
                        break;
1302

1303
                OPTION_LONG("locale", "LOCALE", "Set primary locale (LANG=)"):
5✔
1304
                        r = free_and_strdup_warn(&arg_locale, opts.arg);
5✔
1305
                        if (r < 0)
5✔
1306
                                return r;
1307
                        break;
1308

1309
                OPTION_LONG("locale-messages", "LOCALE", "Set message locale (LC_MESSAGES=)"):
4✔
1310
                        r = free_and_strdup_warn(&arg_locale_messages, opts.arg);
4✔
1311
                        if (r < 0)
4✔
1312
                                return r;
1313
                        break;
1314

1315
                OPTION_LONG("keymap", "KEYMAP", "Set keymap"):
4✔
1316
                        if (!keymap_is_valid(opts.arg))
4✔
1317
                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
1318
                                                       "Keymap %s is not valid.", opts.arg);
1319

1320
                        r = free_and_strdup_warn(&arg_keymap, opts.arg);
4✔
1321
                        if (r < 0)
4✔
1322
                                return r;
1323
                        break;
1324

1325
                OPTION_LONG("timezone", "TIMEZONE", "Set timezone"):
5✔
1326
                        if (!timezone_is_valid(opts.arg, LOG_ERR))
5✔
1327
                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
1✔
1328
                                                       "Timezone %s is not valid.", opts.arg);
1329

1330
                        r = free_and_strdup_warn(&arg_timezone, opts.arg);
4✔
1331
                        if (r < 0)
4✔
1332
                                return r;
1333
                        break;
1334

1335
                OPTION_LONG("hostname", "NAME", "Set hostname"):
5✔
1336
                        if (!hostname_is_valid(opts.arg, VALID_HOSTNAME_TRAILING_DOT|VALID_HOSTNAME_QUESTION_MARK))
5✔
1337
                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
1338
                                                       "Host name %s is not valid.", opts.arg);
1339

1340
                        r = free_and_strdup_warn(&arg_hostname, opts.arg);
5✔
1341
                        if (r < 0)
5✔
1342
                                return r;
1343

1344
                        hostname_cleanup(arg_hostname);
5✔
1345
                        break;
1346

1347
                OPTION_LONG("setup-machine-id", NULL, "Set a random machine ID"):
1✔
1348
                        r = sd_id128_randomize(&arg_machine_id);
1✔
1349
                        if (r < 0)
1✔
1350
                                return log_error_errno(r, "Failed to generate randomized machine ID: %m");
×
1351
                        break;
1352

1353
                OPTION_LONG("machine-id", "ID", "Set specified machine ID"):
4✔
1354
                        r = sd_id128_from_string(opts.arg, &arg_machine_id);
4✔
1355
                        if (r < 0)
4✔
1356
                                return log_error_errno(r, "Failed to parse machine id %s.", opts.arg);
1✔
1357
                        break;
1358

1359
                OPTION_LONG("root-password", "PASSWORD", "Set root password from plaintext password"):
4✔
1360
                        r = free_and_strdup_warn(&arg_root_password, opts.arg);
4✔
1361
                        if (r < 0)
4✔
1362
                                return r;
1363

1364
                        arg_root_password_is_hashed = false;
4✔
1365
                        break;
4✔
1366

1367
                OPTION_LONG("root-password-file", "FILE", "Set root password from file"):
1✔
1368
                        arg_root_password = mfree(arg_root_password);
1✔
1369

1370
                        r = read_one_line_file(opts.arg, &arg_root_password);
1✔
1371
                        if (r < 0)
1✔
1372
                                return log_error_errno(r, "Failed to read %s: %m", opts.arg);
×
1373

1374
                        arg_root_password_is_hashed = false;
1✔
1375
                        break;
1✔
1376

1377
                OPTION_LONG("root-password-hashed", "HASH", "Set root password from hashed password"):
4✔
1378
                        r = free_and_strdup_warn(&arg_root_password, opts.arg);
4✔
1379
                        if (r < 0)
4✔
1380
                                return r;
1381

1382
                        arg_root_password_is_hashed = true;
4✔
1383
                        break;
4✔
1384

1385
                OPTION_LONG("root-shell", "SHELL", "Set root shell"):
5✔
1386
                        r = free_and_strdup_warn(&arg_root_shell, opts.arg);
5✔
1387
                        if (r < 0)
5✔
1388
                                return r;
1389
                        break;
1390

1391
                OPTION_LONG("kernel-command-line", "CMDLINE", "Set kernel command line"):
3✔
1392
                        r = free_and_strdup_warn(&arg_kernel_cmdline, opts.arg);
3✔
1393
                        if (r < 0)
3✔
1394
                                return r;
1395
                        break;
1396

1397
                OPTION_LONG("prompt-locale", NULL, "Prompt the user for locale settings"):
108✔
1398
                        arg_prompt_locale = true;
108✔
1399
                        break;
108✔
1400

1401
                OPTION_LONG("prompt-keymap", NULL, "Prompt the user for keymap settings"):
2✔
1402
                        arg_prompt_keymap = true;
2✔
1403
                        arg_prompt_keymap_auto = false;
2✔
1404
                        break;
2✔
1405

1406
                OPTION_LONG("prompt-keymap-auto", NULL,
107✔
1407
                            "Prompt the user for keymap settings if invoked on local console"):
1408
                        arg_prompt_keymap_auto = true;
107✔
1409
                        break;
107✔
1410

1411
                OPTION_LONG("prompt-timezone", NULL, "Prompt the user for timezone"):
108✔
1412
                        arg_prompt_timezone = true;
108✔
1413
                        break;
108✔
1414

1415
                OPTION_LONG("prompt-hostname", NULL, "Prompt the user for hostname"):
1✔
1416
                        arg_prompt_hostname = true;
1✔
1417
                        break;
1✔
1418

1419
                OPTION_LONG("prompt-root-password", NULL, "Prompt the user for root password"):
108✔
1420
                        arg_prompt_root_password = true;
108✔
1421
                        break;
108✔
1422

1423
                OPTION_LONG("prompt-root-shell", NULL, "Prompt the user for root shell"):
4✔
1424
                        arg_prompt_root_shell = true;
4✔
1425
                        break;
4✔
1426

1427
                OPTION_LONG("prompt", NULL, "Prompt for all of the above"):
×
1428
                        arg_prompt_locale = arg_prompt_keymap = arg_prompt_timezone = arg_prompt_hostname =
×
1429
                                arg_prompt_root_password = arg_prompt_root_shell = true;
×
1430
                        arg_prompt_keymap_auto = false;
×
1431
                        break;
×
1432

1433
                OPTION_LONG("copy-locale", NULL, "Copy locale from host"):
2✔
1434
                        arg_copy_locale = true;
2✔
1435
                        break;
2✔
1436

1437
                OPTION_LONG("copy-keymap", NULL, "Copy keymap from host"):
2✔
1438
                        arg_copy_keymap = true;
2✔
1439
                        break;
2✔
1440

1441
                OPTION_LONG("copy-timezone", NULL, "Copy timezone from host"):
2✔
1442
                        arg_copy_timezone = true;
2✔
1443
                        break;
2✔
1444

1445
                OPTION_LONG("copy-root-password", NULL, "Copy root password from host"):
1✔
1446
                        arg_copy_root_password = true;
1✔
1447
                        break;
1✔
1448

1449
                OPTION_LONG("copy-root-shell", NULL, "Copy root shell from host"):
1✔
1450
                        arg_copy_root_shell = true;
1✔
1451
                        break;
1✔
1452

1453
                OPTION_LONG("copy", NULL, "Copy all of the above"):
1✔
1454
                        arg_copy_locale = arg_copy_keymap = arg_copy_timezone = arg_copy_root_password =
1✔
1455
                                arg_copy_root_shell = true;
1✔
1456
                        break;
1✔
1457

1458
                OPTION_LONG("force", NULL, "Overwrite existing files"):
3✔
1459
                        arg_force = true;
3✔
1460
                        break;
3✔
1461

1462
                OPTION_LONG("delete-root-password", NULL, "Delete root password"):
1✔
1463
                        arg_delete_root_password = true;
1✔
1464
                        break;
1✔
1465

1466
                OPTION_LONG("welcome", "BOOL", "Whether to show the welcome text"):
1✔
1467
                        r = parse_boolean_argument("--welcome=", opts.arg, &arg_welcome);
1✔
1468
                        if (r < 0)
1✔
1469
                                return r;
1470
                        break;
1471

1472
                OPTION_LONG("chrome", "BOOL",
×
1473
                            "Whether to show a color bar at top and bottom of terminal"):
1474
                        r = parse_boolean_argument("--chrome=", opts.arg, &arg_chrome);
×
1475
                        if (r < 0)
×
1476
                                return r;
1477
                        break;
1478

1479
                OPTION_LONG("mute-console", "BOOL",
106✔
1480
                            "Whether to disallow kernel/PID 1 writes to the console while running"):
1481
                        r = parse_boolean_argument("--mute-console=", opts.arg, &arg_mute_console);
106✔
1482
                        if (r < 0)
106✔
1483
                                return r;
1484
                        break;
1485

1486
                OPTION_LONG("reset", NULL, "Remove existing files"):
1✔
1487
                        arg_reset = true;
1✔
1488
                        break;
1✔
1489
                }
1490

1491
        if (arg_delete_root_password && (arg_copy_root_password || arg_root_password || arg_prompt_root_password))
142✔
1492
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
1493
                                       "--delete-root-password cannot be combined with other root password options.");
1494

1495
        if (arg_image && arg_root)
142✔
1496
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
1497
                                       "--root= and --image= cannot be used together.");
1498

1499
        if (!sd_id128_is_null(arg_machine_id) && !(arg_image || arg_root) && !arg_force)
280✔
1500
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
1501
                                       "--machine-id=/--setup-machine-id only works with --root= or --image=.");
1502

1503
        return 1;
1504
}
1505

1506
static int reload_system_manager(sd_bus **bus) {
×
1507
        int r;
×
1508

1509
        assert(bus);
×
1510

1511
        if (!*bus) {
×
1512
                r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, bus);
×
1513
                if (r < 0)
×
1514
                        return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, RUNTIME_SCOPE_SYSTEM);
×
1515
        }
1516

1517
        r = bus_service_manager_reload(*bus);
×
1518
        if (r < 0)
×
1519
                return r;
1520

1521
        log_info("Requested manager reload to apply locale configuration.");
×
1522
        return 0;
1523
}
1524

1525
static int reload_vconsole(sd_bus **bus) {
×
1526
        _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
×
1527
        _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
×
1528
        _cleanup_(bus_wait_for_jobs_freep) BusWaitForJobs *w = NULL;
×
1529
        const char *object;
×
1530
        int r;
×
1531

1532
        assert(bus);
×
1533

1534
        if (!*bus) {
×
1535
                r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, bus);
×
1536
                if (r < 0)
×
1537
                        return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, RUNTIME_SCOPE_SYSTEM);
×
1538
        }
1539

1540
        r = bus_wait_for_jobs_new(*bus, &w);
×
1541
        if (r < 0)
×
1542
                return log_error_errno(r, "Could not watch jobs: %m");
×
1543

1544
        r = bus_call_method(*bus, bus_systemd_mgr, "RestartUnit", &error, &reply,
×
1545
                            "ss", "systemd-vconsole-setup.service", "replace");
1546
        if (r < 0)
×
1547
                return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, r));
×
1548

1549
        r = sd_bus_message_read(reply, "o", &object);
×
1550
        if (r < 0)
×
1551
                return bus_log_parse_error(r);
×
1552

1553
        r = bus_wait_for_jobs_one(w, object, BUS_WAIT_JOBS_LOG_ERROR, NULL);
×
1554
        if (r < 0)
×
1555
                return log_error_errno(r, "Failed to wait for systemd-vconsole-setup.service/restart: %m");
×
1556
        return 0;
1557
}
1558

1559
static int run(int argc, char *argv[]) {
144✔
1560
        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
144✔
1561
        _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
144✔
1562
        _cleanup_(umount_and_freep) char *mounted_dir = NULL;
×
1563
        _cleanup_close_ int rfd = -EBADF;
144✔
1564
        int r;
144✔
1565

1566
        r = parse_argv(argc, argv);
144✔
1567
        if (r <= 0)
144✔
1568
                return r;
1569

1570
        log_setup();
142✔
1571

1572
        umask(0022);
142✔
1573

1574
        bool offline = arg_root || arg_image;
142✔
1575

1576
        if (!offline) {
106✔
1577
                /* If we are called without --root=/--image= let's honour the systemd.firstboot kernel
1578
                 * command line option, because we are called to provision the host with basic settings (as
1579
                 * opposed to some other file system tree/image) */
1580

1581
                bool enabled;
106✔
1582
                r = proc_cmdline_get_bool("systemd.firstboot", /* flags= */ 0, &enabled);
106✔
1583
                if (r < 0)
106✔
1584
                        return log_error_errno(r, "Failed to parse systemd.firstboot= kernel command line argument, ignoring: %m");
×
1585
                if (r > 0 && !enabled) {
106✔
1586
                        log_debug("Found systemd.firstboot=no kernel command line argument, turning off all prompts.");
106✔
1587
                        arg_prompt_locale = arg_prompt_keymap = arg_prompt_keymap_auto = arg_prompt_timezone = arg_prompt_hostname = arg_prompt_root_password = arg_prompt_root_shell = false;
106✔
1588
                }
1589
        }
1590

1591
        r = mac_init();
142✔
1592
        if (r < 0)
142✔
1593
                return r;
1594

1595
        if (arg_image) {
142✔
1596
                assert(!arg_root);
×
1597

1598
                r = mount_image_privately_interactively(
×
1599
                                arg_image,
1600
                                arg_image_policy,
1601
                                DISSECT_IMAGE_GENERIC_ROOT |
1602
                                DISSECT_IMAGE_REQUIRE_ROOT |
1603
                                DISSECT_IMAGE_VALIDATE_OS |
1604
                                DISSECT_IMAGE_RELAX_VAR_CHECK |
1605
                                DISSECT_IMAGE_FSCK |
1606
                                DISSECT_IMAGE_GROWFS |
1607
                                DISSECT_IMAGE_ALLOW_USERSPACE_VERITY,
1608
                                &mounted_dir,
1609
                                &rfd,
1610
                                &loop_device);
1611
                if (r < 0)
×
1612
                        return r;
1613

1614
                arg_root = strdup(mounted_dir);
×
1615
                if (!arg_root)
×
1616
                        return log_oom();
×
1617
        } else {
1618
                rfd = open(empty_to_root(arg_root), O_DIRECTORY|O_CLOEXEC);
142✔
1619
                if (rfd < 0)
142✔
1620
                        return log_error_errno(errno, "Failed to open %s: %m", empty_to_root(arg_root));
×
1621
        }
1622

1623
        LOG_SET_PREFIX(arg_image ?: arg_root);
286✔
1624
        DEFER_VOID_CALL(chrome_hide);
×
1625

1626
        /* We check these conditions here instead of in parse_argv() so that we can take the root directory
1627
         * into account. */
1628

1629
        if (arg_keymap && !keymap_is_ok(arg_keymap, FD_TO_PTR(rfd)))
142✔
1630
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Keymap %s is not installed.", arg_keymap);
×
1631
        if (arg_locale && !locale_is_ok(arg_locale, FD_TO_PTR(rfd)))
142✔
1632
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Locale %s is not installed.", arg_locale);
×
1633
        if (arg_locale_messages && !locale_is_ok(arg_locale_messages, FD_TO_PTR(rfd)))
142✔
1634
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Locale %s is not installed.", arg_locale_messages);
×
1635

1636
        if (arg_root_shell) {
142✔
1637
                r = find_shell(rfd, arg_root_shell);
5✔
1638
                if (r < 0)
5✔
1639
                        return r;
1640
        }
1641

1642
        r = process_reset(rfd);
141✔
1643
        if (r < 0)
141✔
1644
                return r;
1645

1646
        _cleanup_(sd_varlink_flush_close_unrefp) sd_varlink *mute_console_link = NULL;
142✔
1647
        r = process_locale(rfd, &mute_console_link);
141✔
1648
        if (r < 0)
141✔
1649
                return r;
1650
        if (r > 0 && !offline)
141✔
1651
                (void) reload_system_manager(&bus);
×
1652

1653
        r = process_keymap(rfd, &mute_console_link);
141✔
1654
        if (r < 0)
141✔
1655
                return r;
1656
        if (r > 0 && !offline)
141✔
1657
                (void) reload_vconsole(&bus);
×
1658

1659
        r = process_timezone(rfd, &mute_console_link);
141✔
1660
        if (r < 0)
141✔
1661
                return r;
1662

1663
        r = process_hostname(rfd, &mute_console_link);
141✔
1664
        if (r < 0)
141✔
1665
                return r;
1666

1667
        r = process_root_account(rfd, &mute_console_link);
141✔
1668
        if (r < 0)
141✔
1669
                return r;
1670

1671
        r = process_kernel_cmdline(rfd);
141✔
1672
        if (r < 0)
141✔
1673
                return r;
1674

1675
        r = process_machine_id(rfd);
141✔
1676
        if (r < 0)
141✔
1677
                return r;
×
1678

1679
        return 0;
1680
}
1681

1682
DEFINE_MAIN_FUNCTION(run);
144✔
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