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

systemd / systemd / 15746219612

18 Jun 2025 03:36PM UTC coverage: 72.045% (-0.04%) from 72.087%
15746219612

push

github

bluca
test-cpu-set-util: use ASSERT_XYZ() macros

119 of 121 new or added lines in 1 file covered. (98.35%)

1096 existing lines in 62 files now uncovered.

300222 of 416715 relevant lines covered (72.04%)

712541.77 hits per line

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

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

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

10
#include "alloc-util.h"
11
#include "dirent-util.h"
12
#include "errno-util.h"
13
#include "fd-util.h"
14
#include "fileio.h"
15
#include "format-util.h"
16
#include "fs-util.h"
17
#include "log.h"
18
#include "missing_fcntl.h"
19
#include "missing_fs.h"
20
#include "missing_syscall.h"
21
#include "mountpoint-util.h"
22
#include "parse-util.h"
23
#include "path-util.h"
24
#include "process-util.h"
25
#include "socket-util.h"
26
#include "sort-util.h"
27
#include "stat-util.h"
28
#include "stdio-util.h"
29
#include "string-util.h"
30

31
/* The maximum number of iterations in the loop to close descriptors in the fallback case
32
 * when /proc/self/fd/ is inaccessible. */
33
#define MAX_FD_LOOP_LIMIT (1024*1024)
34

35
int close_nointr(int fd) {
41,297,504✔
36
        assert(fd >= 0);
41,297,504✔
37

38
        if (close(fd) >= 0)
41,297,504✔
39
                return 0;
40

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

53
        return -errno;
16,575✔
54
}
55

56
int safe_close(int fd) {
108,166,160✔
57
        /*
58
         * Like close_nointr() but cannot fail. Guarantees errno is unchanged. Is a noop for negative fds,
59
         * and returns -EBADF, so that it can be used in this syntax:
60
         *
61
         * fd = safe_close(fd);
62
         */
63

64
        if (fd >= 0) {
108,166,160✔
65
                PROTECT_ERRNO;
×
66

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

72
                assert_se(close_nointr(fd) != -EBADF);
40,867,959✔
73
        }
74

75
        return -EBADF;
108,166,160✔
76
}
77

78
void safe_close_pair(int p[static 2]) {
502,868✔
79
        assert(p);
502,868✔
80

81
        if (p[0] == p[1]) {
502,868✔
82
                /* Special case pairs which use the same fd in both
83
                 * directions... */
84
                p[0] = p[1] = safe_close(p[0]);
467,349✔
85
                return;
467,349✔
86
        }
87

88
        p[0] = safe_close(p[0]);
35,519✔
89
        p[1] = safe_close(p[1]);
35,519✔
90
}
91

92
void close_many(const int fds[], size_t n_fds) {
3,255,018✔
93
        assert(fds || n_fds == 0);
3,255,018✔
94

95
        FOREACH_ARRAY(fd, fds, n_fds)
3,305,532✔
96
                safe_close(*fd);
50,514✔
97
}
3,255,018✔
98

99
void close_many_unset(int fds[], size_t n_fds) {
28✔
100
        assert(fds || n_fds == 0);
28✔
101

102
        FOREACH_ARRAY(fd, fds, n_fds)
29✔
103
                *fd = safe_close(*fd);
1✔
104
}
28✔
105

106
void close_many_and_free(int *fds, size_t n_fds) {
588✔
107
        assert(fds || n_fds == 0);
588✔
108

109
        close_many(fds, n_fds);
588✔
110
        free(fds);
588✔
111
}
588✔
112

113
int fclose_nointr(FILE *f) {
1,973,355✔
114
        assert(f);
1,973,355✔
115

116
        /* Same as close_nointr(), but for fclose() */
117

118
        errno = 0; /* Extra safety: if the FILE* object is not encapsulating an fd, it might not set errno
1,973,355✔
119
                    * correctly. Let's hence initialize it to zero first, so that we aren't confused by any
120
                    * prior errno here */
121
        if (fclose(f) == 0)
1,973,355✔
122
                return 0;
123

124
        if (errno == EINTR)
×
125
                return 0;
126

127
        return errno_or_else(EIO);
×
128
}
129

130
FILE* safe_fclose(FILE *f) {
3,809,579✔
131

132
        /* Same as safe_close(), but for fclose() */
133

134
        if (f) {
3,809,579✔
135
                PROTECT_ERRNO;
×
136

137
                assert_se(fclose_nointr(f) != -EBADF);
1,973,355✔
138
        }
139

140
        return NULL;
3,809,579✔
141
}
142

143
DIR* safe_closedir(DIR *d) {
×
144

145
        if (d) {
×
146
                PROTECT_ERRNO;
×
147

148
                assert_se(closedir(d) >= 0 || errno != EBADF);
×
149
        }
150

151
        return NULL;
×
152
}
153

154
int fd_nonblock(int fd, bool nonblock) {
1,870,385✔
155
        int flags, nflags;
1,870,385✔
156

157
        assert(fd >= 0);
1,870,385✔
158

159
        flags = fcntl(fd, F_GETFL, 0);
1,870,385✔
160
        if (flags < 0)
1,870,385✔
161
                return -errno;
×
162

163
        nflags = UPDATE_FLAG(flags, O_NONBLOCK, nonblock);
1,870,385✔
164
        if (nflags == flags)
1,870,385✔
165
                return 0;
166

167
        if (fcntl(fd, F_SETFL, nflags) < 0)
1,848,287✔
168
                return -errno;
×
169

170
        return 1;
171
}
172

