Bug 13550 - username/password specified to gitsm:// does not get propagated to submodules
Summary: username/password specified to gitsm:// does not get propagated to submodules
Status: RESOLVED WONTFIX
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 4.3 M3
Assignee: Yoann Congal
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2019-09-25 07:44 UTC by marom
Modified: 2023-08-03 12:41 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Path that fixes the problem for me (542 bytes, application/octet-stream)
2019-09-25 07:44 UTC, marom
no flags Details
Refreshed patch "gitsm: propagate user parameter to submodules" (923 bytes, patch)
2023-07-26 14:25 UTC, Yoann Congal
yoann.congal: commit-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description marom 2019-09-25 07:44:29 UTC
Created attachment 4567 [details]
Path that fixes the problem for me

I have a recipe that takes the sources from git using a username/password with a line looking like this

SRC_URI = "gitsm://${COMPANY_GIT_REPO}/path/to/project.git;protocol=https;user=${GIT_USER}"

The project has a submodule requiring the same username/password but bitbake exits with a message like

fatal: could not read Username for 'https://${COMPANY_GIT_REPO}': No such device or address

The patch attached solved my problem (bitbake version 1.40.0). If a user is present it adds the parameter to submodule fetching.
Comment 1 marom 2019-09-30 12:04:07 UTC
I found another way to solve the problem by making the url of the submodule relative. 

So I rewrote

[submodule "mysubmodule"]
	path = mysubmodule
	url = https://myhost/mysubmodule.git

as

[submodule "mysubmodule"]
	path = mysubmodule
	url = ../mysubmodule.git

I guess that is the way things are meant to be... inherit the user/password is acceptable as long as the submodule is on the same host, which means exactly the same use case covered by the patch I submitted.
Comment 2 Randy MacLeod 2021-05-20 15:46:46 UTC
Mark, Unless you reply today, I'm going to assume that you like the patch as is:

diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index b21fed2669..152bdc98c4 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -130,6 +130,8 @@ class GitSM(Git):
             url += ';protocol=%s' % proto
             url += ";name=%s" % module
             url += ";subpath=%s" % paths[module]
+            if ud.user:
+                url += ";user=%s" % ud.user 
 
             ld = d.createCopy()
             # Not necessary to set SRC_URI, since we're passing the URI to

and ask Tony to submit it.
Comment 3 Tony Tascioglu 2021-07-23 16:53:05 UTC
Sorry, I lost track of this. I'll get to it as soon as I can.
Comment 4 Yoann Congal 2023-07-26 13:24:03 UTC
I've checked :
* "user=" parameter of SRC_URI in indeed not passed to submodules (as of bitbake commit 64bc00a46d). Same for the gitsm://USER@... part of the URL
* The patch does fix that (I'll attach a refreshed version of the patch)

However :
* Passing password from git SRC_URI is not supported [0]
* I don't see the point supporting passing the user but not the password
* Recommended method to give a password to git SRC_URI is .netrc (for the git over http protocol)
* This .netrc config does apply for git submodules
* Using .netrc, I have no trouble having a git submodule pointing to http git URL using authentication. 

I would close this ticket since what the reporter want is supported (via the only supported method : .netrc) but I have a doubt since the observation "user is not propagated to submodules" is still true.

[0] : https://git.openembedded.org/bitbake/tree/lib/bb/fetch2/git.py?id=a0d8108eba8d542707740d00c66c1c5f5b963f18#n692
Comment 5 Yoann Congal 2023-07-26 14:25:23 UTC
Created attachment 4963 [details]
Refreshed patch "gitsm: propagate user parameter to submodules"
Comment 6 Yoann Congal 2023-07-27 15:47:38 UTC
From bug triage meeting 2023-07-27 :
* I will send a patch commenting in the code that we don't support this (so we don't get more bugs about this)
* Then, close this bug as WONTFIX
Comment 7 Yoann Congal 2023-07-28 16:29:45 UTC
> * I will send a patch commenting in the code that we don't support this (so we don't get more bugs about this)

=> https://lists.openembedded.org/g/bitbake-devel/message/14893
Comment 8 Yoann Congal 2023-08-03 12:41:21 UTC
Non-support documented here : https://git.yoctoproject.org/poky/commit/?id=d8a51fd6288b54c2fe9d08a65a50e2d8cd38b91b

I close the bug I "won't fix" but the way to handle this is to use a .netrc file which will contain the username and the password.