1271138
diff -up dos2unix-3.1/dos2unix.c.preserve-file-modes dos2unix-3.1/dos2unix.c
1271138
--- dos2unix-3.1/dos2unix.c.preserve-file-modes	2008-09-08 09:58:05.000000000 +0100
1271138
+++ dos2unix-3.1/dos2unix.c	2008-09-08 10:16:04.000000000 +0100
1271138
@@ -320,9 +320,10 @@ int ConvertDosToUnixNewFile(char *ipInFN
1271138
   struct stat StatBuf;
1271138
   struct utimbuf UTimeBuf;
1271138
   int fd;
1271138
+  mode_t mask;
1271138
 
1271138
   /* retrieve ipInFN file date stamp */
1271138
-  if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
1271138
+  if (stat(ipInFN, &StatBuf))
1271138
     RetVal = -1;
1271138
 
1271138
   if((fd = MakeTempFileFrom(ipOutFN, &TempPath))<0) {
1271138
@@ -346,6 +347,12 @@ int ConvertDosToUnixNewFile(char *ipInFN
1271138
     RetVal = -1;
1271138
   }
1271138
 
1271138
+  /* preserve original mode as modified by umask */
1271138
+  mask = umask(0);
1271138
+  umask(mask);
1271138
+  if (!RetVal && fchmod(fd, StatBuf.st_mode & ~mask))
1271138
+    RetVal = -1;
1271138
+
1271138
   /* conversion sucessful? */
1271138
   if ((!RetVal) && (ConvertDosToUnix(InF, TempF, ipFlag)))
1271138
     RetVal = -1;