173
int stdio_disable_nonblock(void) {
14,539✔
174
        int ret = 0;
14,539✔
175

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

179
        RET_GATHER(ret, fd_nonblock(STDIN_FILENO, false));
14,539✔
180
        RET_GATHER(ret, fd_nonblock(STDOUT_FILENO, false));
14,539✔
181
        RET_GATHER(ret, fd_nonblock(STDERR_FILENO, false));
14,539✔
182

183
        return ret;
14,539✔
184
}
185

186
int fd_cloexec(int fd, bool cloexec) {
83,454✔
187
        int flags, nflags;
83,454✔
188

189
        assert(fd >= 0);
83,454✔
190

191
        flags = fcntl(fd, F_GETFD, 0);
83,454✔
192
        if (flags < 0)
83,454✔
193
                return -errno;
×
194

195
        nflags = UPDATE_FLAG(flags, FD_CLOEXEC, cloexec);
83,454✔
196
        if (nflags == flags)
83,454✔
197
                return 0;
198

199
        return RET_NERRNO(fcntl(fd, F_SETFD, nflags));
74,343✔
200
}
201

202
int fd_cloexec_many(const int fds[], size_t n_fds, bool cloexec) {
100✔
203
        int r = 0;
100✔
204

205
        assert(fds || n_fds == 0);
100✔
206

207
        FOREACH_ARRAY(fd, fds, n_fds) {
126✔
208
                if (*fd < 0) /* Skip gracefully over already invalidated fds */
26✔
209
                        continue;
×
210

211
                RET_GATHER(r, fd_cloexec(*fd, cloexec));
26✔
212
        }
213

214
        return r;
100✔
215
}
216

217
static bool fd_in_set(int fd, const int fds[], size_t n_fds) {
34,852✔
218
        assert(fd >= 0);
34,852✔
219
        assert(fds || n_fds == 0);
34,852✔
220

221
        FOREACH_ARRAY(i, fds, n_fds) {
16,934,798✔
222
                if (*i < 0)
16,903,224✔
223
                        continue;
×
224

225
                if (*i == fd)
16,903,224✔
226
                        return true;
227
        }
228

229
        return false;
230
}
231

232
int get_max_fd(void) {
9✔
233
        struct rlimit rl;
9✔
234
        rlim_t m;
9✔
235

236
        /* Return the highest possible fd, based RLIMIT_NOFILE, but enforcing FD_SETSIZE-1 as lower boundary
237
         * and INT_MAX as upper boundary. */
238

239
        if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
9✔
240
                return -errno;
×
241

242
        m = MAX(rl.rlim_cur, rl.rlim_max);
9✔
243
        if (m < FD_SETSIZE) /* Let's always cover at least 1024 fds */
9✔
244
                return FD_SETSIZE-1;
245

246
        if (m == RLIM_INFINITY || m > INT_MAX) /* Saturate on overflow. After all fds are "int", hence can
9✔
247
                                                * never be above INT_MAX */
248
                return INT_MAX;
249

250
        return (int) (m - 1);
9✔
251
}
252

253
static int close_all_fds_frugal(const int except[], size_t n_except) {
4✔
254
        int max_fd, r = 0;
4✔
255

256
        assert(except || n_except == 0);
4✔
257

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

263
        max_fd = get_max_fd();
4✔
264
        if (max_fd < 0)
4✔
265
                return max_fd;
4✔
266

267
        /* Refuse to do the loop over more too many elements. It's better to fail immediately than to
268
         * spin the CPU for a long time. */
269
        if (max_fd > MAX_FD_LOOP_LIMIT)
4✔
270
                return log_debug_errno(SYNTHETIC_ERRNO(EPERM),
×
271
                                       "Refusing to loop over %d potential fds.", max_fd);
272

273
        for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -EBADF) {
27,992✔
274
                int q;
27,988✔
275

276
                if (fd_in_set(fd, except, n_except))
27,988✔
277
                        continue;
1,414✔
278

279
                q = close_nointr(fd);
26,574✔
280
                if (q != -EBADF)
26,574✔
281
                        RET_GATHER(r, q);
10,000✔
282
        }
283

284
        return r;
285
}
286

287
static bool have_close_range = true; /* Assume we live in the future */
288

289
static int close_all_fds_special_case(const int except[], size_t n_except) {
44,642✔
290
        assert(n_except == 0 || except);
44,642✔
291

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

296
        if (!have_close_range)
44,642✔
297
                return 0;
298

299
        if (n_except == 1 && except[0] < 0) /* Minor optimization: if we only got one fd, and it's invalid,
44,638✔
300
                                             * we got none */
301
                n_except = 0;
302

303
        switch (n_except) {
44,638✔
304

305
        case 0:
8,260✔
306
                /* Close everything. Yay! */
307

308
                if (close_range(3, INT_MAX, 0) >= 0)
8,260✔
309
                        return 1;
310

311
                if (ERRNO_IS_NOT_SUPPORTED(errno) || ERRNO_IS_PRIVILEGE(errno)) {
×
312
                        have_close_range = false;
×
313
                        return 0;
×
314
                }
315

316
                return -errno;
×
317

318
        case 1:
14,608✔
319
                /* Close all but exactly one, then we don't need no sorting. This is a pretty common
320
                 * case, hence let's handle it specially. */
321

322
                if ((except[0] <= 3 || close_range(3, except[0]-1, 0) >= 0) &&
14,608✔
323
                    (except[0] >= INT_MAX || close_range(MAX(3, except[0]+1), -1, 0) >= 0))
14,608✔
324
                        return 1;
14,608✔
325

326
                if (ERRNO_IS_NOT_SUPPORTED(errno) || ERRNO_IS_PRIVILEGE(errno)) {
×
327
                        have_close_range = false;
×
328
                        return 0;
×
329
                }
330

331
                return -errno;
×
332

333
        default:
334
                return 0;
335
        }
336
}
337

