diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-24 20:00:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2022-09-24 20:00:32 +0100 |
commit | 43de82c1611acec494eaa7f89c047f9ef8f14088 (patch) | |
tree | b70ddeba0a31de2ebb47487e4bf2d06c21f89caa /src/libutil/addr.c | |
parent | b20b81d996b60b3e284843bd8034162ed1551927 (diff) | |
download | rspamd-43de82c1611acec494eaa7f89c047f9ef8f14088.tar.gz rspamd-43de82c1611acec494eaa7f89c047f9ef8f14088.zip |
[Minor] Some neats when working with Unix sockets
Diffstat (limited to 'src/libutil/addr.c')
-rw-r--r-- | src/libutil/addr.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c index d5502fce0..63e92c801 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -1060,6 +1060,13 @@ rspamd_inet_address_connect (const rspamd_inet_addr_t *addr, gint type, if (addr->af == AF_UNIX) { sa = (const struct sockaddr *)&addr->u.un->addr; + + struct sockaddr_un ssun; + strcpy(ssun.sun_path, tmpnam(NULL)); + ssun.sun_len = SUN_LEN(&ssun); + ssun.sun_family = AF_UNIX; + /* Also bind unix client sockets to allow unconnected reply from that side */ + r = bind (fd, &ssun, ssun.sun_len); } else { sa = &addr->u.in.addr.sa; @@ -1249,6 +1256,9 @@ rspamd_inet_address_sendto (gint fd, const void *buf, gsize len, gint fl, const struct sockaddr *sa; if (addr == NULL) { +#ifdef EADDRNOTAVAIL + errno = EADDRNOTAVAIL; +#endif return -1; } |