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

systemd / systemd / 18578253386

16 Oct 2025 06:50PM UTC coverage: 72.363% (+0.3%) from 72.072%
18578253386

push

github

web-flow
core/mount: properly handle REMOUNTING_* states in mount_stop() (#39269)

5 of 9 new or added lines in 1 file covered. (55.56%)

3694 existing lines in 74 files now uncovered.

304611 of 420946 relevant lines covered (72.36%)

1092905.84 hits per line

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

76.56
/src/nspawn/nspawn-mount.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <linux/magic.h>
4
#include <sys/mount.h>
5
#include <unistd.h>
6

7
#include "alloc-util.h"
8
#include "chase.h"
9
#include "errno-util.h"
10
#include "escape.h"
11
#include "extract-word.h"
12
#include "fd-util.h"
13
#include "format-util.h"
14
#include "fs-util.h"
15
#include "log.h"
16
#include "mkdir-label.h"
17
#include "mount-util.h"
18
#include "mountpoint-util.h"
19
#include "namespace-util.h"
20
#include "nspawn-mount.h"
21
#include "path-util.h"
22
#include "rm-rf.h"
23
#include "sort-util.h"
24
#include "stat-util.h"
25
#include "string-util.h"
26
#include "strv.h"
27
#include "tmpfile-util.h"
28
#include "user-util.h"
29

30
CustomMount* custom_mount_add(CustomMount **l, size_t *n, CustomMountType t) {
563✔
31
        CustomMount *ret;
563✔
32

33
        assert(l);
563✔
34
        assert(n);
563✔
35
        assert(t >= 0);
563✔
36
        assert(t < _CUSTOM_MOUNT_TYPE_MAX);
563✔
37

38
        if (!GREEDY_REALLOC(*l, *n + 1))
563✔
39
                return NULL;
40

41
        ret = *l + *n;
563✔
42
        (*n)++;
563✔
43

44
        *ret = (CustomMount) {
563✔
45
                .type = t,
46
                .destination_uid = UID_INVALID,
47
        };
48

49
        return ret;
563✔
50
}
51

52
void custom_mount_free_all(CustomMount *l, size_t n) {
1,232✔
53
        FOREACH_ARRAY(m, l, n) {
1,505✔
54
                free(m->source);
273✔
55
                free(m->destination);
273✔
56
                free(m->options);
273✔
57

58
                if (m->work_dir) {
273✔
59
                        (void) rm_rf(m->work_dir, REMOVE_ROOT|REMOVE_PHYSICAL);
5✔
60
                        free(m->work_dir);
5✔
61
                }
62

63
                if (m->rm_rf_tmpdir) {
273✔
64
                        (void) rm_rf(m->rm_rf_tmpdir, REMOVE_ROOT|REMOVE_PHYSICAL);
4✔
65
                        free(m->rm_rf_tmpdir);
4✔
66
                }
67

68
                strv_free(m->lower);
273✔
69
                free(m->type_argument);
273✔
70
        }
71

72
        free(l);
1,232✔
73
}
1,232✔
74

75
static int custom_mount_compare(const CustomMount *a, const CustomMount *b) {
118✔
76
        int r;
118✔
77

78
        r = path_compare(a->destination, b->destination);
118✔
79
        if (r != 0)
118✔
80
                return r;
81

82
        return CMP(a->type, b->type);
×
83
}
84

85
static int source_path_parse(const char *p, char **ret) {
528✔
86
        assert(p);
528✔
87
        assert(ret);
528✔
88

89
        if (isempty(p))
528✔
90
                return -EINVAL;
91

92
        if (*p == '+') {
528✔
93
                if (!path_is_absolute(p + 1))
7✔
94
                        return -EINVAL;
528✔
95

96
                char *s = strdup(p);
7✔
97
                if (!s)
7✔
98
                        return -ENOMEM;
99

100
                *ret = TAKE_PTR(s);
7✔
101
                return 0;
7✔
102
        }
103

104
        return path_make_absolute_cwd(p, ret);
521✔
105
}
106

107
static int source_path_parse_nullable(const char *p, char **ret) {
522✔
108
        assert(p);
522✔
109
        assert(ret);
522✔
110

111
        if (isempty(p)) {
522✔
112
                *ret = NULL;
9✔
113
                return 0;
9✔
114
        }
115

116
        return source_path_parse(p, ret);
513✔
117
}
118

119
static char *resolve_source_path(const char *dest, const char *source) {
418✔
120
        if (!source)
418✔
121
                return NULL;
122

123
        if (source[0] == '+')
418✔
124
                return path_join(dest, source + 1);
8✔
125

126
        return strdup(source);
410✔
127
}
128

129
static int allocate_temporary_source(CustomMount *m) {
10✔
130
        int r;
10✔
131

132
        assert(m);
10✔
133
        assert(!m->source);
10✔
134
        assert(!m->rm_rf_tmpdir);
10✔
135

136
        r = mkdtemp_malloc("/var/tmp/nspawn-temp-XXXXXX", &m->rm_rf_tmpdir);
10✔
137
        if (r < 0)
10✔
138
                return log_error_errno(r, "Failed to acquire temporary directory: %m");
×
139

140
        m->source = path_join(m->rm_rf_tmpdir, "src");
10✔
141
        if (!m->source)
10✔
142
                return log_oom();
×
143

144
        if (mkdir(m->source, 0755) < 0)
10✔
145
                return log_error_errno(errno, "Failed to create %s: %m", m->source);
×
146

147
        return 0;
148
}
149

150
int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n) {
421✔
151
        int r;
421✔
152

153
        /* Prepare all custom mounts. This will make sure we know all temporary directories. This is called in the
154
         * parent process, so that we know the temporary directories to remove on exit before we fork off the
155
         * children. */
156

157
        assert(l || n == 0);
421✔
158

159
        /* Order the custom mounts, and make sure we have a working directory */
160
        typesafe_qsort(l, n, custom_mount_compare);
421✔
161

162
        FOREACH_ARRAY(m, l, n) {
873✔
163
                /* /proc we mount in the inner child, i.e. when we acquired CLONE_NEWPID. All other mounts we mount
164
                 * already in the outer child, so that the mounts are already established before CLONE_NEWPID and in
165
                 * particular CLONE_NEWUSER. This also means any custom mounts below /proc also need to be mounted in
166
                 * the inner child, not the outer one. Determine this here. */
167
                m->in_userns = path_startswith(m->destination, "/proc");
452✔
168

169
                if (m->type == CUSTOM_MOUNT_BIND) {
452✔
170
                        if (m->source) {
402✔
171
                                char *s;
401✔
172

173
                                s = resolve_source_path(dest, m->source);
401✔
174
                                if (!s)
401✔
175
                                        return log_oom();
×
176

177
                                free_and_replace(m->source, s);
401✔
178
                        } else {
179
                                /* No source specified? In that case, use a throw-away temporary directory in /var/tmp */
180

181
                                r = allocate_temporary_source(m);
1✔
182
                                if (r < 0)
1✔
183
                                        return r;
184
                        }
185
                }
186

187
                if (m->type == CUSTOM_MOUNT_OVERLAY) {
452✔
188
                        STRV_FOREACH(j, m->lower) {
26✔
189
                                char *s;
15✔
190

191
                                s = resolve_source_path(dest, *j);
15✔
192
                                if (!s)
15✔
193
                                        return log_oom();
×
194

195
                                free_and_replace(*j, s);
15✔
196
                        }
197

198
                        if (m->source) {
11✔
199
                                char *s;
2✔
200

201
                                s = resolve_source_path(dest, m->source);
2✔
202
                                if (!s)
2✔
203
                                        return log_oom();
×
204

205
                                free_and_replace(m->source, s);
2✔
206
                        } else {
207
                                r = allocate_temporary_source(m);
9✔
208
                                if (r < 0)
9✔
209
                                        return r;
210
                        }
211

212
                        if (m->work_dir) {
11✔
213
                                char *s;
×
214

215
                                s = resolve_source_path(dest, m->work_dir);
×
216
                                if (!s)
×
217
                                        return log_oom();
×
218

219
                                free_and_replace(m->work_dir, s);
×
220
                        } else {
221
                                r = tempfn_random(m->source, NULL, &m->work_dir);
11✔
222
                                if (r < 0)
11✔
223
                                        return log_error_errno(r, "Failed to acquire working directory: %m");
×
224
                        }
225

226
                        (void) mkdir_label(m->work_dir, 0700);
11✔
227
                }
228
        }
229

230
        return 0;
231
}
232

