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
This commit is contained in:
paulc 2017-03-15 11:09:41 +00:00
parent a899f5516e
commit ec09d51bfd
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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