410 Commits

Author SHA1 Message Date
Giuseppe Scrivano
b31d82ff8e
main: use parsed upper layer directory
Use the directory in the loaded layer structure, and do not use the
value passed on the CLI.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-04-28 18:46:30 +02:00
Giuseppe Scrivano
02a3582501
refactor: Remove unnecessary upperdir realpath
The explicit resolution of the upper directory path using `realpath()`
is not required before passing it to `read_dirs` since
`direct_load_data_source()` already does it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-04-28 18:46:30 +02:00
Giuseppe Scrivano
6bbd62bb13
main: use extended override xattr
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-12-02 09:52:35 +01:00
Henrik Holst
e107b0bfe4 Remove unsupported option "lazytime"
Signed-off-by: Henrik Holst <6200749+hholst80@users.noreply.github.com>
2024-08-17 11:41:49 +02:00
Akihiko Odaki
20161f96d7 main: Isolate security xattrs for STAT_OVERRIDE_CONTAINERS
The major use case of stat override is to enable rootless containers
on network filesystems, and they also lack security xattr support in
non-root user namespaces. Trying to set security xattrs on them result
in ENOTSUP and break things.

It makes little sense to share security xattrs with the underlying
filesystems when overriding stat in the first place. Linux's NFS server
exposes security xattrs only when the user explicitly claims the
security consistencies between the server and clients, and hide them
otherwise. Following this precedent, we should isolate security xattrs
since we know the security policy enforced by fuse-overlayfs is already
distinct from the underlying filesystem when overriding owners and file
mode.

Mark security xattrs inaccessible with STAT_OVERRIDE_CONTAINERS to
prefix all access to them with XATTR_CONTAINERS_OVERRIDE_PREFIX.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 22:50:14 +09:00
Akihiko Odaki
9810b85aad main: Override inaccessible xattrs
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 22:50:14 +09:00
Akihiko Odaki
90bea22c73 Prefer user.containers.override_stat over user.fuseoverlayfs.
Previously, fuse-overlayfs always used user.fuseoverlayfs.override_stat
for the upper layer while honoring user.containers.override_stat for
lower layers so that it can consume a layer created by
containers/storage.

It turned out that containers/storage also needs to get the overriding
extended attribute set by fuse-overlayfs and to set one for the upper
layer to make the root directory of the upper layer inherit the mode
of a lower layer. Adding code to get and to set
user.fuseoverlayfs.override_stat to containers/storage is a bit ugly.

The underlying problem is that fuse-overlayfs changes what name to use
ad hoc. Fix it by always preferring user.containers.override_stat, which
containers/storage honors, over user.fuseoverlayfs.overlayfs, which is
specific to fuse-overlayfs.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 22:50:14 +09:00
Akihiko Odaki
9610adf7ab main: Do not set -1 for owner overriding xattrs
ovl_setattr () used to pass -1 as uid or gid when either of them
is not changed for do_fchown () / do_chown (), but if these functions
use overriding xattrs instead of real fchown () or chown (), it causes
-1 to be written in owner overriding xattrs and break them.

Replace -1 with the current uid or gid before calling do_fchown () /
do_chown ().

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 22:50:01 +09:00
Akihiko Odaki
136aefd2f6 main: Fix file owner retrieval for chmod
do_fchmod () and do_chmod () used to call override_mode () directly to
retrieve the owner information, but the usage of override_mode () was
wrong; override_mode () expects struct stat is already populated by
the information provided by the underlying filesystem, but do_fchmod ()
and do_chmod () only zeroed st_uid and st_gid. override_mode () does not
update the owner information when st_mode is not S_IFDIR nor S_IFREG so
this caused chmod to change the file owner to root at random.

