diff options
author | Martin Peres <martin.peres@free.fr> | 2015-10-22 02:48:33 +0300 |
---|---|---|
committer | Martin Peres <martin.peres@linux.intel.com> | 2015-10-22 18:34:28 +0300 |
commit | 359c9c64dcd1043107229c590aad05320784341b (patch) | |
tree | d08fdf6a13f46df1832aa25597fdc199ac18b4a6 | |
parent | 09410759308723aa3c942591c7fff0c7ad549abd (diff) |
env_dump: track the connections to unix socketsenv_dump
-rw-r--r-- | utils/env_dump/Makefile | 2 | ||||
-rw-r--r-- | utils/env_dump/env_dump.c | 2 | ||||
-rw-r--r-- | utils/env_dump/env_dump.h | 3 | ||||
-rw-r--r-- | utils/env_dump/net.c | 63 |
4 files changed, 69 insertions, 1 deletions
diff --git a/utils/env_dump/Makefile b/utils/env_dump/Makefile index 81ef229..40da89a 100644 --- a/utils/env_dump/Makefile +++ b/utils/env_dump/Makefile @@ -2,7 +2,7 @@ CC = gcc CFLAGS = -c -Wall -fPIC LDFLAGS = -shared -SOURCES = env_dump.c fd.c gl.c libs.c posix_env.c +SOURCES = env_dump.c fd.c gl.c libs.c net.c posix_env.c OBJECTS = $(SOURCES:.c=.o) # Name of executable target: diff --git a/utils/env_dump/env_dump.c b/utils/env_dump/env_dump.c index 5107082..51456c7 100644 --- a/utils/env_dump/env_dump.c +++ b/utils/env_dump/env_dump.c @@ -68,10 +68,12 @@ static void init() { _env_dump_fd_init(); _env_dump_gl_init(); _env_dump_libs_init(); + _env_dump_net_init(); } __attribute__((destructor)) static void fini() { + _env_dump_net_fini(); _env_dump_libs_fini(); _env_dump_gl_fini(); _env_dump_fd_init(); diff --git a/utils/env_dump/env_dump.h b/utils/env_dump/env_dump.h index c1c3db3..cb40a6f 100644 --- a/utils/env_dump/env_dump.h +++ b/utils/env_dump/env_dump.h @@ -40,6 +40,9 @@ void _env_dump_fd_fini(); void _env_dump_gl_init(); void _env_dump_gl_fini(); +void _env_dump_net_init(); +void _env_dump_net_fini(); + void _env_dump_posix_env_init(); void _env_dump_posix_env_fini(); diff --git a/utils/env_dump/net.c b/utils/env_dump/net.c new file mode 100644 index 0000000..1940925 --- /dev/null +++ b/utils/env_dump/net.c @@ -0,0 +1,63 @@ +/* Copyright (c) 2015, Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define _GNU_SOURCE + +#include "env_dump.h" + +#include <sys/socket.h> +#include <sys/types.h> +#include <sys/un.h> +#include <link.h> + +int +connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) +{ + static int(*orig_connect)(int, const struct sockaddr *, socklen_t); + struct sockaddr_un *addr_unix; + int ret; + + if (orig_connect == NULL) + orig_connect = dlsym(RTLD_NEXT, "connect"); + + ret = orig_connect(sockfd, addr, addrlen); + if (!ret && addr->sa_family == AF_UNIX) { + addr_unix = (struct sockaddr_un *)addr; + fprintf(env_file, "SOCKET_UNIX_CONNECT,%s\n", addr_unix->sun_path+1); + } + + return ret; +} + +void _env_dump_net_init() +{ + +} + +void _env_dump_net_fini() +{ + +} |