X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Flibacess-native.so_src%2Fmain.c;h=b5f066f70809e5bc4868aec4c2affc7413b8e7bc;hb=8b72370eae1a3cfa8916136fd8ffc1460e9291ba;hp=7f62545f979c18a492f18cc1ed5368df5d8535c0;hpb=feb0895318d823867b858ec841589ca3ab81f510;p=tpg%2Facess2.git diff --git a/AcessNative/libacess-native.so_src/main.c b/AcessNative/libacess-native.so_src/main.c index 7f62545f..b5f066f7 100644 --- a/AcessNative/libacess-native.so_src/main.c +++ b/AcessNative/libacess-native.so_src/main.c @@ -10,6 +10,8 @@ #include #include "../ld-acess_src/exports.h" +extern int gbSyscallDebugEnabled; + #ifdef __WINDOWS__ int DllMain(void) { @@ -40,10 +42,13 @@ int libacessnative_init(int argc, char *argv[], char **envp) { Request_Preinit(); + //gbSyscallDebugEnabled = 1; + const char *preopens = getenv_p(envp, ENV_VAR_PREOPENS); printf("preopens = %s\n", preopens); if( preopens ) { + int exp_fd = 0; while( *preopens ) { const char *splitter = strchr(preopens, ':'); @@ -60,7 +65,15 @@ int libacessnative_init(int argc, char *argv[], char **envp) int fd = acess__SysOpen(path, 6); // WRITE,READ,no EXEC if( fd == -1 ) { fprintf(stderr, "Unable to preopen '%s' errno=%i\n", path, acess__errno); + exit(1); + } + if( fd != exp_fd ) { + // Oh... this is bad + fprintf(stderr, "Pre-opening '%s' resulted in an incorrect FD (expected %i, got %i)", + path, exp_fd, fd); + exit(1); } + exp_fd += 1; if( !splitter ) break; @@ -127,17 +140,3 @@ void Warning(const char *format, ...) printf("\n"); } -void __libc_csu_fini() -{ -} - -void __libc_csu_init() -{ -} - -void __stack_chk_fail(void) -{ - fprintf(stderr, "__stack_chk_fail"); - exit(1); -} -