diff options
author | Peter Wu <peter@lekensteyn.nl> | 2020-02-15 19:05:37 +0000 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2020-02-15 20:05:09 +0000 |
commit | 52627a18288ba460387444d8c2f0fa2477b1a286 (patch) | |
tree | c0e5858de77d95f51b6d176124d1bdd010a1612c /src/libserver/cfg_utils.c | |
parent | 3535e32ecdfc118c4d03979a182f81e7e33beb7f (diff) | |
download | rspamd-52627a18288ba460387444d8c2f0fa2477b1a286.tar.gz rspamd-52627a18288ba460387444d8c2f0fa2477b1a286.zip |
[Fix] Support listening on systemd sockets by name
* Add support for looking up sockets by the systemd socket name, e.g.
`systemd:rspamd-proxy.socket` or the name from `FileDescriptorName`.
https://www.freedesktop.org/software/systemd/man/sd_listen_fds.html
* Replace EOVERFLOW error code to avoid confusing error messages.
Fixes: #2035
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r-- | src/libserver/cfg_utils.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index be1d948a7..b74759229 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -98,7 +98,7 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, const gchar *str) { struct rspamd_worker_bind_conf *cnf; - gchar *err; + const gchar *fdname; gboolean ret = TRUE; if (str == NULL) { @@ -112,11 +112,13 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, if (g_ascii_strncasecmp (str, "systemd:", sizeof ("systemd:") - 1) == 0) { /* The actual socket will be passed by systemd environment */ + fdname = str + sizeof ("systemd:") - 1; cnf->is_systemd = TRUE; - cnf->cnt = strtoul (str + sizeof ("systemd:") - 1, &err, 10); - cnf->addrs = g_ptr_array_new (); + cnf->addrs = g_ptr_array_new_full (1, g_free); - if (err == NULL || *err == '\0') { + if (fdname[0]) { + g_ptr_array_add (cnf->addrs, g_strdup (fdname)); + cnf->cnt = cnf->addrs->len; cnf->name = g_strdup (str); LL_PREPEND (cf->bind_conf, cnf); } |