// === GLOBALS ===
int acess__errno;
+char *gsExecutablePath = "./ld-acess";
// === CODE ===
// --- VFS Calls
return native_execve("./ld-acess", new_argv, envp);
}
+int acess__SysSpawn(const char *binary, const char **argv, const char **envp, int nfd, int fds[], struct s_sys_spawninfo *info)
+{
+ int kernel_tid;
+ int newID;
+ newID = _Syscall(SYS_AN_SPAWN, "<d>d>d", sizeof(int), &kernel_tid,
+ nfd*sizeof(int), fds,
+ info ? sizeof(*info) : 0, info);
+
+ int argc = 0;
+ while( argv[argc++] );
+
+ const char *new_argv[5+argc+1];
+ int new_argc = 0, i;
+ char client_id_str[11];
+ sprintf(client_id_str, "%i", newID);
+ new_argv[new_argc++] = gsExecutablePath; // TODO: Get path to ld-acess executable
+ new_argv[new_argc++] = "--key";
+ new_argv[new_argc++] = client_id_str;
+ new_argv[new_argc++] = "--binary";
+ new_argv[new_argc++] = binary;
+ for( i = 0; argv[i]; i ++)
+ new_argv[new_argc++] = argv[i];
+ new_argv[new_argc++] = NULL;
+
+ // TODO: Debug output?
+
+ native_spawn(gsExecutablePath, new_argv, envp);
+
+ return kernel_tid;
+}
+
void acess_sleep(void)
{
DEBUG("%s()", __func__);
DEFSYM(clone),
DEFSYM(execve),
+ DEFSYM(_SysSpawn),
DEFSYM(sleep),
DEFSYM(waittid),
extern uint64_t native_tell(int FD);
extern int native_execve(const char *filename, const char *const argv[], const char *const envp[]);
+extern int native_spawn(const char *filename, const char *const argv[], const char *const envp[]);
// Syscalls used by the linker
extern int acess_open(const char *Path, int Flags);
#include <string.h>
#include <stddef.h>
#include <unistd.h>
+#include <spawn.h> // posix_spawn
#include "request.h"
#if SYSCALL_TRACE
perror("native_execve");
return ret;
}
+
+int native_spawn(const char *filename, const char *const argv[], const char *const envp[])
+{
+ int rv;
+
+ rv = posix_spawn(NULL, filename, NULL, NULL, (void*)argv, (void*)envp);
+
+ return rv;
+}