233
int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only) {
511✔
234
        _cleanup_free_ char *source = NULL, *destination = NULL, *opts = NULL, *p = NULL;
511✔
235
        CustomMount *m;
511✔
236
        int r;
511✔
237

238
        assert(l);
511✔
239
        assert(n);
511✔
240

241
        r = extract_many_words(&s, ":", EXTRACT_DONT_COALESCE_SEPARATORS, &source, &destination);
511✔
242
        if (r < 0)
511✔
243
                return r;
244
        if (r == 0)
511✔
245
                return -EINVAL;
246
        if (r == 1) {
511✔
247
                destination = strdup(source[0] == '+' ? source+1 : source);
477✔
248
                if (!destination)
477✔
249
                        return -ENOMEM;
250
        }
251
        if (r == 2 && !isempty(s)) {
511✔
252
                opts = strdup(s);
12✔
253
                if (!opts)
12✔
254
                        return -ENOMEM;
255
        }
256

257
        r = source_path_parse_nullable(source, &p);
511✔
258
        if (r < 0)
511✔
259
                return r;
260

261
        if (!path_is_absolute(destination))
1,018✔
262
                return -EINVAL;
263

264
        m = custom_mount_add(l, n, CUSTOM_MOUNT_BIND);
507✔
265
        if (!m)
507✔
266
                return -ENOMEM;
267

268
        m->source = TAKE_PTR(p);
507✔
269
        m->destination = TAKE_PTR(destination);
507✔
270
        m->read_only = read_only;
507✔
271
        m->options = TAKE_PTR(opts);
507✔
272

273
        return 0;
507✔
274
}
275

