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

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
« sandbox.h ('K') | « 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_;
@@ -217,7 +218,7 @@
sys.close(devnull);
}
if (proc_fd >= 0) {
- setProcSelfMaps(sys.openat(proc_fd, "self/maps", O_RDONLY, 0));
+ setProcSelf(sys.openat(proc_fd, "self", O_RDONLY|O_DIRECTORY, 0));
}
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) {
Mark Seaborn 2012/04/27 23:07:38 The smallest change would be to make setProcSelf()
Markus (顧孟勤) 2012/04/28 01:15:43 That actually breaks the existing API in a subtle
+ proc_self_ = proc_self;
}
void Sandbox::startSandbox() {
@@ -262,6 +263,11 @@
}
SysCalls sys;
+ if (proc_self_ >= 0) {
+ proc_self_maps_ = sys.openat(proc_self_, "maps", O_RDONLY, 0);
+ NOINTR_SYS(sys.close(proc_self_));
jln (very slow on Chromium) 2012/04/27 23:08:20 Should we check for close() errors here ? Since th
+ proc_self_ = -1;
+ }
if (proc_self_maps_ < 0) {
proc_self_maps_ = sys.open("/proc/self/maps", O_RDONLY, 0);
if (proc_self_maps_ < 0) {
« sandbox.h ('K') | « sandbox.h ('k') | sandbox_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698