mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Stub out getsockname()
This commit is contained in:
parent
5717dfe3b9
commit
49d76c6311
4 changed files with 29 additions and 37 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -33,8 +33,6 @@ Thumbs.db
|
||||||
/examples/docker/test-*.env
|
/examples/docker/test-*.env
|
||||||
/world/mkworld
|
/world/mkworld
|
||||||
/world/*.c25519
|
/world/*.c25519
|
||||||
/tiny-httpd
|
|
||||||
/netcon/tiny-httpd
|
|
||||||
|
|
||||||
# Miscellaneous temporaries, build files, etc.
|
# Miscellaneous temporaries, build files, etc.
|
||||||
*.log
|
*.log
|
||||||
|
|
|
@ -105,15 +105,15 @@ netcon: $(OBJS)
|
||||||
ln -sf zerotier-netcon-service zerotier-cli
|
ln -sf zerotier-netcon-service zerotier-cli
|
||||||
ln -sf zerotier-netcon-service zerotier-idtool
|
ln -sf zerotier-netcon-service zerotier-idtool
|
||||||
|
|
||||||
install-intercept:
|
#install-intercept:
|
||||||
cp libzerotierintercept.so /lib/libzerotierintercept.so
|
# cp libzerotierintercept.so /lib/libzerotierintercept.so
|
||||||
ln -sf /lib/libzerotierintercept.so /lib/libzerotierintercept
|
# ln -sf /lib/libzerotierintercept.so /lib/libzerotierintercept
|
||||||
/usr/bin/install -c netcon/zerotier-intercept /usr/bin
|
# /usr/bin/install -c netcon/zerotier-intercept /usr/bin
|
||||||
|
|
||||||
uninstall-intercept:
|
#uninstall-intercept:
|
||||||
rm -r /lib/libzerotierintercept.so
|
# rm -r /lib/libzerotierintercept.so
|
||||||
rm -r /lib/libzerotierintercept
|
# rm -r /lib/libzerotierintercept
|
||||||
rm -r /usr/bin/zerotier-intercept
|
# rm -r /usr/bin/zerotier-intercept
|
||||||
|
|
||||||
selftest: $(OBJS) selftest.o
|
selftest: $(OBJS) selftest.o
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LDLIBS)
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LDLIBS)
|
||||||
|
|
|
@ -75,6 +75,7 @@ static int (*realclose)(CLOSE_SIG);
|
||||||
static int (*realclone)(CLONE_SIG);
|
static int (*realclone)(CLONE_SIG);
|
||||||
static int (*realdup2)(DUP2_SIG);
|
static int (*realdup2)(DUP2_SIG);
|
||||||
static int (*realdup3)(DUP3_SIG);
|
static int (*realdup3)(DUP3_SIG);
|
||||||
|
static int (*realgetsockname)(GETSOCKNAME_SIG);
|
||||||
|
|
||||||
/* Exported Function Prototypes */
|
/* Exported Function Prototypes */
|
||||||
void my_init(void);
|
void my_init(void);
|
||||||
|
@ -92,6 +93,7 @@ int close(CLOSE_SIG);
|
||||||
int clone(CLONE_SIG);
|
int clone(CLONE_SIG);
|
||||||
int dup2(DUP2_SIG);
|
int dup2(DUP2_SIG);
|
||||||
int dup3(DUP3_SIG);
|
int dup3(DUP3_SIG);
|
||||||
|
int getsockname(GETSOCKNAME_SIG);
|
||||||
|
|
||||||
int connect_to_service(void);
|
int connect_to_service(void);
|
||||||
int init_service_connection();
|
int init_service_connection();
|
||||||
|
@ -309,16 +311,11 @@ void my_dest(void) {
|
||||||
|
|
||||||
void load_symbols(void)
|
void load_symbols(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_OLD_DLSYM
|
|
||||||
void *lib;
|
|
||||||
#endif
|
|
||||||
/* possibly add check to beginning of each method to avoid needing to cll the constructor */
|
|
||||||
if(thispid == getpid()) {
|
if(thispid == getpid()) {
|
||||||
dwr(MSG_DEBUG,"detected duplicate call to global ctor (pid=%d).\n", thispid);
|
dwr(MSG_DEBUG,"detected duplicate call to global constructor (pid=%d).\n", thispid);
|
||||||
}
|
}
|
||||||
thispid = getpid();
|
thispid = getpid();
|
||||||
|
|
||||||
#ifndef USE_OLD_DLSYM
|
|
||||||
realconnect = dlsym(RTLD_NEXT, "connect");
|
realconnect = dlsym(RTLD_NEXT, "connect");
|
||||||
realbind = dlsym(RTLD_NEXT, "bind");
|
realbind = dlsym(RTLD_NEXT, "bind");
|
||||||
realaccept = dlsym(RTLD_NEXT, "accept");
|
realaccept = dlsym(RTLD_NEXT, "accept");
|
||||||
|
@ -334,26 +331,7 @@ void load_symbols(void)
|
||||||
realsyscall = dlsym(RTLD_NEXT, "syscall");
|
realsyscall = dlsym(RTLD_NEXT, "syscall");
|
||||||
realdup2 = dlsym(RTLD_NEXT, "dup2");
|
realdup2 = dlsym(RTLD_NEXT, "dup2");
|
||||||
realdup3 = dlsym(RTLD_NEXT, "dup3");
|
realdup3 = dlsym(RTLD_NEXT, "dup3");
|
||||||
#else
|
realgetsockname = dlsym(RTLD_NEXT, "getsockname");
|
||||||
lib = dlopen(LIBCONNECT, RTLD_LAZY);
|
|
||||||
realconnect = dlsym(lib, "connect");
|
|
||||||
realbind = dlsym(lib, "bind");
|
|
||||||
realaccept = dlsym(lib, "accept");
|
|
||||||
reallisten = dlsym(lib, "listen");
|
|
||||||
realsocket = dlsym(lib, "socket");
|
|
||||||
realselect = dlsym(lib, "select");
|
|
||||||
realsetsockopt = dlsym(lib, "setsockopt");
|
|
||||||
realgetsockopt = dlsym(lib, "getsockopt");
|
|
||||||
realaccept4 = dlsym(lib), "accept4");
|
|
||||||
realclone = dlsym(lib, "clone");
|
|
||||||
realclose = dlsym(lib, "close");
|
|
||||||
realsyscall = dlsym(lib, "syscall");
|
|
||||||
realdup2 = dlsym(RTLD_NEXT, "dup2");
|
|
||||||
realdup3 = dlsym(RTLD_NEXT, "dup3");
|
|
||||||
dlclose(lib);
|
|
||||||
lib = dlopen(LIBC, RTLD_LAZY);
|
|
||||||
dlclose(lib);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Private Function Prototypes */
|
/* Private Function Prototypes */
|
||||||
|
@ -825,7 +803,7 @@ int accept(ACCEPT_SIG)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following line is required for libuv/nodejs to accept connections properly,
|
/* The following line is required for libuv/nodejs to accept connections properly,
|
||||||
however, this has the side effect of causing certain webservers to max out the CPU
|
however, this has the side effect of causing certain webservers to max out the CPU
|
||||||
in an accept loop */
|
in an accept loop */
|
||||||
//fcntl(sockfd, F_SETFL, O_NONBLOCK);
|
//fcntl(sockfd, F_SETFL, O_NONBLOCK);
|
||||||
|
|
||||||
|
@ -1040,6 +1018,21 @@ int dup3(DUP3_SIG)
|
||||||
return realdup3(oldfd, newfd, flags);
|
return realdup3(oldfd, newfd, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
-------------------------------------- getsockname()----------------------------
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
int getsockname(GETSOCKNAME_SIG)
|
||||||
|
{
|
||||||
|
if (realgetsockname == NULL) {
|
||||||
|
dwr(MSG_ERROR, "getsockname(): SYMBOL NOT FOUND.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return realgetsockname(sockfd,addr,addrlen);
|
||||||
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
------------------------------------ syscall()----------------------------------
|
------------------------------------ syscall()----------------------------------
|
||||||
|
|
|
@ -185,6 +185,7 @@ struct shutdown_st
|
||||||
#define SYSCALL_SIG long number, ...
|
#define SYSCALL_SIG long number, ...
|
||||||
#define CLONE_SIG int (*fn)(void *), void *child_stack, int flags, void *arg, ...
|
#define CLONE_SIG int (*fn)(void *), void *child_stack, int flags, void *arg, ...
|
||||||
#define POLL_SIG struct pollfd *fds, nfds_t nfds, int timeout
|
#define POLL_SIG struct pollfd *fds, nfds_t nfds, int timeout
|
||||||
|
#define GETSOCKNAME_SIG int sockfd, struct sockaddr *addr, socklen_t *addrlen
|
||||||
|
|
||||||
#define DUP2_SIG int oldfd, int newfd
|
#define DUP2_SIG int oldfd, int newfd
|
||||||
#define DUP3_SIG int oldfd, int newfd, int flags
|
#define DUP3_SIG int oldfd, int newfd, int flags
|
||||||
|
|
Loading…
Add table
Reference in a new issue