patch avoid that vdr ignore settings from umask

Message ID 1123175092.11345.4.camel@wopr.deltab.de
State New
Headers

Commit Message

Andreas Brachold Aug. 4, 2005, 5:04 p.m. UTC
  Hi,

I offer a small patch for vdr-1.3.27, (testet with 1.3.22)
so that all created files and directorys (*.rec,001.vdr,...) 
no longer use fixed minimal permissions, without any chance to adjust
this through settings from umask. 

On most systems are follow default setting "umask 022". 


Thereby, as before, the files are created with the following
permissions : 
-rw-r--r--  1 vdr video 7463489 Aug  4 18:01 001.vdr


with this patch are now able use "umask 002"
-rw-rw-r--  1 vdr video 7463489 Aug  4 18:01 001.vdr


or  use "umask 000"
-rw-rw-rw-  1 vdr video 7463489 Aug  4 18:01 001.vdr

Cu,
Andreas
  

Comments

Klaus Schmidinger Aug. 6, 2005, 10 a.m. UTC | #1
Andreas Brachold wrote:
> Hi,
> 
> I offer a small patch for vdr-1.3.27, (testet with 1.3.22)
> so that all created files and directorys (*.rec,001.vdr,...) 
> no longer use fixed minimal permissions, without any chance to adjust
> this through settings from umask. 
> 
> On most systems are follow default setting "umask 022". 
> 
> 
> Thereby, as before, the files are created with the following
> permissions : 
> -rw-r--r--  1 vdr video 7463489 Aug  4 18:01 001.vdr
> 
> 
> with this patch are now able use "umask 002"
> -rw-rw-r--  1 vdr video 7463489 Aug  4 18:01 001.vdr
> 
> 
> or  use "umask 000"
> -rw-rw-rw-  1 vdr video 7463489 Aug  4 18:01 001.vdr
> 
> Cu,
> Andreas

Adopted for version 1.3.28.

Klaus
  

Patch

diff -Nur vdr-1.3.27.org/recording.c vdr-1.3.27/recording.c
--- vdr-1.3.27.org/recording.c	2005-06-05 16:11:45.000000000 +0200
+++ vdr-1.3.27/recording.c	2005-08-04 18:39:54.000000000 +0200
@@ -199,7 +199,7 @@ 
 bool cResumeFile::Save(int Index)
 {
   if (fileName) {
-     int f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+     int f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, DEFFILEMODE);
      if (f >= 0) {
         if (safe_write(f, &Index, sizeof(Index)) < 0)
            LOG_ERROR_STR(fileName);
@@ -974,7 +974,7 @@ 
         else if (!Record)
            isyslog("missing index file %s", fileName);
         if (Record) {
-           if ((f = open(fileName, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) >= 0) {
+           if ((f = open(fileName, O_WRONLY | O_CREAT | O_APPEND, DEFFILEMODE)) >= 0) {
               if (delta) {
                  esyslog("ERROR: padding index file with %d '0' bytes", delta);
                  while (delta--)
diff -Nur vdr-1.3.27.org/tools.c vdr-1.3.27/tools.c
--- vdr-1.3.27.org/tools.c	2005-05-29 12:18:26.000000000 +0200
+++ vdr-1.3.27/tools.c	2005-08-04 18:39:54.000000000 +0200
@@ -308,7 +308,7 @@ 
         struct stat fs;
         if (stat(s, &fs) != 0 || !S_ISDIR(fs.st_mode)) {
            dsyslog("creating directory %s", s);
-           if (mkdir(s, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1) {
+           if (mkdir(s, ACCESSPERMS) == -1) {
               LOG_ERROR_STR(s);
               result = false;
               break;
@@ -451,7 +451,7 @@ 
       if (access(buf, F_OK) != 0) { // the file does not exist
          timeval tp1, tp2;
          gettimeofday(&tp1, NULL);
-         int f = open(buf, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+         int f = open(buf, O_WRONLY | O_CREAT, DEFFILEMODE);
          // O_SYNC doesn't work on all file systems
          if (f >= 0) {
             if (fdatasync(f) < 0)
@@ -843,7 +843,7 @@ 
   if (f < 0 && fileName) {
      time_t Timeout = time(NULL) + WaitSeconds;
      do {
-        f = open(fileName, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+        f = open(fileName, O_WRONLY | O_CREAT | O_EXCL, DEFFILEMODE);
         if (f < 0) {
            if (errno == EEXIST) {
               struct stat fs;
diff -Nur vdr-1.3.27.org/tools.h vdr-1.3.27/tools.h
--- vdr-1.3.27.org/tools.h	2005-05-29 12:24:54.000000000 +0200
+++ vdr-1.3.27/tools.h	2005-08-04 18:39:54.000000000 +0200
@@ -158,7 +158,7 @@ 
   cFile(void);
   ~cFile();
   operator int () { return f; }
-  bool Open(const char *FileName, int Flags, mode_t Mode = S_IRUSR | S_IWUSR | S_IRGRP);
+  bool Open(const char *FileName, int Flags, mode_t Mode = DEFFILEMODE);
   bool Open(int FileDes);
   void Close(void);
   bool IsOpen(void) { return f >= 0; }
diff -Nur vdr-1.3.27.org/videodir.c vdr-1.3.27/videodir.c
--- vdr-1.3.27.org/videodir.c	2004-12-26 12:52:12.000000000 +0100
+++ vdr-1.3.27/videodir.c	2005-08-04 18:39:54.000000000 +0200
@@ -137,7 +137,7 @@ 
            }
         }
      }
-  int Result = open(ActualFileName, Flags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+  int Result = open(ActualFileName, Flags, DEFFILEMODE);
   if (ActualFileName != FileName)
      free((char *)ActualFileName);
   return Result;