Instead of hard-coding the permission mode, stat() the source file and use its mode to create the destination file.
Signed-off-by: Djalal Harouni <tix...@opendz.org> --- src/shared/util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/util.c b/src/shared/util.c index d086fac..0886674 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -4133,16 +4133,20 @@ int vt_disallocate(const char *name) { int copy_file(const char *from, const char *to, int flags) { _cleanup_close_ int fdf = -1; + struct stat st = {}; int r, fdt; assert(from); assert(to); + if (stat(from, &st) < 0) + return -errno; + fdf = open(from, O_RDONLY|O_CLOEXEC|O_NOCTTY); if (fdf < 0) return -errno; - fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0644); + fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, st.st_mode); if (fdt < 0) return -errno; -- 1.7.11.7 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel