bug-patch
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-patch] file's group not preserved after patch


From: Brian R. Landy
Subject: [bug-patch] file's group not preserved after patch
Date: Sun, 30 Aug 2009 12:31:59 -0400

After patching a file its group is changed to that of the tempfile that is created instead of retaining the original group.

I'm attaching a crude patch that resolves the issue (although probably there are better ways to do this). I was testing with patch-2.5.9-81, the later version available would not compile for me as it was missing getopt_int.h.

Thanks,
Brian

--- patch-2.5.9-81-gaad98f0/util.c      2009-04-04 19:47:38.000000000 -0500
+++ patch-2.5.9-81-gaad98f0_patched/util.c 2009-08-30 11:05:33.000000000 -0500
@@ -272,6 +272,8 @@
        say ("Renaming file %s to %s\n",
             quotearg_n (0, from), quotearg_n (1, to));

+      struct stat tostat;
+      stat(to, &tostat);
       if (rename (from, to) != 0)
        {
          bool to_dir_known_to_exist = false;
@@ -307,6 +309,7 @@
        }

     rename_succeeded:
+      chown(to,-1,tostat.st_gid);
       if (fromst)
        insert_file (fromst);
       /* Do not clear *FROM_NEEDS_REMOVAL if it's possible that the





reply via email to

[Prev in Thread] Current Thread [Next in Thread]