summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-09-04 13:42:51 +0200
committerAndreas Gruenbacher <agruen@suse.de>2009-09-04 13:55:32 +0200
commitba37782d741e8921036bf939127a1aa62ecb13c3 (patch)
tree7dc4f18c8cec480f20a6faf56fa577fd0b449fce
parent80d8b7827b65c186ccf93c56628dfce355ea44e1 (diff)
downloadpatch-ba37782d741e8921036bf939127a1aa62ecb13c3.tar.gz
Try to preserve the owning group of patched files
-rw-r--r--ChangeLog3
-rw-r--r--src/patch.c15
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f944d44..43d61dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);