276
int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s) {
17✔
277
        _cleanup_free_ char *path = NULL, *opts = NULL;
17✔
278
        const char *p = ASSERT_PTR(s);
17✔
279
        CustomMount *m;
17✔
280
        int r;
17✔
281

282
        assert(l);
17✔
283
        assert(n);
17✔
284

285
        r = extract_first_word(&p, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
17✔
286
        if (r < 0)
17✔
287
                return r;
288
        if (r == 0)
17✔
289
                return -EINVAL;
290

291
        if (isempty(p))
17✔
292
                opts = strdup("mode=0755");
16✔
293
        else
294
                opts = strdup(p);
1✔
295
        if (!opts)
17✔
296
                return -ENOMEM;
297

298
        if (!path_is_absolute(path))
32✔
299
                return -EINVAL;
300

301
        m = custom_mount_add(l, n, CUSTOM_MOUNT_TMPFS);
15✔
302
        if (!m)
15✔
303
                return -ENOMEM;
304

305
        m->destination = TAKE_PTR(path);
15✔
306
        m->options = TAKE_PTR(opts);
15✔
307

308
        return 0;
15✔
309
}
310

311
int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only) {
15✔
312
        _cleanup_free_ char *upper = NULL, *destination = NULL;
15✔
313
        _cleanup_strv_free_ char **lower = NULL;
15✔
314
        CustomMount *m;
15✔
315
        int r, k;
15✔
316

317
        k = strv_split_full(&lower, s, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
15✔
318
        if (k < 0)
15✔
319
                return k;
320
        if (k < 2)
15✔
321
                return -EADDRNOTAVAIL;
322
        if (k == 2) {
11✔
323
                _cleanup_free_ char *p = NULL;
×
324

325
                /* If two parameters are specified, the first one is the lower, the second one the upper directory. And
326
                 * we'll also define the destination mount point the same as the upper. */
327

328
                r = source_path_parse(lower[0], &p);
×
329
                if (r < 0)
×
330
                        return r;
331

332
                free_and_replace(lower[0], p);
×
333

334
                r = source_path_parse(lower[1], &p);
×
335
                if (r < 0)
×
336
                        return r;
337

338
                free_and_replace(lower[1], p);
×
339

340
                upper = TAKE_PTR(lower[1]);
×
341

342
                destination = strdup(upper[0] == '+' ? upper+1 : upper); /* take the destination without "+" prefix */
×
343
                if (!destination)
×
344
                        return -ENOMEM;
345
        } else {
346
                _cleanup_free_ char *p = NULL;
11✔
347

348
                /* If more than two parameters are specified, the last one is the destination, the second to last one
349
                 * the "upper", and all before that the "lower" directories. */
350

351
                destination = lower[k - 1];
11✔
352
                upper = TAKE_PTR(lower[k - 2]);
11✔
353

354
                STRV_FOREACH(i, lower) {
26✔
355
                        r = source_path_parse(*i, &p);
15✔
356
                        if (r < 0)
15✔
357
                                return r;
358

359
                        free_and_replace(*i, p);
15✔
360
                }
361

362
                /* If the upper directory is unspecified, then let's create it automatically as a throw-away directory
363
                 * in /var/tmp */
364
                r = source_path_parse_nullable(upper, &p);
11✔
365
                if (r < 0)
11✔
366
                        return r;
367

368
                free_and_replace(upper, p);
11✔
369

370
                if (!path_is_absolute(destination))
11✔
371
                        return -EINVAL;
372
        }
373

374
        m = custom_mount_add(l, n, CUSTOM_MOUNT_OVERLAY);
11✔
375
        if (!m)
11✔
376
                return -ENOMEM;
377

378
        m->destination = TAKE_PTR(destination);
11✔
379
        m->source = TAKE_PTR(upper);
11✔
380
        m->lower = TAKE_PTR(lower);
11✔
381
        m->read_only = read_only;
11✔
382

383
        return 0;
11✔
384
}
385

386
int inaccessible_mount_parse(CustomMount **l, size_t *n, const char *s) {
22✔
387
        _cleanup_free_ char *path = NULL;
22✔
388
        CustomMount *m;
22✔
389

390
        assert(l);
22✔
391
        assert(n);
22✔
392
        assert(s);
22✔
393

394
        if (!path_is_absolute(s))
22✔
395
                return -EINVAL;
396

397
        path = strdup(s);
20✔
398
        if (!path)
20✔
399
                return -ENOMEM;
400

401
        m = custom_mount_add(l, n, CUSTOM_MOUNT_INACCESSIBLE);
20✔
402
        if (!m)
20✔
403
                return -ENOMEM;
404

405
        m->destination = TAKE_PTR(path);
20✔
406
        return 0;
20✔
407
}
408

409
int tmpfs_patch_options(
1,116✔
410
                const char *options,
411
                uid_t uid_shift,
412
                const char *selinux_apifs_context,
413
                char **ret) {
414

415
        _cleanup_free_ char *buf = NULL;
1,116✔
416

417
        assert(ret);
1,116✔
418

419
        if (options) {
1,116✔
420
                buf = strdup(options);
1,116✔
421
                if (!buf)
1,116✔
422
                        return -ENOMEM;
423
        }
424

425
        if (uid_shift != UID_INVALID)
1,116✔
426
                if (strextendf_with_separator(&buf, ",", "uid=" UID_FMT ",gid=" UID_FMT, uid_shift, uid_shift) < 0)
1,104✔
427
                        return -ENOMEM;
428

429
#if HAVE_SELINUX
430
        if (selinux_apifs_context)
431
                if (strextendf_with_separator(&buf, ",", "context=\"%s\"", selinux_apifs_context) < 0)
432
                        return -ENOMEM;
433
#endif
434

435
        *ret = TAKE_PTR(buf);
1,116✔
436
        return !!*ret;
1,116✔
437
}
438

439
int mount_sysfs(const char *dest, MountSettingsMask mount_settings) {
121✔
440
        _cleanup_free_ char *top = NULL, *full = NULL;;
121✔
441
        unsigned long extra_flags = 0;
121✔
442
        int r;
121✔
443

444
        top = path_join(dest, "/sys");
121✔
445
        if (!top)
121✔
446
                return log_oom();
×
447

448
        r = path_is_mount_point(top);
121✔
449
        if (r < 0)
121✔
450
                return log_error_errno(r, "Failed to determine if '%s' is a mountpoint: %m", top);
×
451
        if (r == 0) {
121✔
452
                /* If this is not a mount point yet, then mount a tmpfs there */
453
                r = mount_nofollow_verbose(LOG_ERR, "tmpfs", top, "tmpfs", MS_NOSUID|MS_NOEXEC|MS_NODEV, "mode=0555" TMPFS_LIMITS_SYS);
1✔
454
                if (r < 0)
1✔
455
                        return r;
456
        } else {
457
                r = path_is_fs_type(top, SYSFS_MAGIC);
120✔
458
                if (r < 0)
120✔
459
                        return log_error_errno(r, "Failed to determine filesystem type of %s: %m", top);
×
460

461
                /* /sys/ might already be mounted as sysfs by the outer child in the !netns case. In this case, it's
462
                 * all good. Don't touch it because we don't have the right to do so, see
463
                 * https://github.com/systemd/systemd/issues/1555.
464
                 */
465
                if (r > 0)
120✔
466
                        return 0;
467
        }
468

469
        full = path_join(top, "/full");
51✔
470
        if (!full)
51✔
471
                return log_oom();
×
472

473
        if (mkdir(full, 0755) < 0 && errno != EEXIST)
51✔
474
                return log_error_errno(errno, "Failed to create directory '%s': %m", full);
×
475

476
        if (FLAGS_SET(mount_settings, MOUNT_APPLY_APIVFS_RO))
51✔
477
                extra_flags |= MS_RDONLY;
47✔
478

479
        r = mount_nofollow_verbose(LOG_ERR, "sysfs", full, "sysfs",
51✔
480
                                   MS_NOSUID|MS_NOEXEC|MS_NODEV|extra_flags, NULL);
481
        if (r < 0)
51✔
482
                return r;
483

484
        FOREACH_STRING(x, "block", "bus", "class", "dev", "devices", "kernel") {
357✔
485
                _cleanup_free_ char *from = NULL, *to = NULL;
306✔
486

487
                from = path_join(full, x);
306✔
488
                if (!from)
306✔
489
                        return log_oom();
×
490

491
                to = path_join(top, x);
306✔
492
                if (!to)
306✔
493
                        return log_oom();
×
494

495
                (void) mkdir(to, 0755);
306✔
496

497
                r = mount_nofollow_verbose(LOG_ERR, from, to, NULL, MS_BIND, NULL);
306✔
498
                if (r < 0)
306✔
499
                        return r;
500

501
                r = mount_nofollow_verbose(LOG_ERR, NULL, to, NULL,
306✔
502
                                           MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT|extra_flags, NULL);
503
                if (r < 0)
306✔
504
                        return r;
505
        }
506

507
        r = umount_verbose(LOG_ERR, full, UMOUNT_NOFOLLOW);
51✔
508
        if (r < 0)
51✔
509
                return r;
510

511
        if (rmdir(full) < 0)
51✔
512
                return log_error_errno(errno, "Failed to remove %s: %m", full);
×
513

514
        /* Create mountpoints. Otherwise we are not allowed since we remount /sys/ read-only. */
515
        FOREACH_STRING(p, "/fs/cgroup", "/fs/bpf") {
153✔
516
                _cleanup_free_ char *x = path_join(top, p);
204✔
517
                if (!x)
102✔
518
                        return log_oom();
×
519

520
                (void) mkdir_p(x, 0755);
102✔
521
        }
522

523
        return mount_nofollow_verbose(LOG_ERR, NULL, top, NULL,
121✔
524
                                      MS_BIND|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT|extra_flags, NULL);
525
}
526

527
#define PROC_DEFAULT_MOUNT_FLAGS (MS_NOSUID|MS_NOEXEC|MS_NODEV)
528
#define SYS_DEFAULT_MOUNT_FLAGS  (MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV)
529

530
int mount_all(const char *dest,
370✔
531
              MountSettingsMask mount_settings,
532
              uid_t uid_shift,
533
              const char *selinux_apifs_context) {
534

535
#define PROC_INACCESSIBLE_REG(path)                                     \
536
        { "/run/systemd/inaccessible/reg", (path), NULL, NULL, MS_BIND, \
537
          MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ... */ \
538
        { NULL, (path), NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT, \
539
          MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO } /* Then, make it r/o */
540

541
#define PROC_READ_ONLY(path)                                            \
542
        { (path), (path), NULL, NULL, MS_BIND,                          \
543
          MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO }, /* Bind mount first ... */ \
544
        { NULL,   (path), NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT, \
545
          MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO } /* Then, make it r/o */
546

547
        typedef struct MountPoint {
370✔
548
                const char *what;
549
                const char *where;
550
                const char *type;
551
                const char *options;
552
                unsigned long flags;
553
                MountSettingsMask mount_settings;
554
        } MountPoint;
555

556
        static const MountPoint mount_table[] = {
370✔
557
                /* First we list inner child mounts (i.e. mounts applied *after* entering user namespacing when we are privileged) */
558
                { "proc",            "/proc",           "proc",  NULL,        PROC_DEFAULT_MOUNT_FLAGS,
559
                  MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_MKDIR|MOUNT_FOLLOW_SYMLINKS }, /* we follow symlinks here since not following them requires /proc/ already being mounted, which we don't have here. */
560

561
                { "/proc/sys",       "/proc/sys",       NULL,    NULL,        MS_BIND,
562
                  MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO },                          /* Bind mount first ... */
563

564
                { "/proc/sys/net",   "/proc/sys/net",   NULL,    NULL,        MS_BIND,
565
                  MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO|MOUNT_APPLY_APIVFS_NETNS }, /* (except for this) */
566

567
                { NULL,              "/proc/sys",       NULL,    NULL,        MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
568
                  MOUNT_FATAL|MOUNT_IN_USERNS|MOUNT_APPLY_APIVFS_RO },                          /* ... then, make it r/o */
569

570
                /* Make these files inaccessible to container payloads: they potentially leak information about kernel
571
                 * internals or the host's execution environment to the container */
572
                PROC_INACCESSIBLE_REG("/proc/kallsyms"),
573
                PROC_INACCESSIBLE_REG("/proc/kcore"),
574
                PROC_INACCESSIBLE_REG("/proc/keys"),
575
                PROC_INACCESSIBLE_REG("/proc/sysrq-trigger"),
576
                PROC_INACCESSIBLE_REG("/proc/timer_list"),
577

578
                /* Make these directories read-only to container payloads: they show hardware information, and in some
579
                 * cases contain tunables the container really shouldn't have access to. */
580
                PROC_READ_ONLY("/proc/acpi"),
581
                PROC_READ_ONLY("/proc/apm"),
582
                PROC_READ_ONLY("/proc/asound"),
583
                PROC_READ_ONLY("/proc/bus"),
584
                PROC_READ_ONLY("/proc/fs"),
585
                PROC_READ_ONLY("/proc/irq"),
586
                PROC_READ_ONLY("/proc/scsi"),
587

588
                { "mqueue",                 "/dev/mqueue",                  "mqueue", NULL,                            MS_NOSUID|MS_NOEXEC|MS_NODEV,
589
                  MOUNT_IN_USERNS|MOUNT_MKDIR },
590

591
                /* Then we list outer child mounts (i.e. mounts applied *before* entering user namespacing when we are privileged) */
592
                { "tmpfs",                  "/tmp",                         "tmpfs", "mode=01777" NESTED_TMPFS_LIMITS, MS_NOSUID|MS_NODEV|MS_STRICTATIME,
593
                  MOUNT_FATAL|MOUNT_APPLY_TMPFS_TMP|MOUNT_MKDIR|MOUNT_USRQUOTA_GRACEFUL },
594
                { "tmpfs",                  "/sys",                         "tmpfs", "mode=0555" TMPFS_LIMITS_SYS,     MS_NOSUID|MS_NOEXEC|MS_NODEV,
595
                  MOUNT_FATAL|MOUNT_APPLY_APIVFS_NETNS|MOUNT_MKDIR|MOUNT_UNMANAGED },
596
                { "sysfs",                  "/sys",                         "sysfs", NULL,                             SYS_DEFAULT_MOUNT_FLAGS,
597
                  MOUNT_FATAL|MOUNT_APPLY_APIVFS_RO|MOUNT_MKDIR|MOUNT_UNMANAGED },    /* skipped if above was mounted */
598
                { "sysfs",                  "/sys",                         "sysfs", NULL,                             MS_NOSUID|MS_NOEXEC|MS_NODEV,
599
                  MOUNT_FATAL|MOUNT_MKDIR|MOUNT_UNMANAGED },                          /* skipped if above was mounted */
600
                { "tmpfs",                  "/dev",                         "tmpfs", "mode=0755" TMPFS_LIMITS_PRIVATE_DEV, MS_NOSUID|MS_STRICTATIME,
601
                  MOUNT_FATAL|MOUNT_MKDIR },
602
                { "tmpfs",                  "/dev/shm",                     "tmpfs", "mode=01777" NESTED_TMPFS_LIMITS, MS_NOSUID|MS_NODEV|MS_STRICTATIME,
603
                  MOUNT_FATAL|MOUNT_MKDIR|MOUNT_USRQUOTA_GRACEFUL },
604
                { "tmpfs",                  "/run",                         "tmpfs", "mode=0755" TMPFS_LIMITS_RUN,     MS_NOSUID|MS_NODEV|MS_STRICTATIME,
605
                  MOUNT_FATAL|MOUNT_MKDIR },
606
                { "/run/host",              "/run/host",                    NULL,    NULL,                             MS_BIND,
607
                  MOUNT_FATAL|MOUNT_MKDIR|MOUNT_PREFIX_ROOT }, /* Prepare this so that we can make it read-only when we are done */
608
                { "/etc/os-release",        "/run/host/os-release",         NULL,    NULL,                             MS_BIND,
609
                  MOUNT_TOUCH }, /* As per kernel interface requirements, bind mount first (creating mount points) and make read-only later */
610
                { "/usr/lib/os-release",    "/run/host/os-release",         NULL,    NULL,                             MS_BIND,
611
                  MOUNT_FATAL }, /* If /etc/os-release doesn't exist use the version in /usr/lib as fallback */
612
                { NULL,                     "/run/host/os-release",         NULL,    NULL,                             MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
613
                  MOUNT_FATAL },
614
                { NULL,                     "/run/host/os-release",         NULL,    NULL,                             MS_PRIVATE,
615
                  MOUNT_FATAL },  /* Turn off propagation (we only want that for the mount propagation tunnel dir) */
616
                { NULL,                     "/run/host",                    NULL,    NULL,                             MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
617
                  MOUNT_FATAL|MOUNT_IN_USERNS },
618
#if HAVE_SELINUX
619
                { "/sys/fs/selinux",        "/sys/fs/selinux",              NULL,    NULL,                             MS_BIND,
620
                  MOUNT_MKDIR|MOUNT_PRIVILEGED },  /* Bind mount first (mkdir/chown the mount point in case /sys/ is mounted as minimal skeleton tmpfs) */
621
                { NULL,                     "/sys/fs/selinux",              NULL,    NULL,                             MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
622
                  MOUNT_UNMANAGED|MOUNT_PRIVILEGED },  /* Then, make it r/o (don't mkdir/chown the mount point here, the previous entry already did that) */
623
                { NULL,                     "/sys/fs/selinux",              NULL,    NULL,                             MS_PRIVATE,
624
                  MOUNT_UNMANAGED|MOUNT_PRIVILEGED },  /* Turn off propagation (we only want that for the mount propagation tunnel dir) */
625
#endif
626
        };
627

628
        bool use_userns = FLAGS_SET(mount_settings, MOUNT_USE_USERNS);
370✔
629
        bool netns = FLAGS_SET(mount_settings, MOUNT_APPLY_APIVFS_NETNS);
370✔
630
        bool ro = FLAGS_SET(mount_settings, MOUNT_APPLY_APIVFS_RO);
370✔
631
        bool in_userns = FLAGS_SET(mount_settings, MOUNT_IN_USERNS);
370✔
632
        bool tmpfs_tmp = FLAGS_SET(mount_settings, MOUNT_APPLY_TMPFS_TMP);
370✔
633
        bool unmanaged = FLAGS_SET(mount_settings, MOUNT_UNMANAGED);
370✔
634
        bool privileged = FLAGS_SET(mount_settings, MOUNT_PRIVILEGED);
370✔
635
        int r;
370✔
636

637
        FOREACH_ELEMENT(m, mount_table) {
15,910✔
638
                _cleanup_free_ char *where = NULL, *options = NULL, *prefixed = NULL;
15,540✔
639
                bool fatal = FLAGS_SET(m->mount_settings, MOUNT_FATAL);
15,540✔
640
                const char *o;
15,540✔
641

642
                /* If we are in managed user namespace mode but the entry is marked for mount outside of
643
                 * managed user namespace mode, and to be mounted outside the user namespace, then skip it */
644
                if (!unmanaged && FLAGS_SET(m->mount_settings, MOUNT_UNMANAGED) && !FLAGS_SET(m->mount_settings, MOUNT_IN_USERNS))
15,540✔
645
                        continue;
30✔
646

647
                if (in_userns != FLAGS_SET(m->mount_settings, MOUNT_IN_USERNS))
15,510✔
648
                        continue;
8,919✔
649

650
                if (!netns && FLAGS_SET(m->mount_settings, MOUNT_APPLY_APIVFS_NETNS))
6,591✔
651
                        continue;
210✔
652

653
                if (!ro && FLAGS_SET(m->mount_settings, MOUNT_APPLY_APIVFS_RO))
6,381✔
654
                        continue;
228✔
655

656
                if (!tmpfs_tmp && FLAGS_SET(m->mount_settings, MOUNT_APPLY_TMPFS_TMP))
6,153✔
657
                        continue;
×
658

659
                if (!privileged && FLAGS_SET(m->mount_settings, MOUNT_PRIVILEGED))
6,153✔
660
                        continue;
×
661

662
                r = chase(m->where, dest, CHASE_NONEXISTENT|CHASE_PREFIX_ROOT, &where, NULL);
6,153✔
663
                if (r < 0)
6,153✔
664
                        return log_error_errno(r, "Failed to resolve %s%s: %m", strempty(dest), m->where);
×
665

666
                /* Skip this entry if it is not a remount. */
667
                if (m->what) {
6,153✔
668
                        r = path_is_mount_point(where);
4,065✔
669
                        if (r < 0 && r != -ENOENT)
4,065✔
670
                                return log_error_errno(r, "Failed to detect whether %s is a mount point: %m", where);
×
671
                        if (r > 0)
4,065✔
672
                                continue;
574✔
673
                }
674

675
                if ((m->mount_settings & (MOUNT_MKDIR|MOUNT_TOUCH)) != 0) {
5,579✔
676
                        uid_t u = (use_userns && !in_userns) ? uid_shift : UID_INVALID;
1,975✔
677

678
                        if (FLAGS_SET(m->mount_settings, MOUNT_TOUCH))
1,975✔
679
                                r = mkdir_parents_safe(dest, where, 0755, u, u, 0);
249✔
680
                        else
681
                                r = mkdir_p_safe(dest, where, 0755, u, u, 0);
1,726✔
682
                        if (r < 0 && r != -EEXIST) {
1,975✔
683
                                if (fatal && r != -EROFS)
×
684
                                        return log_error_errno(r, "Failed to create directory %s: %m", where);
×
685

686
                                log_debug_errno(r, "Failed to create directory %s: %m", where);
×
687

688
                                /* If mkdir() or chown() failed due to the root directory being read only,
689
                                 * attempt to mount this fs anyway and let mount_verbose log any errors */
690
                                if (r != -EROFS)
×
691
                                        continue;
×
692
                        }
693
                }
694

695
                if (FLAGS_SET(m->mount_settings, MOUNT_TOUCH)) {
5,579✔
696
                        r = touch(where);
249✔
697
                        if (r < 0 && r != -EEXIST) {
249✔
698
                                if (fatal && r != -EROFS)
×
699
                                        return log_error_errno(r, "Failed to create file %s: %m", where);
×
700

701
                                log_debug_errno(r, "Failed to create file %s: %m", where);
×
702
                                if (r != -EROFS)
×
703
                                        continue;
×
704
                        }
705
                }
706

707
                o = m->options;
5,579✔
708
                if (streq_ptr(m->type, "tmpfs")) {
5,579✔
709
                        r = tmpfs_patch_options(o, in_userns ? 0 : uid_shift, selinux_apifs_context, &options);
2,192✔
710
                        if (r < 0)
1,096✔
711
                                return log_oom();
×
712
                        if (r > 0)
1,096✔
713
                                o = options;
1,096✔
714
                }
715

716
                if (FLAGS_SET(m->mount_settings, MOUNT_USRQUOTA_GRACEFUL)) {
5,579✔
717
                        r = mount_option_supported(m->type, /* key= */ "usrquota", /* value= */ NULL);
498✔
718
                        if (r < 0)
498✔
719
                                log_warning_errno(r, "Failed to determine if '%s' supports 'usrquota', assuming it doesn't: %m", m->type);
×
720
                        else if (r == 0)
498✔
721
                                log_debug("Kernel doesn't support 'usrquota' on '%s', not including in mount options for '%s'.", m->type, m->where);
18✔
722
                        else {
723
                                _cleanup_free_ char *joined = NULL;
×
724

725
                                if (!strextend_with_separator(&joined, ",", o ?: POINTER_MAX, "usrquota"))
480✔
726
                                        return log_oom();
×
727

728
                                free_and_replace(options, joined);
480✔
729
                                o = options;
480✔
730
                        }
731
                }
732

733
                if (FLAGS_SET(m->mount_settings, MOUNT_PREFIX_ROOT)) {
5,579✔
734
                        /* Optionally prefix the mount source with the root dir. This is useful in bind
735
                         * mounts to be created within the container image before we transition into it. Note
736
                         * that MOUNT_IN_USERNS is run after we transitioned hence prefixing is not necessary
737
                         * for those. */
738
                        r = chase(m->what, dest, CHASE_PREFIX_ROOT, &prefixed, NULL);
249✔
739
                        if (r < 0)
249✔
740
                                return log_error_errno(r, "Failed to resolve %s%s: %m", strempty(dest), m->what);
×
741
                }
742

743
                r = mount_verbose_full(
8,661✔
744
                                fatal ? LOG_ERR : LOG_DEBUG,
745
                                prefixed ?: m->what,
5,579✔
746
                                where,
747
                                m->type,
5,579✔
748
                                m->flags,
5,579✔
749
                                o,
750
                                FLAGS_SET(m->mount_settings, MOUNT_FOLLOW_SYMLINKS));
5,579✔
751
                if (r < 0 && fatal)
5,579✔
752
                        return r;
753
        }
754

755
        return 0;
756
}
757

758
static int parse_mount_bind_options(const char *options, unsigned long *open_tree_flags, char **mount_opts, RemountIdmapping *idmapping) {
42✔
759
        unsigned long flags = *open_tree_flags;
42✔
760
        char *opts = NULL;
42✔
761
        RemountIdmapping new_idmapping = *idmapping;
42✔
762
        int r;
42✔
763

764
        assert(options);
42✔
765

766
        for (;;) {
134✔
767
                _cleanup_free_ char *word = NULL;
46✔
768

769
                r = extract_first_word(&options, &word, ",", 0);
88✔
770
                if (r < 0)
88✔
771
                        return log_error_errno(r, "Failed to extract mount option: %m");
×
772
                if (r == 0)
88✔
773
                        break;
774

775
                if (streq(word, "rbind"))
46✔
776
                        flags |= AT_RECURSIVE;
×
777
                else if (streq(word, "norbind"))
46✔
778
                        flags &= ~AT_RECURSIVE;
4✔
779
                else if (streq(word, "idmap"))
42✔
780
                        new_idmapping = REMOUNT_IDMAPPING_HOST_ROOT;
781
                else if (streq(word, "noidmap"))
42✔
782
                        new_idmapping = REMOUNT_IDMAPPING_NONE;
783
                else if (streq(word, "rootidmap"))
38✔
784
                        new_idmapping = REMOUNT_IDMAPPING_HOST_OWNER;
785
                else if (streq(word, "owneridmap"))
32✔
786
                        new_idmapping = REMOUNT_IDMAPPING_HOST_OWNER_TO_TARGET_OWNER;
787
                else
788
                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
789
                                               "Invalid bind mount option: %s", word);
790
        }
791

792
        *open_tree_flags = flags;
42✔
793
        *idmapping = new_idmapping;
42✔
794
        /* in the future mount_opts will hold string options for mount(2) */
795
        *mount_opts = opts;
42✔
796

797
        return 0;
42✔
798
}
799

800
static int mount_bind(const char *dest, CustomMount *m, uid_t uid_shift, uid_t uid_range) {
290✔
801
        _cleanup_free_ char *mount_opts = NULL, *where = NULL;
290✔
802
        unsigned long open_tree_flags = OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_RECURSIVE;
290✔
803
        struct stat source_st, dest_st;
290✔
804
        uid_t dest_uid = UID_INVALID;
290✔
805
        int r;
290✔
806
        RemountIdmapping idmapping = REMOUNT_IDMAPPING_NONE;
290✔
807

808
        assert(dest);
290✔
809
        assert(m);
290✔
810

811
        if (m->options) {
290✔
812
                r = parse_mount_bind_options(m->options, &open_tree_flags, &mount_opts, &idmapping);
42✔
813
                if (r < 0)
42✔
814
                        return r;
815
        }
816

817
        /* If this is a bind mount from a temporary sources change ownership of the source to the container's
818
         * root UID. Otherwise it would always show up as "nobody" if user namespacing is used. */
819
        if (m->rm_rf_tmpdir && chown(m->source, uid_shift, uid_shift) < 0)
290✔
820
                return log_error_errno(errno, "Failed to chown %s: %m", m->source);
×
821

822
        /* UID/GIDs of idmapped mounts are always resolved in the caller's user namespace. In other
823
         * words, they're not nested. If we're doing an idmapped mount from a bind mount that's
824
         * already idmapped itself, the old idmap is replaced with the new one. This means that the
825
         * source uid which we put in the idmap userns has to be the uid of mount source in the
826
         * caller's userns *without* any mount idmapping in place. To get that uid, we clone the
827
         * mount source tree and clear any existing idmapping and temporarily mount that tree over
828
         * the mount source before we stat the mount source to figure out the source uid. */
829
        _cleanup_close_ int fd_clone =
290✔
830
                idmapping == REMOUNT_IDMAPPING_NONE ?
290✔
831
                RET_NERRNO(open_tree(
252✔
832
                        AT_FDCWD,
833
                        m->source,
252✔
834
                        open_tree_flags)) :
290✔
835
                open_tree_try_drop_idmap(
38✔
836
                        AT_FDCWD,
837
                        m->source,
38✔
838
                        open_tree_flags);
839
        if (fd_clone < 0)
38✔
UNCOV
840
                return log_error_errno(errno, "Failed to clone %s: %m", m->source);
×
841

842
        if (fstat(fd_clone, &source_st) < 0)
290✔
UNCOV
843
                return log_error_errno(errno, "Failed to stat %s: %m", m->source);
×
844

845
        r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
290✔
846
        if (r < 0)
290✔
UNCOV
847
                return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
×
848
        if (r > 0) { /* Path exists already? */
290✔
849

850
                if (stat(where, &dest_st) < 0)
170✔
UNCOV
851
                        return log_error_errno(errno, "Failed to stat %s: %m", where);
×
852

853
                dest_uid = uid_is_valid(m->destination_uid) ? uid_shift + m->destination_uid : dest_st.st_uid;
170✔
854

855
                if (S_ISDIR(source_st.st_mode) && !S_ISDIR(dest_st.st_mode))
170✔
UNCOV
856
                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
857
                                               "Cannot bind mount directory %s on file %s.",
858
                                               m->source, where);
859

860
                if (!S_ISDIR(source_st.st_mode) && S_ISDIR(dest_st.st_mode))
170✔
UNCOV
861
                        return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
862
                                               "Cannot bind mount file %s on directory %s.",
863
                                               m->source, where);
864

865
        } else { /* Path doesn't exist yet? */
866
                r = mkdir_parents_safe_label(dest, where, 0755, uid_shift, uid_shift, MKDIR_IGNORE_EXISTING);
120✔
867
                if (r < 0)
120✔
UNCOV
868
                        return log_error_errno(r, "Failed to make parents of %s: %m", where);
×
869

870
                /* Create the mount point. Any non-directory file can be
871
                * mounted on any non-directory file (regular, fifo, socket,
872
                * char, block).
873
                */
874
                if (S_ISDIR(source_st.st_mode))
120✔
875
                        r = mkdir_label(where, 0755);
118✔
876
                else
877
                        r = touch(where);
2✔
878
                if (r < 0)
120✔
UNCOV
879
                        return log_error_errno(r, "Failed to create mount point %s: %m", where);
×
880

881
                if (chown(where, uid_shift, uid_shift) < 0)
120✔
UNCOV
882
                        return log_error_errno(errno, "Failed to chown %s: %m", where);
×
883

884
                dest_uid = uid_shift + (uid_is_valid(m->destination_uid) ? m->destination_uid : 0);
150✔
885
        }
