diff mbox series

fetch2/git: Sanitize git configuration

Message ID 20240709182057.141231-2-wavexx@thregr.org
State New
Headers show
Series fetch2/git: Sanitize git configuration | expand

Commit Message

Yuri D'Elia July 9, 2024, 6:20 p.m. UTC
Prevent loading the local and system configuration by default.

This prevents clone from failing if, for example, the user has set a
different clone.defaultRemoteName (which git still honours from the HOME
directory) whereas the fetcher expects the default remote to be
"origin".

Instead of overriding unsafe values (which might break unexpectedly),
always start with a stock config.
---
 lib/bb/fetch2/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Kanavin July 9, 2024, 6:26 p.m. UTC | #1
Sorry, no. We explicitly allow git to use the system and user
configuration, and there are use cases where it's the only way to make
it work in certain environments.

Alex

On Tue, 9 Jul 2024 at 20:21, Yuri D'Elia via lists.openembedded.org
<wavexx=thregr.org@lists.openembedded.org> wrote:
>
> Prevent loading the local and system configuration by default.
>
> This prevents clone from failing if, for example, the user has set a
> different clone.defaultRemoteName (which git still honours from the HOME
> directory) whereas the fetcher expects the default remote to be
> "origin".
>
> Instead of overriding unsafe values (which might break unexpectedly),
> always start with a stock config.
> ---
>  lib/bb/fetch2/git.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index c7ff769fd..1ea000b3a 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -262,7 +262,7 @@ class Git(FetchMethod):
>              for name in ud.names:
>                  ud.unresolvedrev[name] = 'HEAD'
>
> -        ud.basecmd = d.getVar("FETCHCMD_git") or "git -c gc.autoDetach=false -c core.pager=cat -c safe.bareRepository=all"
> +        ud.basecmd = d.getVar("FETCHCMD_git") or "GIT_CONFIG_GLOBAL=/dev/null git -c gc.autoDetach=false -c core.pager=cat -c safe.bareRepository=all"
>
>          write_tarballs = d.getVar("BB_GENERATE_MIRROR_TARBALLS") or "0"
>          ud.write_tarballs = write_tarballs != "0" or ud.rebaseable
> --
> 2.45.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#16409): https://lists.openembedded.org/g/bitbake-devel/message/16409
> Mute This Topic: https://lists.openembedded.org/mt/107127802/1686489
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Yuri D'Elia July 9, 2024, 6:54 p.m. UTC | #2
On Tue, Jul 09 2024, Alexander Kanavin wrote:
> Sorry, no. We explicitly allow git to use the system and user
> configuration, and there are use cases where it's the only way to make
> it work in certain environments.

I'm new to bitbake. I see why, although this seems a departure from the
explicitly-allowed list of settings passing through the build.

Seems like we explicitly need to set defaultRemoteName then.

Would that be acceptable?
Alexander Kanavin July 9, 2024, 7:08 p.m. UTC | #3
On Tue, 9 Jul 2024 at 21:00, Yuri D'Elia via lists.openembedded.org
<wavexx=thregr.org@lists.openembedded.org> wrote:
> I'm new to bitbake. I see why, although this seems a departure from the
> explicitly-allowed list of settings passing through the build.
>
> Seems like we explicitly need to set defaultRemoteName then.
>
> Would that be acceptable?

I think so. There are indeed numerous places where the fetcher code
assumes the remote name is 'origin' so we need to enforce that.

Alex
diff mbox series

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index c7ff769fd..1ea000b3a 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -262,7 +262,7 @@  class Git(FetchMethod):
             for name in ud.names:
                 ud.unresolvedrev[name] = 'HEAD'
 
-        ud.basecmd = d.getVar("FETCHCMD_git") or "git -c gc.autoDetach=false -c core.pager=cat -c safe.bareRepository=all"
+        ud.basecmd = d.getVar("FETCHCMD_git") or "GIT_CONFIG_GLOBAL=/dev/null git -c gc.autoDetach=false -c core.pager=cat -c safe.bareRepository=all"
 
         write_tarballs = d.getVar("BB_GENERATE_MIRROR_TARBALLS") or "0"
         ud.write_tarballs = write_tarballs != "0" or ud.rebaseable