338
int close_all_fds_without_malloc(const int except[], size_t n_except) {
×
339
        int r;
×
340

341
        assert(n_except == 0 || except);
×
342

343
        r = close_all_fds_special_case(except, n_except);
×
344
        if (r < 0)
×
345
                return r;
346
        if (r > 0) /* special case worked! */
×
347
                return 0;
348

349
        return close_all_fds_frugal(except, n_except);
×
350
}
351

352
int close_all_fds(const int except[], size_t n_except) {
44,642✔
353
        _cleanup_closedir_ DIR *d = NULL;
44,642✔
354
        int r = 0;
44,642✔
355

356
        assert(n_except == 0 || except);
44,642✔
357

358
        r = close_all_fds_special_case(except, n_except);
44,642✔
359
        if (r < 0)
44,642✔
360
                return r;
361
        if (r > 0) /* special case worked! */
44,642✔
362
                return 0;
363

364
        if (have_close_range) {
21,774✔
365
                _cleanup_free_ int *sorted_malloc = NULL;
21,770✔
366
                size_t n_sorted;
21,770✔
367
                int *sorted;
21,770✔
368

369
                /* In the best case we have close_range() to close all fds between a start and an end fd,
370
                 * which we can use on the "inverted" exception array, i.e. all intervals between all
371
                 * adjacent pairs from the sorted exception array. This changes loop complexity from O(n)
372
                 * where n is number of open fds to O(mâ‹…log(m)) where m is the number of fds to keep
373
                 * open. Given that we assume n ≫ m that's preferable to us. */
374

375
                assert(n_except < SIZE_MAX);
21,770✔
376
                n_sorted = n_except + 1;
21,770✔
377

378
                if (n_sorted > 64) /* Use heap for large numbers of fds, stack otherwise */
21,770✔
379
                        sorted = sorted_malloc = new(int, n_sorted);
4✔
380
                else
381
                        sorted = newa(int, n_sorted);
21,766✔
382

383
                if (sorted) {
21,770✔
384
                        memcpy(sorted, except, n_except * sizeof(int));
21,770✔
385

386
                        /* Let's add fd 2 to the list of fds, to simplify the loop below, as this
387
                         * allows us to cover the head of the array the same way as the body */
388
                        sorted[n_sorted-1] = 2;
21,770✔
389

390
                        typesafe_qsort(sorted, n_sorted, cmp_int);
21,770✔
391

392
                        for (size_t i = 0; i < n_sorted-1; i++) {
99,282✔
393
                                int start, end;
77,514✔
394

395
                                start = MAX(sorted[i], 2); /* The first three fds shall always remain open */
77,514✔
396
                                end = MAX(sorted[i+1], 2);
77,514✔
397

398
                                assert(end >= start);
77,514✔
399

400
                                if (end - start <= 1)
77,514✔
401
                                        continue;
30,939✔
402

403
                                /* Close everything between the start and end fds (both of which shall stay open) */
404
                                if (close_range(start + 1, end - 1, 0) < 0) {
46,575✔
405
                                        if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno))
2✔
406
                                                return -errno;
×
407

408
                                        have_close_range = false;
2✔
409
                                        break;
2✔
410
                                }
411
                        }
412

413
                        if (have_close_range) {
21,770✔
414
                                /* The loop succeeded. Let's now close everything beyond the end */
415

416
                                if (sorted[n_sorted-1] >= INT_MAX) /* Dont let the addition below overflow */
21,768✔
417
                                        return 0;
418

419
                                if (close_range(sorted[n_sorted-1] + 1, INT_MAX, 0) >= 0)
21,768✔
420
                                        return 0;
421

422
                                if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno))
×
423
                                        return -errno;
×
424

425
                                have_close_range = false;
×
426
                        }
427
                }
428

429
                /* Fallback on OOM or if close_range() is not supported */
430
        }
431

432
        d = opendir("/proc/self/fd");
6✔
433
        if (!d)
6✔
434
                return close_all_fds_frugal(except, n_except); /* ultimate fallback if /proc/ is not available */
4✔
435

436
        FOREACH_DIRENT(de, d, return -errno) {
6,878✔
437
                int fd = -EBADF, q;
6,872✔
438

439
                if (!IN_SET(de->d_type, DT_LNK, DT_UNKNOWN))
6,872✔
440
                        continue;
×
441

442
                fd = parse_fd(de->d_name);
6,872✔
443
                if (fd < 0)
6,872✔
444
                        /* Let's better ignore this, just in case */
445
                        continue;
×
446

447
                if (fd < 3)
6,872✔
448
                        continue;
6✔
449

450
                if (fd == dirfd(d))
6,866✔
451
                        continue;
2✔
452

453
                if (fd_in_set(fd, except, n_except))
6,864✔
454
                        continue;
1,864✔
455

456
                q = close_nointr(fd);
5,000✔
457
                if (q < 0 && q != -EBADF && r >= 0) /* Valgrind has its own FD and doesn't want to have it closed */
5,000✔
458
                        r = q;
×
459
        }
