Commit Graph

28 Commits

Author SHA1 Message Date
Miloslav Trmač 5c67136767 Move pkg/chunked/internal to pkg/chunked/internal/minimal
We now have several internal subpackages of pkg/chunked, so delineate
more explicitly the parts that should be kept as small as possible
because the c/image compression package depends on them.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-12-13 01:27:58 +01:00
Giuseppe Scrivano ce0186617a
chunked: improve creation of files under root
ihen the file name is the root directory, avoid using an empty string
or the ".." name to open the file.  The latter does not cause any
security issues or unexpected behavior, it is logically incorrect and
should be avoided.

Closes: https://github.com/containers/storage/issues/2191

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-12-11 13:36:03 +01:00
Giuseppe Scrivano c33a45d30b
chunked: clarify recursion termination condition
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-12-11 11:03:41 +01:00
Colin Walters 12363bda1b overlay,chunked: Add some more O_CLOEXEC
Just some more missing `O_CLOEXEC` I noticed while reading
the code for unrelated reasons.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-07-29 08:42:39 -04:00
Miloslav Trmač 412ff916c2 Remove various unused parameters
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2024-07-10 23:54:30 +02:00
Jan Rodák 3b348dc157 Fix errcheck: error return value of `unix.Unlinkat` is not checked
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2024-07-09 16:46:49 +02:00
openshift-merge-bot[bot] 04e417873e
Merge pull request #1959 from cgwalters/no-file-uint
chunked: Fix two minor linter issues
2024-06-07 19:19:59 +00:00
Giuseppe Scrivano 097fcb9be6
chunked: return PathError for appendHole errors
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:27 +02:00
Giuseppe Scrivano 3e272b739f
chunked: return PathError for mknodat
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:27 +02:00
Giuseppe Scrivano 7f546d3443
chunked: return PathError for symlinkat
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:27 +02:00
Giuseppe Scrivano 1512399b81
chunked: return PathError for mkdirat
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:27 +02:00
Giuseppe Scrivano 4955d9b3f1
chunked: return better error for Dup failures
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:27 +02:00
Giuseppe Scrivano 915afd193d
chunked: return PathError for open*
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:26 +02:00
Giuseppe Scrivano cdf703fa81
chunked: return PathError for fsetxattr
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:26 +02:00
Giuseppe Scrivano 145b4f9a52
chunked: return PathError for utimensat
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:25:25 +02:00
Giuseppe Scrivano 7094880624
chunked: return PathError for Linkat errors
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:24:53 +02:00
Giuseppe Scrivano 886d4eedba
chunked: return PathError for fchmodat/fchmod
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:24:27 +02:00
Giuseppe Scrivano d1447ae783
chunked: unify chown calls
refactor all calls to Fchown and Fchownat into a single function, and
provide a better error messages.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:24:27 +02:00
Giuseppe Scrivano 62c4c243a3
chunked: refactor doHardLink to get full destination path
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 17:24:23 +02:00
Colin Walters 6371f588df chunked: Fix two minor linter issues
My IDE runs a linter by default, and these two show up.
For the file one, it's because `Fd()` returns `uintptr`
which is unsigned and can't be negative.  IOW, a `File`
object should always be a valid opened fd.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-07 10:15:11 -04:00
Colin Walters cfde71b024 chunked: Add helpers for /proc/self/fd accesses
It's not hard to grep for /proc/self/fd, but this way is a bit
cleaner and avoids typos, etc.

Signed-off-by: Colin Walters <walters@verbum.org>
2024-06-07 09:30:55 -04:00
Giuseppe Scrivano c4ba01f635
chunked: use filepath.Split() instead of Dir()/Base()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 14:37:42 +02:00
Giuseppe Scrivano 4c716c8628
chunked: honor mode for mkdirat
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-07 08:32:24 +02:00
Giuseppe Scrivano 61a2c5ddf3
chunked: refactor args to openOrCreateDirUnderRoot()
follow the same pattern used by other functions

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 22:33:43 +02:00
Giuseppe Scrivano 7c61cfaee7
chunked: refactor args to openFileUnderRoot()
follow the same pattern used by other functions.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 22:33:43 +02:00
Giuseppe Scrivano c811876d13
chunked: fix opening parent dir
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 22:33:43 +02:00
Giuseppe Scrivano 2278cb1e0e
chunked: provide constructor for seekableFile
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 21:37:13 +02:00
Giuseppe Scrivano 37800897ab
chunked: split file operations to a new file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-06-06 13:11:46 +02:00