345 Commits

Author SHA1 Message Date
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
Giuseppe Scrivano
e9cdbc444c
main: print usage statistics on USR1
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 11:10:33 +02:00
Giuseppe Scrivano
540f80dbe8
main: record how many objects are in memory
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-06 11:10:33 +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
Giuseppe Scrivano
4725e0ba66
main: reserve sfs.f_namemax for whiteout prefix
redure the reported sfs.f_namemax by the maximum length that can be
added for whiteout files.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-04 16:45:07 +02:00
Giuseppe Scrivano
d34833dfb3
main: skip ENAMETOOLONG for whiteouts lookup
adding the .wh. prefix could cause the lookup to cross the f_namemax
limit and fail the lookup with ENAMETOOLONG.  If the lookup fails with
ENAMETOOLONG then the whiteout file doesn't exist.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-04 16:41:42 +02: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
b1cc0e2b98
main: honor chownat flags
honor the specified flags to fchownat.

commit 50787d38278fa41c1b3f8167ccfe13ec83d9a063 introduced the
regression.

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

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-09-03 22:25:02 +02:00
Giuseppe Scrivano
b958a3062e
Merge pull request #230 from mgoltzsche/fix_alpine_file_exists_at
utils.c: fix file_exists_at on musl.
2020-08-27 09:43:56 +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
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
50787d3827
main: prepare wrappers for chown/chmod
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-21 16:43:59 +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
8f666d4820
main: fix segfault if no mountpoint specified
Closes: https://github.com/containers/fuse-overlayfs/issues/225

Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-07-17 23:39:03 +02:00
Giuseppe Scrivano
2b8dff330f
main: fix memory leak when creating a whiteout
Closes: https://github.com/containers/fuse-overlayfs/issues/222

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-29 13:54:22 +02:00
Giuseppe Scrivano
1d8f4b529d
main: fix lookup for overflow uid
we were mistakenly using the overflow GID also for UIDs lookups.  Not
a big issue as they usually have the same value.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-20 20:34:28 +02:00
Giuseppe Scrivano
0d985794d9
main: add error checks for workdir initialization
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-20 20:33:52 +02:00
Giuseppe Scrivano
f26f1f71ae
mkdir: if the destination exists atomically swap them
if the destination already exists as it could not be properly cleaned
up, attempt to atomically swap the two directories and free the old
one.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-17 15:05:00 +02:00
Giuseppe Scrivano
6d75146e29
main: correctly report copyup error
the copyup function returns the error code set in ret.  Make sure ret
has the correct return code if set_fd_origin fails.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-05-26 22:20:15 +02:00
Giuseppe Scrivano
f6262ed778
main: fix copy loop
fix potential infinite loop on a short read.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:32 +02:00
Giuseppe Scrivano
9b687001bb
main: fix signature for ovl_ioctl
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:31 +02:00
Giuseppe Scrivano
cb934ef871
main: delete dead code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:30 +02:00
Giuseppe Scrivano
b947555f87
main: remove superflous check
pnode cannot be NULL.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:30 +02:00
Giuseppe Scrivano
33a3a7970e
main: avoid double free on cleanup
the cleanup_node_init label already takes care of it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 15:13:29 +02:00
Giuseppe Scrivano
5b271aa796
main: add check for malloc
Signed-off-by: Giuseppe Scrivano <giuseppe@scrivano.org>
2020-04-25 13:43:00 +02:00