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

Unified Diff: content/common/sandbox_mac_system_access_unittest.mm

Issue 10695185: Allow /dev/urandom from ppapi sandbox. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Log type for failure. Created 8 years, 5 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 | « no previous file | content/ppapi_plugin/ppapi.sb » ('j') | content/ppapi_plugin/ppapi.sb » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_mac_system_access_unittest.mm
diff --git a/content/common/sandbox_mac_system_access_unittest.mm b/content/common/sandbox_mac_system_access_unittest.mm
index d9086ebd6da06ed32b211e630a4965eaebf4128b..4fc68a576c2cf96c15c38f9aa28263364c0f620a 100644
--- a/content/common/sandbox_mac_system_access_unittest.mm
+++ b/content/common/sandbox_mac_system_access_unittest.mm
@@ -96,4 +96,40 @@ TEST_F(MacSandboxTest, FileAccess) {
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedFileAccessTestCase", NULL));
}
+//--------------------- /dev/urandom Sandboxing ----------------------
+// /dev/urandom is available to ppapi sandbox only.
+class MacSandboxedUrandomTestCase : public sandboxtest::MacSandboxTestCase {
+ public:
+ virtual bool SandboxedTest();
+};
+
+REGISTER_SANDBOX_TEST_CASE(MacSandboxedUrandomTestCase);
+
+bool MacSandboxedUrandomTestCase::SandboxedTest() {
+ int fdes = open("/dev/urandom", O_RDONLY);
+ file_util::ScopedFD file_closer(&fdes);
+
+ // Open succeeds under ppapi sandbox, else it is not permitted.
+ if (test_data_ == "ppapi") {
+ return fdes != -1;
+ } else {
+ return fdes == -1 && errno == EPERM;
+ }
+}
+
+TEST_F(MacSandboxTest, UrandomAccess) {
+ // Similar to RunTestInAllSandboxTypes(), except changing
+ // |test_data| for the ppapi case. Passing "" in the non-ppapi case
+ // to overwrite the test data (NULL means not to change it).
+ for (content::SandboxType i = content::SANDBOX_TYPE_FIRST_TYPE;
+ i < content::SANDBOX_TYPE_AFTER_LAST_TYPE; ++i) {
+ if (i == content::SANDBOX_TYPE_PPAPI) {
+ EXPECT_TRUE(RunTestInSandbox(i, "MacSandboxedUrandomTestCase", "ppapi"));
+ } else {
+ EXPECT_TRUE(RunTestInSandbox(i, "MacSandboxedUrandomTestCase", ""))
+ << "for sandbox type " << i;
+ }
+ }
+}
+
} // namespace
« no previous file with comments | « no previous file | content/ppapi_plugin/ppapi.sb » ('j') | content/ppapi_plugin/ppapi.sb » ('J')

Powered by Google App Engine
This is Rietveld 408576698