Ejemplo n.º 1
0
static int find_exec_pathsearch(const char *filepath, char **argv, char *newpath, int newpath_size, char ***new_argv)
{
   char *newname = NULL;
   int result;

   if (!filepath) {
      newpath[0] = '\0';
      return 0;
   }
   if (filepath[0] == '/' || filepath[0] == '.') {
      find_exec(filepath, argv, newpath, newpath_size, new_argv);
      return 0;
   }
   check_for_fork();
   if (ldcsid < 0 || !use_ldcs) {
      strncpy(newpath, filepath, newpath_size);
      newpath[newpath_size-1] = '\0';
      return 0;
   }
   sync_cwd();

   result = exec_pathsearch(ldcsid, filepath, &newname);
   if (result == -1)
      return -1;

   result = prep_exec(filepath, argv, newname, newpath, newpath_size, new_argv);
   return result;
}
Ejemplo n.º 2
0
static int find_exec(const char *filepath, char **argv, char *newpath, int newpath_size, char ***new_argv)
{
   char *newname = NULL;

   if (!filepath) {
      newpath[0] = '\0';
      return 0;
   }

   check_for_fork();
   if (ldcsid < 0 || !use_ldcs || exec_filter(filepath) != REDIRECT) {
      strncpy(newpath, filepath, newpath_size);
      newpath[newpath_size-1] = '\0';
      return 0;
   }

   sync_cwd();
   debug_printf2("Exec operation requesting file: %s\n", filepath);
   send_file_query(ldcsid, (char *) filepath, &newname);
   debug_printf("Exec file request returned %s -> %s\n", filepath, newname ? newname : "NULL");

   return prep_exec(filepath, argv, newname, newpath, newpath_size, new_argv);
}
Ejemplo n.º 3
0
Archivo: client.c Proyecto: hpc/Spindle
char *client_library_load(const char *name)
{
   char *newname;
   int errcode;

   check_for_fork();
   if (!use_ldcs || ldcsid == -1) {
      return (char *) name;
   }
   if (!(opts & OPT_RELOCSO)) {
      return (char *) name;
   }
   
   /* Don't relocate a new copy of libc, it's always already loaded into the process. */
   find_libc_name();
   if (libc_name && strcmp(name, libc_name) == 0) {
      debug_printf("la_objsearch not redirecting libc %s\n", name);
      test_log(name);
      return (char *) name;
   }
   
   sync_cwd();

   get_relocated_file(ldcsid, name, &newname, &errcode);
 
   if(!newname) {
      newname = concatStrings(NOT_FOUND_PREFIX, name);
   }
   else {
      patch_on_load_success(newname, name);
   }

   debug_printf("la_objsearch redirecting %s to %s\n", name, newname);
   test_log(newname);
   return newname;
}
Ejemplo n.º 4
0
Archivo: client.c Proyecto: hpc/Spindle
static int init_server_connection()
{
   char *connection, *rankinfo_s, *opts_s, *cachesize_s;

   debug_printf("Initializing connection to server\n");

   if (ldcsid != -1)
      return 0;
   if (!use_ldcs)
      return 0;

   location = getenv("LDCS_LOCATION");
   number = atoi(getenv("LDCS_NUMBER"));
   connection = getenv("LDCS_CONNECTION");
   rankinfo_s = getenv("LDCS_RANKINFO");
   opts_s = getenv("LDCS_OPTIONS");
   cachesize_s = getenv("LDCS_CACHESIZE");
   opts = atol(opts_s);
   shm_cachesize = atoi(cachesize_s) * 1024;

   if (strchr(location, '$')) {
      location = parse_location(location);
   }

   if (!(opts & OPT_FOLLOWFORK)) {
      debug_printf("Disabling environment variables because we're not following forks\n");
      unsetenv("LD_AUDIT");
      unsetenv("LDCS_LOCATION");
      unsetenv("LDCS_NUMBER");
      unsetenv("LDCS_CONNECTION");
      unsetenv("LDCS_RANKINFO");
      unsetenv("LDCS_OPTIONS");
   }

   if (opts & OPT_SHMCACHE) {
      assert(shm_cachesize);
#if defined(COMM_BITER)
      shm_cache_limit = shm_cachesize > 512*1024 ? shm_cachesize - 512*1024 : 0;
#else
      shm_cache_limit = shm_cachesize;
#endif
      shmcache_init(location, number, shm_cachesize, shm_cache_limit);
   }

   if (connection) {
      /* boostrapper established the connection for us.  Reuse it. */
      debug_printf("Recreating existing connection to server\n");
      debug_printf3("location = %s, number = %d, connection = %s, rankinfo = %s\n",
                    location, number, connection, rankinfo_s);
      ldcsid  = client_register_connection(connection);
      if (ldcsid == -1)
         return -1;
      assert(rankinfo_s);
      sscanf(rankinfo_s, "%d %d %d %d", rankinfo+0, rankinfo+1, rankinfo+2, rankinfo+3);
      unsetenv("LDCS_CONNECTION");
   }
   else {
      /* Establish a new connection */
      debug_printf("open connection to ldcs %s %d\n", location, number);
      ldcsid = client_open_connection(location, number);
      if (ldcsid == -1)
         return -1;

      send_pid(ldcsid);
      send_location(ldcsid, location);
      send_rankinfo_query(ldcsid, rankinfo+0, rankinfo+1, rankinfo+2, rankinfo+3);
   }
   
   snprintf(debugging_name, 32, "Client.%d", rankinfo[0]);
   LOGGING_INIT(debugging_name);

   sync_cwd();

   if (opts & OPT_RELOCPY)
      parse_python_prefixes(ldcsid);
   return 0;
}