Skip to contentSkip to conversation

fetch2/git: Sanitize git configuration

PATCH In review Yuri D'Elia 2 participants 4 messages Jul 9, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/git: Sanitize git configuration

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(-)
lib/bb/fetch2/git.py +1 -1
index c7ff769fd..1ea000b3a 100644
@@ -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
Signature · 1 line
2.45.2
#1 lore raw

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

Quoted 39 lines · Yuri D'Elia via lists.openembedded.org

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(-)
lib/bb/fetch2/git.py +1 -2
index c7ff769fd..1ea000b3a 100644
@@ -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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 3 lines · Alexander Kanavin

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?

#3 lore raw
Quoted 6 lines · Yuri D'Elia via lists.openembedded.org

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