460

461
        return r;
462
}
463

464
int pack_fds(int fds[], size_t n_fds) {
9,897✔
465
        if (n_fds <= 0)
9,897✔
466
                return 0;
467

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

475
        assert(fds);
1,578✔
476

477
        for (int start = 0;;) {
478
                int restart_from = -1;
1,578✔
479

480
                for (int i = start; i < (int) n_fds; i++) {
4,210✔
481
                        int nfd;
2,632✔
482

483
                        /* Already at right index? */
484
                        if (fds[i] == i + 3)
2,632✔
485
                                continue;
3✔
486

487
                        nfd = fcntl(fds[i], F_DUPFD, i + 3);
2,629✔
488
                        if (nfd < 0)
2,629✔
489
                                return -errno;
×
490

491
                        safe_close(fds[i]);
2,629✔
492
                        fds[i] = nfd;
2,629✔
493

494
                        /* Hmm, the fd we wanted isn't free? Then
495
                         * let's remember that and try again from here */
496
                        if (nfd != i + 3 && restart_from < 0)
2,629✔
497
                                restart_from = i;
×
498
                }
499

500
                if (restart_from < 0)
1,578✔
501
                        break;
502

503
                start = restart_from;
504
        }
505

506
        assert(fds[0] == 3);
1,578✔
507

508
        return 0;
509
}
510

511
int fd_validate(int fd) {
113,214✔
512
        if (fd < 0)
113,214✔
513
                return -EBADF;
514

515
        if (fcntl(fd, F_GETFD) < 0)
113,212✔
516
                return -errno;
44,735✔
517

518
        return 0;
519
}
520

521
int same_fd(int a, int b) {
13,207✔
522
        struct stat sta, stb;
13,207✔
523
        pid_t pid;
13,207✔
524
        int r, fa, fb;
13,207✔
525

526
        assert(a >= 0);
13,207✔
527
        assert(b >= 0);
13,207✔
528

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

538
        if (a == b) {
13,207✔
539
                /* Let's validate that the fd is valid */
540
                r = fd_validate(a);
7✔
541
                if (r < 0)
7✔
542
                        return r;
13,207✔
543

544
                return true;
6✔
545
        }
546

547
        /* Try to use F_DUPFD_QUERY if we have it first, as it is the nicest API */
548
        r = fcntl(a, F_DUPFD_QUERY, b);
13,200✔
549
        if (r > 0)
13,200✔
550
                return true;
551
        if (r == 0) {
13,192✔
552
                /* 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. */
553
                r = fd_validate(b);
13,191✔
554
                if (r < 0)
13,191✔
555
                        return r;
556

557
                return false;
13,190✔
558
        }
559
        /* 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. */
560
        if (errno == EBADF) {
1✔
561
                /* EBADF could mean two things: the first fd is not valid, or it is valid and is O_PATH and
562
                 * F_DUPFD_QUERY is not supported. Let's validate the fd explicitly, to distinguish this
563
                 * case. */
564
                r = fd_validate(a);
1✔
565
                if (r < 0)
1✔
566
                        return r;
567

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

572
        /* Try to use kcmp() if we have it. */
573
        pid = getpid_cached();
×
574
        r = kcmp(pid, pid, KCMP_FILE, a, b);
×
575
        if (r >= 0)
×
576
                return !r;
×
577
        if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno))
×
578
                return -errno;
×
579

580
        /* We have neither F_DUPFD_QUERY nor kcmp(), use fstat() instead. */
581
        if (fstat(a, &sta) < 0)
×
582
                return -errno;
×
583

584
        if (fstat(b, &stb) < 0)
×
585
                return -errno;
×
586

587
        if (!stat_inode_same(&sta, &stb))
×
588
                return false;
589

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

593
        if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode))
×
594
                return false;
595

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

602
        fb = fcntl(b, F_GETFL);
×
603
        if (fb < 0)
×
604
                return -errno;
×
605

606
        return fa == fb;
×
607
}
608

609
bool fdname_is_valid(const char *s) {
13,587✔
610
        const char *p;
13,587✔
611

612
        /* Validates a name for $LISTEN_FDNAMES. We basically allow
613
         * everything ASCII that's not a control character. Also, as
614
         * special exception the ":" character is not allowed, as we
615
         * use that as field separator in $LISTEN_FDNAMES.
616
         *
617
         * Note that the empty string is explicitly allowed
618
         * here. However, we limit the length of the names to 255
619
         * characters. */
620

621
        if (!s)
13,587✔
622
                return false;
623

624
        for (p = s; *p; p++) {
206,848✔
625
                if (*p < ' ')
193,266✔
626
                        return false;
627
                if (*p >= 127)
193,266✔
628
                        return false;
629
                if (*p == ':')
193,266✔
630
                        return false;
631
        }
632

633
        return p - s <= FDNAME_MAX;
13,582✔
634
}
635

636
int fd_get_path(int fd, char **ret) {
1,824,721✔
637
        int r;
1,824,721✔
638

639
        assert(fd >= 0 || fd == AT_FDCWD);
1,824,721✔
640

641
        if (fd == AT_FDCWD)
1,824,721✔
642
                return safe_getcwd(ret);
5,107✔
643

644
        r = readlink_malloc(FORMAT_PROC_FD_PATH(fd), ret);
1,819,614✔
645
        if (r == -ENOENT)
1,819,614✔
646
                return proc_fd_enoent_errno();
4✔
647
        return r;
648
}
649

