6b11e3d52e
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>
43 lines
2.2 KiB
Plaintext
43 lines
2.2 KiB
Plaintext
safe.directory::
|
|
These config entries specify Git-tracked directories that are
|
|
considered safe even if they are owned by someone other than the
|
|
current user. By default, Git will refuse to even parse a Git
|
|
config of a repository owned by someone else, let alone run its
|
|
hooks, and this config setting allows users to specify exceptions,
|
|
e.g. for intentionally shared repositories (see the `--shared`
|
|
option in linkgit:git-init[1]).
|
|
+
|
|
This is a multi-valued setting, i.e. you can add more than one directory
|
|
via `git config --add`. To reset the list of safe directories (e.g. to
|
|
override any such directories specified in the system config), add a
|
|
`safe.directory` entry with an empty value.
|
|
+
|
|
This config setting is only respected when specified in a system or global
|
|
config, not when it is specified in a repository config or via the command
|
|
line option `-c safe.directory=<path>`.
|
|
+
|
|
The value of this setting is interpolated, i.e. `~/<path>` expands to a
|
|
path relative to the home directory and `%(prefix)/<path>` expands to a
|
|
path relative to Git's (runtime) prefix.
|
|
+
|
|
To completely opt-out of this security check, set `safe.directory` to the
|
|
string `*`. This will allow all repositories to be treated as if their
|
|
directory was listed in the `safe.directory` list. If `safe.directory=*`
|
|
is set in system config and you want to re-enable this protection, then
|
|
initialize your list with an empty value before listing the repositories
|
|
that you deem safe.
|
|
+
|
|
As explained, Git only allows you to access repositories owned by
|
|
yourself, i.e. the user who is running Git, by default. When Git
|
|
is running as 'root' in a non Windows platform that provides sudo,
|
|
however, git checks the SUDO_UID environment variable that sudo creates
|
|
and will allow access to the uid recorded as its value in addition to
|
|
the id from 'root'.
|
|
This is to make it easy to perform a common sequence during installation
|
|
"make && sudo make install". A git process running under 'sudo' runs as
|
|
'root' but the 'sudo' command exports the environment variable to record
|
|
which id the original user has.
|
|
If that is not what you would prefer and want git to only trust
|
|
repositories that are owned by root instead, then you can remove
|
|
the `SUDO_UID` variable from root's environment before invoking git.
|