mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Replace auto with explicit type declarations
PiperOrigin-RevId: 399419917 Change-Id: I4b7acd8ab6e2542e2971b29bed0745378b2b6743
This commit is contained in:
parent
448f393c29
commit
fb81c00fd1
|
@ -120,7 +120,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
// Let the sandboxee run.
|
// Let the sandboxee run.
|
||||||
if (!s2.RunAsync()) {
|
if (!s2.RunAsync()) {
|
||||||
auto result = s2.AwaitResult();
|
sandbox2::Result result = s2.AwaitResult();
|
||||||
LOG(ERROR) << "RunAsync failed: " << result.ToString();
|
LOG(ERROR) << "RunAsync failed: " << result.ToString();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = s2.AwaitResult();
|
sandbox2::Result result = s2.AwaitResult();
|
||||||
if (result.final_status() != sandbox2::Result::OK) {
|
if (result.final_status() != sandbox2::Result::OK) {
|
||||||
LOG(ERROR) << "Sandbox error: " << result.ToString();
|
LOG(ERROR) << "Sandbox error: " << result.ToString();
|
||||||
return 3; // e.g. sandbox violation, signal (sigsegv)
|
return 3; // e.g. sandbox violation, signal (sigsegv)
|
||||||
|
|
|
@ -86,7 +86,7 @@ static int SandboxIteration(sandbox2::ForkClient* fork_client, int32_t i) {
|
||||||
CHECK(s2.RunAsync());
|
CHECK(s2.RunAsync());
|
||||||
// Send integer, which will be returned as the sandboxee's exit code.
|
// Send integer, which will be returned as the sandboxee's exit code.
|
||||||
CHECK(s2.comms()->SendInt32(i));
|
CHECK(s2.comms()->SendInt32(i));
|
||||||
auto result = s2.AwaitResult();
|
sandbox2::Result result = s2.AwaitResult();
|
||||||
|
|
||||||
LOG(INFO) << "Final execution status of PID " << s2.GetPid() << ": "
|
LOG(INFO) << "Final execution status of PID " << s2.GetPid() << ": "
|
||||||
<< result.ToString();
|
<< result.ToString();
|
||||||
|
|
|
@ -140,7 +140,7 @@ int main(int argc, char** argv) {
|
||||||
sandbox2::Sandbox2 s2(std::move(executor), std::move(policy));
|
sandbox2::Sandbox2 s2(std::move(executor), std::move(policy));
|
||||||
|
|
||||||
// Let the sandboxee run (synchronously).
|
// Let the sandboxee run (synchronously).
|
||||||
auto result = s2.Run();
|
sandbox2::Result result = s2.Run();
|
||||||
|
|
||||||
LOG(INFO) << "Final execution status: " << result.ToString();
|
LOG(INFO) << "Final execution status: " << result.ToString();
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
// A simple sandbox2 testing tool.
|
// A simple sandbox2 testing tool.
|
||||||
//
|
//
|
||||||
// Usage:
|
// Usage:
|
||||||
// sandbox2tool -v=1 -sandbox2_danger_danger_permit_all -logtostderr -- /bin/ls
|
// sandbox2tool -v=1 -sandbox2tool_resolve_and_add_libraries \
|
||||||
|
// -sandbox2_danger_danger_permit_all -logtostderr /bin/ls
|
||||||
|
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -155,12 +156,13 @@ int main(int argc, char** argv) {
|
||||||
builder.AddTmpfs("/tmp");
|
builder.AddTmpfs("/tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mounts_string = absl::GetFlag(FLAGS_sandbox2tool_additional_bind_mounts);
|
std::string mounts_string =
|
||||||
|
absl::GetFlag(FLAGS_sandbox2tool_additional_bind_mounts);
|
||||||
if (!mounts_string.empty()) {
|
if (!mounts_string.empty()) {
|
||||||
for (auto mount : absl::StrSplit(mounts_string, ',')) {
|
for (absl::string_view mount : absl::StrSplit(mounts_string, ',')) {
|
||||||
std::vector<std::string> source_target = absl::StrSplit(mount, "=>");
|
std::vector<std::string> source_target = absl::StrSplit(mount, "=>");
|
||||||
auto source = source_target[0];
|
std::string source = source_target[0];
|
||||||
auto target = source_target[0];
|
std::string target = source_target[0];
|
||||||
if (source_target.size() == 2) {
|
if (source_target.size() == 2) {
|
||||||
target = source_target[1];
|
target = source_target[1];
|
||||||
}
|
}
|
||||||
|
@ -218,7 +220,7 @@ int main(int argc, char** argv) {
|
||||||
LOG(ERROR) << "Sandbox failed";
|
LOG(ERROR) << "Sandbox failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = s2.AwaitResult();
|
sandbox2::Result result = s2.AwaitResult();
|
||||||
|
|
||||||
if (result.final_status() != sandbox2::Result::OK) {
|
if (result.final_status() != sandbox2::Result::OK) {
|
||||||
LOG(ERROR) << "Sandbox error: " << result.ToString();
|
LOG(ERROR) << "Sandbox error: " << result.ToString();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user