Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: main.cc

Issue 3495002: [update_engine] Fix file creation mask to be 0600 (Closed) Base URL: http://git.chromium.org/git/update_engine.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « file_writer.h ('k') | split_file_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 #include <tr1/memory> 6 #include <tr1/memory>
7 #include <vector> 7 #include <vector>
8 8
9 #include <base/at_exit.h> 9 #include <base/at_exit.h>
10 #include <base/command_line.h> 10 #include <base/command_line.h>
11 #include <base/logging.h> 11 #include <base/logging.h>
12 #include <base/string_util.h> 12 #include <base/string_util.h>
13 #include <gflags/gflags.h> 13 #include <gflags/gflags.h>
14 #include <glib.h> 14 #include <glib.h>
15 #include <metrics/metrics_library.h> 15 #include <metrics/metrics_library.h>
16 #include <sys/types.h>
adlr 2010/09/23 19:16:06 the order of includes is: corresponding .h, if ap
17 #include <sys/stat.h>
16 18
17 #include "update_engine/dbus_constants.h" 19 #include "update_engine/dbus_constants.h"
18 #include "update_engine/dbus_service.h" 20 #include "update_engine/dbus_service.h"
19 #include "update_engine/prefs.h" 21 #include "update_engine/prefs.h"
20 #include "update_engine/subprocess.h" 22 #include "update_engine/subprocess.h"
21 #include "update_engine/update_attempter.h" 23 #include "update_engine/update_attempter.h"
22 #include "update_engine/update_check_scheduler.h" 24 #include "update_engine/update_check_scheduler.h"
23 25
24 extern "C" { 26 extern "C" {
25 #include "update_engine/update_engine.dbusserver.h" 27 #include "update_engine/update_engine.dbusserver.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 (FLAGS_logtostderr ? 100 (FLAGS_logtostderr ?
99 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG : 101 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG :
100 logging::LOG_ONLY_TO_FILE), 102 logging::LOG_ONLY_TO_FILE),
101 logging::DONT_LOCK_LOG_FILE, 103 logging::DONT_LOCK_LOG_FILE,
102 logging::APPEND_TO_OLD_LOG_FILE); 104 logging::APPEND_TO_OLD_LOG_FILE);
103 if (!FLAGS_foreground) 105 if (!FLAGS_foreground)
104 PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed"; 106 PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed";
105 107
106 LOG(INFO) << "Chrome OS Update Engine starting"; 108 LOG(INFO) << "Chrome OS Update Engine starting";
107 109
110 // Ensure that all written files have safe permissions.
111 // This is a mask, so we _block_ execute for the owner, and ALL
112 // permissions for other users.
113 // Done _after_ log file creation.
114 umask(S_IXUSR | S_IRWXG | S_IRWXO);
115
108 // Create the single GMainLoop 116 // Create the single GMainLoop
109 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); 117 GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
110 118
111 chromeos_update_engine::Prefs prefs; 119 chromeos_update_engine::Prefs prefs;
112 LOG_IF(ERROR, !prefs.Init(FilePath("/var/lib/update_engine/prefs"))) 120 LOG_IF(ERROR, !prefs.Init(FilePath("/var/lib/update_engine/prefs")))
113 << "Failed to initialize preferences."; 121 << "Failed to initialize preferences.";
114 122
115 MetricsLibrary metrics_lib; 123 MetricsLibrary metrics_lib;
116 metrics_lib.Init(); 124 metrics_lib.Init();
117 125
(...skipping 21 matching lines...) Expand all
139 g_main_loop_run(loop); 147 g_main_loop_run(loop);
140 148
141 // Cleanup: 149 // Cleanup:
142 g_main_loop_unref(loop); 150 g_main_loop_unref(loop);
143 update_attempter.set_dbus_service(NULL); 151 update_attempter.set_dbus_service(NULL);
144 g_object_unref(G_OBJECT(service)); 152 g_object_unref(G_OBJECT(service));
145 153
146 LOG(INFO) << "Chrome OS Update Engine terminating"; 154 LOG(INFO) << "Chrome OS Update Engine terminating";
147 return 0; 155 return 0;
148 } 156 }
OLDNEW
« no previous file with comments | « file_writer.h ('k') | split_file_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698