886

887
        if (move_mount(fd_clone, "", AT_FDCWD, where, MOVE_MOUNT_F_EMPTY_PATH) < 0)
290✔
UNCOV
888
                return log_error_errno(errno, "Failed to mount %s to %s: %m", m->source, where);
×
889

890
        fd_clone = safe_close(fd_clone);
290✔
891

892
        if (m->read_only) {
290✔
893
                r = bind_remount_recursive(where, MS_RDONLY, MS_RDONLY, NULL);
2✔
894
                if (r < 0)
2✔
UNCOV
895
                        return log_error_errno(r, "Read-only bind mount failed: %m");
×
896
        }
897

898
        if (idmapping != REMOUNT_IDMAPPING_NONE) {
290✔
899
                r = remount_idmap(STRV_MAKE(where), uid_shift, uid_range, source_st.st_uid, dest_uid, idmapping);
38✔
900
                if (r < 0)
38✔
UNCOV
901
                        return log_error_errno(r, "Failed to map ids for bind mount %s: %m", where);
×
902
        }
903

904
        return 0;
905
}
906

907
static int mount_tmpfs(const char *dest, CustomMount *m, uid_t uid_shift, const char *selinux_apifs_context) {
4✔
908
        const char *options;
4✔
909
        _cleanup_free_ char *buf = NULL, *where = NULL;
4✔
910
        int r;
4✔
911

912
        assert(dest);
4✔
913
        assert(m);
4✔
914

915
        r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
4✔
916
        if (r < 0)
4✔
UNCOV
917
                return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
×
918
        if (r == 0) { /* Doesn't exist yet? */
4✔
UNCOV
919
                r = mkdir_p_label(where, 0755);
×
920
                if (r < 0)
×
921
                        return log_error_errno(r, "Creating mount point for tmpfs %s failed: %m", where);
×
922
        }
923

924
        r = tmpfs_patch_options(m->options, uid_shift == 0 ? UID_INVALID : uid_shift, selinux_apifs_context, &buf);
8✔
925
        if (r < 0)
4✔
UNCOV
926
                return log_oom();
×
927
        options = r > 0 ? buf : m->options;
4✔
928

929
        return mount_nofollow_verbose(LOG_ERR, "tmpfs", where, "tmpfs", MS_NODEV|MS_STRICTATIME, options);
4✔
930
}
931