650
int move_fd(int from, int to, int cloexec) {
22,196✔
651
        int r;
22,196✔
652

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

657
        if (from < 0)
22,196✔
658
                return -EBADF;
659
        if (to < 0)
22,196✔
660
                return -EBADF;
661

662
        if (from == to) {
22,196✔
663

UNCOV
664
                if (cloexec >= 0) {
×
UNCOV
665
                        r = fd_cloexec(to, cloexec);
×
UNCOV
666
                        if (r < 0)
×
667
                                return r;
668
                }
669

UNCOV
670
                return to;
×
671
        }
672

673
        if (cloexec < 0) {
22,196✔
UNCOV
674
                int fl;
×
675

UNCOV
676
                fl = fcntl(from, F_GETFD, 0);
×
UNCOV
677
                if (fl < 0)
×
UNCOV
678
                        return -errno;
×
679

UNCOV
680
                cloexec = FLAGS_SET(fl, FD_CLOEXEC);
×
681
        }
682

683
        r = dup3(from, to, cloexec ? O_CLOEXEC : 0);
44,392✔
684
        if (r < 0)
22,196✔
UNCOV
685
                return -errno;
×
686

687
        assert(r == to);
22,196✔
688

689
        safe_close(from);
22,196✔
690

691
        return to;
22,196✔
692
}
693

694
int fd_move_above_stdio(int fd) {
771,295✔
695
        int flags, copy;
771,295✔
696
        PROTECT_ERRNO;
771,295✔
697

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

711
        if (fd < 0 || fd > 2)
771,295✔
712
                return fd;
713

714
        flags = fcntl(fd, F_GETFD, 0);
104✔
715
        if (flags < 0)
104✔
716
                return fd;
717

718
        if (flags & FD_CLOEXEC)
104✔
719
                copy = fcntl(fd, F_DUPFD_CLOEXEC, 3);
102✔
720
        else
721
                copy = fcntl(fd, F_DUPFD, 3);
2✔
722
        if (copy < 0)
104✔
723
                return fd;
724

725
        assert(copy > 2);
104✔
726

727
        (void) close(fd);
104✔
728
        return copy;
729
}
730

731
int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd) {
14,838✔
732
        int fd[3] = { original_input_fd,             /* Put together an array of fds we work on */
14,838✔
733
                      original_output_fd,
734
                      original_error_fd },
735
            null_fd = -EBADF,                        /* If we open /dev/null, we store the fd to it here */
14,838✔
736
            copy_fd[3] = EBADF_TRIPLET,              /* This contains all fds we duplicate here
14,838✔
737
                                                      * temporarily, and hence need to close at the end. */
738
            r;
739
        bool null_readable, null_writable;
14,838✔
740

741
        /* Sets up stdin, stdout, stderr with the three file descriptors passed in. If any of the descriptors
742
         * is specified as -EBADF it will be connected with /dev/null instead. If any of the file descriptors
743
         * is passed as itself (e.g. stdin as STDIN_FILENO) it is left unmodified, but the O_CLOEXEC bit is
744
         * turned off should it be on.
745
         *
746
         * Note that if any of the passed file descriptors are > 2 they will be closed — both on success and
747
         * on failure! Thus, callers should assume that when this function returns the input fds are
748
         * invalidated.
749
         *
750
         * Note that when this function fails stdin/stdout/stderr might remain half set up!
751
         *
752
         * O_CLOEXEC is turned off for all three file descriptors (which is how it should be for
753
         * stdin/stdout/stderr). */
754

755
        null_readable = original_input_fd < 0;
14,838✔
756
        null_writable = original_output_fd < 0 || original_error_fd < 0;
14,838✔
757

758
        /* First step, open /dev/null once, if we need it */
759
        if (null_readable || null_writable) {
14,838✔
760

761
                /* Let's open this with O_CLOEXEC first, and convert it to non-O_CLOEXEC when we move the fd to the final position. */
762
                null_fd = open("/dev/null", (null_readable && null_writable ? O_RDWR :
24,649✔
763
                                             null_readable ? O_RDONLY : O_WRONLY) | O_CLOEXEC);
12,279✔
764
                if (null_fd < 0) {
12,370✔
UNCOV
765
                        r = -errno;
×
UNCOV
766
                        goto finish;
×
767
                }
768

769
                /* If this fd is in the 0…2 range, let's move it out of it */
770
                if (null_fd < 3) {
12,370✔
771
                        int copy;
13✔
772

773
                        copy = fcntl(null_fd, F_DUPFD_CLOEXEC, 3); /* Duplicate this with O_CLOEXEC set */
13✔
774
                        if (copy < 0) {
13✔
UNCOV
775
                                r = -errno;
×
UNCOV
776
                                goto finish;
×
777
                        }
778

779
                        close_and_replace(null_fd, copy);
13✔
780
                }
781
        }
782

783
        /* Let's assemble fd[] with the fds to install in place of stdin/stdout/stderr */
784
        for (int i = 0; i < 3; i++)
59,352✔
785
                if (fd[i] < 0)
44,514✔
786
                        fd[i] = null_fd;        /* A negative parameter means: connect this one to /dev/null */
12,545✔
787
                else if (fd[i] != i && fd[i] < 3) {
31,969✔
788
                        /* 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. */
789
                        copy_fd[i] = fcntl(fd[i], F_DUPFD_CLOEXEC, 3); /* Duplicate this with O_CLOEXEC set */
82✔
790
                        if (copy_fd[i] < 0) {
82✔
UNCOV
791
                                r = -errno;
×
UNCOV
792
                                goto finish;
×
793
                        }
794

795
                        fd[i] = copy_fd[i];
82✔
796
                }
797

798
        /* At this point we now have the fds to use in fd[], and they are all above the stdio range, so that
799
         * we have freedom to move them around. If the fds already were at the right places then the specific
800
         * fds are -EBADF. Let's now move them to the right places. This is the point of no return. */
801
        for (int i = 0; i < 3; i++)
59,352✔
802
                if (fd[i] == i) {
44,514✔
803
                        /* fd is already in place, but let's make sure O_CLOEXEC is off */
804
                        r = fd_cloexec(i, false);
4,792✔
805
                        if (r < 0)
4,792✔
UNCOV
806
                                goto finish;
×
807
                } else {
808
                        assert(fd[i] > 2);
39,722✔
809

810
                        if (dup2(fd[i], i) < 0) { /* Turns off O_CLOEXEC on the new fd. */
39,722✔
UNCOV
811
                                r = -errno;
×
UNCOV
812
                                goto finish;
×
813
                        }
814
                }
815

816
        r = 0;
817

818
finish:
14,838✔
819
        /* Close the original fds, but only if they were outside of the stdio range. Also, properly check for the same
820
         * fd passed in multiple times. */
821
        safe_close_above_stdio(original_input_fd);
14,838✔
822
        if (original_output_fd != original_input_fd)
14,838✔
823
                safe_close_above_stdio(original_output_fd);
14,597✔
824
        if (original_error_fd != original_input_fd && original_error_fd != original_output_fd)
14,838✔
825
                safe_close_above_stdio(original_error_fd);
14,425✔
826

827
        /* Close the copies we moved > 2 */
828
        close_many(copy_fd, 3);
14,838✔
829

830
        /* Close our null fd, if it's > 2 */
831
        safe_close_above_stdio(null_fd);
14,838✔
832

833
        return r;
14,838✔
834
}
835

