Merge pull request #26 from theopolis/feature-mode-flag
[#23] Add logfile_mode to control logfile permissions
This commit is contained in:
commit
a94afc6807
@ -361,6 +361,9 @@ DECLARE_int32(minloglevel);
|
|||||||
// default logging directory.
|
// default logging directory.
|
||||||
DECLARE_string(log_dir);
|
DECLARE_string(log_dir);
|
||||||
|
|
||||||
|
// Set the log file mode.
|
||||||
|
DECLARE_int32(logfile_mode);
|
||||||
|
|
||||||
// Sets the path of the directory into which to put additional links
|
// Sets the path of the directory into which to put additional links
|
||||||
// to the log files.
|
// to the log files.
|
||||||
DECLARE_string(log_link);
|
DECLARE_string(log_link);
|
||||||
|
|||||||
@ -161,6 +161,8 @@ static const char* DefaultLogDir() {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");
|
||||||
|
|
||||||
GLOG_DEFINE_string(log_dir, DefaultLogDir(),
|
GLOG_DEFINE_string(log_dir, DefaultLogDir(),
|
||||||
"If specified, logfiles are written into this directory instead "
|
"If specified, logfiles are written into this directory instead "
|
||||||
"of the default logging directory.");
|
"of the default logging directory.");
|
||||||
@ -899,7 +901,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
|||||||
string string_filename = base_filename_+filename_extension_+
|
string string_filename = base_filename_+filename_extension_+
|
||||||
time_pid_string;
|
time_pid_string;
|
||||||
const char* filename = string_filename.c_str();
|
const char* filename = string_filename.c_str();
|
||||||
int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0664);
|
int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, FLAGS_logfile_mode);
|
||||||
if (fd == -1) return false;
|
if (fd == -1) return false;
|
||||||
#ifdef HAVE_FCNTL
|
#ifdef HAVE_FCNTL
|
||||||
// Mark the file close-on-exec. We don't really care if this fails
|
// Mark the file close-on-exec. We don't really care if this fails
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user