-
Notifications
You must be signed in to change notification settings - Fork 64
source: add ecr-credential-helper-shim #836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [package] | ||
| name = "ecr-credential-helper-shim" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
| publish = false | ||
| build = "../build.rs" | ||
|
|
||
| [package.metadata.build-package] | ||
| source-groups = [ "ecr-credential-helper-shim" ] | ||
|
|
||
| [lib] | ||
| path = "../packages.rs" | ||
|
|
||
| [build-dependencies] | ||
| glibc = { path = "../glibc" } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| %global _cross_first_party 1 | ||
| %undefine _debugsource_packages | ||
|
|
||
| Name: %{_cross_os}ecr-credential-helper-shim | ||
| Version: 0.1.0 | ||
| Release: 1%{?dist} | ||
| Summary: FIPS shim for ECR credential helper | ||
| License: Apache-2.0 OR MIT | ||
| URL: https://github.com/bottlerocket-os/bottlerocket | ||
| BuildRequires: %{_cross_os}glibc-devel | ||
|
|
||
| %description | ||
| %{summary}. | ||
|
|
||
| %prep | ||
| %setup -T -c | ||
| %cargo_prep | ||
|
|
||
| %build | ||
| %cargo_build --manifest-path %{_builddir}/sources/Cargo.toml \ | ||
| -p ecr-credential-helper-shim \ | ||
| --target-dir=${HOME}/.cache/ecr-credential-helper-shim | ||
|
|
||
| %install | ||
| install -d %{buildroot}%{_cross_bindir} | ||
| install -p -m 0755 ${HOME}/.cache/ecr-credential-helper-shim/%{__cargo_target}/release/ecr-credential-helper-shim %{buildroot}%{_cross_bindir}/docker-credential-ecr-login | ||
|
|
||
| %files | ||
| %{_cross_bindir}/docker-credential-ecr-login |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,8 @@ members = [ | |
| "xfscli", | ||
|
|
||
| "whippet", | ||
|
|
||
| "ecr-credential-helper-shim", | ||
| ] | ||
|
|
||
| [workspace.dependencies] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
|
|
||
| [package] | ||
| name = "ecr-credential-helper-shim" | ||
| version = "0.1.0" | ||
| authors = ["Jingwei Wang <jweiw@amazon.com>"] | ||
| license = "Apache-2.0 OR MIT" | ||
| edition = "2021" | ||
| publish = false | ||
| # Don't rebuild crate just because of changes to README. | ||
| exclude = ["README.md"] | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| use std::env; | ||
| use std::process::{self, Command}; | ||
|
|
||
| fn main() { | ||
| let godebug = env::var("GODEBUG") | ||
| .unwrap_or_default() | ||
| .replace("fips140=only", "fips140=on"); | ||
|
|
||
| let status = Command::new("/usr/libexec/docker-credential-ecr-login") | ||
| .args(env::args().skip(1)) | ||
| .env("GODEBUG", &godebug) | ||
| .status(); | ||
|
Comment on lines
+9
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than executing the call of the helper in a separate process (fork), you should https://www.man7.org/linux/man-pages/man3/exec.3.html So that you don't have to capture the status, and you don't have to worry about handling STDOUT/STDERR in case they require special handling by whatever is calling your shim. |
||
|
|
||
| match status { | ||
| Ok(s) => process::exit(s.code().unwrap_or(1)), | ||
| Err(err) => { | ||
| eprintln!("Failed to exec /usr/libexec/docker-credential-ecr-login: {err}"); | ||
| process::exit(1); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,7 @@ func main() { | |
| // Bottlerocket does not have a $HOME set by default and notation expect to find | ||
| // credentials from the ecr-credential-helper here. | ||
| os.Setenv("HOME", "/root") | ||
| os.Setenv("GODEBUG", "fips140=on") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will notation break if |
||
|
|
||
| cmd := exec.Command("notation", "verify", imageRef) | ||
| output, err := cmd.CombinedOutput() | ||
|
|
||
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.
Can you clarify why a new package rather than using the OS package?