patch avoid that vdr ignore settings from umask
Commit Message
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
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
@@ -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--)
@@ -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;
@@ -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; }
@@ -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;