summaryrefslogtreecommitdiff
path: root/src/libgit2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2022-07-05 23:47:15 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2022-07-12 14:12:48 -0400
commited24b8bacc739b072a789ca7396e46bd751ca2ec (patch)
tree4faad93c0dd9f8e0e14d0a111b3229456b2b2176 /src/libgit2
parentaf9e00321f06383ccf61f4ca9616716bec0eb2da (diff)
downloadlibgit2-ed24b8bacc739b072a789ca7396e46bd751ca2ec.tar.gz
repo: allow users running with sudo to access their repositories
In the ownership checks implemented for CVE-2022-24765, we disallowed users to access their own repositories when running with `sudo`. Examine the `SUDO_UID` environment variable and allow users running with `sudo`. This matches git's behavior.
Diffstat (limited to 'src/libgit2')
-rw-r--r--src/libgit2/repository.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c
index 17aec00df..f761b5f32 100644
--- a/src/libgit2/repository.c
+++ b/src/libgit2/repository.c
@@ -531,7 +531,8 @@ static int validate_ownership_path(bool *is_safe, const char *path)
{
git_fs_path_owner_t owner_level =
GIT_FS_PATH_OWNER_CURRENT_USER |
- GIT_FS_PATH_USER_IS_ADMINISTRATOR;
+ GIT_FS_PATH_USER_IS_ADMINISTRATOR |
+ GIT_FS_PATH_OWNER_RUNNING_SUDO;
int error = 0;
if (path)