From ec09d51bfd7ca5ac9f7c04184295b545fc0038c8 Mon Sep 17 00:00:00 2001 From: paulc Date: Wed, 15 Mar 2017 11:09:41 +0000 Subject: [PATCH] Added setting for new CDR file permissions, defaults to 0640. git-svn-id: http://yate.null.ro/svn/yate/trunk@6192 acf43c95-373e-0410-b603-e72c3f656dc1 --- conf.d/cdrfile.conf.sample | 5 +++++ modules/cdrfile.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/conf.d/cdrfile.conf.sample b/conf.d/cdrfile.conf.sample index 094f8fb5..1c813e10 100644 --- a/conf.d/cdrfile.conf.sample +++ b/conf.d/cdrfile.conf.sample @@ -4,6 +4,11 @@ ; Example: file=/var/log/yate-cdr.tsv ;file= +; mode: integer: Permissions to apply to newly created file +; Typically it is expressed in octal, default 0640 is [- rw- r-- ---] +; Use 0644 to make the CDR files world readable +;mode=0640 + ; tabs: bool: Use tab-separated instead of comma-separated if format is missing ;tabs=true diff --git a/modules/cdrfile.cpp b/modules/cdrfile.cpp index 0e164f86..292d8162 100644 --- a/modules/cdrfile.cpp +++ b/modules/cdrfile.cpp @@ -60,7 +60,7 @@ public: { } virtual ~CdrFileHandler(); virtual bool received(Message &msg); - void init(const char *fname, bool tabsep, bool combined, const char* format); + void init(const char *fname, bool tabsep, bool combined, const char* format, int mode); private: int m_file; bool m_combined; @@ -76,7 +76,7 @@ CdrFileHandler::~CdrFileHandler() } } -void CdrFileHandler::init(const char *fname, bool tabsep, bool combined, const char* format) +void CdrFileHandler::init(const char *fname, bool tabsep, bool combined, const char* format, int mode) { Lock lock(this); if (m_file >= 0) { @@ -105,7 +105,7 @@ void CdrFileHandler::init(const char *fname, bool tabsep, bool combined, const c ); } if (fname) { - m_file = ::open(fname,O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE,0640); + m_file = ::open(fname,O_WRONLY|O_CREAT|O_APPEND|O_LARGEFILE,mode); if (m_file < 0) Alarm("cdrfile","system",DebugWarn,"Failed to open or create '%s': %s (%d)", fname,::strerror(errno),errno); @@ -156,7 +156,9 @@ void CdrFilePlugin::initialize() } if (m_handler) m_handler->init(file,cfg.getBoolValue("general","tabs",true), - cfg.getBoolValue("general","combined",false),cfg.getValue("general","format")); + cfg.getBoolValue("general","combined",false), + cfg.getValue("general","format"), + cfg.getIntValue("general","mode",0640)); } }; // anonymous namespace