Use the logic rpl_stat () employs to file owner retrieval for chmod
functions to ensure they provide the owner information consistent with
rpl_stat ().

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 21:35:51 +09:00
Giuseppe Scrivano
c08211ddd7
main: automatically cleanup newpath
this was already the assumption in the source code.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-02-06 10:21:52 +01:00
Giuseppe Scrivano
d9e78eadb7
main: create dir in two steps with xattrs permissions
if xattrs permissions are used, create the directory in two steps and
set the correct ownership before moving it into the target.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-02 11:49:16 +01:00
Giuseppe Scrivano
d65ce2a8bb
main: propagate xattrs permissions with copyup
when a directory is copied up, propagate its mode if using xattrs
permissions.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-01 21:35:03 +01:00
Giuseppe Scrivano
f73fd2db7c
fuse-overlayfs: honor mode for dirs with xattr_permissions
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-30 18:10:19 +01:00
Giuseppe Scrivano
2d8613e7f5
fuse-overlayfs: honor mode for devices with xattr_permissions
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-30 18:07:11 +01:00
Giuseppe Scrivano
95e12f97f5
fuse-overlayfs: propagate force mode xattr
if the lower dir has a force mode xattr, use it for the upper layer
too.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-30 08:40:04 +01:00
Giuseppe Scrivano
40b431e243
fuse-overlayfs: honor umask with xattr_permissions
Closes: https://github.com/containers/fuse-overlayfs/issues/407

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-29 21:04:14 +01:00
Giuseppe Scrivano
ba472b58bc
code: add clang-format
add a clang-format definition file and apply it to the code.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-02 15:12:42 +02:00
Giuseppe Scrivano
98206a6a90
main: fix performance issue with large dirs
cache the number of links for a directory instead of calculating it on
every stat.  It makes a huge difference when the directory has a lot
of entries.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-08-29 16:03:50 +02:00
Giuseppe Scrivano
06f8a69efa
main: fix check for writeable /proc
fix the check for writeable /proc to use statfs instead of statvfs,
and use the unitialized statvfs structure to check for the writeable
bit.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-06-07 21:30:02 +02:00
Giuseppe Scrivano
d617afcefb
fuse-overlays: change license to GPLv2+
the contributors agreed on the change in the attached issue.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-04-11 18:25:46 +02:00
Giuseppe Scrivano
2666df2a49
main: check that ACLs are supported in the lower layers
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2180118

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-03-23 23:02:18 +01:00
Giuseppe Scrivano
34d47e9a74
main: pick node version that is loaded
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-11-30 16:29:43 +01:00
Giuseppe Scrivano
36b482bf52
main: invalidate inode after unlink
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-11-30 15:49:46 +01:00
Giuseppe Scrivano
0d8c5480d1
main: report the st_ino known so far
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-11-30 15:46:04 +01:00
Giuseppe Scrivano
2d90664f24
main: fix copy_file_range for deleted files
if the file was deleted, access it through the hidden_dirfd.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-25 09:28:41 +02:00
Giuseppe Scrivano
43c2a067ee
Merge pull request #370 from giuseppe/inherit-acl
main: inherit ACLs for new files/dirs
2022-08-25 09:27:43 +02:00
Giuseppe Scrivano
9a69652588
Merge pull request #371 from giuseppe/warn-unused-args
main: print a warning if an argument is ignored
2022-08-25 09:27:37 +02:00
Giuseppe Scrivano
0988e9bc39
main: add checks for valid /proc mount
since fuse-overlayfs needs a writeable /proc mount, add some checks to validate it.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-24 15:22:52 +02:00
Giuseppe Scrivano
952fa4dc28
main: print a warning if an argument is ignored
Closes: https://github.com/containers/fuse-overlayfs/issues/339

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-24 15:10:29 +02:00
Giuseppe Scrivano
1746aef29c
main: handle -o volatile separately
so we can ignore invalid values for the option.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-24 15:10:29 +02:00
Giuseppe Scrivano
0448402ab5
main: fix passing noatime
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-24 15:08:30 +02:00
Giuseppe Scrivano
e3685b8c17
main: inherit ACLs for new files/dirs
when creating a new file/directory, inherit the ACL from the parent directory.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-24 14:54:15 +02:00
Giuseppe Scrivano
6221dede8b
Merge pull request #357 from Tuupertunut/main
Refactor and fix rename code
2022-06-08 21:52:44 +02:00
Tuupertunut
6a0de4a5b0 Refactor and fix rename code
- Create source whiteout only when needed
- Fix missing source whiteout when destination is whiteout
- Try the EXCHANGE trick also when NOREPLACE is set

