[#23] Add logfile_mode to control logfile permissions
authorTeddy Reed <teddy@prosauce.org>
Wed, 13 May 2015 06:22:24 +0000 (23:22 -0700)
committerTeddy Reed <teddy@prosauce.org>
Mon, 10 Aug 2015 23:49:33 +0000 (16:49 -0700)
src/glog/logging.h.in
src/logging.cc

index b4229d0..70bf88b 100644 (file)
@@ -360,6 +360,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);
index 5543e3a..12bc849 100644 (file)
@@ -161,6 +161,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.");
@@ -897,7 +899,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
   string string_filename = base_filename_+filename_extension_+
                            time_pid_string;
   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;
 #ifdef HAVE_FCNTL
   // Mark the file close-on-exec. We don't really care if this fails