932
static char *joined_and_escaped_lower_dirs(char **lower) {
2✔
UNCOV
933
        _cleanup_strv_free_ char **sv = NULL;
×
934

935
        sv = strv_copy(lower);
2✔
936
        if (!sv)
2✔
937
                return NULL;
938

939
        strv_reverse(sv);
2✔
940

941
        if (!strv_shell_escape(sv, ",:"))
2✔
942
                return NULL;
943

944
        return strv_join(sv, ":");
2✔
945
}
946

947
static int mount_overlay(const char *dest, CustomMount *m) {
2✔
948
        _cleanup_free_ char *lower = NULL, *where = NULL, *escaped_source = NULL;
2✔
949
        const char *options;
2✔
950
        int r;
2✔
951

952
        assert(dest);
2✔
953
        assert(m);
2✔
954

955
        r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
2✔
956
        if (r < 0)
2✔
UNCOV
957
                return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
×
958
        if (r == 0) { /* Doesn't exist yet? */
2✔
UNCOV
959
                r = mkdir_label(where, 0755);
×
960
                if (r < 0)
×
961
                        return log_error_errno(r, "Creating mount point for overlay %s failed: %m", where);
×
962
        }
963

964
        (void) mkdir_p_label(m->source, 0755);
2✔
965

966
        lower = joined_and_escaped_lower_dirs(m->lower);
2✔
967
        if (!lower)
2✔
UNCOV
968
                return log_oom();
×
969

970
        escaped_source = shell_escape(m->source, ",:");
2✔
971
        if (!escaped_source)
2✔
UNCOV
972
                return log_oom();
×
973

974
        if (m->read_only)
2✔
UNCOV
975
                options = strjoina("lowerdir=", escaped_source, ":", lower);
×
976
        else {
977
                _cleanup_free_ char *escaped_work_dir = NULL;
2✔
978

979
                escaped_work_dir = shell_escape(m->work_dir, ",:");
2✔
980
                if (!escaped_work_dir)
2✔
UNCOV
981
                        return log_oom();
×
982

983
                options = strjoina("lowerdir=", lower, ",upperdir=", escaped_source, ",workdir=", escaped_work_dir);
26✔
984
        }
985

986
        return mount_nofollow_verbose(LOG_ERR, "overlay", where, "overlay", m->read_only ? MS_RDONLY : 0, options);
2✔
987
}
988