836
int fd_reopen(int fd, int flags) {
1,496,202✔
837
        assert(fd >= 0 || fd == AT_FDCWD);
1,496,202✔
838
        assert(!FLAGS_SET(flags, O_CREAT));
1,496,202✔
839

840
        /* Reopens the specified fd with new flags. This is useful for convert an O_PATH fd into a regular one, or to
841
         * turn O_RDWR fds into O_RDONLY fds.
842
         *
843
         * This doesn't work on sockets (since they cannot be open()ed, ever).
844
         *
845
         * This implicitly resets the file read index to 0.
846
         *
847
         * If AT_FDCWD is specified as file descriptor gets an fd to the current cwd.
848
         *
849
         * If the specified file descriptor refers to a symlink via O_PATH, then this function cannot be used
850
         * to follow that symlink. Because we cannot have non-O_PATH fds to symlinks reopening it without
851
         * O_PATH will always result in -ELOOP. Or in other words: if you have an O_PATH fd to a symlink you
852
         * can reopen it only if you pass O_PATH again. */
853

854
        if (FLAGS_SET(flags, O_NOFOLLOW))
1,496,202✔
855
                /* O_NOFOLLOW is not allowed in fd_reopen(), because after all this is primarily implemented
856
                 * via a symlink-based interface in /proc/self/fd. Let's refuse this here early. Note that
857
                 * the kernel would generate ELOOP here too, hence this manual check is mostly redundant –
858
                 * the only reason we add it here is so that the O_DIRECTORY special case (see below) behaves
859
                 * the same way as the non-O_DIRECTORY case. */
860
                return -ELOOP;
1,496,202✔
861

862
        if (FLAGS_SET(flags, O_DIRECTORY) || fd == AT_FDCWD)
1,496,196✔
863
                /* If we shall reopen the fd as directory we can just go via "." and thus bypass the whole
864
                 * magic /proc/ directory, and make ourselves independent of that being mounted. */
865
                return RET_NERRNO(openat(fd, ".", flags | O_DIRECTORY));
250,768✔
866

867
        int new_fd = open(FORMAT_PROC_FD_PATH(fd), flags);
1,245,434✔
868
        if (new_fd < 0) {
1,245,434✔
869
                if (errno != ENOENT)
52,306✔
870
                        return -errno;
52,303✔
871

872
                return proc_fd_enoent_errno();
3✔
873
        }
874

875
        return new_fd;
876
}
877

