tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Sandbox.h (2800B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef mozilla_Sandbox_h
      7 #define mozilla_Sandbox_h
      8 
      9 #include <string>
     10 #include <vector>
     11 #include "mozilla/ipc/UtilityProcessSandboxing.h"
     12 
     13 enum MacSandboxType {
     14  MacSandboxType_Default = 0,
     15  MacSandboxType_Content,
     16  MacSandboxType_GMP,
     17  MacSandboxType_RDD,
     18  MacSandboxType_Socket,
     19  MacSandboxType_Utility,
     20  MacSandboxType_GPU,
     21  MacSandboxType_Invalid
     22 };
     23 
     24 typedef struct _MacSandboxInfo {
     25  _MacSandboxInfo()
     26      : type(MacSandboxType_Default),
     27        level(0),
     28        hasFilePrivileges(false),
     29        hasSandboxedProfile(false),
     30        hasAudio(false),
     31        hasWindowServer(false),
     32        shouldLog(false) {}
     33  _MacSandboxInfo(const struct _MacSandboxInfo& other) = default;
     34 
     35  void AppendAsParams(std::vector<std::string>& aParams) const;
     36  static void AppendFileAccessParam(std::vector<std::string>& aParams,
     37                                    bool aHasFilePrivileges);
     38 
     39 private:
     40  void AppendStartupParam(std::vector<std::string>& aParams) const;
     41  void AppendLoggingParam(std::vector<std::string>& aParams) const;
     42  void AppendAppPathParam(std::vector<std::string>& aParams) const;
     43  void AppendPluginPathParam(std::vector<std::string>& aParams) const;
     44  void AppendLevelParam(std::vector<std::string>& aParams) const;
     45  void AppendAudioParam(std::vector<std::string>& aParams) const;
     46  void AppendWindowServerParam(std::vector<std::string>& aParams) const;
     47  void AppendReadPathParams(std::vector<std::string>& aParams) const;
     48 #ifdef DEBUG
     49  void AppendDebugWriteDirParam(std::vector<std::string>& aParams) const;
     50 #endif
     51 
     52 public:
     53  MacSandboxType type;
     54  mozilla::ipc::SandboxingKind utilityKind;
     55  int32_t level;
     56  bool hasFilePrivileges;
     57  bool hasSandboxedProfile;
     58  bool hasAudio;
     59  bool hasWindowServer;
     60 
     61  std::string appPath;
     62  std::string appBinaryPath;
     63  std::string appDir;
     64  std::string profileDir;
     65  std::string debugWriteDir;
     66 
     67  std::string pluginPath;
     68  std::string pluginBinaryPath;
     69 
     70  std::string testingReadPath1;
     71  std::string testingReadPath2;
     72  std::string testingReadPath3;
     73  std::string testingReadPath4;
     74 
     75  std::string crashServerPort;
     76 
     77  bool shouldLog;
     78 } MacSandboxInfo;
     79 
     80 namespace mozilla {
     81 
     82 bool StartMacSandbox(MacSandboxInfo const& aInfo, std::string& aErrorMessage);
     83 bool StartMacSandboxIfEnabled(MacSandboxType aSandboxType, int aArgc,
     84                              char** aArgv, std::string& aErrorMessage);
     85 bool IsMacSandboxStarted();
     86 #ifdef DEBUG
     87 void AssertMacSandboxEnabled();
     88 #endif /* DEBUG */
     89 
     90 }  // namespace mozilla
     91 
     92 #endif  // mozilla_Sandbox_h