+#define acess__SysSpawn _disabled_acess__SysSpawn
#include "../ld-acess_src/exports.c"
void *_crt0_exit_handler;
return &acess__errno;
}
+#undef acess__SysSpawn
+
+int acess__SysSpawn(const char *binary, const char **argv, const char **envp, int nfd, int fds[], struct s_sys_spawninfo *info)
+{
+ int argc = 0;
+ while( argv[argc++] );
+
+ Debug("_SysSpawn('%s', %p (%i), %p, %i, %p, %p)",
+ binary, argv, argc, envp, nfd, fds, 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);
+
+
+ // TODO: Translate internal path to actual path
+
+ // TODO: set environment variables for libacess-native
+ // > ACESSNATIVE_KEY=`newID`
+ native_spawn(binary, argv, envp);
+
+ return 0;
+}
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
extern int giSyscall_ClientID;
extern void Request_Preinit(void);
#endif
#ifdef __linux__
-int __attribute__ ((constructor)) libacessnative_init(void);
+int __attribute__ ((constructor(102))) libacessnative_init(int argc, char *argv[], char **envp);
-int libacessnative_init(void)
+const char *getenv_p(char **envp, const char *name)
{
- Request_Preinit();
+ size_t namelen = strlen(name);
+ for(; *envp; envp ++)
+ {
+ if( strncmp(*envp, name, namelen) != 0 )
+ continue ;
+ if( (*envp)[namelen] != '=' )
+ continue ;
+ return (*envp)+namelen+1;
+ }
+ return 0;
+}
- const char *preopens = getenv("AN_PREOPEN");
+int libacessnative_init(int argc, char *argv[], char **envp)
+{
+ Request_Preinit();
+
+ const char *preopens = getenv_p(envp, "AN_PREOPEN");
+ printf("preopens = %s\n", preopens);
if( preopens )
{
while( *preopens )