diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2009-09-04 13:42:51 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2009-09-04 13:55:32 +0200 |
commit | ba37782d741e8921036bf939127a1aa62ecb13c3 (patch) | |
tree | 7dc4f18c8cec480f20a6faf56fa577fd0b449fce | |
parent | 80d8b7827b65c186ccf93c56628dfce355ea44e1 (diff) | |
download | patch-ba37782d741e8921036bf939127a1aa62ecb13c3.tar.gz |
Try to preserve the owning group of patched files
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/patch.c | 15 |
2 files changed, 15 insertions, 3 deletions
@@ -3,6 +3,9 @@ * Makefile.in (LIBSRCS, LIBHDRS, LIBM4FILES): Add the gnulib which were imported on 2009-06-05 here as well. + * src/partime.c (main): Try to preserve the owning group of patched + files. + 2009-07-19 Andreas Gruenbacher <agruen@suse.de> * gl/lib/full-write.c, gl/lib/safe-write.c, gl/lib/full-write.h, diff --git a/src/patch.c b/src/patch.c index 8f9c6ee..c935592 100644 --- a/src/patch.c +++ b/src/patch.c @@ -408,9 +408,18 @@ main (int argc, char **argv) quotearg (outname)); } - if (! inerrno && chmod (outname, instat.st_mode) != 0) - pfatal ("Can't set permissions on file %s", - quotearg (outname)); + if (! inerrno) + { + if (chmod (outname, instat.st_mode) != 0) + pfatal ("Can't set permissions on file %s", + quotearg (outname)); + if (geteuid () != instat.st_gid) + { + /* Fails if we are not in group instat.st_gid. */ + chown (outname, -1, instat.st_gid); + } + /* FIXME: There may be other attributes to preserve. */ + } } else create_backup (outname, 0, 0, true); |