Bug 1430118 - Look for log file names in the passed environment. r?bobowen draft
authorGian-Carlo Pascutto <gpascutto@mozilla.com>
Wed, 17 Jan 2018 09:54:48 +0100
changeset 721994 050496a0a3b7e54b8b7f7bc58d08e1b7af8f1618
parent 721993 7d9ba3d649624ea9ab78fed37c2d5686135ea640
child 746501 81b8e95a5e80e979231d8e4064f8b973fb2dc5de
push id96022
push userbmo:gpascutto@mozilla.com
push dateThu, 18 Jan 2018 09:29:55 +0000
reviewersbobowen
bugs1430118
milestone59.0a1
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;