commit - 6e6049bedc731142c42807f4db5b8447ed4f1b2d
commit + c530dc2326756e37023dbbdd885deff9c9dc7f33
blob - 0cc9e662fbf0e1f79d663932fbb770959945ac7a
blob + 2beec0b333c8f864cac68acb81ef75faa133b416
--- got/got.c
+++ got/got.c
static const struct got_error *
apply_unveil(const char *repo_path, int repo_read_only,
- const char *worktree_path, int create_worktree)
+ const char *worktree_path)
{
const struct got_error *err;
if (unveil("gmon.out", "rwc") != 0)
return got_error_from_errno2("unveil", "gmon.out");
#endif
- if (create_worktree) {
- /* Pre-create work tree path to avoid unveiling its parents. */
- err = got_path_mkdir(worktree_path);
-
- if (errno == EEXIST) {
- if (got_path_dir_is_empty(worktree_path)) {
- errno = 0;
- err = NULL;
- } else {
- err = got_error_path(worktree_path,
- GOT_ERR_DIR_NOT_EMPTY);
- }
- }
-
- if (err && (err->code != GOT_ERR_ERRNO || errno != EISDIR))
- return err;
- }
-
if (repo_path && unveil(repo_path, repo_read_only ? "r" : "rwc") != 0)
return got_error_from_errno2("unveil", repo_path);
!(error->code == GOT_ERR_ERRNO && errno == EEXIST))
goto done;
- error = apply_unveil(repo_path, 0, NULL, 0);
+ error = apply_unveil(repo_path, 0, NULL);
if (error)
goto done;
if (unveil(path_dir, "r") != 0)
return got_error_from_errno2("unveil", path_dir);
- error = apply_unveil(got_repo_get_path(repo), 0, NULL, 0);
+ error = apply_unveil(got_repo_get_path(repo), 0, NULL);
if (error)
goto done;
if (error != NULL)
goto done;
- error = apply_unveil(got_repo_get_path(repo), 0, worktree_path, 1);
+ /* Pre-create work tree path for unveil(2) */
+ error = got_path_mkdir(worktree_path);
+ if (error) {
+ if (!(error->code == GOT_ERR_ERRNO && errno == EISDIR))
+ goto done;
+ if (!got_path_dir_is_empty(worktree_path)) {
+ error = got_error_path(worktree_path,
+ GOT_ERR_DIR_NOT_EMPTY);
+ goto done;
+ }
+ }
+
+ error = apply_unveil(got_repo_get_path(repo), 0, worktree_path);
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 0,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 1,
- worktree ? got_worktree_get_root_path(worktree) : NULL, 0);
+ worktree ? got_worktree_get_root_path(worktree) : NULL);
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 1,
- worktree ? got_worktree_get_root_path(worktree) : NULL, 0);
+ worktree ? got_worktree_get_root_path(worktree) : NULL);
if (error)
goto done;
if (error != NULL)
goto done;
- error = apply_unveil(got_repo_get_path(repo), 1, NULL, 0);
+ error = apply_unveil(got_repo_get_path(repo), 1, NULL);
if (error)
goto done;
if (error != NULL)
goto done;
- error = apply_unveil(got_repo_get_path(repo), 1, NULL, 0);
+ error = apply_unveil(got_repo_get_path(repo), 1, NULL);
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 1,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), do_list,
- worktree ? got_worktree_get_root_path(worktree) : NULL, 0);
+ worktree ? got_worktree_get_root_path(worktree) : NULL);
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), do_list,
- worktree ? got_worktree_get_root_path(worktree) : NULL, 0);
+ worktree ? got_worktree_get_root_path(worktree) : NULL);
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 1,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 1,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 1,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
/* Editor is done; we can now apply unveil(2) */
if (err == NULL) {
- err = apply_unveil(a->repo_path, 0, a->worktree_path, 0);
+ err = apply_unveil(a->repo_path, 0, a->worktree_path);
if (err) {
free(*logmsg);
*logmsg = NULL;
error = get_editor(&editor);
else
error = apply_unveil(got_repo_get_path(repo), 0,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 0,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 0,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
goto done;
error = apply_unveil(got_repo_get_path(repo), 0,
- got_worktree_get_root_path(worktree), 0);
+ got_worktree_get_root_path(worktree));
if (error)
goto done;