369 Commits

Author SHA1 Message Date
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
Giuseppe Scrivano
3f9fc4e8d3
main: drop unused variables
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-23 11:45:58 +02:00
Giuseppe Scrivano
12552f315f
main: check for parent->children before accessing it
this should not happen, but better be sure.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-21 22:45:47 +02:00
Giuseppe Scrivano
f41a872e0d
main: fix invalid access when filtering xattrs
Fix an invalid access when filtering internal xattrs.

The size passed to memmove was longer than the remaining bytes to
process.

As part of the fix: move the filtering logic to a separate function.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-21 22:45:46 +02:00
Giuseppe Scrivano
a8d7c0b0f4
main: avoid temporary copy
use directly node->path instead of copying it to a temporary buffer.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-19 09:32:39 +02:00
Giuseppe Scrivano
8241648406
main: fix a memory leak on errors
It was reported by static analysis.  The resource is not really leaked
since fuse-overlayfs exits immediately when load_default_plugins()
fails.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-19 09:25:48 +02:00
Daniel J Walsh
b2a8df7ea8
Merge pull request #290 from giuseppe/fix-fd-leak
main, rename: fix leak on error
2021-04-17 06:09:11 -04:00
Giuseppe Scrivano
0db6ecbbd9
main: move directory load at readdir time
move the logic for loading the directory content at readdir time when
the offset is set to 0, so that any new file to the directory is
propagated.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-16 21:53:37 +02:00
Giuseppe Scrivano
d4188a4f59
main, rename: fix leak on error
fix a fd leak on the error exit path.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-16 20:36:35 +02:00
cptpcrd
defd480c0e main: improve UTIME_NOW special-casing
FUSE never passes FUSE_SET_ATTR_ATIME_NOW without also passing
FUSE_SET_ATTR_ATIME. Since FUSE_SET_ATTR_ATIME_NOW was only checked if
FUSE_SET_ATTR_ATIME was not set, it would never be triggered.

Note that this is an *improvement*, not a *fix*, because FUSE always
passes the current time in st_atim whenever it sets
FUSE_SET_ATTR_ATIME_NOW. As a result, the previous code works properly,
but it does so differently from the way it was intended to.

(All of the above descriptions of st_atim handling also applies to
st_mtim.)
2021-04-13 21:33:00 -04:00
cptpcrd
d23dbe914d main: tv_sec -> tv_nsec
As specified in utimensat(2), *tv_nsec*, not *tv_sec*, should be set to
UTIME_NOW or UTIME_OMIT.

The way this bug manifests is that if utimensat() is called with
one of the timestamps set to UTIME_OMIT, fuse-overlayfs will
accidentally reset the timestamp to 1073741822, which is 2004-01-10
13:37:02 UTC.
2021-04-13 21:32:57 -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
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
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
062ec18711
main: honor FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT also for renames
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-05 14:56:55 +01:00
Giuseppe Scrivano
0d77a9fdd0
main: simplify logic for FUSE_OVERLAYFS_DISABLE_OVL_WHITEOUT
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-05 14:56:35 +01:00
Giuseppe Scrivano
44561349cd
main: use strncpy instead of strcpy
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:04:48 +01:00
Giuseppe Scrivano
c1fd9a7e0b
main: ignore write error
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:03:14 +01:00
Giuseppe Scrivano
360a0c6bfd
main: drop unused variable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:02:37 +01:00
Giuseppe Scrivano
5df063677b
main: check for asprintf return code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-03-04 11:00:46 +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
6f2af48a03
main: check if whiteout device already exists
on newer kernels unprivileged users can create whiteout devices.  If
the whiteout device creation failed with EEXIST, check whether the
existing file is already a whiteout.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-25 19:00:15 +01:00
Giuseppe Scrivano
3ae5b85c5b
main: fix compiler warning
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-20 09:29:05 +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
a513d3de66
main: block setting the user.containers. xattr
it is reserved for internal usage with containers/storage.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-11-07 12:08:18 +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
Daniel J Walsh
d450ee1560
Merge pull request #256 from giuseppe/open-rm-files
main: open hidden files
2020-11-03 17:08:45 -05: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
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
589e363cc8
main: honor option volatile
upstream Linux added an option "volatile" for overlay mounts that has
the same meaning as fsync=0 already supported by fuse-overlayfs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-21 18:03:17 +02:00
Shotaro Gotanda
e6012da12f main: fix typo
Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
2020-10-21 05:27:45 +09:00
Shotaro Gotanda
6043ce7ddb main: fix fuse_reply_error to use errno on malloc failure
fuse_reply_error should receive errno instead of ENOMEM just after
malloc returned NULL.

Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
2020-10-21 00:30:23 +09:00
Shotaro Gotanda
df46733cf8 main: fix fuse_reply_error to use ENOMEM on calloc failure
fuse_reply_error should receive ENOMEM instead of ENOENT.

Signed-off-by: Shotaro Gotanda <g.sho1500@gmail.com>
2020-10-21 00:25:57 +09:00
Shotaro Gotanda
65ea4595c4
fix typo 2020-10-20 06:41:44 +09:00
Daniel J Walsh
f009906072
Merge pull request #246 from giuseppe/create-inodes-0755
main: create inodes with 0755 with xattr_permissions
2020-10-10 07:16:29 -04:00
Giuseppe Scrivano
9eb724ca15
main: create inodes with 0755 with xattr_permissions
make sure the inodes are created with mode 0755 when using
xattr_permissions, otherwise the original permission could prevent
running on NFS.  Requires Linux 5.9 for NFS with xattr support.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-09 16:33:14 +02: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
3c4eb36f7b
Merge pull request #239 from giuseppe/leak-fix
main: fix a potential leak and be more aggressive on releasing inodes
2020-10-07 11:01:54 -04:00
Giuseppe Scrivano
0e33eb5da8
main: drop the ino if the last node is removed
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 17:47:36 +02:00
Giuseppe Scrivano
228544e71d
main: remove unreferenced inodes on forget_multi
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 17:47:35 +02:00
Giuseppe Scrivano
6e2675593c
main: attempt an inode free on releasedir
if the reference held by the directory is the last one, it would miss
to clean up the inode.  Fix it by calling do_forget.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 17:47:34 +02:00