989
static int mount_inaccessible(const char *dest, CustomMount *m) {
4✔
990
        _cleanup_free_ char *where = NULL, *source = NULL;
4✔
991
        struct stat st;
4✔
992
        int r;
4✔
993

994
        assert(dest);
4✔
995
        assert(m);
4✔
996

997
        r = chase_and_stat(m->destination, dest, CHASE_PREFIX_ROOT, &where, &st);
4✔
998
        if (r < 0) {
4✔
UNCOV
999
                log_full_errno(m->graceful ? LOG_DEBUG : LOG_ERR, r, "Failed to resolve %s/%s: %m", dest, m->destination);
×
1000
                return m->graceful ? 0 : r;
×
1001
        }
1002

1003
        r = mode_to_inaccessible_node(NULL, st.st_mode, &source);
4✔
1004
        if (r < 0)
4✔
UNCOV
1005
                return m->graceful ? 0 : r;
×
1006

1007
        r = mount_nofollow_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, source, where, NULL, MS_BIND, NULL);
4✔
1008
        if (r < 0)
4✔
UNCOV
1009
                return m->graceful ? 0 : r;
×
1010

1011
        r = mount_nofollow_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, NULL, where, NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL);
4✔
1012
        if (r < 0) {
4✔
UNCOV
1013
                (void) umount_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, where, UMOUNT_NOFOLLOW);
×
1014
                return m->graceful ? 0 : r;
×
1015
        }
1016

1017
        return 0;
1018
}
1019

UNCOV
1020
static int mount_arbitrary(const char *dest, CustomMount *m) {
×
1021
        _cleanup_free_ char *where = NULL;
×
1022
        int r;
×
1023

UNCOV
1024
        assert(dest);
×
1025
        assert(m);
×
1026

UNCOV
1027
        r = chase(m->destination, dest, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &where, NULL);
×
1028
        if (r < 0)
×
1029
                return log_error_errno(r, "Failed to resolve %s/%s: %m", dest, m->destination);
×
1030
        if (r == 0) { /* Doesn't exist yet? */
×
1031
                r = mkdir_p_label(where, 0755);
×
1032
                if (r < 0)
×
1033
                        return log_error_errno(r, "Creating mount point for mount %s failed: %m", where);
×
1034
        }
1035

UNCOV
1036
        return mount_nofollow_verbose(LOG_ERR, m->source, where, m->type_argument, 0, m->options);
×
1037
}
1038

1039
int mount_custom(
625✔
1040
                const char *dest,
1041
                CustomMount *mounts, size_t n,
1042
                uid_t uid_shift,
1043
                uid_t uid_range,
1044
                const char *selinux_apifs_context,
1045
                MountSettingsMask mount_settings) {
1046
        int r;
625✔
1047

1048
        assert(dest);
625✔
1049

1050
        FOREACH_ARRAY(m, mounts, n) {
1,366✔
1051
                if (FLAGS_SET(mount_settings, MOUNT_IN_USERNS) != m->in_userns)
741✔
1052
                        continue;
147✔
1053

1054
                if (FLAGS_SET(mount_settings, MOUNT_ROOT_ONLY) && !path_equal(m->destination, "/"))
594✔
1055
                        continue;
294✔
1056

1057
                if (FLAGS_SET(mount_settings, MOUNT_NON_ROOT_ONLY) && path_equal(m->destination, "/"))
300✔
UNCOV
1058
                        continue;
×
1059

1060
                switch (m->type) {
300✔
1061

1062
                case CUSTOM_MOUNT_BIND:
290✔
1063
                        r = mount_bind(dest, m, uid_shift, uid_range);
290✔
1064
                        break;
290✔
1065

1066
                case CUSTOM_MOUNT_TMPFS:
4✔
1067
                        r = mount_tmpfs(dest, m, uid_shift, selinux_apifs_context);
4✔
1068
                        break;
4✔
1069

1070
                case CUSTOM_MOUNT_OVERLAY:
2✔
1071
                        r = mount_overlay(dest, m);
2✔
1072
                        break;
2✔
1073

1074
                case CUSTOM_MOUNT_INACCESSIBLE:
4✔
1075
                        r = mount_inaccessible(dest, m);
4✔
1076
                        break;
4✔
1077

UNCOV
1078
                case CUSTOM_MOUNT_ARBITRARY:
×
1079
                        r = mount_arbitrary(dest, m);
×
1080
                        break;
×
1081

UNCOV
1082
                default:
×
1083
                        assert_not_reached();
×
1084
                }
1085

1086
                if (r < 0)
300✔
1087
                        return r;
1088
        }
1089

1090
        return 0;
1091
}
1092

1093
bool has_custom_root_mount(const CustomMount *mounts, size_t n) {
484✔
1094
        FOREACH_ARRAY(m, mounts, n)
997✔
1095
                if (path_equal(m->destination, "/"))
513✔
1096
                        return true;
1097

1098
        return false;
1099
}
1100

1101
static int setup_volatile_state(const char *directory) {
4✔
1102
        int r;
4✔
1103

1104
        assert(directory);
4✔
1105

1106
        /* --volatile=state means we simply overmount /var with a tmpfs, and the rest read-only. */
1107

1108
        /* First, remount the root directory. */
1109
        r = bind_remount_recursive(directory, MS_RDONLY, MS_RDONLY, NULL);
4✔
1110
        if (r < 0)
4✔
UNCOV
1111
                return log_error_errno(r, "Failed to remount %s read-only: %m", directory);
×
1112

1113
        return 0;
1114
}
1115

1116
static int setup_volatile_state_after_remount_idmap(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
4✔
1117
        _cleanup_free_ char *buf = NULL;
8✔
1118
        int r;
4✔
1119

1120
        assert(directory);
4✔
1121

1122
        /* Then, after remount_idmap(), overmount /var/ with a tmpfs. */
1123

1124
        _cleanup_free_ char *p = path_join(directory, "/var");
8✔
1125
        if (!p)
4✔
UNCOV
1126
                return log_oom();
×
1127

1128
        r = mkdir(p, 0755);
4✔
1129
        if (r < 0 && errno != EEXIST)
4✔
UNCOV
1130
                return log_error_errno(errno, "Failed to create %s: %m", directory);
×
1131

1132
        const char *options = "mode=0755" TMPFS_LIMITS_VOLATILE_STATE;
4✔
1133
        r = tmpfs_patch_options(options, uid_shift == 0 ? UID_INVALID : uid_shift, selinux_apifs_context, &buf);
6✔
1134
        if (r < 0)
4✔
UNCOV
1135
                return log_oom();
×
1136
        if (r > 0)
4✔
1137
                options = buf;
4✔
1138

1139
        return mount_nofollow_verbose(LOG_ERR, "tmpfs", p, "tmpfs", MS_STRICTATIME, options);
4✔
1140
}
1141

