Bug 1348671 - [PATCH] install-info: Use create-tmp-then-rename pattern
Summary: [PATCH] install-info: Use create-tmp-then-rename pattern
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: texinfo
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Vitezslav Crhonek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1352154
TreeView+ depends on / blocked
 
Reported: 2016-06-21 17:39 UTC by Colin Walters
Modified: 2016-07-02 19:32 UTC (History)
2 users (show)

Fixed In Version: texinfo-6.1-3.fc24 texinfo-6.0-3.fc23
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-23 17:53:17 UTC


Attachments (Terms of Use)
0001-install-info-Use-create-tmp-then-rename-pattern.patch (1.71 KB, application/mbox)
2016-06-21 17:39 UTC, Colin Walters
no flags Details

Description Colin Walters 2016-06-21 17:39:45 UTC
Created attachment 1170337 [details]
0001-install-info-Use-create-tmp-then-rename-pattern.patch

From 23c3374a73a438029c17bcf385e7486754bead7a Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Tue, 21 Jun 2016 13:02:04 -0400
Subject: [PATCH] install-info: Use create-tmp-then-rename pattern

rpm-ostree uses
https://github.com/ostreedev/ostree/blob/master/man/rofiles-fuse.xml
when running `%post` scripts, to avoid corruption of the underlying
hardlink store.

Switch to that pattern to be compatible.
---
 install-info/install-info.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/install-info/install-info.c b/install-info/install-info.c
index 4e39122..ef29eaf 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -954,18 +954,23 @@ output_dirfile (char *dirfile, int dir_nlines, struct line_data *dir_lines,
   int n_entries_added = 0;
   int i;
   FILE *output;
+  char *dirfile_tmp = NULL;
+
+  asprintf (&dirfile_tmp, "%s.tmp", dirfile);
+  if (!dirfile_tmp)
+    xalloc_die ();
 
   if (compression_program)
     {
-      char *command = concat (compression_program, ">", dirfile);
+      char *command = concat (compression_program, ">", dirfile_tmp);
       output = popen (command, "w");
     }
   else
-    output = fopen (dirfile, "w");
+    output = fopen (dirfile_tmp, "w");
 
   if (!output)
     {
-      perror (dirfile);
+      perror (dirfile_tmp);
       exit (EXIT_FAILURE);
     }
 
@@ -1076,6 +1081,12 @@ output_dirfile (char *dirfile, int dir_nlines, struct line_data *dir_lines,
     pclose (output);
   else
     fclose (output);
+
+  if (rename (dirfile_tmp, dirfile) < 0)
+    {
+      perror (dirfile_tmp);
+      exit (EXIT_FAILURE);
+    }
 }
 ^L
 /* Parse the input to find the section names and the entry names it
-- 
2.5.5

Comment 1 Vitezslav Crhonek 2016-06-22 07:58:42 UTC
I would add free (dirfile_tmp) at the end, otherwise the patch looks fine, I'll apply it. Thanks.

Comment 2 Colin Walters 2016-06-22 12:56:30 UTC
Yep, sorry - I had the free() in a version of this patch, but I lost it when juggling multiple branches.  Thanks for the review!

Comment 3 Fedora Update System 2016-06-22 13:35:30 UTC
texinfo-6.1-3.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-81e90d2724

Comment 4 Fedora Update System 2016-06-22 13:40:59 UTC
texinfo-6.0-3.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e9bc854cca

Comment 5 Fedora Update System 2016-06-22 22:59:17 UTC
texinfo-6.0-3.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-e9bc854cca

Comment 6 Fedora Update System 2016-06-22 23:02:25 UTC
texinfo-6.1-3.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-81e90d2724

Comment 7 Fedora Update System 2016-06-23 17:53:15 UTC
texinfo-6.1-3.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2016-07-02 19:32:07 UTC
texinfo-6.0-3.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.