summaryrefslogtreecommitdiffstats
path: root/src/libutil/addr.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-09-24 20:00:32 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-09-24 20:00:32 +0100
commit43de82c1611acec494eaa7f89c047f9ef8f14088 (patch)
treeb70ddeba0a31de2ebb47487e4bf2d06c21f89caa /src/libutil/addr.c
parentb20b81d996b60b3e284843bd8034162ed1551927 (diff)
downloadrspamd-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.c10
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;
}