commit - 063406214771fb1483c7582bc7bd45f5d6b26c48
commit + fc63f50d9b54fdd7a892d5a770542bdb07fb05d1
blob - 74fe659e70bb073b8f4a4b266a409395c5b01931
blob + 722952754253ee0d9a9c6c0f8631e3877a540634
--- got/got.c
+++ got/got.c
}
if (dirfd != -1) {
- fd = openat(dirfd, de_name, O_RDONLY | O_NOFOLLOW);
+ fd = openat(dirfd, de_name,
+ O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
if (!got_err_open_nofollow_on_symlink()) {
err = got_error_from_errno2("openat",
blob - c1f88d0af838f822b1b8acf17870ecafaf1755c0
blob + 09594d5d6583729be1e8a986168dd0e06386ada4
--- lib/fileindex.c
+++ lib/fileindex.c
}
subdirfd = openat(fd, de->d_name,
- O_RDONLY | O_NOFOLLOW | O_DIRECTORY);
+ O_RDONLY | O_NOFOLLOW | O_DIRECTORY | O_CLOEXEC);
if (subdirfd == -1) {
if (errno == EACCES) {
*next = TAILQ_NEXT(dle, entry);
blob - f329f0ce1b044f1a4e9d126d1601c61dcec503cf
blob + 2d85d99def0e84249e38b3f4724dd5e35e1a18a9
--- lib/lockfile.c
+++ lib/lockfile.c
do {
if (dir_fd != -1) {
(*lf)->fd = openat(dir_fd, (*lf)->path,
- O_RDONLY | O_CREAT | O_EXCL | O_EXLOCK,
+ O_RDONLY | O_CREAT | O_EXCL | O_EXLOCK | O_CLOEXEC,
GOT_DEFAULT_FILE_MODE);
} else {
(*lf)->fd = open((*lf)->path,
blob - 0dd65c8a831a778b1fb0333b3c7f20b4b0700e43
blob + 3ba7b56d06178ad4108d482597b641ac537cdd0a
--- lib/pack.c
+++ lib/pack.c
goto done;
}
- p->fd = openat(dir_fd, relpath, O_RDONLY | O_NOFOLLOW);
+ p->fd = openat(dir_fd, relpath, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (p->fd == -1) {
err = got_error_from_errno2("openat", relpath);
free(p);
blob - 1a48cc6fbe11cca415c2f0cf8bec78db23888941
blob + 0abbba735fa136834bb9dca379d704cb0cd1fb6c
--- lib/repository.c
+++ lib/repository.c
/* No luck. Search the filesystem. */
packdir_fd = openat(got_repo_get_fd(repo),
- GOT_OBJECTS_PACK_DIR, O_DIRECTORY);
+ GOT_OBJECTS_PACK_DIR, O_DIRECTORY | O_CLOEXEC);
if (packdir_fd == -1) {
if (errno == ENOENT)
err = got_error_no_obj(id);
{
const struct got_error *err = NULL;
- *fd = openat(got_repo_get_fd(repo), relpath, O_RDONLY | O_NOFOLLOW);
+ *fd = openat(got_repo_get_fd(repo), relpath,
+ O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (*fd == -1)
return got_error_from_errno_fmt("openat: %s/%s",
got_repo_get_path_git_dir(repo), relpath);
STAILQ_INIT(&matched_ids);
packdir_fd = openat(got_repo_get_fd(repo),
- GOT_OBJECTS_PACK_DIR, O_DIRECTORY);
+ GOT_OBJECTS_PACK_DIR, O_DIRECTORY | O_CLOEXEC);
if (packdir_fd == -1) {
if (errno != ENOENT)
err = got_error_from_errno2("openat", GOT_OBJECTS_PACK_DIR);
blob - 6b3999173b914646a3f1c15bceeafb2cb21db292
blob + 739ff3d01b9b761e9af99eed1c1ef1141465eb90
--- lib/repository_admin.c
+++ lib/repository_admin.c
struct stat sb;
packdir_fd = openat(got_repo_get_fd(repo),
- GOT_OBJECTS_PACK_DIR, O_DIRECTORY);
+ GOT_OBJECTS_PACK_DIR, O_DIRECTORY | O_CLOEXEC);
if (packdir_fd == -1) {
if (errno == ENOENT)
return NULL;
blob - 2dcfd9925316591111540d22e46e18eda34a0249
blob + 393ab8001b98f2af8c123775d21fc1512d6c3b7e
--- lib/worktree.c
+++ lib/worktree.c
}
if (dirfd != -1) {
- fd = openat(dirfd, de_name, O_RDONLY | O_NOFOLLOW);
+ fd = openat(dirfd, de_name, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
err = got_error_from_errno2("openat", abspath);
goto done;
return got_error_from_errno("asprintf");
if (dirfd != -1) {
- fd = openat(dirfd, ignores_filename, O_RDONLY | O_NOFOLLOW);
+ fd = openat(dirfd, ignores_filename,
+ O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd == -1) {
if (errno != ENOENT && errno != EACCES)
err = got_error_from_errno2("openat",
return err;
if (dirfd2 != -1) {
- fd2 = openat(dirfd2, de_name2, O_RDONLY | O_NOFOLLOW);
+ fd2 = openat(dirfd2, de_name2,
+ O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd2 == -1) {
if (!got_err_open_nofollow_on_symlink()) {
err = got_error_from_errno2("openat", path2);