diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-06-09 14:36:07 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-06-09 14:36:07 +0100 |
commit | 903111c6cc2cbc07de9f84a8ad1b9cddc5dfaaeb (patch) | |
tree | 354c8a0122232003e707ddfa4d32aec35d0afa99 /src/libutil/addr.c | |
parent | ae6f563623c765e574bd9a211be7524f7495ea28 (diff) | |
download | rspamd-903111c6cc2cbc07de9f84a8ad1b9cddc5dfaaeb.tar.gz rspamd-903111c6cc2cbc07de9f84a8ad1b9cddc5dfaaeb.zip |
[Project] Do not listen sockets in the main process
Diffstat (limited to 'src/libutil/addr.c')
-rw-r--r-- | src/libutil/addr.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c index b43f7cf03..bb98dbee2 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -1114,34 +1114,36 @@ rspamd_inet_address_listen (const rspamd_inet_addr_t *addr, gint type, } } - if (type != (int)SOCK_DGRAM) { + if (addr->af == AF_UNIX) { + path = addr->u.un->addr.sun_path; + /* Try to set mode and owner */ - if (addr->af == AF_UNIX) { - path = addr->u.un->addr.sun_path; - /* Try to set mode and owner */ - - if (addr->u.un->owner != (uid_t)-1 || addr->u.un->group != (gid_t)-1) { - if (chown (path, addr->u.un->owner, addr->u.un->group) == -1) { - msg_info ("cannot change owner for %s to %d:%d: %s", - path, addr->u.un->owner, addr->u.un->group, - strerror (errno)); - } + if (addr->u.un->owner != (uid_t)-1 || addr->u.un->group != (gid_t)-1) { + if (chown (path, addr->u.un->owner, addr->u.un->group) == -1) { + msg_info ("cannot change owner for %s to %d:%d: %s", + path, addr->u.un->owner, addr->u.un->group, + strerror (errno)); } + } - if (chmod (path, addr->u.un->mode) == -1) { - msg_info ("cannot change mode for %s to %od %s", - path, addr->u.un->mode, strerror (errno)); - } + if (chmod (path, addr->u.un->mode) == -1) { + msg_info ("cannot change mode for %s to %od %s", + path, addr->u.un->mode, strerror (errno)); } + } - r = listen (fd, listen_queue); + if (type != (int)SOCK_DGRAM) { - if (r == -1) { - msg_warn ("listen %s failed: %d, '%s'", - rspamd_inet_address_to_string_pretty (addr), - errno, strerror (errno)); + if (!(opts & RSPAMD_INET_ADDRESS_LISTEN_NOLISTEN)) { + r = listen (fd, listen_queue); - goto err; + if (r == -1) { + msg_warn ("listen %s failed: %d, '%s'", + rspamd_inet_address_to_string_pretty (addr), + errno, strerror (errno)); + + goto err; + } } } |