878
int fd_reopen_propagate_append_and_position(int fd, int flags) {
28✔
879
        /* Invokes fd_reopen(fd, flags), but propagates O_APPEND if set on original fd, and also tries to
880
         * keep current file position.
881
         *
882
         * You should use this if the original fd potentially is O_APPEND, otherwise we get rather
883
         * "unexpected" behavior. Unless you intentionally want to overwrite pre-existing data, and have
884
         * your output overwritten by the next user.
885
         *
886
         * Use case: "systemd-run --pty >> some-log".
887
         *
888
         * The "keep position" part is obviously nonsense for the O_APPEND case, but should reduce surprises
889
         * if someone carefully pre-positioned the passed in original input or non-append output FDs. */
890

891
        assert(fd >= 0);
28✔
892
        assert(!(flags & (O_APPEND|O_DIRECTORY)));
28✔
893

894
        int existing_flags = fcntl(fd, F_GETFL);
28✔
895
        if (existing_flags < 0)
28✔
UNCOV
896
                return -errno;
×
897

898
        int new_fd = fd_reopen(fd, flags | (existing_flags & O_APPEND));
28✔
899
        if (new_fd < 0)
28✔
900
                return new_fd;
901

902
        /* Try to adjust the offset, but ignore errors. */
903
        off_t p = lseek(fd, 0, SEEK_CUR);
19✔
904
        if (p > 0) {
19✔
UNCOV
905
                off_t new_p = lseek(new_fd, p, SEEK_SET);
×
UNCOV
906
                if (new_p < 0)
×
UNCOV
907
                        log_debug_errno(errno,
×
908
                                        "Failed to propagate file position for re-opened fd %d, ignoring: %m",
909
                                        fd);
UNCOV
910
                else if (new_p != p)
×
UNCOV
911
                        log_debug("Failed to propagate file position for re-opened fd %d (%lld != %lld), ignoring.",
×
912
                                  fd, (long long) new_p, (long long) p);
913
        }
914

915
        return new_fd;
916
}
917

918
int fd_reopen_condition(
1,201,113✔
919
                int fd,
920
                int flags,
921
                int mask,
922
                int *ret_new_fd) {
923

924
        int r, new_fd;
1,201,113✔
925

926
        assert(fd >= 0);
1,201,113✔
927
        assert(!FLAGS_SET(flags, O_CREAT));
1,201,113✔
928

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

933
        r = fcntl(fd, F_GETFL);
1,201,113✔
934
        if (r < 0)
1,201,113✔
UNCOV
935
                return -errno;
×
936

937
        if ((r & mask) == (flags & mask)) {
1,201,113✔
938
                *ret_new_fd = -EBADF;
1,197,077✔
939
                return fd;
1,197,077✔
940
        }
941

942
        new_fd = fd_reopen(fd, flags);
4,036✔
943
        if (new_fd < 0)
4,036✔
944
                return new_fd;
945

946
        *ret_new_fd = new_fd;
4,036✔
947
        return new_fd;
4,036✔
948
}
949

950
int fd_is_opath(int fd) {
445,035✔
951
        int r;
445,035✔
952

953
        assert(fd >= 0);
445,035✔
954

955
        r = fcntl(fd, F_GETFL);
445,035✔
956
        if (r < 0)
445,035✔
UNCOV
957
                return -errno;
×
958

959
        return FLAGS_SET(r, O_PATH);
445,035✔
960
}
961

962
int fd_verify_safe_flags_full(int fd, int extra_flags) {
496✔
963
        int flags, unexpected_flags;
496✔
964

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

979
        assert(fd >= 0);
496✔
980

981
        flags = fcntl(fd, F_GETFL);
496✔
982
        if (flags < 0)
496✔
UNCOV
983
                return -errno;
×
984

985
        unexpected_flags = flags & ~(O_ACCMODE_STRICT|O_NOFOLLOW|RAW_O_LARGEFILE|extra_flags);
496✔
986
        if (unexpected_flags != 0)
496✔
UNCOV
987
                return log_debug_errno(SYNTHETIC_ERRNO(EREMOTEIO),
×
988
                                       "Unexpected flags set for extrinsic fd: 0%o",
989
                                       (unsigned) unexpected_flags);
990

991
        return flags & (O_ACCMODE_STRICT | extra_flags); /* return the flags variable, but remove the noise */
496✔
992
}
993

994
int read_nr_open(void) {
29,551✔
995
        _cleanup_free_ char *nr_open = NULL;
29,551✔
996
        int r;
29,551✔
997

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

1001
        r = read_one_line_file("/proc/sys/fs/nr_open", &nr_open);
29,551✔
1002
        if (r < 0)
29,551✔
1003
                log_debug_errno(r, "Failed to read /proc/sys/fs/nr_open, ignoring: %m");
29,551✔
1004
        else {
1005
                int v;
29,548✔
1006

1007
                r = safe_atoi(nr_open, &v);
29,548✔
1008
                if (r < 0)
29,548✔
UNCOV
1009
                        log_debug_errno(r, "Failed to parse /proc/sys/fs/nr_open value '%s', ignoring: %m", nr_open);
×
1010
                else
1011
                        return v;
29,548✔
1012
        }
1013

1014
        /* If we fail, fall back to the hard-coded kernel limit of 1024 * 1024. */
1015
        return 1024 * 1024;
1016
}
1017

1018
int fd_get_diskseq(int fd, uint64_t *ret) {
57,220✔
1019
        uint64_t diskseq;
57,220✔
1020

1021
        assert(fd >= 0);
57,220✔
1022
        assert(ret);
57,220✔
1023

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

1031
                return -EOPNOTSUPP;
1032
        }
1033

1034
        *ret = diskseq;
57,220✔
1035

1036
        return 0;
57,220✔
1037
}
1038

