diff --git a/src/client/client/client.c b/src/client/client/client.c index dd68406..836c707 100644 --- a/src/client/client/client.c +++ b/src/client/client/client.c @@ -37,6 +37,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include "client_api.h" #include "spindle_launch.h" #include "shmcache.h" +#include "should_intercept.h" errno_location_t app_errno_location; @@ -375,7 +376,13 @@ char *client_library_load(const char *name) test_log(name); return (char *) name; } - + + /* Do not relocate if the file is to be excluded (e.g., on the local file system) */ + if( is_excluded_path(name) ) { + test_log(name); + return (char *) name; + } + sync_cwd(); get_relocated_file(ldcsid, name, &newname, &errcode); diff --git a/src/client/client/should_intercept.c b/src/client/client/should_intercept.c index 9f8b187..6761381 100644 --- a/src/client/client/should_intercept.c +++ b/src/client/client/should_intercept.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "spindle_launch.h" #include "client.h" @@ -28,6 +29,49 @@ extern int relocate_spindleapi(); +int is_excluded_path(const char *pathname) { + static int is_enabled = -1; + static const char *exclude_prefixes[] = { + "/bin", + "/dev", + "/etc", + "/lib", + "/opt", + "/proc", + "/sbin", + "/sys", + "/tmp", + "/usr", + "/var", + NULL + }; + int i; + + if( is_enabled < 0 ) { + const char *envar = getenv("SPINDLE_DISABLE_EXCLUDE"); + is_enabled = 1; // Default + if( NULL != envar && '1' == envar[0] ) { + is_enabled = 0; + } + } + + if( 0 == is_enabled ) { + return 0; + } + + if( NULL == pathname ) { + return 0; + } + + for(i = 0; NULL != exclude_prefixes[i]; ++i ) { + if( 0 == strncmp(pathname, exclude_prefixes[i], strlen(exclude_prefixes[i])) ) { + return 1; + } + } + + return 0; +} + static int is_python_path(const char *pathname) { unsigned int i; @@ -93,6 +137,10 @@ int open_filter(const char *fname, int flags) { char *last_slash, *last_dot; + if( is_excluded_path(fname) ) { + return ORIG_CALL; + } + if (relocate_spindleapi()) { if (open_for_excl(flags)) return EXCL_OPEN; @@ -130,6 +178,10 @@ int fopen_filter(const char *fname, const char *flags) { char *last_slash, *last_dot; + if( is_excluded_path(fname) ) { + return ORIG_CALL; + } + if (relocate_spindleapi()) { if (open_for_excl(flags)) return EXCL_OPEN; @@ -161,6 +213,10 @@ int fopen_filter(const char *fname, const char *flags) int exec_filter(const char *fname) { + if( is_excluded_path(fname) ) { + return ORIG_CALL; + } + if (relocate_spindleapi()) return REDIRECT; @@ -174,6 +230,10 @@ int stat_filter(const char *fname) { char *last_dot, *last_slash; + if( is_excluded_path(fname) ) { + return ORIG_CALL; + } + if (relocate_spindleapi()) return REDIRECT; diff --git a/src/client/client/should_intercept.h b/src/client/client/should_intercept.h index f6a9b51..5a0aa39 100644 --- a/src/client/client/should_intercept.h +++ b/src/client/client/should_intercept.h @@ -32,5 +32,6 @@ int fopen_filter(const char *fname, const char *flags); int exec_filter(const char *fname); int stat_filter(const char *fname); int fd_filter(int fd); +int is_excluded_path(const char *pathname); #endif