From patchwork Thu Aug 4 17:04:52 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Brachold X-Patchwork-Id: 11963 Received: from web1.dns-net.de ([212.91.231.162]) by www.linuxtv.org with esmtp (Exim 4.34) id 1E0j9Q-0003Fq-Gt for vdr@linuxtv.org; Thu, 04 Aug 2005 19:05:00 +0200 Received: from wopr.deltab.de (tc15-n68-100.de.inter.net [213.73.68.100]) by web1.dns-net.de (8.11.6/8.11.6) with ESMTP id j74H4xV21087 for ; Thu, 4 Aug 2005 19:04:59 +0200 From: Andreas Brachold To: vdr@linuxtv.org Date: Thu, 04 Aug 2005 19:04:52 +0200 Message-Id: <1123175092.11345.4.camel@wopr.deltab.de> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 Subject: [vdr] patch avoid that vdr ignore settings from umask X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2005 17:05:00 -0000 Status: O X-Status: X-Keywords: X-UID: 3926 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 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;