47 Commits

Author SHA1 Message Date
Giuseppe Scrivano
6a1040f01d
main: lookup upperdir only for created directories
always stop looking up at the upper layer for newly created
directories so to not expose the lower directory content.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-05-07 11:56:22 +02:00
Giuseppe Scrivano
27cabd561b
main: Allow escaped colons in directory paths
Allow directory paths specified for lowerdir, upperdir and workdir to
contain colon characters.

Previously, colons were unconditionally treated as separators,
making it impossible to use directories with colons in their names.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-04-28 18:46:30 +02:00
Giuseppe Scrivano
af77bb6584
tests: bump fedora version
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-12-02 09:52:35 +01: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
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
da0f9cb03b tests: Use Fedora to test fast_ino_check
The test of fast_ino_check used CentOS Stream 8, which is no longer
supported and whose repositories are no longer available.

While we can update it to use CentOS Stream 9, use Fedora instead for
consistency with the other test cases.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 17:51:50 +09:00
Akihiko Odaki
3a1b242526 tests: Drop the test case for https://github.com/containers/fuse-overlayfs/issues/86
The test case for https://github.com/containers/fuse-overlayfs/issues/86
does no longer work because it relies on CentOS Stream 8 repositories,
which are unavailable.

While we can update it to use CentOS Stream 9, the issue says it is
limited to CentOS 6, and it is unclear if the test case will reproduce
the intended scenario with CentOS Stream 8 or 9 so drop it.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
2024-06-17 17:49:20 +09: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
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
dcfadc012e
tests: use centos:stream8
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-02-01 09:54:20 +01:00
Giuseppe Scrivano
cbb4594654
test: fix race when opening file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-07-29 11:05:29 +02:00
Giuseppe Scrivano
79f885bc7b
tests: fix race condition
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-07-28 15:40:46 +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
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
11ad142525
main: fix reading xattrs longer than 256 bytes
fix reading extended attributes longer than 256 bytes.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-21 17:50:06 +01:00
Giuseppe Scrivano
d612d48326
main: mark directory not loaded on rename
if a whiteout was created as part of a rename operation, mark the
directory content as not loaded so to avoid some optimizations when a
whiteout file must be deleted.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-05 17:51:18 +01:00
Giuseppe Scrivano
5530c154d8
tests: fix test
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 12:00:12 +01:00
Giuseppe Scrivano
450b0d790f
fuse-overlayfs: fix renameat2(RENAME_NOREPLACE)
when device whiteouts are created (supported for unprivileged users in
newer Linux kernels) make sure the RENAME_NOREPLACE flag is dropped
when renaming the file on top of an existing whiteout.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-01 23:00:50 +01:00
Giuseppe Scrivano
abf77369b3
tests: upgrade to centos:8
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-21 17:44:49 +01:00
Giuseppe Scrivano
53f598afea
tests: drop -ti
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-21 17:04:29 +01:00
Giuseppe Scrivano
98c62ee1a0
main: open hidden files
if a file is delete and not accessible from the file system, but it is
still referenced, we must be able to open and use it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-02 13:20:31 +01:00
Giuseppe Scrivano
a65b310508
build: rename Dockerfile to Containerfile
since these files need the -v option that is not present with Docker,
rename the files to Containerfile to avoid confusion.

more info: https://twitter.com/cpuguy83/status/1313523894536429568

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 19:22:49 +02:00
Giuseppe Scrivano
573cfac0a6
main: prevent creating files longer than f_namemax
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-04 20:30:02 +02:00
Max Goltzsche
d5b725b6f1
utils.c: fix file_exists_at musl compatibility.
utils.c: file_exists_at: fallback to `fstatat` when `faccessat` fails with `EINVAL` (on musl).
.travis.yml: alpine test added.
main.c: reallocate path before appending.