1142
static int setup_volatile_yes(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
8✔
1143
        bool tmpfs_mounted = false, bind_mounted = false;
8✔
UNCOV
1144
        _cleanup_(rmdir_and_freep) char *template = NULL;
×
1145
        _cleanup_free_ char *buf = NULL, *bindir = NULL, *f = NULL, *t = NULL;
8✔
1146
        struct stat st;
8✔
1147
        int r;
8✔
1148

1149
        assert(directory);
8✔
1150

1151
        /* --volatile=yes means we mount a tmpfs to the root dir, and the original /usr to use inside it, and
1152
         * that read-only. Before we start setting this up let's validate if the image has the /usr merge
1153
         * implemented, and let's output a friendly log message if it hasn't. */
1154

1155
        bindir = path_join(directory, "/bin");
8✔
1156
        if (!bindir)
8✔
UNCOV
1157
                return log_oom();
×
1158
        if (lstat(bindir, &st) < 0) {
8✔
UNCOV
1159
                if (errno != ENOENT)
×
1160
                        return log_error_errno(errno, "Failed to stat /bin directory below image: %m");
×
1161

1162
                /* ENOENT is fine, just means the image is probably just a naked /usr and we can create the
1163
                 * rest. */
1164
        } else if (S_ISDIR(st.st_mode))
8✔
UNCOV
1165
                return log_error_errno(SYNTHETIC_ERRNO(EISDIR),
×
1166
                                       "Sorry, --volatile=yes mode is not supported with OS images that have not merged /bin/, /sbin/, /lib/, /lib64/ into /usr/. "
1167
                                       "Please work with your distribution and help them adopt the merged /usr scheme.");
1168
        else if (!S_ISLNK(st.st_mode))
8✔
UNCOV
1169
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
×
1170
                                       "Error starting image: if --volatile=yes is used /bin must be a symlink (for merged /usr support) or non-existent (in which case a symlink is created automatically).");
1171

1172
        r = mkdtemp_malloc("/tmp/nspawn-volatile-XXXXXX", &template);
8✔
1173
        if (r < 0)
8✔
UNCOV
1174
                return log_error_errno(r, "Failed to create temporary directory: %m");
×
1175

1176
        const char *options = "mode=0755" TMPFS_LIMITS_ROOTFS;
8✔
1177
        r = tmpfs_patch_options(options, uid_shift == 0 ? UID_INVALID : uid_shift, selinux_apifs_context, &buf);
12✔
1178
        if (r < 0)
8✔
UNCOV
1179
                goto fail;
×
1180
        if (r > 0)
8✔
1181
                options = buf;
8✔
1182

1183
        r = mount_nofollow_verbose(LOG_ERR, "tmpfs", template, "tmpfs", MS_STRICTATIME, options);
8✔
1184
        if (r < 0)
8✔
UNCOV
1185
                goto fail;
×
1186

1187
        tmpfs_mounted = true;
8✔
1188

1189
        f = path_join(directory, "/usr");
8✔
1190
        if (!f) {
8✔
UNCOV
1191
                r = log_oom();
×
1192
                goto fail;
×
1193
        }
1194

1195
        t = path_join(template, "/usr");
8✔
1196
        if (!t) {
8✔
UNCOV
1197
                r = log_oom();
×
1198
                goto fail;
×
1199
        }
1200

1201
        r = mkdir(t, 0755);
8✔
1202
        if (r < 0 && errno != EEXIST) {
8✔
UNCOV
1203
                r = log_error_errno(errno, "Failed to create %s: %m", t);
×
1204
                goto fail;
×
1205
        }
1206

1207
        r = mount_nofollow_verbose(LOG_ERR, f, t, NULL, MS_BIND|MS_REC, NULL);
8✔
1208
        if (r < 0)
8✔
UNCOV
1209
                goto fail;
×
1210

1211
        bind_mounted = true;
8✔
1212

1213
        r = bind_remount_recursive(t, MS_RDONLY, MS_RDONLY, NULL);
8✔
1214
        if (r < 0) {
8✔
UNCOV
1215
                log_error_errno(r, "Failed to remount %s read-only: %m", t);
×
1216
                goto fail;
×
1217
        }
1218

1219
        r = mount_nofollow_verbose(LOG_ERR, template, directory, NULL, MS_MOVE, NULL);
8✔
1220
        if (r < 0)
8✔
UNCOV
1221
                goto fail;
×
1222

1223
        (void) rmdir(template);
8✔
1224

1225
        return 0;
8✔
1226

1227
fail:
UNCOV
1228
        if (bind_mounted)
×
1229
                (void) umount_verbose(LOG_ERR, t, UMOUNT_NOFOLLOW);
×
1230

UNCOV
1231
        if (tmpfs_mounted)
×
1232
                (void) umount_verbose(LOG_ERR, template, UMOUNT_NOFOLLOW);
×
1233

1234
        return r;
1235
}
1236

1237
static int setup_volatile_overlay(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
4✔
1238
        _cleanup_free_ char *buf = NULL, *escaped_directory = NULL, *escaped_upper = NULL, *escaped_work = NULL;
4✔
1239
        _cleanup_(rmdir_and_freep) char *template = NULL;
4✔
1240
        const char *upper, *work, *options;
4✔
1241
        bool tmpfs_mounted = false;
4✔
1242
        int r;
4✔
1243

1244
        assert(directory);
4✔
1245

1246
        /* --volatile=overlay means we mount an overlayfs to the root dir. */
1247

1248
        r = mkdtemp_malloc("/tmp/nspawn-volatile-XXXXXX", &template);
4✔
1249
        if (r < 0)
4✔
UNCOV
1250
                return log_error_errno(r, "Failed to create temporary directory: %m");
×
1251

1252
        options = "mode=0755" TMPFS_LIMITS_ROOTFS;
4✔
1253
        r = tmpfs_patch_options(options, uid_shift == 0 ? UID_INVALID : uid_shift, selinux_apifs_context, &buf);
6✔
1254
        if (r < 0)
4✔
UNCOV
1255
                goto finish;
×
1256
        if (r > 0)
4✔
1257
                options = buf;
4✔
1258

1259
        r = mount_nofollow_verbose(LOG_ERR, "tmpfs", template, "tmpfs", MS_STRICTATIME, options);
4✔
1260
        if (r < 0)
4✔
UNCOV
1261
                goto finish;
×
1262

1263
        tmpfs_mounted = true;
4✔
1264

1265
        upper = strjoina(template, "/upper");
20✔
1266
        work = strjoina(template, "/work");
20✔
1267

1268
        if (mkdir(upper, 0755) < 0) {
4✔
UNCOV
1269
                r = log_error_errno(errno, "Failed to create %s: %m", upper);
×
1270
                goto finish;
×
1271
        }
1272
        if (mkdir(work, 0755) < 0) {
4✔
UNCOV
1273
                r = log_error_errno(errno, "Failed to create %s: %m", work);
×
1274
                goto finish;
×
1275
        }
1276

1277
        /* And now, let's overmount the root dir with an overlayfs that uses the root dir as lower dir. It's kinda nice
1278
         * that the kernel allows us to do that without going through some mount point rearrangements. */
1279

1280
        escaped_directory = shell_escape(directory, ",:");
4✔
1281
        escaped_upper = shell_escape(upper, ",:");
4✔
1282
        escaped_work = shell_escape(work, ",:");
4✔
1283
        if (!escaped_directory || !escaped_upper || !escaped_work) {
4✔
UNCOV
1284
                r = -ENOMEM;
×
1285
                goto finish;
×
1286
        }
1287

1288
        options = strjoina("lowerdir=", escaped_directory, ",upperdir=", escaped_upper, ",workdir=", escaped_work);
52✔
1289
        r = mount_nofollow_verbose(LOG_ERR, "overlay", directory, "overlay", 0, options);
4✔
1290

1291
finish:
UNCOV
1292
        if (tmpfs_mounted)
×
1293
                (void) umount_verbose(LOG_ERR, template, UMOUNT_NOFOLLOW);
4✔
1294

1295
        return r;
1296
}
1297

1298
int setup_volatile_mode(
251✔
1299
                const char *directory,
1300
                VolatileMode mode,
1301
                uid_t uid_shift,
1302
                const char *selinux_apifs_context) {
1303

1304
        switch (mode) {
251✔
1305

1306
        case VOLATILE_YES:
8✔
1307
                return setup_volatile_yes(directory, uid_shift, selinux_apifs_context);
8✔
1308

1309
        case VOLATILE_STATE:
4✔
1310
                return setup_volatile_state(directory);
4✔
1311

1312
        case VOLATILE_OVERLAY:
4✔
1313
                return setup_volatile_overlay(directory, uid_shift, selinux_apifs_context);
4✔
1314

1315
        default:
1316
                return 0;
1317
        }
1318
}
1319

1320
int setup_volatile_mode_after_remount_idmap(
249✔
1321
                const char *directory,
1322
                VolatileMode mode,
1323
                uid_t uid_shift,
1324
                const char *selinux_apifs_context) {
1325

1326
        switch (mode) {
249✔
1327

1328
        case VOLATILE_STATE:
4✔
1329
                return setup_volatile_state_after_remount_idmap(directory, uid_shift, selinux_apifs_context);
4✔
1330

1331
        default:
1332
                return 0;
1333
        }
1334
}
1335

