19 Commits

Author SHA1 Message Date
David Hedberg
5ec356b29e main: Add option static_nlink to set st_nlink to 1 for all directories
Skips calculation of st_nlink for directories, which can be
expensive on higher latency file systems such as NFS.

Signed-off-by: David Hedberg <david.hedberg@gmail.com>
2021-03-16 18:51:42 +01:00
Giuseppe Scrivano
e5d35c9a01
main: add squash_to_uid and squash_to_gid
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-22 15:57:56 +01:00
Giuseppe Scrivano
33a2fa47c9
main: invalidate directory cache on create/rename
if we are adding a new file to a directory, the parent directory must
be invalidated if it is in the middle of a opendir/releasedir
otherwise the added files won't be cached.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-11 15:34:01 +01: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
Patrick J. LoPresti
032877c501 Add squash_to_root mount option
(https://github.com/containers/fuse-overlayfs/issues/241).
2020-10-08 12:49:40 -07:00
Daniel J Walsh
cb6b7d55bc
Fix problems found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-11 10:29:03 -04: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
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
Giuseppe Scrivano
f703870668
main: drop nlink optimization
calculate the nlink for the directory on each stat.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-16 11:54:39 +01:00
Sascha Grunert
ae73314491
Fix build with -fno-common
To avoid that the compiler complains when building with `-fno-common`.
Can be reproduced by:

```
> make CFLAGS=-fno-common
...
ld: fuse_overlayfs-direct.o:(.data+0x0): multiple definition of \
    `direct_access_ds'; fuse_overlayfs-main.o:(.bss+0x0): \
    first defined here
ld: fuse_overlayfs-utils.o:(.bss+0x0): multiple definition of \
    `direct_access_ds'; fuse_overlayfs-main.o:(.bss+0x0): \
    first defined here
ld: fuse_overlayfs-plugin-manager.o:(.bss+0x0): multiple definition of \
    `direct_access_ds'; fuse_overlayfs-main.o:(.bss+0x0): \
    first defined here
```

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-08 09:08:16 +01:00
Giuseppe Scrivano
5d053201d1
main: drop special handling for security.capability
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-29 11:53:49 +01: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
Giuseppe Scrivano
53c165e6bd
main: refactor to use a data store
this is the first step towards supporting data from lower layers
coming from other sources.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-20 19:44:20 +02:00