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

systemd / systemd / 21121026098

18 Jan 2026 06:15PM UTC coverage: 72.736% (+0.2%) from 72.561%
21121026098

push

github

YHNdnzj
cryptenroll,cryptsetup,shutdown: only call mlockall if we have CAP_IPC_LOCK

Calling mlockall in an unprivileged process most notably had the effect
of making systemd-cryptenroll OOM while trying to open a normal-sized
argon2 keyslot due to it hitting RLIMIT_MEMLOCK.

9 of 14 new or added lines in 4 files covered. (64.29%)

1479 existing lines in 62 files now uncovered.

310610 of 427035 relevant lines covered (72.74%)

1127441.3 hits per line

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

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

3
#include <fcntl.h>
4
#include <linux/fs.h>
5
#include <sys/ioctl.h>
6
#include <sys/kcmp.h>
7
#include <sys/resource.h>
8
#include <sys/stat.h>
9
#include <unistd.h>
10

11
#include "alloc-util.h"
12
#include "dirent-util.h"
13
#include "errno-util.h"
14
#include "fd-util.h"
15
#include "fileio.h"
16
#include "format-util.h"
17
#include "fs-util.h"
18
#include "log.h"
19
#include "parse-util.h"
20
#include "path-util.h"
21
#include "process-util.h"
22
#include "sort-util.h"
23
#include "stat-util.h"
24
#include "stdio-util.h"
25
#include "string-util.h"
26

27
/* The maximum number of iterations in the loop to close descriptors in the fallback case
28
 * when /proc/self/fd/ is inaccessible. */
29
#define MAX_FD_LOOP_LIMIT (1024*1024)
30

31
int close_nointr(int fd) {
41,738,465✔
32
        assert(fd >= 0);
41,738,465✔
33

34
        if (close(fd) >= 0)
41,738,465✔
35
                return 0;
36

37
        /*
38
         * Just ignore EINTR; a retry loop is the wrong thing to do on
39
         * Linux.
40
         *
41
         * http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
42
         * https://bugzilla.gnome.org/show_bug.cgi?id=682819
43
         * http://utcc.utoronto.ca/~cks/space/blog/unix/CloseEINTR
44
         * https://sites.google.com/site/michaelsafyan/software-engineering/checkforeintrwheninvokingclosethinkagain
45
         */
46
        if (errno == EINTR)
10,946✔
47
                return 0;
48

49
        return -errno;
10,946✔
50
}
51

52
int safe_close(int fd) {
113,660,001✔
53
        /*
54
         * Like close_nointr() but cannot fail. Guarantees errno is unchanged. Is a noop for negative fds,
55
         * and returns -EBADF, so that it can be used in this syntax:
56
         *
57
         * fd = safe_close(fd);
58
         */
59

60
        if (fd >= 0) {
113,660,001✔
61
                PROTECT_ERRNO;
×
62

63
                /* The kernel might return pretty much any error code
64
                 * via close(), but the fd will be closed anyway. The
65
                 * only condition we want to check for here is whether
66
                 * the fd was invalid at all... */
67

68
                assert_se(close_nointr(fd) != -EBADF);
41,308,051✔
69
        }
70

71
        return -EBADF;
113,660,001✔
72
}
73

74
void safe_close_pair(int p[static 2]) {
569,462✔
75
        assert(p);
569,462✔
76

77
        if (p[0] == p[1]) {
569,462✔
78
                /* Special case pairs which use the same fd in both
79
                 * directions... */
80
                p[0] = p[1] = safe_close(p[0]);
536,122✔
81
                return;
536,122✔
82
        }
83

84
        p[0] = safe_close(p[0]);
33,340✔
85
        p[1] = safe_close(p[1]);
33,340✔
86
}
87

88
void close_many(const int fds[], size_t n_fds) {
3,393,740✔
89
        assert(fds || n_fds == 0);
3,393,740✔
90

91
        FOREACH_ARRAY(fd, fds, n_fds)
3,448,875✔
92
                safe_close(*fd);
55,135✔
93
}
3,393,740✔
94

95
void close_many_unset(int fds[], size_t n_fds) {
34✔
96
        assert(fds || n_fds == 0);
34✔
97

98
        FOREACH_ARRAY(fd, fds, n_fds)
35✔
99
                *fd = safe_close(*fd);
1✔
100
}
34✔
101

102
void close_many_and_free(int *fds, size_t n_fds) {
741✔
103
        assert(fds || n_fds == 0);
741✔
104

105
        close_many(fds, n_fds);
741✔
106
        free(fds);
741✔
107
}
741✔
108

109
int fclose_nointr(FILE *f) {
2,096,721✔
110
        assert(f);
2,096,721✔
111

112
        /* Same as close_nointr(), but for fclose() */
113

114
        errno = 0; /* Extra safety: if the FILE* object is not encapsulating an fd, it might not set errno
2,096,721✔
115
                    * correctly. Let's hence initialize it to zero first, so that we aren't confused by any
116
                    * prior errno here */
117
        if (fclose(f) == 0)
2,096,721✔
118
                return 0;
119

120
        if (errno == EINTR)
×
121
                return 0;
122

123
        return errno_or_else(EIO);
×
124
}
125

126
FILE* safe_fclose(FILE *f) {
3,961,067✔
127

128
        /* Same as safe_close(), but for fclose() */
129

130
        if (f) {
3,961,067✔
131
                PROTECT_ERRNO;
×
132

133
                assert_se(fclose_nointr(f) != -EBADF);
2,096,721✔
134
        }
135

136
        return NULL;
3,961,067✔
137
}
138

139
DIR* safe_closedir(DIR *d) {
×
140

141
        if (d) {
×
142
                PROTECT_ERRNO;
×
143

144
                assert_se(closedir(d) >= 0 || errno != EBADF);
×
145
        }
146

147
        return NULL;
×
148
}
149

150
int fd_nonblock(int fd, bool nonblock) {
1,920,496✔
151
        int flags, nflags;
1,920,496✔
152

153
        assert(fd >= 0);
1,920,496✔
154

155
        flags = fcntl(fd, F_GETFL, 0);
1,920,496✔
156
        if (flags < 0)
1,920,496✔
157
                return -errno;
×
158

159
        nflags = UPDATE_FLAG(flags, O_NONBLOCK, nonblock);
1,920,496✔
160
        if (nflags == flags)
1,920,496✔
161
                return 0;
162

163
        if (fcntl(fd, F_SETFL, nflags) < 0)
1,897,130✔
164
                return -errno;
×
165

166
        return 1;
167
}
168

