On Sat, 26.10.13 21:17, Zbigniew Jędrzejewski-Szmek (zbys...@in.waw.pl) wrote:
> > On Sat, Oct 26, 2013 at 12:59:40AM +0100, Djalal Harouni wrote: > > Instead of hard-coding the permission mode, stat() the source file and > > use its mode to create the destination file. > Hi, > > Is this patch trying to fix something specific? copy_file is only used > to copy resolv.conf into the container. It's unlikely that the mode > from host is relevant in the container. (Also, quick side note: doing the stat() separately before is creates a race. It's a mucher better idea to use fstat() here, so that we might not end up copying a mode over from an older file. -- but yeah, I agree with Zbigniew, I see no reason for this patch and if we really want this different then moving the mode into a copy_file() parameter to make it explicit sounds more robust anyway.) > > > Signed-off-by: Djalal Harouni <tix...@opendz.org> > No need to add that in systemd. > > Zbyszek > > > --- > > 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; > _______________________________________________ > systemd-devel mailing list > systemd-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/systemd-devel Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel