]> granicus.if.org Git - recode/commitdiff
Don’t insist on chmod succeeding for output files
authorReuben Thomas <rrt@sc3d.org>
Tue, 16 Jan 2018 00:23:58 +0000 (00:23 +0000)
committerReuben Thomas <rrt@sc3d.org>
Fri, 19 Jan 2018 00:19:36 +0000 (00:19 +0000)
Support file systems that lack permissions (e.g. FAT).

Fixes Debian bug #237249.

src/main.c

index 9a264c7e96e033653c1534f34f29027afca64f61..6bccfc04e543e6b28837145664931f1fef7fabbe 100644 (file)
@@ -878,10 +878,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"),
                  if (unlink (input_name) < 0)
                    error (EXIT_FAILURE, errno, "unlink (%s)", input_name);
 
-                 /* Preserve the file permissions.  */
+                 /* Preserve the file permissions if possible.  */
+
+                 chmod (output_name, file_stat.st_mode & 07777);
 
-                 if (chmod (output_name, file_stat.st_mode & 07777) < 0)
-                   error (EXIT_FAILURE, errno, "chmod (%s)", output_name);
                  if (rename (output_name, input_name) < 0)
                    error (EXIT_FAILURE, errno, "rename (%s, %s)",
                           output_name, input_name);