Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Unified Diff: sandbox.cc

Issue 10178029: Make a small change to the API. Instead of passing in a file (Closed) Base URL: http://seccompsandbox.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox.h ('k') | sandbox_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox.cc
===================================================================
--- sandbox.cc (revision 179)
+++ sandbox.cc (working copy)
@@ -11,6 +11,7 @@
namespace playground {
// Global variables
+int Sandbox::proc_self_ = -1;
int Sandbox::proc_self_maps_ = -1;
enum Sandbox::SandboxStatus Sandbox::status_ = STATUS_UNKNOWN;
int Sandbox::pid_;
@@ -193,7 +194,7 @@
}
}
-int Sandbox::supportsSeccompSandbox(int proc_fd) {
+int Sandbox::supportsSeccompSandbox(int proc_self) {
if (status_ != STATUS_UNKNOWN) {
return status_ != STATUS_UNSUPPORTED;
}
@@ -216,8 +217,8 @@
sys.dup2(devnull, 2);
sys.close(devnull);
}
- if (proc_fd >= 0) {
- setProcSelfMaps(sys.openat(proc_fd, "self/maps", O_RDONLY, 0));
+ if (proc_self >= 0) {
+ setProcSelf(sys.dup(proc_self));
}
startSandbox();
write(sys, fds[1], "", 1);
@@ -250,8 +251,8 @@
}
}
-void Sandbox::setProcSelfMaps(int proc_self_maps) {
- proc_self_maps_ = proc_self_maps;
+void Sandbox::setProcSelf(int proc_self) {
+ proc_self_ = proc_self;
}
void Sandbox::startSandbox() {
@@ -262,6 +263,13 @@
}
SysCalls sys;
+ if (proc_self_ >= 0) {
+ proc_self_maps_ = sys.openat(proc_self_, "maps", O_RDONLY, 0);
+ if (NOINTR_SYS(sys.close(proc_self_))) {
+ die("Failed to close proc_self_");
+ }
+ proc_self_ = -1;
+ }
if (proc_self_maps_ < 0) {
proc_self_maps_ = sys.open("/proc/self/maps", O_RDONLY, 0);
if (proc_self_maps_ < 0) {
« no previous file with comments | « sandbox.h ('k') | sandbox_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698