169
int stdio_disable_nonblock(void) {
15,656✔
170
        int ret = 0;
15,656✔
171

172
        /* stdin/stdout/stderr really should have O_NONBLOCK, which would confuse apps if left on, as
173
         * write()s might unexpectedly fail with EAGAIN. */
174

175
        RET_GATHER(ret, fd_nonblock(STDIN_FILENO, false));
15,656✔
176
        RET_GATHER(ret, fd_nonblock(STDOUT_FILENO, false));
15,656✔
177
        RET_GATHER(ret, fd_nonblock(STDERR_FILENO, false));
15,656✔
178

179
        return ret;
15,656✔
180
}
181

182
int fd_cloexec(int fd, bool cloexec) {
78,569✔
183
        int flags, nflags;
78,569✔
184

185
        assert(fd >= 0);
78,569✔
186

187
        flags = fcntl(fd, F_GETFD, 0);
78,569✔
188
        if (flags < 0)
78,569✔
189
                return -errno;
×
190

191
        nflags = UPDATE_FLAG(flags, FD_CLOEXEC, cloexec);
78,569✔
192
        if (nflags == flags)
78,569✔
193
                return 0;
194

195
        return RET_NERRNO(fcntl(fd, F_SETFD, nflags));
67,046✔
196
}
197

198
int fd_cloexec_many(const int fds[], size_t n_fds, bool cloexec) {
111✔
199
        int r = 0;
111✔
200

201
        assert(fds || n_fds == 0);
111✔
202

203
        FOREACH_ARRAY(fd, fds, n_fds) {
143✔
204
                if (*fd < 0) /* Skip gracefully over already invalidated fds */
32✔
205
                        continue;
×
206

207
                RET_GATHER(r, fd_cloexec(*fd, cloexec));
32✔
208
        }
209

210
        return r;
111✔
211
}
212

213
static bool fd_in_set(int fd, const int fds[], size_t n_fds) {
20,991✔
214
        assert(fd >= 0);
20,991✔
215
        assert(fds || n_fds == 0);
20,991✔
216

217
        FOREACH_ARRAY(i, fds, n_fds) {
5,730,347✔
218
                if (*i < 0)
5,710,220✔
219
                        continue;
×
220

221
                if (*i == fd)
5,710,220✔
222
                        return true;
223
        }
224

225
        return false;
226
}
227

228
int get_max_fd(void) {
6✔
229
        struct rlimit rl;
6✔
230
        rlim_t m;
6✔
231

232
        /* Return the highest possible fd, based RLIMIT_NOFILE, but enforcing FD_SETSIZE-1 as lower boundary
233
         * and INT_MAX as upper boundary. */
234

235
        if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
6✔
236
                return -errno;
×
237

238
        m = MAX(rl.rlim_cur, rl.rlim_max);
6✔
239
        if (m < FD_SETSIZE) /* Let's always cover at least 1024 fds */
6✔
240
                return FD_SETSIZE-1;
241

242
        if (m == RLIM_INFINITY || m > INT_MAX) /* Saturate on overflow. After all fds are "int", hence can
6✔
243
                                                * never be above INT_MAX */
244
                return INT_MAX;
245

246
        return (int) (m - 1);
6✔
247
}
248

249
int close_all_fds_frugal(const int except[], size_t n_except) {
3✔
250
        int max_fd, r = 0;
3✔
251

252
        assert(except || n_except == 0);
3✔
253

254
        /* This is the inner fallback core of close_all_fds(). This never calls malloc() or so and hence is
255
         * safe to be called in signal handler context. Most users should call close_all_fds(), but when we
256
         * assume we are called from signal handler context, then use this simpler call instead. */
257

258
        max_fd = get_max_fd();
3✔
259
        if (max_fd < 0)
3✔
260
                return max_fd;
3✔
261

262
        /* Refuse to do the loop over more too many elements. It's better to fail immediately than to
263
         * spin the CPU for a long time. */
264
        if (max_fd > MAX_FD_LOOP_LIMIT)
3✔
265
                return log_debug_errno(SYNTHETIC_ERRNO(EPERM),
×
266
                                       "Refusing to loop over %d potential fds.", max_fd);
267

268
        for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -EBADF) {
20,994✔
269
                int q;
20,991✔
270

271
                if (fd_in_set(fd, except, n_except))
20,991✔
272
                        continue;
864✔
273

274
                q = close_nointr(fd);
20,127✔
275
                if (q != -EBADF)
20,127✔
276
                        RET_GATHER(r, q);
9,182✔
277
        }
278

279
        return r;
280
}
281

282
static int close_all_fds_special_case(const int except[], size_t n_except) {
44,298✔
283
        assert(n_except == 0 || except);
44,298✔
284

285
        /* Handles a few common special cases separately, since they are common and can be optimized really
286
         * nicely, since we won't need sorting for them. Returns > 0 if the special casing worked, 0
287
         * otherwise. */
288

289
        if (n_except == 1 && except[0] < 0) /* Minor optimization: if we only got one fd, and it's invalid,
44,298✔
290
                                             * we got none */
291
                n_except = 0;
292

293
        switch (n_except) {
44,298✔
294

295
        case 0:
8,737✔
296
                /* Close everything. Yay! */
297
                if (close_range(3, INT_MAX, 0) < 0)
8,737✔
298
                        return -errno;
×
299

300
                return 1;
301

302
        case 1:
15,481✔
303
                /* Close all but exactly one, then we don't need no sorting. This is a pretty common
304
                 * case, hence let's handle it specially. */
305

306
                if (except[0] > 3 && close_range(3, except[0] - 1, 0) < 0)
15,481✔
307
                        return -errno;
×
308

309
                if (except[0] < INT_MAX && close_range(MAX(3, except[0] + 1), -1, 0) < 0)
15,481✔
310
                        return -errno;
×
311

312
                return 1;
313

314
        default:
315
                return 0;
316
        }
317
}
318

