Commit Graph

9 Commits

Author SHA1 Message Date
Nalin Dahyabhai fdf1c75cd3 linters: unused arguments shouldn't have names
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Daniel J Walsh 8d5d763213
Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-19 07:11:44 -04:00
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
Doug Rabson be3b9c3686 Make util and copier build on FreeBSD
The mknod syscall takes a uint64 value for dev on FreeBSD.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-06-13 13:36:20 +01:00
Nalin Dahyabhai 1dbf430563 copier: add GetOptions.NoCrossDevice
Add a NoCrossDevice flag to GetOptions, telling it to ignore
subdirectories on devices different than the top reference directory
that we start from, i.e., ignore the contents of mounted filesystems.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-14 10:19:19 -04:00
Nalin Dahyabhai effb375b5a ADD/COPY: create the destination directory first, chroot to it
Always create the destination directory first when ADDing or COPYing
content into a container, then extract contents into it using the
destination directory as the chroot instead of the container's root
directory.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-02 16:29:43 -05:00
Nalin Dahyabhai 9b3e7b1f02 copier: don't assume we can chroot() on Unixy systems
Fall back to non-chroot behavior on Unixy systems when we're not started
as UID 0.  Break the unit tests that exercise chroot functionality into
a separate file so that we don't even try to run those cases on non-Unix
OSes.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-12-16 18:00:45 -05:00
Nalin Dahyabhai 348665657c copier: add Mkdir()
Add a function for doing Mkdir-possibly-in-a-chroot, for ensuring that a
directory exists without having to possibly create it directly from
outside of a chroot.

Make use of filepath.ToSlash() and filepath.FromSlash() where it's
appropriate.

Add more unit tests.

Address some review comments:

* Check for ERANGE instead of E2BIG errors from llistxattr() and
  lgetxattr() as indicators that the buffer we passed to them is too
  small.
* Factor an `isRelevantXattr` helper out of Lgetxattrs() and
  Lsetxattrs().
* Drop our getcwd() function in favor of using os.Getwd().
* Adjust the comment describing the GetOptions.KeepDirectoryNames field.
* Clean hdr.Name before attempting to compute where an item being
  extracted should go.
* When writing items to the filesystem, create with 0?00 permissions,
  set ownership, then set the correct permissions.
* Merge StatResponse.Error, GetResponse.Error, and PutResponse.Error
  into Response.Error.
* When reading items from the filesystem, if a glob matches multiple
  items, and one of the items is excluded, continue checking the other
  items.
* Make sure we always Wait() on a child process if we spawned one.
* Clean up the cleanup logic for pipes that we use to communicate with a
  child process.
* Clean up the kill-the-child-process logic we call when we encounter an
  error communicating with the child process.
* Drop the separate Options structure, use helper methods to simplify
  pulling out the right ID maps and exclusions list for the request.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-08-20 13:33:42 -04:00
Nalin Dahyabhai 36f4b8f7fa Add the "copier" package
Add new primitives for reading and writing data, represented as tar
streams, from and to possibly-chrooted directories via subprocesses.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-07-20 23:08:57 -04:00