struct rspamd_worker *worker = (struct rspamd_worker *)w->data; | struct rspamd_worker *worker = (struct rspamd_worker *)w->data; | ||||
struct rspamd_controller_worker_ctx *ctx; | struct rspamd_controller_worker_ctx *ctx; | ||||
struct rspamd_controller_session *session; | struct rspamd_controller_session *session; | ||||
rspamd_inet_addr_t *addr; | |||||
rspamd_inet_addr_t *addr = NULL; | |||||
gint nfd; | gint nfd; | ||||
ctx = worker->ctx; | ctx = worker->ctx; | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||
struct rspamd_cryptobox_keypair *decrypt_keypair = NULL; | struct rspamd_cryptobox_keypair *decrypt_keypair = NULL; | ||||
gchar *data; | gchar *data; | ||||
if (stat (filename, &st) == -1) { | |||||
g_set_error (err, cfg_rcl_error_quark (), errno, | |||||
"cannot stat %s: %s", filename, strerror (errno)); | |||||
return FALSE; | |||||
} | |||||
if ((fd = open (filename, O_RDONLY)) == -1) { | if ((fd = open (filename, O_RDONLY)) == -1) { | ||||
g_set_error (err, cfg_rcl_error_quark (), errno, | g_set_error (err, cfg_rcl_error_quark (), errno, | ||||
"cannot open %s: %s", filename, strerror (errno)); | "cannot open %s: %s", filename, strerror (errno)); | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
if (fstat (fd, &st) == -1) { | |||||
g_set_error (err, cfg_rcl_error_quark (), errno, | |||||
"cannot stat %s: %s", filename, strerror (errno)); | |||||
close (fd); | |||||
return FALSE; | |||||
} | |||||
/* Now mmap this file to simplify reading process */ | /* Now mmap this file to simplify reading process */ | ||||
if ((data = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { | if ((data = mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { | ||||
g_set_error (err, cfg_rcl_error_quark (), errno, | g_set_error (err, cfg_rcl_error_quark (), errno, | ||||
"cannot mmap %s: %s", filename, strerror (errno)); | "cannot mmap %s: %s", filename, strerror (errno)); | ||||
close (fd); | close (fd); | ||||
return FALSE; | return FALSE; | ||||
} | } | ||||
/* Try to load keyfile if available */ | /* Try to load keyfile if available */ | ||||
rspamd_snprintf (keypair_path, sizeof (keypair_path), "%s.key", | rspamd_snprintf (keypair_path, sizeof (keypair_path), "%s.key", | ||||
filename); | filename); | ||||
if (stat (keypair_path, &st) == -1 && | |||||
(fd = open (keypair_path, O_RDONLY)) != -1) { | |||||
if ((fd = open (keypair_path, O_RDONLY)) != -1) { | |||||
struct ucl_parser *kp_parser; | struct ucl_parser *kp_parser; | ||||
kp_parser = ucl_parser_new (0); | kp_parser = ucl_parser_new (0); | ||||
} | } | ||||
ucl_parser_free (kp_parser); | ucl_parser_free (kp_parser); | ||||
close (fd); | |||||
} | } | ||||
parser = ucl_parser_new (UCL_PARSER_SAVE_COMMENTS); | parser = ucl_parser_new (UCL_PARSER_SAVE_COMMENTS); | ||||
cur = found; | cur = found; | ||||
} | } | ||||
} | } | ||||
g_strfreev (path_components); | |||||
} | } | ||||
return rspamd_rcl_add_doc_obj (ucl_object_ref (cur), | return rspamd_rcl_add_doc_obj (ucl_object_ref (cur), |
if (lseek (fd, off, SEEK_SET) == -1) { | if (lseek (fd, off, SEEK_SET) == -1) { | ||||
msg_err_map ("can't seek in map to pos %d for buffered reading %s: %s", | msg_err_map ("can't seek in map to pos %d for buffered reading %s: %s", | ||||
(gint)off, fname, strerror (errno)); | (gint)off, fname, strerror (errno)); | ||||
close (fd); | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
cdb = g_malloc0 (sizeof (struct cdb)); | cdb = g_malloc0 (sizeof (struct cdb)); | ||||
if (cdb_init (cdb, fd) == -1) { | if (cdb_init (cdb, fd) == -1) { | ||||
g_free (cdb); | |||||
msg_err_map ("cannot init cdb map from %s: %s", chunk, strerror (errno)); | msg_err_map ("cannot init cdb map from %s: %s", chunk, strerror (errno)); | ||||
return NULL; | return NULL; |
if (target) { | if (target) { | ||||
*target = res; | *target = res; | ||||
} | } | ||||
else { | |||||
ucl_object_unref (res); | |||||
} | |||||
return RSPAMD_STAT_PROCESS_OK; | return RSPAMD_STAT_PROCESS_OK; | ||||
} | } |
} | } | ||||
if (ev_base == NULL) { | if (ev_base == NULL) { | ||||
g_free (auth); | |||||
rspamd_http_message_unref (msg); | |||||
if (body) { | |||||
rspamd_fstring_free (body); | |||||
} | |||||
return luaL_error (L, | return luaL_error (L, | ||||
"Bad params to rspamd_http:request(): ev_base isn't passed"); | "Bad params to rspamd_http:request(): ev_base isn't passed"); | ||||
} | } |
signature->str, (guint *)&signature->len, rsa); | signature->str, (guint *)&signature->len, rsa); | ||||
if (ret != 1) { | if (ret != 1) { | ||||
rspamd_fstring_free (signature); | |||||
return luaL_error (L, "cannot sign: %s", | return luaL_error (L, "cannot sign: %s", | ||||
ERR_error_string (ERR_get_error (), NULL)); | ERR_error_string (ERR_get_error (), NULL)); | ||||
} | } |
struct rspamd_lua_regexp *re; | struct rspamd_lua_regexp *re; | ||||
gboolean stringify = FALSE, own_re = FALSE; | gboolean stringify = FALSE, own_re = FALSE; | ||||
if (t == NULL) { | |||||
return luaL_error (L, "invalid arguments"); | |||||
} | |||||
if (lua_type (L, 2) == LUA_TUSERDATA) { | if (lua_type (L, 2) == LUA_TUSERDATA) { | ||||
re = lua_check_regexp (L, 2); | re = lua_check_regexp (L, 2); | ||||
} | } | ||||
own_re = TRUE; | own_re = TRUE; | ||||
} | } | ||||
if (t && re) { | |||||
if (re) { | |||||
if (lua_isboolean (L, 3)) { | if (lua_isboolean (L, 3)) { | ||||
stringify = lua_toboolean (L, 3); | stringify = lua_toboolean (L, 3); | ||||
} | } |
} | } | ||||
else { | else { | ||||
msg_info ("bad url protocol: %s", *cvec); | msg_info ("bad url protocol: %s", *cvec); | ||||
g_strfreev (strvec); | |||||
return FALSE; | return FALSE; | ||||
} | } | ||||
{ | { | ||||
struct rspamadm_lua_repl_context *ctx = | struct rspamadm_lua_repl_context *ctx = | ||||
(struct rspamadm_lua_repl_context *)w->data; | (struct rspamadm_lua_repl_context *)w->data; | ||||
rspamd_inet_addr_t *addr; | |||||
rspamd_inet_addr_t *addr = NULL; | |||||
struct rspamadm_lua_repl_session *session; | struct rspamadm_lua_repl_session *session; | ||||
gint nfd; | gint nfd; | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||
rspamd_control_handler (EV_P_ ev_io *w, int revents) | rspamd_control_handler (EV_P_ ev_io *w, int revents) | ||||
{ | { | ||||
struct rspamd_main *rspamd_main = (struct rspamd_main *)w->data; | struct rspamd_main *rspamd_main = (struct rspamd_main *)w->data; | ||||
rspamd_inet_addr_t *addr; | |||||
rspamd_inet_addr_t *addr = NULL; | |||||
gint nfd; | gint nfd; | ||||
if ((nfd = | if ((nfd = | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||
{ | { | ||||
struct rspamd_worker *worker = (struct rspamd_worker *)w->data; | struct rspamd_worker *worker = (struct rspamd_worker *)w->data; | ||||
struct rspamd_proxy_ctx *ctx; | struct rspamd_proxy_ctx *ctx; | ||||
rspamd_inet_addr_t *addr; | |||||
rspamd_inet_addr_t *addr = NULL; | |||||
struct rspamd_proxy_session *session; | struct rspamd_proxy_session *session; | ||||
gint nfd; | gint nfd; | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||
struct rspamd_worker *worker = (struct rspamd_worker *) w->data; | struct rspamd_worker *worker = (struct rspamd_worker *) w->data; | ||||
struct rspamd_worker_ctx *ctx; | struct rspamd_worker_ctx *ctx; | ||||
struct rspamd_worker_session *session; | struct rspamd_worker_session *session; | ||||
rspamd_inet_addr_t *addr; | |||||
rspamd_inet_addr_t *addr = NULL; | |||||
gint nfd, http_opts = 0; | gint nfd, http_opts = 0; | ||||
ctx = worker->ctx; | ctx = worker->ctx; | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||
rspamd_server_accept (gint fd, short what, void *arg) | rspamd_server_accept (gint fd, short what, void *arg) | ||||
{ | { | ||||
struct rspamd_http_connection_router *rt = arg; | struct rspamd_http_connection_router *rt = arg; | ||||
rspamd_inet_addr_t *addr; | |||||
rspamd_inet_addr_t *addr = NULL; | |||||
gint nfd; | gint nfd; | ||||
if ((nfd = | if ((nfd = | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
/* Check for EAGAIN */ | /* Check for EAGAIN */ | ||||
if (nfd == 0) { | if (nfd == 0) { | ||||
rspamd_inet_address_free (addr); | |||||
return; | return; | ||||
} | } | ||||