319
int close_all_fds_without_malloc(const int except[], size_t n_except) {
2✔
320
        int r;
2✔
321

322
        assert(n_except == 0 || except);
2✔
323

324
        r = close_all_fds_special_case(except, n_except);
2✔
325
        if (r < 0)
2✔
326
                return r;
327
        if (r > 0) /* special case worked! */
2✔
328
                return 0;
329

330
        return close_all_fds_frugal(except, n_except);
1✔
331
}
332

333
int close_all_fds(const int except[], size_t n_except) {
44,296✔
334
        int r;
44,296✔
335

336
        assert(n_except == 0 || except);
44,296✔
337

338
        r = close_all_fds_special_case(except, n_except);
44,296✔
339
        if (r < 0)
44,296✔
340
                return r;
44,296✔
341
        if (r > 0) /* special case worked! */
44,296✔
342
                return 0;
343

344
        _cleanup_free_ int *sorted_malloc = NULL;
20,079✔
345
        size_t n_sorted;
20,079✔
346
        int *sorted;
20,079✔
347

348
        /* In the best case we have close_range() to close all fds between a start and an end fd, which we
349
         * can use on the "inverted" exception array, i.e. all intervals between all adjacent pairs from the
350
         * sorted exception array. This changes loop complexity from O(n) where n is number of open fds to
351
         * O(m⋅log(m)) where m is the number of fds to keep open. Given that we assume n ≫ m that's
352
         * preferable to us. */
353

354
        assert(n_except < SIZE_MAX);
20,079✔
355
        n_sorted = n_except + 1;
20,079✔
356

357
        if (n_sorted > ALLOCA_MAX / sizeof(int)) /* Use heap for large numbers of fds, stack otherwise */
20,079✔
358
                sorted = sorted_malloc = new(int, n_sorted);
×
359
        else
360
                sorted = newa(int, n_sorted);
20,079✔
361

362
        if (!sorted) /* Fallback on OOM. */
20,079✔
363
                return close_all_fds_frugal(except, n_except);
×
364

365
        memcpy(sorted, except, n_except * sizeof(int));
20,079✔
366

367
        /* Let's add fd 2 to the list of fds, to simplify the loop below, as this
368
         * allows us to cover the head of the array the same way as the body */
369
        sorted[n_sorted-1] = 2;
20,079✔
370

371
        typesafe_qsort(sorted, n_sorted, cmp_int);
20,079✔
372

373
        for (size_t i = 0; i < n_sorted-1; i++) {
90,142✔
374
                int start, end;
70,063✔
375

376
                start = MAX(sorted[i], 2); /* The first three fds shall always remain open */
70,063✔
377
                end = MAX(sorted[i+1], 2);
70,063✔
378

379
                assert(end >= start);
70,063✔
380

381
                if (end - start <= 1)
70,063✔
382
                        continue;
26,757✔
383

384
                /* Close everything between the start and end fds (both of which shall stay open) */
385
                if (close_range(start + 1, end - 1, 0) < 0)
43,306✔
386
                        return -errno;
×
387
        }
388

389
        /* The loop succeeded. Let's now close everything beyond the end */
390

391
        if (sorted[n_sorted-1] >= INT_MAX) /* Dont let the addition below overflow */
20,079✔
392
                return 0;
393

394
        if (close_range(sorted[n_sorted-1] + 1, INT_MAX, 0) < 0)
20,079✔
395
                return -errno;
×
396

397
        return 0;
398
}
399

400
int pack_fds(int fds[], size_t n_fds) {
10,066✔
401
        if (n_fds <= 0)
10,066✔
402
                return 0;
403

404
        /* Shifts around the fds in the provided array such that they
405
         * all end up packed next to each-other, in order, starting
406
         * from SD_LISTEN_FDS_START. This must be called after close_all_fds();
407
         * it is likely to freeze up otherwise. You should probably use safe_fork_full
408
         * with FORK_CLOSE_ALL_FDS|FORK_PACK_FDS set, to ensure that this is done correctly.
409
         * The fds array is modified in place with the new FD numbers. */
410

411
        assert(fds);
1,746✔
412

413
        for (int start = 0;;) {
414
                int restart_from = -1;
1,746✔
415

416
                for (int i = start; i < (int) n_fds; i++) {
5,432✔
417
                        int nfd;
3,686✔
418

419
                        /* Already at right index? */
420
                        if (fds[i] == i + 3)
3,686✔
421
                                continue;
3✔
422

423
                        nfd = fcntl(fds[i], F_DUPFD, i + 3);
3,683✔
424
                        if (nfd < 0)
3,683✔
425
                                return -errno;
×
426

427
                        safe_close(fds[i]);
3,683✔
428
                        fds[i] = nfd;
3,683✔
429

430
                        /* Hmm, the fd we wanted isn't free? Then
431
                         * let's remember that and try again from here */
432
                        if (nfd != i + 3 && restart_from < 0)
3,683✔
433
                                restart_from = i;
×
434
                }
435

436
                if (restart_from < 0)
1,746✔
437
                        break;
438

439
                start = restart_from;
440
        }
441

442
        assert(fds[0] == 3);
1,746✔
443

444
        return 0;
445
}
446

447
int fd_validate(int fd) {
73,580✔
448
        if (fd < 0)
73,580✔
449
                return -EBADF;
450

451
        if (fcntl(fd, F_GETFD) < 0)
73,578✔
452
                return -errno;
28,360✔
453

454
        return 0;
455
}
456

