Commit Graph

28 Commits

Author SHA1 Message Date
Giuseppe Scrivano 0c1d6be80d
fsdiff: mount both layers are read-only
there is no reason to mount the first layer as writeable.  If fixes mounting
layers that are in a read-only location like an additional image store, or
are backed by composefs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-10-23 15:02:06 +02:00
Giuseppe Scrivano afafcdc7ad
fsdiff: mount the image read-only
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-17 00:31:39 +02:00
Kir Kolyshkin a4d8f720a2 Format sources with gofumpt
gofumpt is a superset of gofmt, enabling some more code formatting
rules.

This commit is brought to you by

	gofumpt -w .

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2023-05-26 16:17:31 -07:00
Miloslav Trmač 5e410ef763 Misc individual warning fixes
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:53 +02:00
Miloslav Trmač 5e8eb4c69a Check and report errors in driver.Put()
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:46:53 +02:00
Miloslav Trmač bceefe29a5 Use time.Until instead of time.Sub(...time.Now())
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:46 +02:00
Giuseppe Scrivano f0cd0b97b1
chrootarchive: use unshare to detect user namespace
use the function in containers/storage that has the same
functionalities.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-09-08 23:07:14 +02:00
Sergio Lopez 7617ae34d8 Limited support for operating on images on macOS
Supporting macOS presents a number of challenges since the lack of
user namespaces means that operations that alter the ownership or
permissions on a file face harsh limitations, since are requested by
an unprivileged user that may need to potentially operate on arbitrary
uids/gids.

To overcome this challenges, we rely on the existing "forceMask"
feature to store the actual ownership and permission bits as an
extended attribute entry on each file.

In addition to automatically enabling "forceMask" when running on
macOS, we also need some minor changes to ensure the compatibility
with this OS. The most significant is the fact that, on macOS
SafeLchmod and SafeChmod also operate on the extended attributes, to
allow us to properly create the directories supporting the image.

With this changes in place, buildah is able to perform basic
operations on OCI images, such as downloading the image, creating a
working container, and removing them.

Signed-off-by: Sergio Lopez <slp@redhat.com>
2022-06-06 08:01:54 +02:00
Nalin Dahyabhai d467d9fd38 drivers.NaiveDiffDriver.Changes(): mount the parent read-only
The parent layer, by virtue of being a parent layer isn't going to be
modified, so default to mounting it read-only.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2022-01-27 15:47:05 -05:00
Daniel J Walsh 534b0b3281
Standardize on capatalized logrus messages, and remove stutters
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-23 14:43:35 -04:00
Daniel J Walsh b3531c3df8
Vendor in opencontainers/runc v1.0.0
The RunningInUserNS Function was removed from libcontainer and is now
in contianerd.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-22 08:41:17 -04:00
Daniel J Walsh e96cd8656f
Naive diff should pass in the ro option on parent directory
If we are just mounting the parent directory, we should do it read
only.  We should not use the upper and work directory.

If there is only one lower directory we should return that path.  No
reason to mount the lower directory at all.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-08-06 08:37:29 -04:00
Daniel J Walsh 976fe22092
Add storage options to IgnoreChownErrors
Modified patch of Kevin Pelzel.

Also changed ApplyDiff to take new ApplyDiffOpts Struct.

Signed-off-by: Kevin Pelzel <kevinpelzel22@gmail.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-07-26 06:05:27 -04:00
Giuseppe Scrivano e4016865a3
NaiveDiff: set InUserNS
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-30 21:01:19 +01:00
Daniel J Walsh b6ccc0acfa
Add MountOpts to stop adding fields to Get Interface
This patch adds a MountOpts field to the drivers so we can simplify
the interface to Get and allow additional options to be passed in the future.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-05 09:23:46 -04:00
Giuseppe Scrivano 1897396330
drivers: inform Mount of the mappings used by the container
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-26 06:12:42 +02:00
Tomas Tomecek 404315aaed log errors from ApplyUncompressedLayer
Related: https://github.com/projectatomic/libpod/issues/1087

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
2018-07-13 11:11:00 +02:00
Nalin Dahyabhai 97326e1d2f Support for per-container uid/gid mapping: lower
Expose reading and writing ID mapping in the archive and chrootarchive
packages, and in the driver interface.  Generally this means that
when computing or applying diffs, we need to have ID mappings passed in
that are specific to the layers we're using.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-04-03 10:34:32 -04:00
Nalin Dahyabhai b71d4c4197 Support for per-container uid/gid mapping: upper
Add support to the Store objects for per-container UID/GID mapping.
* UID and GID maps can be specified when creating layers and containers.
* If mapping options are specified when creating a container, those
  options are used for creating the layer which we create for the
  container and recorded with the container for convenience.
* A layer defaults to using the ID mapping configured for its parent, or
  to the default which was used to initialize the Store object if it has
  no parent.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2018-04-03 10:34:32 -04:00
Daniel J Walsh 5a785c73f4 Pass MountLabel down to diff drivers
Currently when we do a commmit, we are mounting the container without using
the mountlabel.  In certain situations we can leak mount points where the
image is already mounted with a label.  If you then attempt to commit the
image, the kernel will attempt to mount the image without a label.  The
kernel will reject this mount since SELinux does not allow the same image
to be mounted with different labels.

Passing down the label to the diff drivers, fixes this issue.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-02-06 13:42:25 -05:00
Nalin Dahyabhai 88b9193bae Fix builds with go 1.7
The skopeo package builds on Darwin use Go 1.7, so make sure we can
build on it, by replacing a call to time.Until(t) with
t.Sub(time.Now()), as suggested in the standard library documentation.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-09-29 17:25:19 -04:00
Daniel J Walsh 57641cc0f9 Backport moby drivers general changes to containers/storage
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-26 20:45:15 +00:00
Daniel J Walsh f39066fe1b Update packages to match latest code in moby/pkg
Had to vendor in a new version of golang.org/x/net to build
Also had to make some changes to drivers to handle
archive.Reader -> io.Reader
archive.Archive -> io.ReadCloser

Also update .gitingore to ignore emacs files, containers-storage.*
and generated man pages.

Also no longer test travis against golang 1.7, cri-o, moby have also
done this.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2017-09-12 18:00:29 +00:00
Mrunal Patel 59da502256 Update deps to github.com/sirupsen/logrus v1.0.0
Also updates github.com/Microsoft/hcsshim
and github.com/docker/go-connections so they work
with the newer version of logrus.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2017-08-01 07:25:56 -07:00
Nalin Dahyabhai 9697353ba3 Remove GetPutWrapper interfaces
Remove the GetPutWrapper interfaces, which shouldn't be necessary if the
counter checker works correctly (which should ensure that Diff() ends
with the layer either mounted or unmounted, as it was before it was
called), and which didn't integrate properly with overlay2.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-08-25 15:24:06 -04:00
Nalin Dahyabhai bfeac14190 Don't lose a ref when generating diffs
Don't lose track of a mount reference when generating diffs between
layers using the naive method.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-08-25 12:10:39 -04:00
Nalin Dahyabhai b22d7114e7 Use Mount/Unmount instead of Get/Put when diffing
When computing the differences between two layers, attempt to avoid
disrupting users of those layers by using possibly-refcounted
Mount/Unmount callbacks, if provided, instead of calling a driver's own
Get/Put methods correctly.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-08-17 15:33:49 -04:00
Nalin Dahyabhai 60ff079996 Rename: cow/cowman -> storage/oci-storage
Rename the library module and CLI wrapper.
Rename daemon/graphdriver to drivers.
Catch up vendoring to match modules we've pruned.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-07-18 17:35:50 -04:00