Commit Graph

12 Commits

Author SHA1 Message Date
Kir Kolyshkin 1ede7ddce7 Use any instead of interface{}
Brought to you by

	gofmt -r 'interface{} -> any' -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-08 10:19:51 -07:00
flouthoc aadfc5cf30
unit_test: use Parallel test where possible
Add `t.Parallel()` to unit tests whereever its possible without race.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:15 -08:00
Nalin Dahyabhai 8ae99121c1 CI: enable the gofumpt linter
Turn on the gofumpt linter.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-15 13:17:44 -04:00
Aditya R 9c99d7ca88
run: use internal.GetTempDir with os.MkdirTemp
Projects which are using buildah as a library and set `TMPDIR` manually
can stumble upon a use-case where `TMPDIR` was set to a relative path.

Such as `export TMPDIR=.` in such case buildah will try to create a
temporary root using `Mkdirtemp` leading to a point where bundle is not
generated correctly since path was relative.

Following use case can be resolved by making sure that buildah always
converts relative path to absolute path and `GetTempDir` does it well.

Example reproducer with podman

```Dockerfile
FROM alpine
RUN echo hello
```

```console
export TMPDIR=.
podman build --no-cache -t test .
```

Expected failure
```console
STEP 1/2: FROM alpine
STEP 2/2: RUN echo hello
error running container: checking permissions on "buildah2341274198": stat buildah2341274198: no such file or directory
ERRO[0000] did not get container create message from subprocess: EOF
Error: building at STEP "RUN echo hello": while running runtime: exit status 1
```

Closes: RHEL-2598

Signed-off-by: Aditya R <arajan@redhat.com>
2023-10-11 21:49:18 +05:30
Nalin Dahyabhai cc619c28d9 Make sure that pathnames picked up from the environment are absolute
When we read TMPDIR and SSH_AUTH_SOCK from the environment, convert them
to absolute paths before using them.  Call auth.GetDefaultAuthFile()
instead of reading REGISTRY_AUTH_FILE.

[NO NEW TESTS NEEDED]

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-09-07 11:20:54 -04:00
Aditya R fd5db96c0f
sshagent: use ExtendedAgent instead of Agent
It seems ExtendedAgent supports signing with flags instead of ignoring
it. This commit mimics how the ExtendedAgent is configured in Buildkit
: https://github.com/moby/buildkit/blob/master/session/sshforward/sshprovider/agentprovider.go#L221

[NO NEW TESTS NEEDED]
Closes: https://github.com/containers/buildah/issues/4636

Signed-off-by: Aditya R <arajan@redhat.com>
2023-03-02 12:48:53 +05:30
Chris Evich 46eea31588
Replace io/ioutil calls with os calls
In golang 1.19, `io/ioutil` is fully deprecated preventing Buildah from
compiling.  Replace all calls with equivalent calls from the `os`
package.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-12-06 14:29:32 -05:00
Aditya R 5038a0dae2
sshagent: LockOSThread before setting SocketLabel
As per the library instruction `sshagent` must acquire `LockOSThread`
before setting and resetting the SocketLabel to ensure that the thread
is locked before following invocation completes setting and reseting the
socket label.

Reference: https://pkg.go.dev/github.com/opencontainers/selinux/go-selinux#SetSocketLabel
Should close: https://github.com/containers/buildah/issues/4245

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]
Existing tests must pass

Signed-off-by: Aditya R <arajan@redhat.com>
2022-10-13 19:51:18 +05:30
Sascha Grunert ce384684c0
Switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-07 11:41:47 +02:00
Aditya Rajan b74d71d574
ssh-agent: Increase timeout before we explicitly close connection
There are cases where remote will close connection by itself with a message
make sure we give connection enough time instead of closing explictly
early.

Future improvement: Relay output and perform close instead of relying on  `ServeAgent` to flush
buffer by closing connection.

[NO NEW TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-11-17 15:05:37 +05:30
Daniel J Walsh 6064a95baa
Run codespell to fix spelling
[NO TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-11 10:15:44 -04:00
Ashley Cui 3a5635f90b Implement SSH RUN mount
Allow ssh socket from host or certain ssh keys to be exposed to a
certain RUN instruction, but not any other instructions, as well as not
showing up in the final image.
This is done by spawining a new agent from buildah and mounting
the listening socket inside the run. SSH_AUTH_SOCK inside the container
will be set to the socket mountpoint. The defualt mountpoint is
/run/buildkit/ssh_agent.{i}

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-08-06 09:00:06 -04:00