SandboxBrokerClient.h (2015B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_SandboxBrokerClient_h 8 #define mozilla_SandboxBrokerClient_h 9 10 #include "broker/SandboxBrokerCommon.h" 11 #include "broker/SandboxBrokerUtils.h" 12 13 // This is the client for the sandbox broker described in 14 // broker/SandboxBroker.h; its constructor takes the file descriptor 15 // returned by SandboxBroker::Create, passed to the child over IPC. 16 // 17 // The operations exposed here can be called from any thread and in 18 // async signal handlers, like the corresponding system calls. The 19 // intended use is from a seccomp-bpf SIGSYS handler, to transparently 20 // replace those syscalls, but they could also be used directly. 21 22 struct stat; 23 struct sockaddr_un; 24 25 namespace mozilla { 26 27 class SandboxBrokerClient final : private SandboxBrokerCommon { 28 public: 29 explicit SandboxBrokerClient(int aFd); 30 ~SandboxBrokerClient(); 31 32 int Open(const char* aPath, int aFlags); 33 int Access(const char* aPath, int aMode); 34 int Stat(const char* aPath, statstruct* aStat); 35 int LStat(const char* aPath, statstruct* aStat); 36 int Chmod(const char* aPath, int aMode); 37 int Link(const char* aPath, const char* aPath2); 38 int Mkdir(const char* aPath, int aMode); 39 int Symlink(const char* aOldPath, const char* aNewPath); 40 int Rename(const char* aOldPath, const char* aNewPath); 41 int Unlink(const char* aPath); 42 int Rmdir(const char* aPath); 43 int Readlink(const char* aPath, void* aBuf, size_t aBufSize); 44 int Connect(const struct sockaddr_un* aAddr, size_t aLen, int aType); 45 46 private: 47 int mFileDesc; 48 49 int DoCall(const Request* aReq, const char* aPath, const char* aPath2, 50 void* aReponseBuff, bool expectFd); 51 }; 52 53 } // namespace mozilla 54 55 #endif // mozilla_SandboxBrokerClient_h