git-commit-vandalism/Documentation/config
Carlo Marcelo Arenas Belón ae9abbb63e git-compat-util: avoid failing dir ownership checks if running privileged
bdc77d1d68 (Add a function to determine whether a path is owned by the
current user, 2022-03-02) checks for the effective uid of the running
process using geteuid() but didn't account for cases where that user was
root (because git was invoked through sudo or a compatible tool) and the
original uid that repository trusted for its config was no longer known,
therefore failing the following otherwise safe call:

  guy@renard ~/Software/uncrustify $ sudo git describe --always --dirty
  [sudo] password for guy:
  fatal: unsafe repository ('/home/guy/Software/uncrustify' is owned by someone else)

Attempt to detect those cases by using the environment variables that
those tools create to keep track of the original user id, and do the
ownership check using that instead.

This assumes the environment the user is running on after going
privileged can't be tampered with, and also adds code to restrict that
the new behavior only applies if running as root, therefore keeping the
most common case, which runs unprivileged, from changing, but because of
that, it will miss cases where sudo (or an equivalent) was used to change
to another unprivileged user or where the equivalent tool used to raise
privileges didn't track the original id in a sudo compatible way.

Because of compatibility with sudo, the code assumes that uid_t is an
unsigned integer type (which is not required by the standard) but is used
that way in their codebase to generate SUDO_UID.  In systems where uid_t
is signed, sudo might be also patched to NOT be unsigned and that might
be able to trigger an edge case and a bug (as described in the code), but
it is considered unlikely to happen and even if it does, the code would
just mostly fail safely, so there was no attempt either to detect it or
prevent it by the code, which is something that might change in the future,
based on expected user feedback.

Reported-by: Guy Maurel <guy.j@maurel.de>
Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Helped-by: Randall Becker <rsbecker@nexbridge.com>
Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Suggested-by: Johannes 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>
2022-05-12 18:12:23 -07:00
..
add.txt Start to implement a built-in version of git add --interactive 2019-11-14 11:10:04 +09:00
advice.txt t, doc: update tests, reference for "--force-if-includes" 2020-10-03 09:59:19 -07:00
alias.txt config/alias.txt: document alias accepting non-command first word 2019-06-06 09:33:42 -07:00
am.txt config.txt: move am.* to a separate file 2018-10-29 10:17:00 +09:00
apply.txt
blame.txt blame: add config options for the output of ignored or unblamable lines 2019-05-16 11:36:23 +09:00
branch.txt pull --rebase/remote rename: document and honor single-letter abbreviations rebase types 2020-02-10 10:52:10 -08:00
browser.txt
checkout.txt checkout: learn to respect checkout.guess 2020-10-08 09:25:29 -07:00
clean.txt
clone.txt clone: allow configurable default for -o/--origin 2020-09-30 22:09:13 -07:00
color.txt doc: fix repeated words 2019-08-11 17:40:07 -07:00
column.txt
commit.txt
commitgraph.txt commit-graph: introduce 'commitGraph.maxNewFilters' 2020-09-18 10:39:22 -07:00
completion.txt
core.txt Merge branch 'ds/maintenance-part-2' 2020-10-27 15:09:47 -07:00
credential.txt crendential-store: use timeout when locking file 2020-11-25 12:30:18 -08:00
diff.txt diff: add config option relative 2020-05-24 16:23:59 -07:00
difftool.txt
extensions.txt docs: add documentation for extensions.objectFormat 2020-07-30 09:16:49 -07:00
fastimport.txt
feature.txt protocol: re-enable v2 protocol by default 2020-09-25 11:40:42 -07:00
fetch.txt negotiator/noop: add noop fetch negotiator 2020-08-18 13:25:05 -07:00
filter.txt
fmt-merge-msg.txt config/fmt-merge-msg.txt: drop space in quote 2020-09-27 14:22:41 -07:00
format.txt Merge branch 'jc/format-patch-name-max' 2020-11-21 15:14:38 -08:00
fsck.txt config/fsck.txt: avoid starting line with dash 2019-03-07 09:25:32 +09:00
gc.txt gc docs: change --keep-base-pack to --keep-largest-pack 2020-11-21 11:39:55 -08:00
gitcvs.txt
gitweb.txt
gpg.txt gpg-interface: add minTrustLevel as a configuration option 2020-01-15 14:06:06 -08:00
grep.txt
gui.txt
guitool.txt
help.txt help.c: help.autocorrect=never means "do not compute suggestions" 2020-11-25 13:02:15 -08:00
http.txt doc: fix some typos 2021-01-04 11:27:48 -08:00
i18n.txt
imap.txt
index.txt repo-settings: create feature.manyFiles setting 2019-08-13 13:33:55 -07:00
init.txt clone: use configured default branch name when appropriate 2020-06-24 09:14:21 -07:00
instaweb.txt
interactive.txt checkout: split part of it to new command 'restore' 2019-05-07 13:04:47 +09:00
log.txt log: add log.excludeDecoration config option 2020-04-16 11:05:48 -07:00
mailinfo.txt
mailmap.txt
maintenance.txt maintenance: create maintenance.strategy config 2020-10-16 08:36:42 -07:00
man.txt
merge.txt merge: teach --autostash option 2020-04-10 09:28:02 -07:00
mergetool.txt mergetool: allow auto-merge for meld to follow the vim-diff behavior 2020-09-16 17:11:20 -07:00
notes.txt
pack.txt config: set pack.useSparse=true by default 2020-03-20 14:22:31 -07:00
pager.txt
pretty.txt
protocol.txt protocol: re-enable v2 protocol by default 2020-09-25 11:40:42 -07:00
pull.txt pull --rebase/remote rename: document and honor single-letter abbreviations rebase types 2020-02-10 10:52:10 -08:00
push.txt t, doc: update tests, reference for "--force-if-includes" 2020-10-03 09:59:19 -07:00
rebase.txt rebase: rename the two primary rebase backends 2020-02-16 15:40:42 -08:00
receive.txt receive-pack: new config receive.procReceiveRefs 2020-08-27 12:47:47 -07:00
remote.txt remote: add promisor and partial clone config to the doc 2019-06-25 14:05:38 -07:00
remotes.txt
repack.txt repack: enable bitmaps by default on bare repos 2019-03-18 14:09:54 +09:00
rerere.txt
reset.txt
safe.txt git-compat-util: avoid failing dir ownership checks if running privileged 2022-05-12 18:12:23 -07:00
sendemail.txt git-send-email: die if sendmail.* config is set 2020-07-23 18:00:34 -07:00
sequencer.txt
showbranch.txt
splitindex.txt
ssh.txt
stash.txt stash: remove the stash.useBuiltin setting 2020-03-05 12:50:28 -08:00
status.txt status: add status.aheadbehind setting 2019-06-21 09:35:00 -07:00
submodule.txt doc: explain how to deactivate submodule.recurse completely 2020-04-06 13:42:43 -07:00
tag.txt separate tar.* config to its own source file 2020-03-18 12:42:09 -07:00
tar.txt separate tar.* config to its own source file 2020-03-18 12:42:09 -07:00
trace2.txt doc: fix some typos 2021-01-04 11:27:48 -08:00
transfer.txt docs: new transfer.advertiseSID option 2020-11-11 18:26:52 -08:00
uploadarchive.txt
uploadpack.txt config/uploadpack.txt: fix typo in --filter=tree:<n> 2020-09-27 14:23:20 -07:00
url.txt
user.txt doc: provide guidance on user.name format 2020-01-22 12:27:08 -08:00
versionsort.txt
web.txt
worktree.txt