git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] setup: support GIT_IGNORE_INSECURE_OWNER environment variable

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jun 26, 2024, 13:11 UTC
Message-ID
<9e5b0cc6-e28c-4c51-ab48-663c61c00ee3@gmail.com>
In-Reply-To
<20240626123358.420292-2-flo@geekplace.eu>
Hi Florian
On 26/06/2024 13:33, Florian Schmaus wrote:
Show 9 quoted lines
> Sometimes more flexibility to disable/ignore the ownership check, besides
> the safe.directory configuration option, is required.
> 
> For example, git-daemon running as nobody user, which typically has no
> home directory. Therefore, we can not add the path to a user-global
> configuration and adding the path to the system-wide configuration could
> have negative security implications.
> 
> Therefore, make the check configurable via an environment variable.

An alternative would be to allow safe.directory to be specified on the command line with "git -c safe.directory='*' daemon ..." rather than adding a dedicated environment variable. Or you could set $HOME to a suitable directory when running "git daemon" and put the user-global config file there. That directory and config file only need to be readable by the user that "git daemon" is running under it can be owned by root or whoever else you want.

Best Wishes
Phillip
Show 28 quoted lines
> If the environment variable GIT_IGNORE_INSECURE_OWNER is set to true,
> then ignore potentially insecure ownership of git-related path
> components.
> 
> Signed-off-by: Florian Schmaus <flo@geekplace.eu>
> ---
>   setup.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/setup.c b/setup.c
> index 3afa6fb09b28..da3f504fb536 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -1278,6 +1278,14 @@ static int ensure_valid_ownership(const char *gitfile,
>   	 */
>   	git_protected_config(safe_directory_cb, &data);
>   
> +	if (data.is_safe)
> +		return data.is_safe;
> +
> +	if (git_env_bool("GIT_IGNORE_INSECURE_OWNER", 0)) {
> +		warning("ignoring dubious ownership in repository at '%s' (GIT_IGNORE_INSECURE_OWNER set)", data.path);
> +		return 1;
> +	}
> +
>   	return data.is_safe;
>   }
>   
Previous: Florian SchmausNext: rsbecker@nexbridge.com
Message 3 of 20 in “support GIT_IGNORE_INSECURE_OWNER environment variable”
  1. 0/1 support GIT_IGNORE_INSECURE_OWNER environment variableFlorian Schmaus, Jun 26, 2024
  2. setup: support GIT_IGNORE_INSECURE_OWNER environment variableFlorian Schmaus, Jun 26, 2024
  3. Phillip WoodJun 26, 2024
  4. rsbecker@nexbridge.comJun 26, 2024
  5. phillip.wood123@gmail.comJun 26, 2024
  6. Phillip WoodJun 26, 2024
  7. Junio C HamanoJun 26, 2024
  8. Florian SchmausJun 26, 2024
  9. Jeff KingJun 26, 2024
  10. Phillip WoodJun 27, 2024
  11. Junio C HamanoJun 27, 2024
  12. Phillip WoodJun 28, 2024
  13. Junio C HamanoJun 28, 2024
  14. Phillip WoodJul 1, 2024
  15. Junio C HamanoJul 1, 2024
  16. Johannes SchindelinJul 1, 2024
  17. Jeff KingJul 1, 2024
  18. Junio C HamanoJul 1, 2024
  19. Jeff KingJul 1, 2024
  20. Eric WongJul 2, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.