Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b45219f
Implement custom thread local storage for user of library
implausible Mar 29, 2021
7a76a33
checkout: cleanup duplication in checkout_create_the_new
implausible Aug 12, 2020
07493cc
thread checkout: move checkout buffers to tls
implausible Mar 29, 2021
e1a1eaa
thread checkout: add locks around shared state
implausible Aug 12, 2020
dc4e588
thread checkout: add locks around non thread-safe actions
implausible Apr 9, 2021
0739689
thread checkout: stub indirection for threading
implausible Aug 12, 2020
27f3c80
thread checkout: add threading to checkout_create_the_new
implausible Mar 29, 2021
37caa8d
meta: show build status for v1.3 branch
ethomson Feb 26, 2022
6b12762
online: test with https instead of git protocol
ethomson Jan 11, 2022
670415a
clone: update bitbucket tests
ethomson Mar 23, 2022
973d959
path: refactor ownership checks into current user and system
ethomson Apr 10, 2022
62d492d
repo: ensure that repo dir is owned by current user
ethomson Apr 11, 2022
e4eabb0
fs_path: mock ownership checks
ethomson Apr 12, 2022
caee92e
repo: test configuration ownership validation
ethomson Apr 11, 2022
f683806
repo: refactor global config loader function
ethomson Apr 11, 2022
eb8c3e5
repo: honor safe.directory during ownership checks
ethomson Apr 11, 2022
b58e905
repo: make ownership checks optional
ethomson Apr 12, 2022
a9eac6a
Merge pull request #6268 from libgit2/ethomson/ownership_13
ethomson Apr 12, 2022
1f39aac
meta: update version numbers for v1.3.1
ethomson Apr 12, 2022
23c24f8
meta: changelog for v1.3.1
ethomson Apr 12, 2022
1f5e7f9
Merge pull request #6271 from libgit2/ethomson/v1.3.1
ethomson Apr 12, 2022
6da6a10
Merge remote-tracking branch 'zawata/feature/custom-tls-for-external-…
zawata Apr 13, 2022
30d5c08
Merge remote-tracking branch 'zawata/multithread/checkout_create_the_…
zawata Apr 13, 2022
4b193b1
New checkout option: disabled_filters
julianmesa-gitkraken May 6, 2022
fe44f25
Merge branch 'disabled-filters-checkout' into libgit-next
ianhattendorf May 7, 2022
e78ee33
Fix degraded performance using GIT_USE_NSEC on repos cloned with GIT_…
julianmesa-gitkraken May 18, 2022
013d416
Merge pull request #7 from julianmesa-gitkraken/fix-nanoseconds-on-no…
ianhattendorf May 18, 2022
3ad710a
Fix the GIT_USE_NSEC performance fix
julianmesa-gitkraken May 26, 2022
4c98283
Merge pull request #8 from julianmesa-gitkraken/fix-nsecs-fix
ianhattendorf May 26, 2022
8254d2e
Do not add the .gitignore file if it not existing
julianmesa-gitkraken Jun 20, 2022
45f0e26
iterator: don't stat directories
julianmesa-gitkraken Jun 20, 2022
a4c112d
path: use fstatat instead of lstat
julianmesa-gitkraken Jun 20, 2022
110e29c
iterator: replace O(N) skip-to-start with O(log N)
julianmesa-gitkraken Jun 20, 2022
8bbbfab
push ignore frames lazily
julianmesa-gitkraken Jun 20, 2022
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
Prev Previous commit
Next Next commit
repo: make ownership checks optional
Introduce the `GIT_OPT_SET_OWNER_VALIDATION` option, so that users can
disable repository ownership validation.
  • Loading branch information
ethomson committed Apr 12, 2022
commit b58e9053b43f8487b1bf523b2259f76cb868105d
12 changes: 11 additions & 1 deletion include/git2/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ typedef enum {
GIT_OPT_SET_ODB_PACKED_PRIORITY,
GIT_OPT_SET_ODB_LOOSE_PRIORITY,
GIT_OPT_GET_EXTENSIONS,
GIT_OPT_SET_EXTENSIONS
GIT_OPT_SET_EXTENSIONS,
GIT_OPT_GET_OWNER_VALIDATION,
GIT_OPT_SET_OWNER_VALIDATION
} git_libgit2_opt_t;

