1 --- bzip2-1.0.2/bzip2.c.nochmod 2005-05-10 16:19:45.000000000 +0200
2 +++ bzip2-1.0.2/bzip2.c 2005-05-10 16:22:00.000000000 +0200
5 static void copyFileName ( Char*, Char* );
6 static void* myMalloc ( Int32 );
7 +static int applySavedFileAttrToOutputFile ( int fd );
12 ret = fflush ( zStream );
13 if (ret == EOF) goto errhandler_io;
14 if (zStream != stdout) {
15 + int fd = fileno ( zStream );
16 + if (fd < 0) goto errhandler_io;
17 + ret = applySavedFileAttrToOutputFile ( fd );
18 + if (ret != 0) goto errhandler_io;
19 ret = fclose ( zStream );
20 outputHandleJustInCase = NULL;
21 if (ret == EOF) goto errhandler_io;
25 if (ferror(zStream)) goto errhandler_io;
26 + if ( stream != stdout) {
27 + int fd = fileno ( stream );
28 + if (fd < 0) goto errhandler_io;
29 + ret = applySavedFileAttrToOutputFile ( fd );
30 + if (ret != 0) goto errhandler_io;
32 ret = fclose ( zStream );
33 if (ret == EOF) goto errhandler_io;
39 -void applySavedMetaInfoToOutputFile ( Char *dstName )
40 +void applySavedTimeInfoToOutputFile ( Char *dstName )
44 @@ -1134,16 +1145,26 @@
45 uTimBuf.actime = fileMetaInfo.st_atime;
46 uTimBuf.modtime = fileMetaInfo.st_mtime;
48 - retVal = chmod ( dstName, fileMetaInfo.st_mode );
49 - ERROR_IF_NOT_ZERO ( retVal );
51 retVal = utime ( dstName, &uTimBuf );
52 ERROR_IF_NOT_ZERO ( retVal );
57 +int applySavedFileAttrToOutputFile ( int fd )
62 + retVal = fchmod ( fd, fileMetaInfo.st_mode );
66 - retVal = chown ( dstName, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
67 + (void) fchown ( fd, fileMetaInfo.st_uid, fileMetaInfo.st_gid );
68 /* chown() will in many cases return with EPERM, which can
77 /*--- If there was an I/O error, we won't get here. ---*/
78 if ( srcMode == SM_F2F ) {
79 - applySavedMetaInfoToOutputFile ( outName );
80 + applySavedTimeInfoToOutputFile ( outName );
81 deleteOutputOnInterrupt = False;
82 if ( !keepInputFiles ) {
83 IntNative retVal = remove ( inName );
85 /*--- If there was an I/O error, we won't get here. ---*/
86 if ( magicNumberOK ) {
87 if ( srcMode == SM_F2F ) {
88 - applySavedMetaInfoToOutputFile ( outName );
89 + applySavedTimeInfoToOutputFile ( outName );
90 deleteOutputOnInterrupt = False;
91 if ( !keepInputFiles ) {
92 IntNative retVal = remove ( inName );