457
int same_fd(int a, int b) {
13,573✔
458
        struct stat sta, stb;
13,573✔
459
        pid_t pid;
13,573✔
460
        int r, fa, fb;
13,573✔
461

462
        assert(a >= 0);
13,573✔
463
        assert(b >= 0);
13,573✔
464

465
        /* Compares two file descriptors. Note that semantics are quite different depending on whether we
466
         * have F_DUPFD_QUERY/kcmp() or we don't. If we have F_DUPFD_QUERY/kcmp() this will only return true
467
         * for dup()ed file descriptors, but not otherwise. If we don't have F_DUPFD_QUERY/kcmp() this will
468
         * also return true for two fds of the same file, created by separate open() calls. Since we use this
469
         * call mostly for filtering out duplicates in the fd store this difference hopefully doesn't matter
470
         * too much.
471
         *
472
         * Guarantees that if either of the passed fds is not allocated we'll return -EBADF. */
473

474
        if (a == b) {
13,573✔
475
                /* Let's validate that the fd is valid */
476
                r = fd_validate(a);
7✔
477
                if (r < 0)
7✔
478
                        return r;
13,573✔
479

480
                return true;
6✔
481
        }
482

483
        /* Try to use F_DUPFD_QUERY if we have it first, as it is the nicest API */
484
        r = fcntl(a, F_DUPFD_QUERY, b);
13,566✔
485
        if (r > 0)
13,566✔
486
                return true;
487
        if (r == 0) {
13,558✔
488
                /* The kernel will return 0 in case the first fd is allocated, but the 2nd is not. (Which is different in the kcmp() case) Explicitly validate it hence. */
489
                r = fd_validate(b);
13,557✔
490
                if (r < 0)
13,557✔
491
                        return r;
492

493
                return false;
13,556✔
494
        }
495
        /* On old kernels (< 6.10) that do not support F_DUPFD_QUERY this will return EINVAL for regular fds, and EBADF on O_PATH fds. Confusing. */
496
        if (errno == EBADF) {
1✔
497
                /* EBADF could mean two things: the first fd is not valid, or it is valid and is O_PATH and
498
                 * F_DUPFD_QUERY is not supported. Let's validate the fd explicitly, to distinguish this
499
                 * case. */
500
                r = fd_validate(a);
1✔
501
                if (r < 0)
1✔
502
                        return r;
503

504
                /* If the fd is valid, but we got EBADF, then let's try kcmp(). */
505
        } else if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno) && errno != EINVAL)
×
506
                return -errno;
×
507

508
        /* Try to use kcmp() if we have it. */
509
        pid = getpid_cached();
×
510
        r = kcmp(pid, pid, KCMP_FILE, a, b);
×
511
        if (r >= 0)
×
512
                return !r;
×
513
        if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno))
×
514
                return -errno;
×
515

516
        /* We have neither F_DUPFD_QUERY nor kcmp(), use fstat() instead. */
517
        if (fstat(a, &sta) < 0)
×
518
                return -errno;
×
519

520
        if (fstat(b, &stb) < 0)
×
521
                return -errno;
×
522

523
        if (!stat_inode_same(&sta, &stb))
×
524
                return false;
525

526
        /* We consider all device fds different, since two device fds might refer to quite different device
527
         * contexts even though they share the same inode and backing dev_t. */
528

529
        if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode))
×
530
                return false;
531

532
        /* The fds refer to the same inode on disk, let's also check if they have the same fd flags. This is
533
         * useful to distinguish the read and write side of a pipe created with pipe(). */
534
        fa = fcntl(a, F_GETFL);
×
535
        if (fa < 0)
×
536
                return -errno;
×
537

538
        fb = fcntl(b, F_GETFL);
×
539
        if (fb < 0)
×
540
                return -errno;
×
541

542
        return fa == fb;
×
543
}
544

545
bool fdname_is_valid(const char *s) {
16,039✔
546
        const char *p;
16,039✔
547

548
        /* Validates a name for $LISTEN_FDNAMES. We basically allow
549
         * everything ASCII that's not a control character. Also, as
550
         * special exception the ":" character is not allowed, as we
551
         * use that as field separator in $LISTEN_FDNAMES.
552
         *
553
         * Note that the empty string is explicitly allowed
554
         * here. However, we limit the length of the names to 255
555
         * characters. */
556

557
        if (!s)
16,039✔
558
                return false;
559

560
        for (p = s; *p; p++) {
240,430✔
561
                if (*p < ' ')
224,396✔
562
                        return false;
563
                if (*p >= 127)
224,396✔
564
                        return false;
565
                if (*p == ':')
224,396✔
566
                        return false;
567
        }
568

569
        return p - s <= FDNAME_MAX;
16,034✔
570
}
571

572
int fd_get_path(int fd, char **ret) {
3,726,801✔
573
        int r;
3,726,801✔
574

575
        assert(fd >= 0 || IN_SET(fd, AT_FDCWD, XAT_FDROOT));
3,726,801✔
576

577
        if (fd == AT_FDCWD)
3✔
578
                return safe_getcwd(ret);
2✔
579
        if (fd == XAT_FDROOT)
3,726,799✔
580
                return strdup_to(ret, "/");
1✔
581

582
        r = readlink_malloc(FORMAT_PROC_FD_PATH(fd), ret);
3,726,798✔
583
        if (r == -ENOENT)
3,726,798✔
584
                return proc_fd_enoent_errno();
4✔
585
        return r;
586
}
587

588
int move_fd(int from, int to, int cloexec) {
18,779✔
589
        int r;
18,779✔
590

591
        /* Move fd 'from' to 'to', make sure FD_CLOEXEC remains equal if requested, and release the old fd. If
592
         * 'cloexec' is passed as -1, the original FD_CLOEXEC is inherited for the new fd. If it is 0, it is turned
593
         * off, if it is > 0 it is turned on. */
594

595
        if (from < 0)
18,779✔
596
                return -EBADF;
597
        if (to < 0)
18,779✔
598
                return -EBADF;
599

600
        if (from == to) {
18,779✔
601

602
                if (cloexec >= 0) {
×
UNCOV
603
                        r = fd_cloexec(to, cloexec);
×
UNCOV
604
                        if (r < 0)
×
605
                                return r;
606
                }
607

UNCOV
608
                return to;
×
609
        }
610

611
        if (cloexec < 0) {
18,779✔
612
                int fl;
×
613

614
                fl = fcntl(from, F_GETFD, 0);
×
UNCOV
615
                if (fl < 0)
×
616
                        return -errno;
×
617

UNCOV
618
                cloexec = FLAGS_SET(fl, FD_CLOEXEC);
×
619
        }
620

621
        r = dup3(from, to, cloexec ? O_CLOEXEC : 0);
37,558✔
622
        if (r < 0)
18,779✔
UNCOV
623
                return -errno;
×
624

625
        assert(r == to);
18,779✔
626

627
        safe_close(from);
18,779✔
628

629
        return to;
18,779✔
630
}
631

