diff options
author | Boris Nagaev <bnagaev@gmail.com> | 2015-11-09 23:38:46 (GMT) |
---|---|---|
committer | Boris Nagaev <bnagaev@gmail.com> | 2015-11-10 08:19:45 (GMT) |
commit | 8448d43531bd8002204521c75c6a49c8a0082574 (patch) | |
tree | 34c673d7452429e329ee4c95723028d099ba2ed3 /tools | |
parent | 16ce867a16bf9acb58cd8da730fc80dfa70e6e8d (diff) | |
download | mxe-8448d43531bd8002204521c75c6a49c8a0082574.zip mxe-8448d43531bd8002204521c75c6a49c8a0082574.tar.gz mxe-8448d43531bd8002204521c75c6a49c8a0082574.tar.bz2 |
disable networking with LD_PRELOAD when build
see #969
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nonetwork.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/nonetwork.c b/tools/nonetwork.c new file mode 100644 index 0000000..d203fb2 --- /dev/null +++ b/tools/nonetwork.c @@ -0,0 +1,36 @@ +// nonetwork, break standard network functions using LD_PRELOAD +// Source: https://github.com/starius/nonetwork +// Copyright (C) 2015 Boris Nagaev +// License: MIT + +#include <errno.h> + +int connect(int sock, const void *addr, unsigned int len) { + errno = 13; // EACCES, Permission denied + return -1; +} + +void *gethostbyname(const char *name) { + return 0; +} + +int getaddrinfo(const char *node, const char *service, + const void *hints, + void **res) { + return -4; // EAI_FAIL +} + +void freeaddrinfo(void *res) { +} + +int getnameinfo(const void * sa, + unsigned int salen, char * host, + unsigned int hostlen, char * serv, + unsigned int servlen, int flags) { + return -4; // EAI_FAIL +} + +struct hostent *gethostbyaddr(const void *addr, unsigned int len, + int type) { + return 0; +} |