1336
/* Expects *pivot_root_new and *pivot_root_old to be initialised to allocated memory or NULL. */
1337
int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s) {
2✔
1338
        _cleanup_free_ char *root_new = NULL, *root_old = NULL;
2✔
1339
        const char *p = s;
2✔
1340
        int r;
2✔
1341

1342
        assert(pivot_root_new);
2✔
1343
        assert(pivot_root_old);
2✔
1344

1345
        r = extract_first_word(&p, &root_new, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
2✔
1346
        if (r < 0)
2✔
1347
                return r;
1348
        if (r == 0)
2✔
1349
                return -EINVAL;
1350

1351
        if (isempty(p))
2✔
1352
                root_old = NULL;
1353
        else {
UNCOV
1354
                root_old = strdup(p);
×
1355
                if (!root_old)
×
1356
                        return -ENOMEM;
1357
        }
1358

1359
        if (!path_is_absolute(root_new))
2✔
1360
                return -EINVAL;
UNCOV
1361
        if (root_old && !path_is_absolute(root_old))
×
1362
                return -EINVAL;
1363

UNCOV
1364
        free_and_replace(*pivot_root_new, root_new);
×
1365
        free_and_replace(*pivot_root_old, root_old);
×
1366

UNCOV
1367
        return 0;
×
1368
}
1369

1370
int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old) {
251✔
1371
        _cleanup_free_ char *directory_pivot_root_new = NULL;
502✔
1372
        _cleanup_free_ char *pivot_tmp_pivot_root_old = NULL;
251✔
1373
        _cleanup_(rmdir_and_freep) char *pivot_tmp = NULL;
251✔
1374
        int r;
251✔
1375

1376
        assert(directory);
251✔
1377

1378
        if (!pivot_root_new)
251✔
1379
                return 0;
1380

1381
        /* Pivot pivot_root_new to / and the existing / to pivot_root_old.
1382
         * If pivot_root_old is NULL, the existing / disappears.
1383
         * This requires a temporary directory, pivot_tmp, which is
1384
         * not a child of either.
1385
         *
1386
         * This is typically used for OSTree-style containers, where the root partition contains several
1387
         * sysroots which could be run. Normally, one would be chosen by the bootloader and pivoted to / by
1388
         * initrd.
1389
         *
1390
         * For example, for an OSTree deployment, pivot_root_new
1391
         * would be: /ostree/deploy/$os/deploy/$checksum. Note that this
1392
         * code doesn’t do the /var mount which OSTree expects: use
1393
         * --bind +/sysroot/ostree/deploy/$os/var:/var for that.
1394
         *
1395
         * So in the OSTree case, we’ll end up with something like:
1396
         *  - directory = /tmp/nspawn-root-123456
1397
         *  - pivot_root_new = /ostree/deploy/os/deploy/123abc
1398
         *  - pivot_root_old = /sysroot
1399
         *  - directory_pivot_root_new =
1400
         *       /tmp/nspawn-root-123456/ostree/deploy/os/deploy/123abc
1401
         *  - pivot_tmp = /tmp/nspawn-pivot-123456
1402
         *  - pivot_tmp_pivot_root_old = /tmp/nspawn-pivot-123456/sysroot
1403
         *
1404
         * Requires all file systems at directory and below to be mounted
1405
         * MS_PRIVATE or MS_SLAVE so they can be moved.
1406
         */
UNCOV
1407
        directory_pivot_root_new = path_join(directory, pivot_root_new);
×
1408
        if (!directory_pivot_root_new)
×
1409
                return log_oom();
×
1410

1411
        /* Remount directory_pivot_root_new to make it movable. */
UNCOV
1412
        r = mount_nofollow_verbose(LOG_ERR, directory_pivot_root_new, directory_pivot_root_new, NULL, MS_BIND, NULL);
×
1413
        if (r < 0)
×
1414
                return r;
1415

UNCOV
1416
        if (pivot_root_old) {
×
1417
                r = mkdtemp_malloc("/tmp/nspawn-pivot-XXXXXX", &pivot_tmp);
×
1418
                if (r < 0)
×
1419
                        return log_error_errno(r, "Failed to create temporary directory: %m");
×
1420

UNCOV
1421
                pivot_tmp_pivot_root_old = path_join(pivot_tmp, pivot_root_old);
×
1422
                if (!pivot_tmp_pivot_root_old)
×
1423
                        return log_oom();
×
1424

UNCOV
1425
                r = mount_nofollow_verbose(LOG_ERR, directory_pivot_root_new, pivot_tmp, NULL, MS_MOVE, NULL);
×
1426
                if (r < 0)
×
1427
                        return r;
1428

UNCOV
1429
                r = mount_nofollow_verbose(LOG_ERR, directory, pivot_tmp_pivot_root_old, NULL, MS_MOVE, NULL);
×
1430
                if (r < 0)
×
1431
                        return r;
1432

UNCOV
1433
                r = mount_nofollow_verbose(LOG_ERR, pivot_tmp, directory, NULL, MS_MOVE, NULL);
×
1434
        } else
UNCOV
1435
                r = mount_nofollow_verbose(LOG_ERR, directory_pivot_root_new, directory, NULL, MS_MOVE, NULL);
×
1436

UNCOV
1437
        if (r < 0)
×
1438
                return r;
×
1439

1440
        return 0;
1441
}
1442

1443
#define NSPAWN_PRIVATE_FULLY_VISIBLE_PROCFS "/run/host/proc"
1444
#define NSPAWN_PRIVATE_FULLY_VISIBLE_SYSFS "/run/host/sys"
1445

1446
int pin_fully_visible_api_fs(void) {
112✔
1447
        int r;
112✔
1448

1449
        log_debug("Pinning fully visible API FS");
112✔
1450

1451
        (void) mkdir_p(NSPAWN_PRIVATE_FULLY_VISIBLE_PROCFS, 0755);
112✔
1452
        (void) mkdir_p(NSPAWN_PRIVATE_FULLY_VISIBLE_SYSFS, 0755);
112✔
1453

1454
        r = mount_follow_verbose(LOG_ERR, "proc", NSPAWN_PRIVATE_FULLY_VISIBLE_PROCFS, "proc", PROC_DEFAULT_MOUNT_FLAGS, NULL);
112✔
1455
        if (r < 0)
112✔
1456
                return r;
1457

1458
        r = mount_follow_verbose(LOG_ERR, "sysfs", NSPAWN_PRIVATE_FULLY_VISIBLE_SYSFS, "sysfs", SYS_DEFAULT_MOUNT_FLAGS, NULL);
112✔
1459
        if (r < 0)
112✔
UNCOV
1460
                return r;
×
1461

1462
        return 0;
1463
}
1464

1465
static int do_wipe_fully_visible_api_fs(void) {
65✔
1466
        if (umount2(NSPAWN_PRIVATE_FULLY_VISIBLE_PROCFS, MNT_DETACH) < 0)
65✔
UNCOV
1467
                return log_error_errno(errno, "Failed to unmount temporary proc: %m");
×
1468

1469
        if (rmdir(NSPAWN_PRIVATE_FULLY_VISIBLE_PROCFS) < 0)
65✔
UNCOV
1470
                return log_error_errno(errno, "Failed to remove temporary proc mountpoint: %m");
×
1471

1472
        if (umount2(NSPAWN_PRIVATE_FULLY_VISIBLE_SYSFS, MNT_DETACH) < 0)
65✔
UNCOV
1473
                return log_error_errno(errno, "Failed to unmount temporary sys: %m");
×
1474

1475
        if (rmdir(NSPAWN_PRIVATE_FULLY_VISIBLE_SYSFS) < 0)
65✔
UNCOV
1476
                return log_error_errno(errno, "Failed to remove temporary sys mountpoint: %m");
×
1477

1478
        return 0;
1479
}
1480

1481
int wipe_fully_visible_api_fs(int mntns_fd) {
65✔
1482
        _cleanup_close_ int orig_mntns_fd = -EBADF;
65✔
1483
        int r, rr;
65✔
1484

1485
        log_debug("Wiping fully visible API FS");
65✔
1486

1487
        orig_mntns_fd = namespace_open_by_type(NAMESPACE_MOUNT);
65✔
1488
        if (orig_mntns_fd < 0)
65✔
UNCOV
1489
                return log_error_errno(orig_mntns_fd, "Failed to pin originating mount namespace: %m");
×
1490

1491
        r = namespace_enter(/* pidns_fd = */ -EBADF,
65✔
1492
                            mntns_fd,
1493
                            /* netns_fd = */ -EBADF,
1494
                            /* userns_fd = */ -EBADF,
1495
                            /* root_fd = */ -EBADF);
1496
        if (r < 0)
65✔
UNCOV
1497
                return log_error_errno(r, "Failed to enter mount namespace: %m");
×
1498

1499
        rr = do_wipe_fully_visible_api_fs();
65✔
1500

1501
        r = namespace_enter(/* pidns_fd = */ -EBADF,
65✔
1502
                            orig_mntns_fd,
1503
                            /* netns_fd = */ -EBADF,
1504
                            /* userns_fd = */ -EBADF,
1505
                            /* root_fd = */ -EBADF);
1506
        if (r < 0)
65✔
UNCOV
1507
                return log_error_errno(r, "Failed to enter original mount namespace: %m");
×
1508

1509
        return rr;
1510
}
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