Ejemplo n.º 1
0
Archivo: client.c Proyecto: hpc/Spindle
int client_init()
{
  int initial_run = 0;
  LOGGING_INIT("Client");
  check_for_fork();
  if (!use_ldcs)
     return -1;

  init_server_connection();
  intercept_open = (opts & OPT_RELOCPY) ? 1 : 0;
  intercept_stat = (opts & OPT_RELOCPY || !(opts & OPT_NOHIDE)) ? 1 : 0;
  intercept_exec = (opts & OPT_RELOCEXEC) ? 1 : 0;
  intercept_fork = 1;
  intercept_close = 1;  

  if (getenv("LDCS_BOOTSTRAPPED")) {
     initial_run = 1;
     unsetenv("LDCS_BOOTSTRAPPED");
  }
  
  if ((opts & OPT_REMAPEXEC) &&
      ((initial_run && (opts & OPT_RELOCAOUT)) ||
       (!initial_run && (opts & OPT_RELOCEXEC))))
  {
     remap_executable(ldcsid);
  }

  return 0;
}
Ejemplo n.º 2
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.º 3
0
Archivo: client.c Proyecto: hpc/Spindle
int client_done()
{
   check_for_fork();
   if (ldcsid == -1 || !use_ldcs)
      return 0;

   debug_printf2("Done. Closing connection %d\n", ldcsid);
   send_end(ldcsid);
   client_close_connection(ldcsid);
   return 0;
}
Ejemplo n.º 4
0
int readlinkat_wrapper(int dirfd, const char *path, char *buf, size_t bufsiz)
{
   char newbuf[MAX_PATH_LEN+1];
   ssize_t rl_result;
   debug_printf2("Intercepted readlink on %s\n", path);

   check_for_fork();

   memset(newbuf, 0, MAX_PATH_LEN+1);
   rl_result = (ssize_t) orig_readlinkat(dirfd, path, newbuf, MAX_PATH_LEN);
   if (rl_result == -1) {
      return -1;
   }

   return (int) readlink_worker(path, buf, bufsiz, newbuf, rl_result);   
}
Ejemplo n.º 5
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.º 6
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;
}