632
int fd_move_above_stdio(int fd) {
758,846✔
633
        int flags, copy;
758,846✔
634
        PROTECT_ERRNO;
758,846✔
635

636
        /* Moves the specified file descriptor if possible out of the range [0…2], i.e. the range of
637
         * stdin/stdout/stderr. If it can't be moved outside of this range the original file descriptor is
638
         * returned. This call is supposed to be used for long-lasting file descriptors we allocate in our code that
639
         * might get loaded into foreign code, and where we want ensure our fds are unlikely used accidentally as
640
         * stdin/stdout/stderr of unrelated code.
641
         *
642
         * Note that this doesn't fix any real bugs, it just makes it less likely that our code will be affected by
643
         * buggy code from others that mindlessly invokes 'fprintf(stderr, …' or similar in places where stderr has
644
         * been closed before.
645
         *
646
         * This function is written in a "best-effort" and "least-impact" style. This means whenever we encounter an
647
         * error we simply return the original file descriptor, and we do not touch errno. */
648

649
        if (fd < 0 || fd > 2)
758,846✔
650
                return fd;
651

652
        flags = fcntl(fd, F_GETFD, 0);
131✔
653
        if (flags < 0)
131✔
654
                return fd;
655

656
        if (flags & FD_CLOEXEC)
131✔
657
                copy = fcntl(fd, F_DUPFD_CLOEXEC, 3);
117✔
658
        else
659
                copy = fcntl(fd, F_DUPFD, 3);
14✔
660
        if (copy < 0)
131✔
661
                return fd;
662

663
        assert(copy > 2);
131✔
664

665
        (void) close(fd);
131✔
666
        return copy;
667
}
668

669
int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd) {
15,966✔
670
        int fd[3] = { original_input_fd,             /* Put together an array of fds we work on */
15,966✔
671
                      original_output_fd,
672
                      original_error_fd },
673
            null_fd = -EBADF,                        /* If we open /dev/null, we store the fd to it here */
15,966✔
674
            copy_fd[3] = EBADF_TRIPLET,              /* This contains all fds we duplicate here
15,966✔
675
                                                      * temporarily, and hence need to close at the end. */
676
            r;
677
        bool null_readable, null_writable;
15,966✔
678

679
        /* Sets up stdin, stdout, stderr with the three file descriptors passed in. If any of the descriptors
680
         * is specified as -EBADF it will be connected with /dev/null instead. If any of the file descriptors
681
         * is passed as itself (e.g. stdin as STDIN_FILENO) it is left unmodified, but the O_CLOEXEC bit is
682
         * turned off should it be on.
683
         *
684
         * Note that if any of the passed file descriptors are > 2 they will be closed — both on success and
685
         * on failure! Thus, callers should assume that when this function returns the input fds are
686
         * invalidated.
687
         *
688
         * Note that when this function fails stdin/stdout/stderr might remain half set up!
689
         *
690
         * O_CLOEXEC is turned off for all three file descriptors (which is how it should be for
691
         * stdin/stdout/stderr). */
692

693
        null_readable = original_input_fd < 0;
15,966✔
694
        null_writable = original_output_fd < 0 || original_error_fd < 0;
15,966✔
695

696
        /* First step, open /dev/null once, if we need it */
697
        if (null_readable || null_writable) {
15,966✔
698

699
                /* Let's open this with O_CLOEXEC first, and convert it to non-O_CLOEXEC when we move the fd to the final position. */
700
                null_fd = open("/dev/null", (null_readable && null_writable ? O_RDWR :
26,603✔
701
                                             null_readable ? O_RDONLY : O_WRONLY) | O_CLOEXEC);
13,248✔
702
                if (null_fd < 0) {
13,355✔
UNCOV
703
                        r = -errno;
×
UNCOV
704
                        goto finish;
×
705
                }
706

707
                /* If this fd is in the 0…2 range, let's move it out of it */
708
                if (null_fd < 3) {
13,355✔
709
                        int copy;
13✔
710

711
                        copy = fcntl(null_fd, F_DUPFD_CLOEXEC, 3); /* Duplicate this with O_CLOEXEC set */
13✔
712
                        if (copy < 0) {
13✔
UNCOV
713
                                r = -errno;
×
UNCOV
714
                                goto finish;
×
715
                        }
716

717
                        close_and_replace(null_fd, copy);
13✔
718
                }
719
        }
720

721
        /* Let's assemble fd[] with the fds to install in place of stdin/stdout/stderr */
722
        for (int i = 0; i < 3; i++)
63,864✔
723
                if (fd[i] < 0)
47,898✔
724
                        fd[i] = null_fd;        /* A negative parameter means: connect this one to /dev/null */
13,543✔
725
                else if (fd[i] != i && fd[i] < 3) {
34,355✔
726
                        /* This fd is in the 0…2 territory, but not at its intended place, move it out of there, so that we can work there. */
727
                        copy_fd[i] = fcntl(fd[i], F_DUPFD_CLOEXEC, 3); /* Duplicate this with O_CLOEXEC set */
108✔
728
                        if (copy_fd[i] < 0) {
108✔
UNCOV
729
                                r = -errno;
×
UNCOV
730
                                goto finish;
×
731
                        }
732

733
                        fd[i] = copy_fd[i];
108✔
734
                }
735

736
        /* At this point we now have the fds to use in fd[], and they are all above the stdio range, so that
737
         * we have freedom to move them around. If the fds already were at the right places then the specific
738
         * fds are -EBADF. Let's now move them to the right places. This is the point of no return. */
739
        for (int i = 0; i < 3; i++)
63,864✔
740
                if (fd[i] == i) {
47,898✔
741
                        /* fd is already in place, but let's make sure O_CLOEXEC is off */
742
                        r = fd_cloexec(i, false);
5,041✔
743
                        if (r < 0)
5,041✔
UNCOV
744
                                goto finish;
×
745
                } else {
746
                        assert(fd[i] > 2);
42,857✔
747

748
                        if (dup2(fd[i], i) < 0) { /* Turns off O_CLOEXEC on the new fd. */
42,857✔
UNCOV
749
                                r = -errno;
×
UNCOV
750
                                goto finish;
×
751
                        }
752
                }
753

754
        r = 0;
755

756
finish:
15,966✔
757
        /* Close the original fds, but only if they were outside of the stdio range. Also, properly check for the same
758
         * fd passed in multiple times. */
759
        safe_close_above_stdio(original_input_fd);
15,966✔
760
        if (original_output_fd != original_input_fd)
15,966✔
761
                safe_close_above_stdio(original_output_fd);
15,680✔
762
        if (original_error_fd != original_input_fd && original_error_fd != original_output_fd)
15,966✔
763
                safe_close_above_stdio(original_error_fd);
15,512✔
764

765
        /* Close the copies we moved > 2 */
766
        close_many(copy_fd, 3);
15,966✔
767

768
        /* Close our null fd, if it's > 2 */
769
        safe_close_above_stdio(null_fd);
15,966✔
770

771
        return r;
15,966✔
772
}
773

