From fed7ac704bdd848ddc16c7ea779a983c9c35cf42 Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Date: Mon, 24 Nov 2025 23:43:26 +0500 Subject: [PATCH] [io] Replace hardcoded 0644 permissions with 0666 to respect umask This change allows the system umask to control file permissions instead of hardcoding them to 0644. Files will now be created with permissions determined by (0666 & ~umask), which is the standard Unix behavior. Files modified: - io/io/src/TFile.cxx - io/io/src/TMapFile.cxx - io/io/src/TMemFile.cxx - io/dcache/src/TDCacheFile.cxx - net/net/src/TFTP.cxx - net/net/src/TApplicationServer.cxx Fixes #17095 --- io/dcache/src/TDCacheFile.cxx | 4 ++-- io/io/src/TFile.cxx | 8 ++++---- io/io/src/TMapFile.cxx | 2 +- io/io/src/TMemFile.cxx | 4 ++-- net/net/src/TApplicationServer.cxx | 2 +- net/net/src/TFTP.cxx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/io/dcache/src/TDCacheFile.cxx b/io/dcache/src/TDCacheFile.cxx index 6edade9942cec..1515d150ddf02 100644 --- a/io/dcache/src/TDCacheFile.cxx +++ b/io/dcache/src/TDCacheFile.cxx @@ -140,7 +140,7 @@ TDCacheFile::TDCacheFile(const char *path, Option_t *option, if (create || update) { #ifndef WIN32 - fD = SysOpen(fname, O_RDWR | O_CREAT, 0644); + fD = SysOpen(fname, O_RDWR | O_CREAT, 0666); #else fD = SysOpen(fname, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE); #endif @@ -151,7 +151,7 @@ TDCacheFile::TDCacheFile(const char *path, Option_t *option, fWritable = kTRUE; } else { #ifndef WIN32 - fD = SysOpen(fname, O_RDONLY, 0644); + fD = SysOpen(fname, O_RDONLY, 0666); #else fD = SysOpen(fname, O_RDONLY | O_BINARY, S_IREAD | S_IWRITE); #endif diff --git a/io/io/src/TFile.cxx b/io/io/src/TFile.cxx index 35b4acddc184a..c8d7030215f0c 100644 --- a/io/io/src/TFile.cxx +++ b/io/io/src/TFile.cxx @@ -533,7 +533,7 @@ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t com // Connect to file system stream if (create || update) { #ifndef WIN32 - fD = TFile::SysOpen(fname.Data(), O_RDWR | O_CREAT, 0644); + fD = TFile::SysOpen(fname.Data(), O_RDWR | O_CREAT, 0666); #else fD = TFile::SysOpen(fname.Data(), O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE); #endif @@ -545,7 +545,7 @@ TFile::TFile(const char *fname1, Option_t *option, const char *ftitle, Int_t com fWritable = kTRUE; } else { #ifndef WIN32 - fD = TFile::SysOpen(fname.Data(), O_RDONLY, 0644); + fD = TFile::SysOpen(fname.Data(), O_RDONLY, 0666); #else fD = TFile::SysOpen(fname.Data(), O_RDONLY | O_BINARY, S_IREAD | S_IWRITE); #endif @@ -2236,7 +2236,7 @@ Int_t TFile::ReOpen(Option_t *mode) // open in READ mode fOption = opt; // set fOption before SysOpen() for TNetFile #ifndef WIN32 - fD = SysOpen(fRealName, O_RDONLY, 0644); + fD = SysOpen(fRealName, O_RDONLY, 0666); #else fD = SysOpen(fRealName, O_RDONLY | O_BINARY, S_IREAD | S_IWRITE); #endif @@ -2258,7 +2258,7 @@ Int_t TFile::ReOpen(Option_t *mode) // open in UPDATE mode fOption = opt; // set fOption before SysOpen() for TNetFile #ifndef WIN32 - fD = SysOpen(fRealName, O_RDWR | O_CREAT, 0644); + fD = SysOpen(fRealName, O_RDWR | O_CREAT, 0666); #else fD = SysOpen(fRealName, O_RDWR | O_CREAT | O_BINARY, S_IREAD | S_IWRITE); #endif diff --git a/io/io/src/TMapFile.cxx b/io/io/src/TMapFile.cxx index 436cdd805e960..8bf9fb7f29153 100644 --- a/io/io/src/TMapFile.cxx +++ b/io/io/src/TMapFile.cxx @@ -333,7 +333,7 @@ TMapFile::TMapFile(const char *name, const char *title, Option_t *option, // Open file to which memory will be mapped if (create || update) { #ifndef WIN32 - fFd = open(fname, O_RDWR | O_CREAT, 0644); + fFd = open(fname, O_RDWR | O_CREAT, 0666); #else fFd = (Longptr_t) CreateFile(fname, // pointer to name of the file GENERIC_WRITE | GENERIC_READ, // access (read-write) mode diff --git a/io/io/src/TMemFile.cxx b/io/io/src/TMemFile.cxx index cf134cbb3458b..a738d0ca9732b 100644 --- a/io/io/src/TMemFile.cxx +++ b/io/io/src/TMemFile.cxx @@ -179,7 +179,7 @@ TMemFile::TMemFile(const char *path, char *buffer, Long64_t size, Option_t *opti Int_t mode = O_RDWR | O_CREAT; if (optmode == EMode::kRecreate) mode |= O_TRUNC; - fD = TMemFile::SysOpen(path, mode, 0644); + fD = TMemFile::SysOpen(path, mode, 0666); if (fD == -1) { SysError("TMemFile", "file %s can not be opened", path); goto zombie; @@ -187,7 +187,7 @@ TMemFile::TMemFile(const char *path, char *buffer, Long64_t size, Option_t *opti fWritable = kTRUE; } else { - fD = TMemFile::SysOpen(path, O_RDONLY, 0644); + fD = TMemFile::SysOpen(path, O_RDONLY, 0666); if (fD == -1) { SysError("TMemFile", "file %s can not be opened for reading", path); goto zombie; diff --git a/net/net/src/TApplicationServer.cxx b/net/net/src/TApplicationServer.cxx index 4eaa93dd68d10..6fea7483a9d41 100644 --- a/net/net/src/TApplicationServer.cxx +++ b/net/net/src/TApplicationServer.cxx @@ -788,7 +788,7 @@ Int_t TApplicationServer::ReceiveFile(const char *file, Bool_t bin, Long64_t siz close(fd); - chmod(file, 0644); + chmod(file, 0666); return 0; } diff --git a/net/net/src/TFTP.cxx b/net/net/src/TFTP.cxx index af77ee52384e5..e87a623f6bf12 100644 --- a/net/net/src/TFTP.cxx +++ b/net/net/src/TFTP.cxx @@ -593,7 +593,7 @@ Long64_t TFTP::GetFile(const char *file, const char *localName) delete [] buf; delete [] buf2; #ifndef R__WIN32 - fchmod(fd, 0644); + fchmod(fd, 0666); #endif close(fd);