]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/gzip-1.3.5-perm.patch
Wir kehren zurueck zu Kudzu, da hwinfo noch mehr Aerger macht.
[people/teissler/ipfire-2.x.git] / src / patches / gzip-1.3.5-perm.patch
CommitLineData
cd1a2927
MT
1fix CAN-2005-0988 race condition when setting file permissions
2borrowed from fedora
3
4--- gzip-1.3.5/gzip.c.perm 2005-04-26 14:22:58.211395152 +0200
5+++ gzip-1.3.5/gzip.c 2005-04-26 14:24:10.414418624 +0200
6@@ -881,6 +881,20 @@
7 }
8
9 close(ifd);
10+ /* ofd ownership and permissions have to be set before close(ofd)*/
11+ if (!to_stdout) {
12+ if (fchmod(ofd, istat.st_mode & 07777)) {
13+ int e = errno;
14+ WARN((stderr, "%s: ", progname));
15+ if (!quiet) {
16+ errno = e;
17+ perror(ofname);
18+ }
19+ }
20+#ifndef NO_CHOWN
21+ fchown(ofd, istat.st_uid, istat.st_gid); /* Copy ownership */
22+#endif
23+ }
24 if (!to_stdout && close(ofd)) {
25 write_error();
26 }
27@@ -902,7 +916,7 @@
28 }
29 fprintf(stderr, "\n");
30 }
31- /* Copy modes, times, ownership, and remove the input file */
32+ /* Copy times and remove the input file */
33 if (!to_stdout) {
34 copy_stat(&istat);
35 }
36@@ -1715,7 +1729,7 @@
37
38
39 /* ========================================================================
40- * Copy modes, times, ownership from input file to output file.
41+ * Copy times from input file to output file.
42 * IN assertion: to_stdout is false.
43 */
44 local void copy_stat(ifstat)
45@@ -1730,18 +1744,6 @@
46 }
47 reset_times(ofname, ifstat);
48 #endif
49- /* Copy the protection modes */
50- if (chmod(ofname, ifstat->st_mode & 07777)) {
51- int e = errno;
52- WARN((stderr, "%s: ", progname));
53- if (!quiet) {
54- errno = e;
55- perror(ofname);
56- }
57- }
58-#ifndef NO_CHOWN
59- chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
60-#endif
61 remove_ofname = 0;
62 /* It's now safe to remove the input file: */
63 if (xunlink (ifname)) {