Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-18 03:12:31 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-18 03:12:31 +0300
commit694c0cc0fb531b17750ac6e81920054f193f8eb8 (patch)
treefad0a4206959b893d567b876d64efa39ba032861 /git-compat-util.h
parentb4eda05d58ca3e4808d3d86ab5826c77995a06f7 (diff)
parent6b11e3d52e919cce91011f4f9025e6f4b61375f2 (diff)
Merge branch 'cb/path-owner-check-with-sudo-plus'
"sudo git foo" used to consider a repository owned by the original user a safe one to access; it now also considers a repository owned by root a safe one, too (after all, if an attacker can craft a malicious repository owned by root, the box is 0wned already). * cb/path-owner-check-with-sudo-plus: git-compat-util: allow root to access both SUDO_UID and root owned
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index fd36d3bfdc..58d7708296 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -497,7 +497,12 @@ static inline int is_path_owned_by_current_uid(const char *path)
euid = geteuid();
if (euid == ROOT_UID)
- extract_id_from_env("SUDO_UID", &euid);
+ {
+ if (st.st_uid == ROOT_UID)
+ return 1;
+ else
+ extract_id_from_env("SUDO_UID", &euid);
+ }
return st.st_uid == euid;
}