diff options
author | Carlo Marcelo Arenas Belón <carenas@gmail.com> | 2022-06-17 22:23:38 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-06-17 23:03:08 +0200 |
commit | 6b11e3d52e919cce91011f4f9025e6f4b61375f2 (patch) | |
tree | 54aeed97455b485cb22328e34d773e9794f10698 /git-compat-util.h | |
parent | t0034: add negative tests and allow git init to mostly work under sudo (diff) | |
download | git-6b11e3d52e919cce91011f4f9025e6f4b61375f2.tar.xz git-6b11e3d52e919cce91011f4f9025e6f4b61375f2.zip |
git-compat-util: allow root to access both SUDO_UID and root owned
Previous changes introduced a regression which will prevent root for
accessing repositories owned by thyself if using sudo because SUDO_UID
takes precedence.
Loosen that restriction by allowing root to access repositories owned
by both uid by default and without having to add a safe.directory
exception.
A previous workaround that was documented in the tests is no longer
needed so it has been removed together with its specially crafted
prerequisite.
Helped-by: Johanness Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index e7cbfa65c9..f505f817d5 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -447,7 +447,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; } |