diff --git a/src/basic/copy.c b/src/basic/copy.c index b384010ae3..54f7235b16 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -969,6 +969,21 @@ int copy_times(int fdf, int fdt, CopyFlags flags) { return 0; } +int copy_access(int fdf, int fdt) { + struct stat st; + + assert(fdf >= 0); + assert(fdt >= 0); + + if (fstat(fdf, &st) < 0) + return -errno; + + if (fchmod(fdt, st.st_mode & 07777) < 0) + return -errno; + + return 0; +} + int copy_xattr(int fdf, int fdt) { _cleanup_free_ char *names = NULL; int ret = 0, r; diff --git a/src/basic/copy.h b/src/basic/copy.h index af8e88af04..ab9031038e 100644 --- a/src/basic/copy.h +++ b/src/basic/copy.h @@ -61,4 +61,5 @@ static inline int copy_bytes(int fdf, int fdt, uint64_t max_bytes, CopyFlags cop } int copy_times(int fdf, int fdt, CopyFlags flags); +int copy_access(int fdf, int fdt); int copy_xattr(int fdf, int fdt);