mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
r18423: record accept, connect and close events in socket wrapper
metze
This commit is contained in:
parent
47ccea11f3
commit
7f29471f0b
@ -113,6 +113,23 @@ static const char *socket_wrapper_dir(void)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *socket_wrapper_dump_dir(void)
|
||||||
|
{
|
||||||
|
const char *s = getenv("SOCKET_WRAPPER_DUMP_DIR");
|
||||||
|
|
||||||
|
if (!socket_wrapper_dir()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (strncmp(s, "./", 2) == 0) {
|
||||||
|
s += 2;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int socket_wrapper_default_iface(void)
|
static unsigned int socket_wrapper_default_iface(void)
|
||||||
{
|
{
|
||||||
const char *s = getenv("SOCKET_WRAPPER_DEFAULT_IFACE");
|
const char *s = getenv("SOCKET_WRAPPER_DEFAULT_IFACE");
|
||||||
@ -401,16 +418,22 @@ static int sockaddr_convert_from_un(const struct socket_info *si,
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum swrap_packet_type {
|
enum swrap_packet_type {
|
||||||
|
SWRAP_CONNECT,
|
||||||
|
SWRAP_ACCEPT,
|
||||||
SWRAP_RECVFROM,
|
SWRAP_RECVFROM,
|
||||||
SWRAP_SENDTO,
|
SWRAP_SENDTO,
|
||||||
SWRAP_RECV,
|
SWRAP_RECV,
|
||||||
SWRAP_SEND
|
SWRAP_SEND,
|
||||||
|
SWRAP_CLOSE
|
||||||
};
|
};
|
||||||
|
|
||||||
static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *addr,
|
static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *addr,
|
||||||
enum swrap_packet_type type,
|
enum swrap_packet_type type,
|
||||||
const void *buf, size_t len, ssize_t ret)
|
const void *buf, size_t len, ssize_t ret)
|
||||||
{
|
{
|
||||||
|
if (!socket_wrapper_dump_dir()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,6 +516,8 @@ _PUBLIC_ int swrap_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
|
|
||||||
DLIST_ADD(sockets, child_si);
|
DLIST_ADD(sockets, child_si);
|
||||||
|
|
||||||
|
swrap_dump_packet(child_si, addr, SWRAP_ACCEPT, NULL, 0, 0);
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,6 +611,8 @@ _PUBLIC_ int swrap_connect(int s, const struct sockaddr *serv_addr, socklen_t ad
|
|||||||
si->peername = sockaddr_dup(serv_addr, addrlen);
|
si->peername = sockaddr_dup(serv_addr, addrlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swrap_dump_packet(si, serv_addr, SWRAP_CONNECT, NULL, 0, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,6 +849,8 @@ _PUBLIC_ int swrap_close(int fd)
|
|||||||
if (si) {
|
if (si) {
|
||||||
DLIST_REMOVE(sockets, si);
|
DLIST_REMOVE(sockets, si);
|
||||||
|
|
||||||
|
swrap_dump_packet(si, NULL, SWRAP_CLOSE, NULL, 0, 0);
|
||||||
|
|
||||||
free(si->path);
|
free(si->path);
|
||||||
free(si->myname);
|
free(si->myname);
|
||||||
free(si->peername);
|
free(si->peername);
|
||||||
|
Loading…
Reference in New Issue
Block a user