-
Notifications
You must be signed in to change notification settings - Fork 61
Support custom URI for downloading targets. #1147
Conversation
Signed-off-by: Patrick Vacek <[email protected]>
Thanks @patrickvacek! This could be a handy feature for some stuff I've been looking at. |
src/libaktualizr/uptane/fetcher.cc
Outdated
@@ -116,6 +116,12 @@ bool Fetcher::fetchVerifyTarget(const Target& target) { | |||
} else { | |||
ds.fhandle = storage->allocateTargetFile(false, target); | |||
} | |||
|
|||
std::string target_url = target.uri(); | |||
if (target_url.empty() || target_url.find("example.com") != std::string::npos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "example.com" do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If "example.com" is part of the custom URL, we ignore it and fall back to the default fileserver based on the autoprov URL in the credentials. This is to support backwards compatibility with the server, which often fills that field with "https://example.com/" despite that that is obviously not where we should go looking for files. It's a hack, but I'm working around something out of my control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the server really do that? Maybe it's just in a tutorial or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this being used? https://github.com/advancedtelematic/aktualizr/blob/master/src/sota_tools/deploy.cc#L91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the server really do that? Maybe it's just in a tutorial or something?
Yes, last I checked, which was yesterday.
Where is this being used? https://github.com/advancedtelematic/aktualizr/blob/master/src/sota_tools/deploy.cc#L91
garage-deploy when credentials indicate offline signing is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we added the "example.com" bit there because there was a problem with that field being null. That was a long time ago and I'd forgotten about it. Perhaps it can be removed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where it comes from originally: https://github.com/advancedtelematic/meta-updater/blob/master/classes/sota.bbclass#L39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it's been there for as long as meta-updater has supported garage-sign: advancedtelematic/meta-updater@e7d4fbf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to change the URL check here to match exactly what we've been using ("https://example.com/") to reduce the likelihood of accidental matches, and I will open a ticket to look into removing that URL as the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## master #1147 +/- ##
==========================================
- Coverage 77.77% 77.75% -0.02%
==========================================
Files 167 167
Lines 9947 9954 +7
==========================================
+ Hits 7736 7740 +4
- Misses 2211 2214 +3
Continue to review full report at Codecov.
|
Only check for exact matches with the default URL, and do the check earlier to reduce the space of URLs that get checked. Signed-off-by: Patrick Vacek <[email protected]>
0688dd4
to
3e758cd
Compare
No description provided.