/**
Expand Down Expand Up @@ -449,6 +451,14 @@ typedef enum {
* > to support repositories with the `noop` extension but does want
* > to support repositories with the `newext` extension.
*
* opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
* > Gets the owner validation setting for repository
* > directories.
*
* opts(GIT_OPT_SET_OWNER_VALIDATION, int enabled)
* > Set that repository directories should be owned by the current
* > user. The default is to validate ownership.
*
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
Expand Down
8 changes: 8 additions & 0 deletions src/libgit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ int git_libgit2_opts(int key, ...)
}
break;

case GIT_OPT_GET_OWNER_VALIDATION:
*(va_arg(ap, int *)) = git_repository__validate_ownership;
break;

case GIT_OPT_SET_OWNER_VALIDATION:
git_repository__validate_ownership = (va_arg(ap, int) != 0);
break;

default:
git_error_set(GIT_ERROR_INVALID, "invalid option key");
error = -1;
Expand Down
4 changes: 3 additions & 1 deletion src/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# include "win32/w32_util.h"
#endif

bool git_repository__validate_ownership = true;
bool git_repository__fsync_gitdir = false;

static const struct {
Expand Down Expand Up @@ -976,7 +977,8 @@ int git_repository_open_ext(
*/
validation_path = repo->is_bare ? repo->gitdir : repo->workdir;

if ((error = validate_ownership(validation_path)) < 0)
if (git_repository__validate_ownership &&
(error = validate_ownership(validation_path)) < 0)
goto cleanup;

cleanup:
Expand Down
1 change: 1 addition & 0 deletions src/repository.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define GIT_DIR_SHORTNAME "GIT~1"

extern bool git_repository__fsync_gitdir;
extern bool git_repository__validate_ownership;

/** Cvar cache identifiers */
typedef enum {
Expand Down
5 changes: 5 additions & 0 deletions tests/clar_libgit2.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ void cl_sandbox_set_search_path_defaults(void)
git_buf_dispose(&path);
}

void cl_sandbox_disable_ownership_validation(void)
{
git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 0);
}

#ifdef GIT_WIN32
bool cl_sandbox_supports_8dot3(void)
{
Expand Down
1 change: 1 addition & 0 deletions tests/clar_libgit2.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void cl_fake_home(void);
void cl_fake_home_cleanup(void *);

void cl_sandbox_set_search_path_defaults(void);
void cl_sandbox_disable_ownership_validation(void);

#ifdef GIT_WIN32
# define cl_msleep(x) Sleep(x)
Expand Down
1 change: 1 addition & 0 deletions tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ int main(int argc, char *argv[])

cl_global_trace_register();
cl_sandbox_set_search_path_defaults();
cl_sandbox_disable_ownership_validation();

/* Run the test suite */
res = clar_test_run();
Expand Down
10 changes: 10 additions & 0 deletions tests/repo/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#include "sysdir.h"
#include <ctype.h>

static int validate_ownership = 0;
static git_buf config_path = GIT_BUF_INIT;

void test_repo_open__initialize(void)
{
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, &config_path));
cl_git_pass(git_libgit2_opts(GIT_OPT_GET_OWNER_VALIDATION, &validate_ownership));
}

void test_repo_open__cleanup(void)
Expand All @@ -23,6 +25,8 @@ void test_repo_open__cleanup(void)

cl_git_pass(git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL, config_path.ptr));
git_buf_dispose(&config_path);

cl_git_pass(git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, validate_ownership));
}

void test_repo_open__bare_empty_repo(void)
Expand Down Expand Up @@ -470,6 +474,8 @@ void test_repo_open__validates_dir_ownership(void)
{
git_repository *repo;

cl_git_pass(git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 1));

cl_fixture_sandbox("empty_standard_repo");
cl_git_pass(cl_rename("empty_standard_repo/.gitted", "empty_standard_repo/.git"));

Expand All @@ -494,6 +500,8 @@ void test_repo_open__can_allowlist_dirs_with_problematic_ownership(void)
config_filename = GIT_BUF_INIT,
config_data = GIT_BUF_INIT;

cl_git_pass(git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 1));

cl_fixture_sandbox("empty_standard_repo");
cl_git_pass(cl_rename("empty_standard_repo/.gitted", "empty_standard_repo/.git"));

Expand Down Expand Up @@ -537,6 +545,8 @@ void test_repo_open__can_reset_safe_directory_list(void)
config_filename = GIT_BUF_INIT,
config_data = GIT_BUF_INIT;

cl_git_pass(git_libgit2_opts(GIT_OPT_SET_OWNER_VALIDATION, 1));

cl_fixture_sandbox("empty_standard_repo");
cl_git_pass(cl_rename("empty_standard_repo/.gitted", "empty_standard_repo/.git"));

Expand Down