1039
int path_is_root_at(int dir_fd, const char *path) {
3,434,130✔
1040
        _cleanup_close_ int fd = -EBADF, pfd = -EBADF;
3,434,130✔
1041

1042
        assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
3,434,130✔
1043

1044
        if (!isempty(path)) {
3,434,130✔
1045
                fd = openat(dir_fd, path, O_PATH|O_DIRECTORY|O_CLOEXEC);
101,371✔
1046
                if (fd < 0)
101,371✔
1047
                        return errno == ENOTDIR ? false : -errno;
14,754✔
1048

1049
                dir_fd = fd;
1050
        }
1051

1052
        pfd = openat(dir_fd, "..", O_PATH|O_DIRECTORY|O_CLOEXEC);
3,419,376✔
1053
        if (pfd < 0)
3,419,376✔
1054
                return errno == ENOTDIR ? false : -errno;
2✔
1055

1056
        /* Even if the parent directory has the same inode, the fd may not point to the root directory "/",
1057
         * and we also need to check that the mount ids are the same. Otherwise, a construct like the
1058
         * following could be used to trick us:
1059
         *
1060
         * $ mkdir /tmp/x /tmp/x/y
1061
         * $ mount --bind /tmp/x /tmp/x/y
1062
         */
1063

1064
        return fds_are_same_mount(dir_fd, pfd);
3,419,374✔
1065
}
1066

1067
int fds_are_same_mount(int fd1, int fd2) {
3,419,392✔
1068
        struct statx sx1 = {}, sx2 = {}; /* explicitly initialize the struct to make msan silent. */
3,419,392✔
1069
        int r;
3,419,392✔
1070

1071
        assert(fd1 >= 0);
3,419,392✔
1072
        assert(fd2 >= 0);
3,419,392✔
1073

1074
        if (statx(fd1, "", AT_EMPTY_PATH, STATX_TYPE|STATX_INO|STATX_MNT_ID, &sx1) < 0)
3,419,392✔
UNCOV
1075
                return -errno;
×
1076

1077
        if (statx(fd2, "", AT_EMPTY_PATH, STATX_TYPE|STATX_INO|STATX_MNT_ID, &sx2) < 0)
3,419,392✔
UNCOV
1078
                return -errno;
×
1079

1080
        /* First, compare inode. If these are different, the fd does not point to the root directory "/". */
1081
        if (!statx_inode_same(&sx1, &sx2))
3,419,392✔
1082
                return false;
1083

1084
        /* Note, statx() does not provide the mount ID and path_get_mnt_id_at() does not work when an old
1085
         * kernel is used. In that case, let's assume that we do not have such spurious mount points in an
1086
         * early boot stage, and silently skip the following check. */
1087

1088
        if (!FLAGS_SET(sx1.stx_mask, STATX_MNT_ID)) {
3,163,353✔
UNCOV
1089
                int mntid;
×
1090

UNCOV
1091
                r = path_get_mnt_id_at_fallback(fd1, "", &mntid);
×
UNCOV
1092
                if (r < 0)
×
1093
                        return r;
×
UNCOV
1094
                assert(mntid >= 0);
×
1095

1096
                sx1.stx_mnt_id = mntid;
×
UNCOV
1097
                sx1.stx_mask |= STATX_MNT_ID;
×
1098
        }
1099

1100
        if (!FLAGS_SET(sx2.stx_mask, STATX_MNT_ID)) {
3,163,353✔
UNCOV
1101
                int mntid;
×
1102

UNCOV
1103
                r = path_get_mnt_id_at_fallback(fd2, "", &mntid);
×
UNCOV
1104
                if (r < 0)
×
UNCOV
1105
                        return r;
×
UNCOV
1106
                assert(mntid >= 0);
×
1107

UNCOV
1108
                sx2.stx_mnt_id = mntid;
×
1109
                sx2.stx_mask |= STATX_MNT_ID;
×
1110
        }
1111

1112
        return statx_mount_same(&sx1, &sx2);
3,163,353✔
1113
}
1114

1115
char* format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int fd) {
3,318,941✔
1116
        assert(buf);
3,318,941✔
1117
        assert(fd >= 0);
3,318,941✔
1118
        assert_se(snprintf_ok(buf, PROC_FD_PATH_MAX, "/proc/self/fd/%i", fd));
3,318,941✔
1119
        return buf;
3,318,941✔
1120
}
1121

1122
const char* accmode_to_string(int flags) {
176✔
1123
        switch (flags & O_ACCMODE_STRICT) {
176✔
1124
        case O_RDONLY:
1125
                return "ro";
1126
        case O_WRONLY:
3✔
1127
                return "wo";
3✔
1128
        case O_RDWR:
170✔
1129
                return "rw";
170✔
UNCOV
1130
        default:
×
UNCOV
1131
                return NULL;
×
1132
        }
1133
}
1134

1135
char* format_proc_pid_fd_path(char buf[static PROC_PID_FD_PATH_MAX], pid_t pid, int fd) {
1✔
1136
        assert(buf);
1✔
1137
        assert(fd >= 0);
1✔
1138
        assert(pid >= 0);
1✔
1139
        assert_se(snprintf_ok(buf, PROC_PID_FD_PATH_MAX, "/proc/" PID_FMT "/fd/%i", pid == 0 ? getpid_cached() : pid, fd));
1✔
1140
        return buf;
1✔
1141
}
1142

1143
int proc_fd_enoent_errno(void) {
7✔
1144
        int r;
7✔
1145

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

1150
        r = proc_mounted();
7✔
1151
        if (r == 0)
7✔
1152
                return -ENOSYS;  /* /proc/ is not available or not set up properly, we're most likely
1153
                                    in some chroot environment. */
1154
        if (r > 0)
7✔
1155
                return -EBADF;   /* If /proc/ is definitely around then this means the fd is not valid. */
7✔
1156

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