| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The Native Client Authors. All rights reserved. | 2 * Copyright 2009 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * Simple environment cleanser to remove all but a whitelisted set of | 8 * Simple environment cleanser to remove all but a whitelisted set of |
| 9 * environment variables deemed safe/appropriate to export to NaCl | 9 * environment variables deemed safe/appropriate to export to NaCl |
| 10 * modules. | 10 * modules. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_ENV_CLEANSER_H_ | 13 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_ENV_CLEANSER_H_ |
| 14 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_ENV_CLEANSER_H_ | 14 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_ENV_CLEANSER_H_ |
| 15 | 15 |
| 16 #include "native_client/src/include/nacl_base.h" | 16 #include "native_client/src/include/nacl_base.h" |
| 17 | 17 |
| 18 EXTERN_C_BEGIN | 18 EXTERN_C_BEGIN |
| 19 | 19 |
| 20 struct NaClEnvCleanser { | 20 struct NaClEnvCleanser { |
| 21 /* private */ | 21 /* private */ |
| 22 int with_whitelist; |
| 22 char const **cleansed_environ; | 23 char const **cleansed_environ; |
| 23 }; | 24 }; |
| 24 | 25 |
| 25 void NaClEnvCleanserCtor(struct NaClEnvCleanser *self); | 26 void NaClEnvCleanserCtor(struct NaClEnvCleanser *self, int with_whitelist); |
| 26 | 27 |
| 27 /* | 28 /* |
| 28 * Initializes the NaClEnvCleanser. Filters the environment at envp | 29 * Initializes the NaClEnvCleanser. Filters the environment at envp |
| 29 * and saves the result in the object. The lifetime of the string | 30 * and saves the result in the object. The lifetime of the string |
| 30 * table and associated strings at envp must be at least that of the | 31 * table and associated strings at envp must be at least that of the |
| 31 * NaClEnvCleanser object, and should not change between the call to | 32 * NaClEnvCleanser object, and should not change between the call to |
| 32 * NaClEnvCleanserInit and to NaClEnvCleanserDtor. | 33 * NaClEnvCleanserInit and to NaClEnvCleanserDtor. |
| 33 */ | 34 */ |
| 34 int NaClEnvCleanserInit(struct NaClEnvCleanser *self, char const *const *envp); | 35 int NaClEnvCleanserInit(struct NaClEnvCleanser *self, char const *const *envp, |
| 36 char const *const *extra_env); |
| 35 | 37 |
| 36 /* | 38 /* |
| 37 * Returns the filtered environment. | 39 * Returns the filtered environment. |
| 38 */ | 40 */ |
| 39 char const *const *NaClEnvCleanserEnvironment(struct NaClEnvCleanser *self); | 41 char const *const *NaClEnvCleanserEnvironment(struct NaClEnvCleanser *self); |
| 40 | 42 |
| 41 /* | 43 /* |
| 42 * Frees memory associated with the NaClEnvCleanser object. | 44 * Frees memory associated with the NaClEnvCleanser object. |
| 43 */ | 45 */ |
| 44 void NaClEnvCleanserDtor(struct NaClEnvCleanser *self); | 46 void NaClEnvCleanserDtor(struct NaClEnvCleanser *self); |
| 45 | 47 |
| 46 EXTERN_C_END | 48 EXTERN_C_END |
| 47 | 49 |
| 48 #endif // NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_ENV_CLEANSER_H_ | 50 #endif // NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_ENV_CLEANSER_H_ |
| OLD | NEW |