774
int fd_reopen(int fd, int flags) {
1,478,776✔
775
        assert(fd >= 0 || IN_SET(fd, AT_FDCWD, XAT_FDROOT));
1,478,776✔
776
        assert(!FLAGS_SET(flags, O_CREAT));
1,478,776✔
777

778
        /* Reopens the specified fd with new flags. This is useful for convert an O_PATH fd into a regular one, or to
779
         * turn O_RDWR fds into O_RDONLY fds.
780
         *
781
         * This doesn't work on sockets (since they cannot be open()ed, ever).
782
         *
783
         * This implicitly resets the file read index to 0.
784
         *
785
         * If AT_FDCWD is specified as file descriptor gets an fd to the current cwd.
786
         *
787
         * If XAT_FDROOT is specified as fd get an fd to the root directory.
788
         *
789
         * If the specified file descriptor refers to a symlink via O_PATH, then this function cannot be used
790
         * to follow that symlink. Because we cannot have non-O_PATH fds to symlinks reopening it without
791
         * O_PATH will always result in -ELOOP. Or in other words: if you have an O_PATH fd to a symlink you
792
         * can reopen it only if you pass O_PATH again. */
793

794
        if (FLAGS_SET(flags, O_NOFOLLOW))
1,478,776✔
795
                /* O_NOFOLLOW is not allowed in fd_reopen(), because after all this is primarily implemented
796
                 * via a symlink-based interface in /proc/self/fd. Let's refuse this here early. Note that
797
                 * the kernel would generate ELOOP here too, hence this manual check is mostly redundant –
798
                 * the only reason we add it here is so that the O_DIRECTORY special case (see below) behaves
799
                 * the same way as the non-O_DIRECTORY case. */
800
                return -ELOOP;
1,478,776✔
801

802
        if (fd == XAT_FDROOT)
1,478,774✔
803
                return RET_NERRNO(open("/", flags | O_DIRECTORY));
1✔
804

805
        if (FLAGS_SET(flags, O_DIRECTORY) || fd == AT_FDCWD)
1,478,773✔
806
                /* If we shall reopen the fd as directory we can just go via "." and thus bypass the whole
807
                 * magic /proc/ directory, and make ourselves independent of that being mounted. */
808
                return RET_NERRNO(openat(fd, ".", flags | O_DIRECTORY));
226,895✔
809

810
        int new_fd = open(FORMAT_PROC_FD_PATH(fd), flags);
1,251,880✔
811
        if (new_fd < 0) {
1,251,880✔
812
                if (errno != ENOENT)
46,522✔
813
                        return -errno;
46,521✔
814

815
                return proc_fd_enoent_errno();
1✔
816
        }
817

818
        return new_fd;
819
}
820

821
int fd_reopen_propagate_append_and_position(int fd, int flags) {
38✔
822
        /* Invokes fd_reopen(fd, flags), but propagates O_APPEND if set on original fd, and also tries to
823
         * keep current file position.
824
         *
825
         * You should use this if the original fd potentially is O_APPEND, otherwise we get rather
826
         * "unexpected" behavior. Unless you intentionally want to overwrite pre-existing data, and have
827
         * your output overwritten by the next user.
828
         *
829
         * Use case: "systemd-run --pty >> some-log".
830
         *
831
         * The "keep position" part is obviously nonsense for the O_APPEND case, but should reduce surprises
832
         * if someone carefully pre-positioned the passed in original input or non-append output FDs. */
833

834
        assert(fd >= 0);
38✔
835
        assert(!(flags & (O_APPEND|O_DIRECTORY)));
38✔
836

837
        int existing_flags = fcntl(fd, F_GETFL);
38✔
838
        if (existing_flags < 0)
38✔
UNCOV
839
                return -errno;
×
840

841
        int new_fd = fd_reopen(fd, flags | (existing_flags & O_APPEND));
38✔
842
        if (new_fd < 0)
38✔
843
                return new_fd;
844

845
        /* Try to adjust the offset, but ignore errors. */
846
        off_t p = lseek(fd, 0, SEEK_CUR);
27✔
847
        if (p > 0) {
27✔
UNCOV
848
                off_t new_p = lseek(new_fd, p, SEEK_SET);
×
UNCOV
849
                if (new_p < 0)
×
UNCOV
850
                        log_debug_errno(errno,
×
851
                                        "Failed to propagate file position for re-opened fd %d, ignoring: %m",
852
                                        fd);
UNCOV
853
                else if (new_p != p)
×
UNCOV
854
                        log_debug("Failed to propagate file position for re-opened fd %d (%lld != %lld), ignoring.",
×
855
                                  fd, (long long) new_p, (long long) p);
856
        }
857

858
        return new_fd;
859
}
860

861
int fd_reopen_condition(
1,257,631✔
862
                int fd,
863
                int flags,
864
                int mask,
865
                int *ret_new_fd) {
866

867
        int r, new_fd;
1,257,631✔
868

869
        assert(fd >= 0);
1,257,631✔
870
        assert(!FLAGS_SET(flags, O_CREAT));
1,257,631✔
871

872
        /* Invokes fd_reopen(fd, flags), but only if the existing F_GETFL flags don't match the specified
873
         * flags (masked by the specified mask). This is useful for converting O_PATH fds into real fds if
874
         * needed, but only then. */
875

876
        r = fcntl(fd, F_GETFL);
1,257,631✔
877
        if (r < 0)
1,257,631✔
UNCOV
878
                return -errno;
×
879

880
        if ((r & mask) == (flags & mask)) {
1,257,631✔
881
                *ret_new_fd = -EBADF;
1,252,003✔
882
                return fd;
1,252,003✔
883
        }
884

885
        new_fd = fd_reopen(fd, flags);
5,628✔
886
        if (new_fd < 0)
5,628✔
887
                return new_fd;
888

889
        *ret_new_fd = new_fd;
5,628✔
890
        return new_fd;
5,628✔
891
}
892

