386 Commits

Author SHA1 Message Date
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
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