Skip to content

Commit

Permalink
[google#23] Add logfile_mode to control logfile permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy Reed authored and Ezequiel Lara Gomez committed Sep 8, 2016
1 parent 4cdc2ed commit 0e7bc43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ DECLARE_int32(minloglevel);
// default logging directory.
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
// to the log files.
DECLARE_string(log_link);
Expand Down
4 changes: 3 additions & 1 deletion src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ static const char* DefaultLogDir() {
return "";
}

GLOG_DEFINE_int32(logfile_mode, 0664, "Log file mode/permissions.");

GLOG_DEFINE_string(log_dir, DefaultLogDir(),
"If specified, logfiles are written into this directory instead "
"of the default logging directory.");
Expand Down Expand Up @@ -911,7 +913,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
//demand that the file is unique for our timestamp (fail if it exists).
flags = flags | O_EXCL;
}
int fd = open(filename, flags, 0664);
int fd = open(filename, flags, FLAGS_logfile_mode);

if (fd == -1) return false;
#ifdef HAVE_FCNTL
Expand Down

0 comments on commit 0e7bc43

Please sign in to comment.