893
int fd_is_opath(int fd) {
481,937✔
894
        int r;
481,937✔
895

896
        assert(fd >= 0);
481,937✔
897

898
        r = fcntl(fd, F_GETFL);
481,937✔
899
        if (r < 0)
481,937✔
UNCOV
900
                return -errno;
×
901

902
        return FLAGS_SET(r, O_PATH);
481,937✔
903
}
904

905
int fd_vet_accmode(int fd, int mode) {
1,510✔
906
        int flags;
1,510✔
907

908
        /* Check if fd is opened with desired access mode.
909
         *
910
         * Returns > 0 on strict match, == 0 if opened for both reading and writing (partial match),
911
         * -EPROTOTYPE otherwise. O_PATH fds are always refused with -EBADFD.
912
         *
913
         * Note that while on O_DIRECTORY -EISDIR will be returned, this should not be relied upon as
914
         * the flag might not have been specified when open() was called originally. */
915

916
        assert(fd >= 0);
1,510✔
917
        assert(IN_SET(mode, O_RDONLY, O_WRONLY, O_RDWR));
1,510✔
918

919
        flags = fcntl(fd, F_GETFL);
1,510✔
920
        if (flags < 0)
1,510✔
921
                return -errno;
1✔
922

923
        /* O_TMPFILE in userspace is defined with O_DIRECTORY OR'ed in, so explicitly permit it.
924
         *
925
         * C.f. https://elixir.bootlin.com/linux/v6.17.7/source/include/uapi/asm-generic/fcntl.h#L92 */
926
        if (FLAGS_SET(flags, O_DIRECTORY) && !FLAGS_SET(flags, O_TMPFILE))
1,509✔
927
                return -EISDIR;
928

929
        if (FLAGS_SET(flags, O_PATH))
1,509✔
930
                return -EBADFD;
931

932
        flags &= O_ACCMODE_STRICT;
1,505✔
933

934
        if (flags == mode)
1,505✔
935
                return 1;
936

937
        if (flags == O_RDWR)
935✔
938
                return 0;
930✔
939

940
        return -EPROTOTYPE;
941
}
942

943
int fd_is_writable(int fd) {
196✔
944
        int r;
196✔
945

946
        assert(fd >= 0);
196✔
947

948
        r = fd_vet_accmode(fd, O_WRONLY);
196✔
949
        if (r >= 0)
196✔
950
                return true;
951

952
        if (IN_SET(r, -EPROTOTYPE, -EBADFD, -EISDIR))
3✔
953
                return false;
2✔
954

955
        return r;
956
}
957

958
int fd_verify_safe_flags_full(int fd, int extra_flags) {
626✔
959
        int flags, unexpected_flags;
626✔
960

961
        /* Check if an extrinsic fd is safe to work on (by a privileged service). This ensures that clients
962
         * can't trick a privileged service into giving access to a file the client doesn't already have
963
         * access to (especially via something like O_PATH).
964
         *
965
         * O_NOFOLLOW: For some reason the kernel will return this flag from fcntl(); it doesn't go away
966
         *             immediately after open(). It should have no effect whatsoever to an already-opened FD,
967
         *             and since we refuse O_PATH it should be safe.
968
         *
969
         * RAW_O_LARGEFILE: glibc secretly sets this and neglects to hide it from us if we call fcntl.
970
         *                  See comment in src/basic/include/fcntl.h for more details about this.
971
         *
972
         * If 'extra_flags' is specified as non-zero the included flags are also allowed.
973
         */
974

975
        assert(fd >= 0);
626✔
976

977
        flags = fcntl(fd, F_GETFL);
626✔
978
        if (flags < 0)
626✔
UNCOV
979
                return -errno;
×
980

981
        unexpected_flags = flags & ~(O_ACCMODE_STRICT|O_NOFOLLOW|RAW_O_LARGEFILE|extra_flags);
626✔
982
        if (unexpected_flags != 0)
626✔
UNCOV
983
                return log_debug_errno(SYNTHETIC_ERRNO(EREMOTEIO),
×
984
                                       "Unexpected flags set for extrinsic fd: 0%o",
985
                                       (unsigned) unexpected_flags);
986

987
        return flags & (O_ACCMODE_STRICT | extra_flags); /* return the flags variable, but remove the noise */
626✔
988
}
989

990
unsigned read_nr_open(void) {
25,753✔
991
        _cleanup_free_ char *nr_open = NULL;
25,753✔
992
        int r;
25,753✔
993

994
        /* Returns the kernel's current fd limit, either by reading it of /proc/sys if that works, or using the
995
         * hard-coded default compiled-in value of current kernels (1M) if not. This call will never fail. */
996

997
        r = read_one_line_file("/proc/sys/fs/nr_open", &nr_open);
25,753✔
998
        if (r < 0)
25,753✔
999
                log_debug_errno(r, "Failed to read /proc/sys/fs/nr_open, ignoring: %m");
25,753✔
1000
        else {
1001
                unsigned v;
25,753✔
1002

1003
                r = safe_atou(nr_open, &v);
25,753✔
1004
                if (r < 0)
25,753✔
UNCOV
1005
                        log_debug_errno(r, "Failed to parse /proc/sys/fs/nr_open value '%s', ignoring: %m", nr_open);
×
1006
                else
1007
                        return v;
25,753✔
1008
        }
1009

1010
        /* If we fail, fall back to the hard-coded kernel limit of 1024 * 1024. */
1011
        return NR_OPEN_DEFAULT;
1012
}
1013

1014
int fd_get_diskseq(int fd, uint64_t *ret) {
61,196✔
1015
        uint64_t diskseq;
61,196✔
1016

1017
        assert(fd >= 0);
61,196✔
1018
        assert(ret);
61,196✔
1019

1020
        if (ioctl(fd, BLKGETDISKSEQ, &diskseq) < 0) {
61,196✔
1021
                /* Note that the kernel is weird: non-existing ioctls currently return EINVAL
1022
                 * rather than ENOTTY on loopback block devices. They should fix that in the kernel,
1023
                 * but in the meantime we accept both here. */
UNCOV
1024
                if (!ERRNO_IS_NOT_SUPPORTED(errno) && errno != EINVAL)
×
UNCOV
1025
                        return -errno;
×
1026

1027
                return -EOPNOTSUPP;
1028
        }
1029

1030
        *ret = diskseq;
61,196✔
1031

1032
        return 0;
61,196✔
1033
}
1034

