]> git.pld-linux.org Git - packages/dos2unix.git/blob - dos2unix-preserve-file-modes.patch
- new
[packages/dos2unix.git] / dos2unix-preserve-file-modes.patch
1 Ripped from Fedora
2
3 --- dos2unix-3.1/dos2unix.c
4 +++ dos2unix-3.1/dos2unix.c
5 @@ -345,11 +345,14 @@ int ConvertDosToUnixOldFile(char* ipInFN
6    char TempPath[16];
7    struct stat StatBuf;
8    struct utimbuf UTimeBuf;
9 +  mode_t mode = S_IRUSR | S_IWUSR;
10    int fd;
11  
12    /* retrieve ipInFN file date stamp */
13 -  if ((ipFlag->KeepDate) && stat(ipInFN, &StatBuf))
14 +  if (stat(ipInFN, &StatBuf))
15      RetVal = -1;
16 +  else
17 +    mode = StatBuf.st_mode;
18  
19    strcpy (TempPath, "./u2dtmpXXXXXX");
20    if((fd=mkstemp (TempPath))<0) {
21 @@ -357,6 +360,9 @@ int ConvertDosToUnixOldFile(char* ipInFN
22           RetVal = -1;
23    }
24  
25 +  if (!RetVal && fchmod (fd, mode) && fchmod (fd, S_IRUSR | S_IWUSR))
26 +    RetVal = -1;
27 +
28  #ifdef DEBUG
29    fprintf(stderr, "dos2unix: using %s as temp file\n", TempPath);
30  #endif DEBUG
This page took 0.090198 seconds and 4 git commands to generate.