diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-14 14:35:52 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-10-14 14:35:52 +0100 |
commit | fb6469c8959825d9269f2550d35406a5b5986552 (patch) | |
tree | 09315babfe385a438a7757fa7cb330559d3b805b /src/libutil/addr.c | |
parent | 1e3f7ff3934ee87a1dbc980c32e3c26d19af74ea (diff) | |
download | rspamd-fb6469c8959825d9269f2550d35406a5b5986552.tar.gz rspamd-fb6469c8959825d9269f2550d35406a5b5986552.zip |
Print unix socket address when accepting connections
Diffstat (limited to 'src/libutil/addr.c')
-rw-r--r-- | src/libutil/addr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c index 3ddd10289..5958e9e3e 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -228,8 +228,18 @@ rspamd_accept_from_socket (gint sock, rspamd_inet_addr_t **target) addr->slen = len; if (addr->af == AF_UNIX) { - addr->u.un = g_slice_alloc (sizeof (*addr->u.un)); - memcpy (&addr->u.un->addr, &su.su, sizeof (struct sockaddr_un)); + addr->u.un = g_slice_alloc0 (sizeof (*addr->u.un)); + /* Get name from the listening socket */ + len = sizeof (su); + + if (getsockname (sock, &su.sa, &len) != -1) { + memcpy (&addr->u.un->addr, &su.su, MIN (len, + sizeof (struct sockaddr_un))); + } + else { + /* Just copy socket address */ + memcpy (&addr->u.un->addr, &su.sa, sizeof (struct sockaddr)); + } } else { memcpy (&addr->u.in.addr, &su, MIN (len, sizeof (addr->u.in.addr))); |