16 Commits

Author SHA1 Message Date
Giuseppe Scrivano
25432c4b52
direct: treat statx EINVAL as ENOSYS
glibc has a fallback code on ENOSYS that can cause EINVAL.

Attempt the fallback on both errors.

Closes: https://github.com/containers/fuse-overlayfs/issues/311

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-04 21:28:25 +02:00
Giuseppe Scrivano
4ad759b35a
fuse-overlayfs: fix read xattrs for devices
always use llistxattr and lgetxattr for listing and reading xattrs so
that the open/openat2 call doesn't fail when accessing a device.

Closes: https://github.com/containers/fuse-overlayfs/issues/312

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-07-28 13:03:55 +02:00
Giuseppe Scrivano
3cb30d4c11
main: honor user.containers.override_stat
also honor user.containers.override_stat to override containers stat
override as it is set by containers/storage.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-06 13:19:51 +01:00
Giuseppe Scrivano
3dbb7d9bd5
main: move stat override mode to enum
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-06 13:17:14 +01:00
Giuseppe Scrivano
de2fc6b14c
main: always remap ids when specified
if a mapping is specified, make sure it is always honored, also when
using xattr permissions.

Closes: https://github.com/containers/fuse-overlayfs/issues/253

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 11:55:21 +01:00
Giuseppe Scrivano
b8086b58fa
main: support writing uid/gid/mode to xattr
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 19:52:28 +02:00
Giuseppe Scrivano
5c7fc2856a
direct: move override_mode to utils
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 16:52:26 +02:00
Giuseppe Scrivano
ab407f7c9e
direct: store if the layer must be remapped
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 16:02:59 +02:00
Giuseppe Scrivano
63abdc1138
fuse-overlays: introduce xattr to override gid/uid/mode
introduce a new xattr "user.fuseoverlayfs.override_stat" that permit
to override the reported uid/gid/mode for lower layers.

It enables sharing storage among different users.

Since it is not possible to use "user.*" xattrs for symlinks, provide
also a privileged variant "security.fuseoverlayfs.override_stat", so
the root user can create the xattr for symlinks as well.

A script "fix-mode.py" is provided for converting an existing
layer/storage to the new model.  It is a destructive operation as
every file is converted to mode 0755, thus it is not usable anymore
with native overlay, or older versions of fuse-overlayfs.

Example with Podman:

Rootless:
Modify /.config/containers/storage.conf and add under storage.options:
additionalimagestores = ["/var/lib/shared-storage"]

Assuming an empty local storage for the user:

$ podman images
REPOSITORY                TAG     IMAGE ID      CREATED      SIZE    ReadOnly
docker.io/library/fedora  latest  a368cbcfa678  5 weeks ago  189 MB  true

and the files show the original mode and owner:

$ podman run --read-only --rm -ti docker.io/library/fedora ls -l /
lrwxrwxrwx.   1 root   root      7 Jan 28  2020 bin -> usr/bin
dr-xr-xr-x.   2 root   root      6 Jan 28  2020 boot
drwxr-xr-x.   5 root   root    360 Aug 15 13:26 dev
drwxr-xr-x.  41 root   root   4096 Jul  9 06:48 etc
drwxr-xr-x.   2 root   root      6 Jan 28  2020 home
lrwxrwxrwx.   1 root   root      7 Jan 28  2020 lib -> usr/lib
lrwxrwxrwx.   1 root   root      9 Jan 28  2020 lib64 -> usr/lib64
drwx------.   2 root   root      6 Jul  9 06:48 lost+found
drwxr-xr-x.   2 root   root      6 Jan 28  2020 media
drwxr-xr-x.   2 root   root      6 Jan 28  2020 mnt
drwxr-xr-x.   2 root   root      6 Jan 28  2020 opt
dr-xr-xr-x. 436 nobody nobody    0 Aug 15 13:26 proc
dr-xr-x---.   2 root   root    196 Jul  9 06:48 root
drwxrwxrwt.   3 root   root     80 Aug 15 13:26 run
lrwxrwxrwx.   1 root   root      8 Jan 28  2020 sbin -> usr/sbin
drwxr-xr-x.   2 root   root      6 Jan 28  2020 srv
dr-xr-xr-x.  13 nobody nobody    0 Aug  5 21:38 sys
drwxrwxrwt.   2 root   root     60 Aug 15 13:26 tmp
drwxr-xr-x.  12 root   root    144 Jul  9 06:48 usr
drwxr-xr-x.  18 root   root    235 Jul  9 06:48 var

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-17 14:01:17 +02:00
Asaf Kahlon
27a01e622e direct.c: fix compilation with musl
Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
2020-06-22 20:48:36 +03:00
Giuseppe Scrivano
fb8eb3300e
main: use openat2 where available
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-21 18:33:33 +02:00
Giuseppe Scrivano
f787603a30
fuse-overlayfs: add missing definitions for _FILE_OFFSET_BITS
it caused an issue on armv7h where different versions of dirent struct
were used in main.c and in the other files.

Regression introduced with c2c2ac5b82fb59322da227d196214b4a58ede634

Closes: https://github.com/containers/fuse-overlayfs/issues/197

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-15 10:18:30 +02:00
Giuseppe Scrivano
1c490d91d8
plugins: allow to manage multiple layers with a ds
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-24 13:52:34 +02:00
Giuseppe Scrivano
9f6f90a6da
direct: use statx when available
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 22:06:40 +02:00
Giuseppe Scrivano
b28a23a39d
fuse-overlayfs: add plugin system
Add a simple plugin mechanism that will help to expand fuse-overlayfs
functionalities, in particular it allows to load data from a layer on
demand.

A plugin is loaded into fuse-overlayfs using the option:

-o plugins=path/to/plugin.so:path/to/another/plugin.so

A layer can use a plugin with the syntax:

-o lowerdir=//plugin-name/DATA-FOR-THE-PLUGIN/path

Each time a file/directory is looked up, if a plugin is registered for
a layer, the plugin is first notified about the request.

After the callback is invoked, fuse-overlayfs still expects the data
to be accessible at the specified directory.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 22:06:39 +02:00
Giuseppe Scrivano
c2c2ac5b82
main: split the code in multiple files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 19:44:20 +02:00