From 1271138cb8faf82190d1c9108caec23c194d7950 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sep 08 2008 09:17:56 +0000 Subject: - Preserve file modes (bug #437465). --- diff --git a/dos2unix-preserve-file-modes.patch b/dos2unix-preserve-file-modes.patch new file mode 100644 index 0000000..1d4ab5d --- /dev/null +++ b/dos2unix-preserve-file-modes.patch @@ -0,0 +1,28 @@ +diff -up dos2unix-3.1/dos2unix.c.preserve-file-modes dos2unix-3.1/dos2unix.c +--- dos2unix-3.1/dos2unix.c.preserve-file-modes 2008-09-08 09:58:05.000000000 +0100 ++++ dos2unix-3.1/dos2unix.c 2008-09-08 10:16:04.000000000 +0100 +@@ -320,9 +320,10 @@ int ConvertDosToUnixNewFile(char *ipInFN + struct stat StatBuf; + struct utimbuf UTimeBuf; + int fd; ++ mode_t mask; + + /* retrieve ipInFN file date stamp */ +- if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf)) ++ if (stat(ipInFN, &StatBuf)) + RetVal = -1; + + if((fd = MakeTempFileFrom(ipOutFN, &TempPath))<0) { +@@ -346,6 +347,12 @@ int ConvertDosToUnixNewFile(char *ipInFN + RetVal = -1; + } + ++ /* preserve original mode as modified by umask */ ++ mask = umask(0); ++ umask(mask); ++ if (!RetVal && fchmod(fd, StatBuf.st_mode & ~mask)) ++ RetVal = -1; ++ + /* conversion sucessful? */ + if ((!RetVal) && (ConvertDosToUnix(InF, TempF, ipFlag))) + RetVal = -1; diff --git a/dos2unix.spec b/dos2unix.spec index 6bb1da2..fc68624 100644 --- a/dos2unix.spec +++ b/dos2unix.spec @@ -14,6 +14,7 @@ Patch5: dos2unix-3.1-tmppath.patch Patch6: dos2unix-c-missing-arg.patch Patch7: dos2unix-missing-proto.patch Patch8: dos2unix-manpage.patch +Patch9: dos2unix-preserve-file-modes.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -31,6 +32,7 @@ Dos2unix converts DOS or MAC text files to UNIX format. %patch6 -p1 -b .c-missing-arg %patch7 -p1 -b .missing-proto %patch8 -p1 -b .manpage +%patch9 -p1 -b .preserve-file-modes for I in *.[ch]; do sed -e 's,#endif.*,#endif,g' -e 's,#else.*,#else,g' $I > $I.new @@ -63,6 +65,7 @@ rm -rf $RPM_BUILD_ROOT %changelog * Mon Sep 8 2008 Tim Waugh 3.1-33 +- Preserve file modes (bug #437465). - Fixed manpage grammar (bug #460731). * Mon Apr 14 2008 Tim Waugh 3.1-32