Closes #174.

Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
2020-08-26 02:22:53 +02:00
Giuseppe Scrivano
83ae5cc252
tests/unlink.sh: make sure directories are empty
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:28 +02:00
Giuseppe Scrivano
26e4226a41
main: fix set mtime for a symlink
Closes: https://github.com/containers/fuse-overlayfs/issues/204

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-04-25 13:28:33 +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
Giuseppe Scrivano
dfd9f18773
main: prevent parent whiteout to hide file
use the full relative path when looking up the whiteout file,
otherwise a whiteout in the upper layer will hide files in
subdirectories.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-27 21:03:21 +01:00
Nalin Dahyabhai
5b4989a869 tests: test that touch -h works
verify that setting attributes on a dangling symlink work, even if the
file type is different on a lower layer.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-15 18:02:35 -05:00
Giuseppe Scrivano
2403cd9537
main: honor opaque whiteout
Closes: https://github.com/containers/fuse-overlayfs/issues/138

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-04 08:36:37 +01:00
Giuseppe Scrivano
042846de50
main: correctly mark the last_layer with a deleted directory
Closes: https://github.com/containers/fuse-overlayfs/issues/136

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-31 14:26:15 +01:00
Giuseppe Scrivano
c9bbc94ab6
fuse-overlayfs: support running without upper layer
when there is no upper layer specified, fail every read operation with
EROFS.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-19 21:33:35 +02:00
Giuseppe Scrivano
45c902ea87
main.c: reload the directory on stat
make sure the directory is reloaded so the correct number of links can
be retrieved.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-15 12:55:55 +02:00
Giuseppe Scrivano
86b9cf5a83
writeback: restore suid mode after write
restore the inode mode if there is a writepage request that could
reset the setuid bit.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-03 16:07:02 +02:00
Giuseppe Scrivano
7251f20c4b
main: correctly read inode for unix sockets
correctly read the inode when processing a UNIX socket.

regression introduced by b25bbde64dc5d06373e087d7fae6367acf1fd09e.

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

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-08-25 23:06:32 +02:00
Giuseppe Scrivano
b25bbde64d
main: introduce inodes cache
introduce a hash map to refer from an inode to the file paths.
A recent change where we enable FUSE writeback by default uncovered an
underlying issue in fuse-overlayfs where changes to a file with
multiple links would not be visible from the other link.

For each inode, maintain a list of nodes that refer to it, so that we
can still access it when a link is removed and more importantly we can
use the inode value with FUSE.

Closes: https://github.com/containers/fuse-overlayfs/issues/108
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1744109

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-08-23 15:27:12 +02:00
Giuseppe Scrivano
08136d8826
main: if the path is a dir, work on the proc path
when reading xattr, if the path cannot be open as it is a directory,
operate on the /proc/fd/FD path.

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

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-08-15 21:55:25 +02:00
Giuseppe Scrivano
62cbd9977c
tests: add test to read back all the container
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-22 12:34:36 +02:00
Giuseppe Scrivano
740b886db2
tests: perform unlink on the mountpoint
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-22 12:34:35 +02:00
Giuseppe Scrivano
528bdc65d4
tests: add tests for new features
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-07-22 12:34:29 +02:00
Giuseppe Scrivano
9adc80c31b
Revert "main: add helper function to get fd to the upper layer"
This reverts commit b4ef7a8fff0a76ac05dccb59edbbb49971b76420.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-21 10:07:39 +02:00
Giuseppe Scrivano
e9f5f04883
rm: fix regression when deleting a file
fix a regression caused by 7dcef0769b1521b8f14bdee58339c26140466c85

Closes: https://bodhi.fedoraproject.org/updates/FEDORA-2019-fff1ded16e#comment-958825

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-06-12 21:17:09 +02:00
Giuseppe Scrivano
02dcd8a3e1
fuse-overlayfs: do not copyup a whiteout on rename
Closes: https://github.com/containers/fuse-overlayfs/issues/69

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2019-05-03 13:02:16 +02:00
Giuseppe Scrivano
3a921aa5d7
fuse-overlayfs: fix first unlink done
fix a regression introduced by f64f65287817fecd0 that prevents a
whiteout file to be created on the first unlink.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-27 21:26:45 +01:00
Giuseppe Scrivano
71be2a838f
.travis.yml: add tests for installing rpm packages on fuse-overlayfs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-17 20:44:54 +01:00