mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Rename static singleton accessor
PiperOrigin-RevId: 384699374 Change-Id: I674baffc77bc6b3815f94512058a14d37d164c6f
This commit is contained in:
parent
34c7be759a
commit
7b711b85e8
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
namespace sapi {
|
namespace sapi {
|
||||||
|
|
||||||
EmbedFile* EmbedFile::GetEmbedFileSingleton() {
|
EmbedFile* EmbedFile::instance() {
|
||||||
static auto* embed_file_instance = new EmbedFile{};
|
static auto* embed_file_instance = new EmbedFile();
|
||||||
return embed_file_instance;
|
return embed_file_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,11 @@ namespace sapi {
|
||||||
// executable files.
|
// executable files.
|
||||||
class EmbedFile {
|
class EmbedFile {
|
||||||
public:
|
public:
|
||||||
EmbedFile() = default;
|
|
||||||
|
|
||||||
EmbedFile(const EmbedFile&) = delete;
|
EmbedFile(const EmbedFile&) = delete;
|
||||||
EmbedFile& operator=(const EmbedFile&) = delete;
|
EmbedFile& operator=(const EmbedFile&) = delete;
|
||||||
|
|
||||||
// Returns the pointer to the per-process EmbedFile object.
|
// Returns the pointer to the per-process EmbedFile object.
|
||||||
static EmbedFile* GetEmbedFileSingleton();
|
static EmbedFile* instance();
|
||||||
|
|
||||||
// Returns a file-descriptor for a given FileToc.
|
// Returns a file-descriptor for a given FileToc.
|
||||||
int GetFdForFileToc(const FileToc* toc);
|
int GetFdForFileToc(const FileToc* toc);
|
||||||
|
@ -46,6 +44,8 @@ class EmbedFile {
|
||||||
// file-descriptors (-1 in case of errors).
|
// file-descriptors (-1 in case of errors).
|
||||||
static int CreateFdForFileToc(const FileToc* toc);
|
static int CreateFdForFileToc(const FileToc* toc);
|
||||||
|
|
||||||
|
EmbedFile() = default;
|
||||||
|
|
||||||
// List of File TOCs and corresponding file-descriptors.
|
// List of File TOCs and corresponding file-descriptors.
|
||||||
absl::flat_hash_map<const FileToc*, int> file_tocs_
|
absl::flat_hash_map<const FileToc*, int> file_tocs_
|
||||||
ABSL_GUARDED_BY(file_tocs_mutex_);
|
ABSL_GUARDED_BY(file_tocs_mutex_);
|
||||||
|
|
|
@ -141,8 +141,7 @@ absl::Status Sandbox::Init() {
|
||||||
std::string lib_path;
|
std::string lib_path;
|
||||||
int embed_lib_fd = -1;
|
int embed_lib_fd = -1;
|
||||||
if (embed_lib_toc_) {
|
if (embed_lib_toc_) {
|
||||||
embed_lib_fd = EmbedFile::GetEmbedFileSingleton()->GetDupFdForFileToc(
|
embed_lib_fd = EmbedFile::instance()->GetDupFdForFileToc(embed_lib_toc_);
|
||||||
embed_lib_toc_);
|
|
||||||
if (embed_lib_fd == -1) {
|
if (embed_lib_fd == -1) {
|
||||||
PLOG(ERROR) << "Cannot create executable FD for TOC:'"
|
PLOG(ERROR) << "Cannot create executable FD for TOC:'"
|
||||||
<< embed_lib_toc_->name << "'";
|
<< embed_lib_toc_->name << "'";
|
||||||
|
|
|
@ -118,7 +118,7 @@ GlobalForkserverStartModeSet GetForkserverStartMode() {
|
||||||
|
|
||||||
std::unique_ptr<GlobalForkClient> StartGlobalForkServer() {
|
std::unique_ptr<GlobalForkClient> StartGlobalForkServer() {
|
||||||
// The fd is owned by EmbedFile
|
// The fd is owned by EmbedFile
|
||||||
int exec_fd = sapi::EmbedFile::GetEmbedFileSingleton()->GetFdForFileToc(
|
int exec_fd = sapi::EmbedFile::instance()->GetFdForFileToc(
|
||||||
forkserver_bin_embed_create());
|
forkserver_bin_embed_create());
|
||||||
SAPI_RAW_CHECK(exec_fd >= 0, "Getting FD for init binary failed");
|
SAPI_RAW_CHECK(exec_fd >= 0, "Getting FD for init binary failed");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user