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

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 8463020: Make sure only the right processes can access the profile path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added user notification for network profiles. Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 685fb3a88bc4394e88235da6959d2804b6e826d4..5780373c10fae5e80931e43a45515a36a8255a9f 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -73,6 +73,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/service/service_process_control.h"
#include "chrome/browser/shell_integration.h"
+#include "chrome/browser/simple_message_box.h"
#include "chrome/browser/translate/translate_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_init.h"
@@ -140,6 +141,7 @@
// progress and should not be taken as an indication of a real refactoring.
#if defined(OS_WIN)
+#include <wtsapi32.h>
#include "base/environment.h" // For PreRead experiment.
#include "base/win/windows_version.h"
#include "chrome/browser/browser_trial.h"
@@ -157,6 +159,9 @@
#include "net/base/net_util.h"
#include "printing/printed_document.h"
#include "ui/base/l10n/l10n_util_win.h"
+
+// Make sure we link the wtsapi lib file in.
+#pragma comment(lib, "wtsapi32.lib")
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
@@ -1186,6 +1191,43 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() {
g_set_application_name(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str());
#endif
+#if defined(OS_WIN)
+ // On windows notify the user if he is serving his profile from a network
+ // share as we don't officially support this setup yet.
+ // However we don't want to bother users on Cytrix setups as those have no
+ // real choice and their admins must be well aware of the risks associated.
+ LPWSTR buffer = NULL;
+ DWORD buffer_length = 0;
+ if (::WTSQuerySessionInformation(WTS_CURRENT_SERVER, WTS_CURRENT_SESSION,
+ WTSClientProtocolType,
+ &buffer, &buffer_length)) {
+ CHECK(buffer_length == sizeof(USHORT));
+ USHORT* type = reinterpret_cast<USHORT*>(buffer);
+ // Zero means local environment and we should warn the user if he runs
+ // on a network share.
+ if (*type == 0) {
+ bool profile_on_network = false;
+ FilePath temp_file;
+ // Try to create some non-empty temp file in the profile dir and use
+ // it to check if there is a reparse-point free path to it.
+ if (file_util::CreateTemporaryFileInDir(user_data_dir_, &temp_file) &&
+ file_util::WriteFile(temp_file, ".", 1)) {
+ FilePath normalized_temp_file;
+ if (!file_util::NormalizeFilePath(temp_file, &normalized_temp_file))
+ profile_on_network = true;
+ }
+ file_util::Delete(temp_file, false);
+ if (profile_on_network) {
+ browser::ShowErrorBox(NULL,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
+ l10n_util::GetStringUTF16(
+ IDS_PROFILE_ON_NETWORK_WARNING));
+ }
+ } // Local session.
+ ::WTSFreeMemory(buffer);
+ } // WTSQuerySessionInformation succeeded.
+#endif
+
// These members must be initialized before returning from this function.
master_prefs_.reset(new FirstRun::MasterPrefs);
browser_init_.reset(new BrowserInit);
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698