git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow for platforms not support abstract naming for Unix sockets
[exim.git]
/
src
/
src
/
expand.c
diff --git
a/src/src/expand.c
b/src/src/expand.c
index 427effedf4606b2b5dc28e1767425672501add6c..4af4a3652ce7f18cee9a34674bb096bfd1bbeaa4 100644
(file)
--- a/
src/src/expand.c
+++ b/
src/src/expand.c
@@
-1755,6
+1755,9
@@
uschar buf[16];
int fd;
ssize_t len;
const uschar * where;
int fd;
ssize_t len;
const uschar * where;
+#ifndef EXIM_HAVE_ABSTRACT_UNIX_SOCKETS
+uschar * sname;
+#endif
if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
{
if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
{
@@
-1762,28
+1765,34
@@
if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
return NULL;
}
return NULL;
}
-#define ABSTRACT_CLIENT
-#ifdef ABSTRACT_CLIENT
+#ifdef EXIM_HAVE_ABSTRACT_UNIX_SOCKETS
sun.sun_path[0] = 0; /* Abstract local socket addr - Linux-specific? */
len = offsetof(struct sockaddr_un, sun_path) + 1
+ snprintf(sun.sun_path+1, sizeof(sun.sun_path)-1, "exim_%d", getpid());
#else
sun.sun_path[0] = 0; /* Abstract local socket addr - Linux-specific? */
len = offsetof(struct sockaddr_un, sun_path) + 1
+ snprintf(sun.sun_path+1, sizeof(sun.sun_path)-1, "exim_%d", getpid());
#else
+sname = string_sprintf("%s/p_%d", spool_directory, getpid());
len = offsetof(struct sockaddr_un, sun_path)
len = offsetof(struct sockaddr_un, sun_path)
- + snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/p_%d",
- spool_directory, getpid());
+ + snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", sname);
#endif
if (bind(fd, (const struct sockaddr *)&sun, len) < 0)
{ where = US"bind"; goto bad; }
#ifdef notdef
#endif
if (bind(fd, (const struct sockaddr *)&sun, len) < 0)
{ where = US"bind"; goto bad; }
#ifdef notdef
-debug_printf("local%s '%s'\n", *sun.sun_path ? "" : " abstract",
- sun.sun_path+ (*sun.sun_path ? 0 : 1));
+debug_printf("local addr '%s%s'\n",
+ *sun.sun_path ? "" : "@",
+ sun.sun_path + (*sun.sun_path ? 0 : 1));
#endif
#endif
+#ifdef EXIM_HAVE_ABSTRACT_UNIX_SOCKETS
sun.sun_path[0] = 0; /* Abstract local socket addr - Linux-specific? */
len = offsetof(struct sockaddr_un, sun_path) + 1
+ snprintf(sun.sun_path+1, sizeof(sun.sun_path)-1, "%s", NOTIFIER_SOCKET_NAME);
sun.sun_path[0] = 0; /* Abstract local socket addr - Linux-specific? */
len = offsetof(struct sockaddr_un, sun_path) + 1
+ snprintf(sun.sun_path+1, sizeof(sun.sun_path)-1, "%s", NOTIFIER_SOCKET_NAME);
+#else
+len = offsetof(struct sockaddr_un, sun_path)
+ + snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%s",
+ spool_directory, NOTIFIER_SOCKET_NAME);
+#endif
if (connect(fd, (const struct sockaddr *)&sun, len) < 0)
{ where = US"connect"; goto bad; }
if (connect(fd, (const struct sockaddr *)&sun, len) < 0)
{ where = US"connect"; goto bad; }
@@
-1794,6
+1803,9
@@
if (send(fd, buf, 1, 0) < 0) { where = US"send"; goto bad; }
if ((len = recv(fd, buf, sizeof(buf), 0)) < 0) { where = US"recv"; goto bad; }
close(fd);
if ((len = recv(fd, buf, sizeof(buf), 0)) < 0) { where = US"recv"; goto bad; }
close(fd);
+#ifndef EXIM_HAVE_ABSTRACT_UNIX_SOCKETS
+Uunlink(sname);
+#endif
return string_copyn(buf, len);
bad:
return string_copyn(buf, len);
bad: