Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/pax/pax.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ main(int argc, char *argv[])
/*
* Keep a reference to cwd, so we can always come back home.
*/
cwdfd = open(".", O_RDONLY | O_CLOEXEC);
cwdfd = open(".", O_RDONLY | O_CLOEXEC | O_CLOFORK);
if (cwdfd < 0) {
syswarn(0, errno, "Can't open current working directory.");
return(exit_val);
Expand Down
2 changes: 1 addition & 1 deletion libexec/rtld-elf/libmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ lmc_parse_file(const char *path)
return;
}

fd = open(path, O_RDONLY | O_CLOEXEC);
fd = open(path, O_RDONLY | O_CLOFORK);
if (fd == -1) {
dbg("lm_parse_file: open(\"%s\") failed, %s", path,
rtld_strerror(errno));
Expand Down
14 changes: 7 additions & 7 deletions libexec/rtld-elf/rtld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ gethints(bool nostdlib)
/* Keep from trying again in case the hints file is bad. */
hints = "";

if ((fd = open(ld_elf_hints_path, O_RDONLY | O_CLOEXEC)) ==
if ((fd = open(ld_elf_hints_path, O_RDONLY | O_CLOFORK)) ==
-1) {
dbg("failed to open hints file \"%s\"",
ld_elf_hints_path);
Expand Down Expand Up @@ -2865,13 +2865,13 @@ load_object(const char *name, int fd_u, const Obj_Entry *refobj, int flags)
* To avoid a race, we open the file and use fstat() rather than
* using stat().
*/
if ((fd = open(path, O_RDONLY | O_CLOEXEC | O_VERIFY)) == -1) {
if ((fd = open(path, O_RDONLY | O_CLOFORK | O_VERIFY)) == -1) {
_rtld_error("Cannot open \"%s\"", path);
free(path);
return (NULL);
}
} else {
fd = fcntl(fd_u, F_DUPFD_CLOEXEC, 0);
fd = fcntl(fd_u, F_DUPFD_CLOFORK, 0);
if (fd == -1) {
_rtld_error("Cannot dup fd");
free(path);
Expand Down Expand Up @@ -3638,7 +3638,7 @@ try_library_path(const char *dir, size_t dirlen, void *param)
strcpy(pathname + dirlen + 1, arg->name);

dbg(" Trying \"%s\"", pathname);
fd = open(pathname, O_RDONLY | O_CLOEXEC | O_VERIFY);
fd = open(pathname, O_RDONLY | O_CLOFORK | O_VERIFY);
if (fd >= 0) {
dbg(" Opened \"%s\", fd %d", pathname, fd);
pathname = xmalloc(dirlen + 1 + arg->namelen + 1);
Expand Down Expand Up @@ -3722,7 +3722,7 @@ search_library_pathfds(const char *name, const char *path, int *fdp)
fdstr);
break;
}
fd = __sys_openat(dirfd, name, O_RDONLY | O_CLOEXEC | O_VERIFY);
fd = __sys_openat(dirfd, name, O_RDONLY | O_CLOFORK | O_VERIFY);
if (fd >= 0) {
*fdp = fd;
len = strlen(fdstr) + strlen(name) + 3;
Expand Down Expand Up @@ -6271,15 +6271,15 @@ open_binary_fd(const char *argv0, bool search_in_path, const char **binpath_res)
continue;
if (strlcat(binpath, argv0, PATH_MAX) >= PATH_MAX)
continue;
fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY);
fd = open(binpath, O_RDONLY | O_CLOFORK | O_VERIFY);
if (fd != -1 || errno != ENOENT) {
res = binpath;
break;
}
}
free(pathenv);
} else {
fd = open(argv0, O_RDONLY | O_CLOEXEC | O_VERIFY);
fd = open(argv0, O_RDONLY | O_CLOFORK | O_VERIFY);
res = argv0;
}

Expand Down
4 changes: 2 additions & 2 deletions share/man/man4/filemon.4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 19, 2025
.Dd January 24, 2026
.Dt FILEMON 4
.Os
.Sh NAME
Expand Down Expand Up @@ -205,7 +205,7 @@ open_filemon(void)
if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1)
err(1, "open(\e"/dev/filemon\e", O_RDWR)");
if ((fm_log = open("filemon.out",
O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, DEFFILEMODE)) == -1)
O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC | O_CLOFORK, DEFFILEMODE)) == -1)
err(1, "open(filemon.out)");

if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/script/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ main(int argc, char *argv[])
if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1)
err(1, "open(\"/dev/filemon\", O_RDWR)");
if ((fm_log = open(fmfname,
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC,
O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_CLOFORK,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1)
err(1, "open(%s)", fmfname);
if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) < 0)
Expand Down
2 changes: 1 addition & 1 deletion usr.bin/sort/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ get_random_seed(const char *random_source)
goto out;
}

rsfd = open(random_source, O_RDONLY | O_CLOEXEC);
rsfd = open(random_source, O_RDONLY | O_CLOEXEC | O_CLOFORK);
if (rsfd < 0)
err(EX_NOINPUT, "open: %s", random_source);

Expand Down
2 changes: 1 addition & 1 deletion usr.sbin/edquota/edquota.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ main(int argc, char *argv[])
freeprivs(protoprivs);
exit(0);
}
tmpfd = mkostemp(tmpfil, O_CLOEXEC);
tmpfd = mkostemp(tmpfil, O_CLOEXEC | O_CLOFORK);
fchown(tmpfd, getuid(), getgid());
if (tflag) {
if ((protoprivs = getprivs(0, quotatype, fspath)) != NULL) {
Expand Down
3 changes: 2 additions & 1 deletion usr.sbin/pw/pw.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ main(int argc, char *argv[])
--argc;
}
fd = open(optarg,
O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC,
O_WRONLY | O_APPEND | O_CREAT |
O_CLOEXEC | O_CLOFORK,
0644);
if (fd == -1)
errx(EX_OSERR,
Expand Down
3 changes: 2 additions & 1 deletion usr.sbin/pw/pw_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ create_and_populate_homedir(struct userconf *cnf, struct passwd *pwd,
if (skeldir != NULL && *skeldir != '\0') {
if (*skeldir == '/')
skeldir++;
skelfd = openat(conf.rootfd, skeldir, O_DIRECTORY|O_CLOEXEC);
skelfd = openat(conf.rootfd, skeldir,
O_DIRECTORY | O_CLOEXEC | O_CLOFORK);
}

copymkdir(conf.rootfd, pwd->pw_dir, skelfd, homemode, pwd->pw_uid,
Expand Down
Loading