1035
static bool is_literal_root(const char *p) {
116,299✔
1036
        if (!p)
116,299✔
1037
                return false;
1038

1039
        /* Check if string consists of at least one '/', and possibly more, but nothing else */
1040
        size_t n = strspn(p, "/");
101,609✔
1041
        return n >= 1 && p[n] == 0;
203,206✔
1042
}
1043

1044
int path_is_root_at(int dir_fd, const char *path) {
4,257,376✔
1045
        assert(dir_fd >= 0 || IN_SET(dir_fd, AT_FDCWD, XAT_FDROOT));
4,257,376✔
1046

1047
        if (dir_fd == XAT_FDROOT && isempty(path))
116,300✔
1048
                return true;
4,257,376✔
1049

1050
        if (IN_SET(dir_fd, XAT_FDROOT, AT_FDCWD) && is_literal_root(path))
4,257,375✔
1051
                return true;
1052

1053
        _cleanup_close_ int fd = -EBADF;
4,257,376✔
1054
        if (!isempty(path)) {
4,257,363✔
1055
                fd = xopenat(dir_fd, path, O_PATH|O_DIRECTORY|O_CLOEXEC);
102,012✔
1056
                if (fd == -ENOTDIR)
102,012✔
1057
                        return false; /* the root dir must be a dir */
1058
                if (fd < 0)
101,184✔
1059
                        return fd;
1060

1061
                dir_fd = fd;
1062
        }
1063

1064
        _cleanup_close_ int root_fd = open("/", O_PATH|O_DIRECTORY|O_CLOEXEC);
8,498,284✔
1065
        if (root_fd < 0)
4,240,921✔
UNCOV
1066
                return -errno;
×
1067

1068
        /* Even if the root directory has the same inode as our fd, the fd may not point to the root
1069
         * directory "/", and we also need to check that the mount ids are the same. Otherwise, a construct
1070
         * like the following could be used to trick us:
1071
         *
1072
         * $ mkdir /tmp/x
1073
         * $ mount --bind / /tmp/x
1074
         */
1075

1076
        return fds_are_same_mount(dir_fd, root_fd);
4,240,921✔
1077
}
1078

1079
int fds_are_same_mount(int fd1, int fd2) {
4,240,939✔
1080
        struct statx sx1 = {}, sx2 = {}; /* explicitly initialize the struct to make msan silent. */
4,240,939✔
1081

1082
        assert(fd1 >= 0 || IN_SET(fd1, AT_FDCWD, XAT_FDROOT));
4,240,939✔
1083
        assert(fd2 >= 0 || IN_SET(fd2, AT_FDCWD, XAT_FDROOT));
4,240,939✔
1084

1085
        const char *fn1;
4,240,939✔
1086
        if (fd1 == XAT_FDROOT) {
4,240,939✔
1087
                fd1 = AT_FDCWD;
1088
                fn1 = "/";
1089
        } else
1090
                fn1 = "";
4,240,937✔
1091

1092
        if (statx(fd1, fn1, AT_EMPTY_PATH, STATX_TYPE|STATX_INO|STATX_MNT_ID, &sx1) < 0)
4,240,939✔
UNCOV
1093
                return -errno;
×
1094

1095
        const char *fn2;
4,240,939✔
1096
        if (fd2 == XAT_FDROOT) {
4,240,939✔
1097
                fd2 = AT_FDCWD;
1098
                fn2 = "/";
1099
        } else
1100
                fn2 = "";
4,240,937✔
1101

1102
        if (statx(fd2, fn2, AT_EMPTY_PATH, STATX_TYPE|STATX_INO|STATX_MNT_ID, &sx2) < 0)
4,240,939✔
UNCOV
1103
                return -errno;
×
1104

1105
        return statx_inode_same(&sx1, &sx2) && statx_mount_same(&sx1, &sx2);
4,240,939✔
1106
}
1107

1108
char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
5,280,011✔
1109
        assert(buf);
5,280,011✔
1110
        assert(fd >= 0);
5,280,011✔
1111
        assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
5,280,011✔
1112
        return buf;
5,280,011✔
1113
}
1114

1115
const char* accmode_to_string(int flags) {
150✔
1116
        switch (flags & O_ACCMODE_STRICT) {
150✔
1117
        case O_RDONLY:
1118
                return "ro";
1119
        case O_WRONLY:
3✔
1120
                return "wo";
3✔
1121
        case O_RDWR:
144✔
1122
                return "rw";
144✔
UNCOV
1123
        default:
×
UNCOV
1124
                return NULL;
×
1125
        }
1126
}
1127

1128
char* format_proc_pid_fd_path(char buf[static PROC_PID_FD_PATH_MAX], pid_t pid, int fd) {
1✔
1129
        assert(buf);
1✔
1130
        assert(fd >= 0);
1✔
1131
        assert(pid >= 0);
1✔
1132
        assert_se(snprintf_ok(buf, PROC_PID_FD_PATH_MAX, "/proc/" PID_FMT "/fd/%i", pid == 0 ? getpid_cached() : pid, fd));
1✔
1133
        return buf;
1✔
1134
}
1135

1136
int proc_fd_enoent_errno(void) {
5✔
1137
        int r;
5✔
1138

1139
        /* When ENOENT is returned during the use of FORMAT_PROC_FD_PATH, it can mean two things:
1140
         * that the fd does not exist or that /proc/ is not mounted.
1141
         * Let's make things debuggable and figure out the most appropriate errno. */
1142

1143
        r = proc_mounted();
5✔
1144
        if (r == 0)
5✔
1145
                return -ENOSYS;  /* /proc/ is not available or not set up properly, we're most likely
1146
                                    in some chroot environment. */
1147
        if (r > 0)
5✔
1148
                return -EBADF;   /* If /proc/ is definitely around then this means the fd is not valid. */
5✔
1149

1150
        return -ENOENT;          /* Otherwise let's propagate the original ENOENT. */
1151
}
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