Bug 1430118 - Look for log file names in the passed environment. r=bobowen
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Wed, 17 Jan 2018 09:54:48 +0100
changeset 399815 caae648c5dab7cbbe50c91b0757c6fa58b988f81
parent 399814 f2f92fe82b0ecb733948dd01954380bb20849559
child 399816 e1903f1d75e0146b451c8da9d237a83ede2e0fa9
push id58288
push usergpascutto@mozilla.com
push dateThu, 18 Jan 2018 12:16:38 +0000
treeherderautoland@caae648c5dab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
bugs1430118
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1430118 - Look for log file names in the passed environment. r=bobowen MozReview-Commit-ID: HVUDYoEwjCd
security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
--- a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
+++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp
@@ -208,17 +208,21 @@ SandboxBroker::LaunchApp(const wchar_t *
     tempPath[pathLen] = L'*';
     tempPath[pathLen + 1] = L'\0';
     mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
                      sandbox::TargetPolicy::FILES_ALLOW_ANY, tempPath);
   }
 #endif
 
   // Enable the child process to write log files when setup
-  wchar_t const* logFileName = _wgetenv(L"MOZ_LOG_FILE");
+  wchar_t const* logFileName = nullptr;
+  auto it = aEnvironment.find(ENVIRONMENT_LITERAL("MOZ_LOG_FILE"));
+  if (it != aEnvironment.end()) {
+    logFileName = (it->second).c_str();
+  }
   char const* logFileModules = getenv("MOZ_LOG");
   if (logFileName && logFileModules) {
     bool rotate = false;
     NSPRLogModulesParser(logFileModules,
       [&rotate](const char* aName, LogLevel aLevel, int32_t aValue) mutable {
         if (strcmp(aName, "rotate") == 0) {
           // Less or eq zero means to turn rotate off.
           rotate = aValue > 0;
@@ -233,17 +237,21 @@ SandboxBroker::LaunchApp(const wchar_t *
       mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
                        sandbox::TargetPolicy::FILES_ALLOW_ANY, logFileNameWild);
     } else {
       mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
                        sandbox::TargetPolicy::FILES_ALLOW_ANY, logFileName);
     }
   }
 
-  logFileName = _wgetenv(L"NSPR_LOG_FILE");
+  logFileName = nullptr;
+  it = aEnvironment.find(ENVIRONMENT_LITERAL("NSPR_LOG_FILE"));
+  if (it != aEnvironment.end()) {
+    logFileName = (it->second).c_str();
+  }
   if (logFileName) {
     mPolicy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
                      sandbox::TargetPolicy::FILES_ALLOW_ANY, logFileName);
   }
 
   // Add DLLs to the policy that have been found to cause instability with the
   // sandbox, so that they will be unloaded when they attempt to load.
   sandbox::ResultCode result;