aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJitendra Bhati <bhatijitendra2022@gmail.com>2026-06-12 17:07:55 +0000
committerAlan Somers <asomers@FreeBSD.org>2026-06-23 14:53:56 +0000
commite03ed9daeb49fffa1d16b8d00240c65e92650d01 (patch)
tree839c90129886abd9bfc9dd27eaba7a55aeb661f3 /include
parent4c419570024951ad1e477c8d6c3d9968199faf4a (diff)
fts: refactor to use fd-relative operations internally
Replace all _open() calls with _openat() in __fts_open(), fts_read(), and fts_children(). Add fts_dirfd to FTSENT. Callers can use openat(ent->fts_dirfd, ent->fts_name, ...) to access files safely without relying on fts_accpath, which enables: 1. Capsicum capability mode where path-based operations fail 2. Security-sensitive programs that avoid TOCTOU races Replace statfs(ent->fts_path) with _fstatfs(ent->fts_dirfd) in fts_ufslinks() when fts_dirfd is valid, falling back to statfs() for root-level entries where fts_dirfd is -1 This is a preparatory change for fts_openat() which will allow callers to provide a pre-opened directory fd, enabling fts(3) traversal inside Capsicum capability mode. Sponsored by: Google LLC (GSoC 2026) Reviewed by: asomers, jillest MFC after: 2 weeks Pull Request: https://github.com/freebsd/freebsd-src/pull/2278
Diffstat (limited to 'include')
-rw-r--r--include/fts.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/fts.h b/include/fts.h
index 479905bda463..716103189dca 100644
--- a/include/fts.h
+++ b/include/fts.h
@@ -133,6 +133,7 @@ struct _ftsent {
struct stat *fts_statp; /* stat(2) information */
char *fts_name; /* file name */
FTS *fts_fts; /* back pointer to main FTS */
+ int fts_dirfd; /* fd for parent directory */
};
#include <sys/cdefs.h>