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

Unified Diff: src/trusted/service_runtime/env_cleanser_test.c

Issue 7031023: Run NaClEnvCleanser in standalone sel_ldr (in addition to sel_main_chrome). Add a couple of ld.so... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 7 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 | « src/trusted/service_runtime/env_cleanser.c ('k') | src/trusted/service_runtime/sel_main.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/service_runtime/env_cleanser_test.c
===================================================================
--- src/trusted/service_runtime/env_cleanser_test.c (revision 5412)
+++ src/trusted/service_runtime/env_cleanser_test.c (working copy)
@@ -1,7 +1,7 @@
/*
- * Copyright 2009 The Native Client Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can
- * be found in the LICENSE file.
+ * Copyright (c) 2011 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
*/
#include <stdio.h>
@@ -41,6 +41,8 @@
"LANG=en_us.UTF-8",
"LC_MEASUREMENT=en_US.UTF-8",
"LD_LIBRARY_PATH=.:/usr/bsy/lib",
+ "NACLENV_LD_PRELOAD=libvalgrind.so",
+ "NACLENV_SHELL=/bin/sh",
NULL,
};
@@ -49,9 +51,17 @@
"LC_MEASUREMENT=en_US.UTF-8",
"LC_PAPER=en_US.UTF-8@legal",
"LC_TIME=%a, %B %d, %Y",
+ "LD_PRELOAD=libvalgrind.so",
+ "SHELL=/bin/sh",
NULL,
};
+static char const *const kFilteredEnvWithoutWhitelist[] = {
+ "LD_PRELOAD=libvalgrind.so",
+ "SHELL=/bin/sh",
+ NULL,
+};
+
int StrInStrTbl(char const *str, char const *const *tbl) {
int i;
@@ -150,8 +160,8 @@
}
printf("\nEnvironment Filtering\n");
- NaClEnvCleanserCtor(&nec);
- if (!NaClEnvCleanserInit(&nec, kMurkyEnv)) {
+ NaClEnvCleanserCtor(&nec, 1);
+ if (!NaClEnvCleanserInit(&nec, kMurkyEnv, NULL)) {
printf("FAILED: NaClEnvCleanser Init failed\n");
++errors;
} else {
@@ -169,6 +179,26 @@
}
NaClEnvCleanserDtor(&nec);
+ printf("\nEnvironment Filtering (without whitelist)\n");
+ NaClEnvCleanserCtor(&nec, 0);
+ if (!NaClEnvCleanserInit(&nec, kMurkyEnv, NULL)) {
+ printf("FAILED: NaClEnvCleanser Init failed\n");
+ ++errors;
+ } else {
+ if (!StrTblsHaveSameEntries(NaClEnvCleanserEnvironment(&nec),
+ kFilteredEnvWithoutWhitelist)) {
+ printf("ERROR: filtered env wrong\n");
+ ++errors;
+
+ PrintStrTbl("Original environment", kMurkyEnv);
+ PrintStrTbl("Filtered environment", NaClEnvCleanserEnvironment(&nec));
+ PrintStrTbl("Expected environment", kFilteredEnvWithoutWhitelist);
+ } else {
+ printf("OK\n");
+ }
+ }
+ NaClEnvCleanserDtor(&nec);
+
printf("%s\n", (0 == errors) ? "PASSED" : "FAILED");
return 0 != errors;
}
« no previous file with comments | « src/trusted/service_runtime/env_cleanser.c ('k') | src/trusted/service_runtime/sel_main.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698