diff -ru gzip-1.2.4/gzip.c gzip-1.2.4.ddm/gzip.c --- gzip-1.2.4/gzip.c 1993-08-19 09:39:43.000000000 -0400 +++ gzip-1.2.4.ddm/gzip.c 2005-04-13 18:13:22.404915816 -0400 @@ -279,7 +279,7 @@ local void version OF((void)); local void treat_stdin OF((void)); local void treat_file OF((char *iname)); -local int create_outfile OF((void)); +local int create_outfile OF((struct stat *istat)); local int do_stat OF((char *name, struct stat *sbuf)); local char *get_suffix OF((char *name)); local int get_istat OF((char *iname, struct stat *sbuf)); @@ -793,7 +793,7 @@ ofd = fileno(stdout); /* keep remove_ofname as zero */ } else { - if (create_outfile() != OK) return; + if (create_outfile(&istat) != OK) return; if (!decompress && save_orig_name && !verbose && !quiet) { fprintf(stderr, "%s: %s compressed to %s\n", @@ -860,7 +860,8 @@ * ofname has already been updated if there was an original name. * OUT assertions: ifd and ofd are closed in case of error. */ -local int create_outfile() +local int create_outfile(istat) + struct stat *istat; { struct stat ostat; /* stat for ofname */ int flags = O_WRONLY | O_CREAT | O_EXCL | O_BINARY; @@ -876,7 +877,7 @@ } /* Create the output file */ remove_ofname = 1; - ofd = OPEN(ofname, flags, RW_USER); + ofd = OPEN(ofname, flags, istat->st_mode & 07777); if (ofd == -1) { perror(ofname); close(ifd); @@ -1608,7 +1609,8 @@ /* ======================================================================== - * Copy modes, times, ownership from input file to output file. + * Copy times and ownership from input file to output file. Modes are set + * when the output file is created. * IN assertion: to_stdout is false. */ local void copy_stat(ifstat) @@ -1623,11 +1625,6 @@ } reset_times(ofname, ifstat); #endif - /* Copy the protection modes */ - if (chmod(ofname, ifstat->st_mode & 07777)) { - WARN((stderr, "%s: ", progname)); - if (!quiet) perror(ofname); - } #ifndef NO_CHOWN chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */ #endif