Signed-off-by: Tuupertunut <tuupertunut@outlook.com>
2022-06-08 21:35:27 +03:00
Aditya R
b010054b22
main: set correct value of RENAME_NOREPLACE ifndef RENAME_EXACHANGE
Set correct value of RENAME_NOREPLACE when RENAME_EXCHANGE is not
already defined i.e use `1 << 0` instead of `1 << 2` which seems
incorrect.

Reference: f2906aa863/include/uapi/linux/fs.h (L50-L52)

Signed-off-by: Aditya R <arajan@redhat.com>
2022-06-08 00:31:14 +05:30
Giuseppe Scrivano
f3f993f157
main: ignore EOVERFLOW when copying xattrs
the kernel returns EOVERFLOW if the rootid cannot be mapped in the
current user namespace when reading the file capabilities
(security.capabilities xattr).

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-06-01 11:40:19 +02:00
Tuupertunut
01f49e9d4b Fix setting attributes on file without permissions
Signed-off-by: Tuupertunut <tuupertunut@outlook.com>
2022-05-27 03:50:18 +03:00
Giuseppe Scrivano
592e50e271
main: fix lookup if underlying file is a symlink
fix lookup if the underlying file is a symlink, while it is a
directory on the upper layer.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-02-01 10:55:46 +01:00
Giuseppe Scrivano
0476f8464b
main: fix type for ioctl
fuse_reply_ioctl expects a int.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-17 17:51:10 +01:00
Giuseppe Scrivano
6d4dbb88fc
main: fix code style
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-17 17:03:45 +01:00
Giuseppe Scrivano
59816ac69d
main: always lookup the parent directory
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-17 17:03:14 +01:00
Giuseppe Scrivano
2a766e3912
main: use full path to detect existing node
Closes: https://github.com/containers/fuse-overlayfs/issues/333

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-17 16:57:42 +01:00
Giuseppe Scrivano
5f43fb17ac
main: honor user.overlay. xattrs
native overlay uses user.overlay to store the overlay metadata instead
of trusted.overlay, let's honor it as well.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-22 11:10:10 +01:00
Giuseppe Scrivano
30791df55f
main: add a mount flag to disable ACLs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-15 12:22:58 +02:00
Giuseppe Scrivano
b5967c7e8c
main: fix check for FUSE_CAP_POSIX_ACL
fix the check for FUSE_CAP_POSIX_ACL.  commit
0a659e75ef61456bda1fa4b0b30117296f66f4fe introduced the issue.

It is needed to run fuse-overlayfs on RHEL 7 kernels.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-09 11:42:33 +02:00
Giuseppe Scrivano
0a659e75ef
main: set FUSE_CAP_POSIX_ACL only when supported
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-08-04 21:28:25 +02:00
Giuseppe Scrivano
c45d315d19
Merge pull request #309 from sipsma/whiteout-in-opaque
Don't create whiteout files in opaque dirs.
2021-07-08 16:17:29 +02:00
Erik Sipsma
e5ce44256f Don't create whiteout files in opaque dirs.
If a dir is opaque, there's no need to create a whiteout within it as
the opacity will block out any files from lower dirs already anyways.

The kernel's overlay implementation also doesn't currently handle
whiteouts in opaque dirs very well (the whiteout shows up in readdir
calls but can't be stat'd), so this fix also improves compatibility
between fuse-overlay and the kernel's overlay a bit too.

Signed-off-by: Erik Sipsma <erik@sipsma.dev>
2021-07-07 04:19:58 +00:00
Nate Coraor
6819869a8f Fix operations on read-only files when running unprivileged.
Fixes #307
2021-07-02 14:12:15 -04:00
Giuseppe Scrivano
dd7e124dea
main: enable POSIX ACLs
Closes: https://github.com/containers/fuse-overlayfs/issues/304

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-23 21:51:37 +02:00