You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dynamic_cfg.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "config.h"
  17. #include "rspamd.h"
  18. #include "map.h"
  19. #include "filter.h"
  20. #include "dynamic_cfg.h"
  21. #include "unix-std.h"
  22. #include "lua/lua_common.h"
  23. #include <math.h>
  24. struct config_json_buf {
  25. GString *buf;
  26. struct rspamd_config *cfg;
  27. };
  28. /**
  29. * Apply configuration to the specified configuration
  30. * @param conf_metrics
  31. * @param cfg
  32. */
  33. static void
  34. apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
  35. {
  36. gint test_act;
  37. const ucl_object_t *cur_elt, *cur_nm, *it_val;
  38. ucl_object_iter_t it = NULL;
  39. const gchar *name;
  40. gdouble nscore;
  41. static const guint priority = 3;
  42. while ((cur_elt = ucl_object_iterate (top, &it, true))) {
  43. if (ucl_object_type (cur_elt) != UCL_OBJECT) {
  44. msg_err ("loaded json array element is not an object");
  45. continue;
  46. }
  47. cur_nm = ucl_object_lookup (cur_elt, "metric");
  48. if (!cur_nm || ucl_object_type (cur_nm) != UCL_STRING) {
  49. msg_err (
  50. "loaded json metric object element has no 'metric' attribute");
  51. continue;
  52. }
  53. cur_nm = ucl_object_lookup (cur_elt, "symbols");
  54. /* Parse symbols */
  55. if (cur_nm && ucl_object_type (cur_nm) == UCL_ARRAY) {
  56. ucl_object_iter_t nit = NULL;
  57. while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) {
  58. if (ucl_object_lookup (it_val, "name") &&
  59. ucl_object_lookup (it_val, "value")) {
  60. const ucl_object_t *n =
  61. ucl_object_lookup (it_val, "name");
  62. const ucl_object_t *v =
  63. ucl_object_lookup (it_val, "value");
  64. nscore = ucl_object_todouble (v);
  65. /*
  66. * We use priority = 3 here
  67. */
  68. rspamd_config_add_symbol (cfg,
  69. ucl_object_tostring (n), nscore, NULL, NULL,
  70. 0, priority, cfg->default_max_shots);
  71. }
  72. else {
  73. msg_info (
  74. "json symbol object has no mandatory 'name' and 'value' attributes");
  75. }
  76. }
  77. }
  78. else {
  79. ucl_object_t *arr;
  80. arr = ucl_object_typed_new (UCL_ARRAY);
  81. ucl_object_insert_key ((ucl_object_t *)cur_elt, arr, "symbols",
  82. sizeof ("symbols") - 1, false);
  83. }
  84. cur_nm = ucl_object_lookup (cur_elt, "actions");
  85. /* Parse actions */
  86. if (cur_nm && ucl_object_type (cur_nm) == UCL_ARRAY) {
  87. ucl_object_iter_t nit = NULL;
  88. while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) {
  89. const ucl_object_t *n = ucl_object_lookup (it_val, "name");
  90. const ucl_object_t *v = ucl_object_lookup (it_val, "value");
  91. if (n != NULL && v != NULL) {
  92. name = ucl_object_tostring (n);
  93. if (!name || !rspamd_action_from_str (name, &test_act)) {
  94. msg_err ("unknown action: %s",
  95. ucl_object_tostring (ucl_object_lookup (it_val,
  96. "name")));
  97. continue;
  98. }
  99. if (ucl_object_type (v) == UCL_NULL) {
  100. nscore = NAN;
  101. }
  102. else {
  103. nscore = ucl_object_todouble (v);
  104. }
  105. ucl_object_t *obj_tbl = ucl_object_typed_new (UCL_OBJECT);
  106. ucl_object_insert_key (obj_tbl, ucl_object_fromdouble (nscore),
  107. "score", 0, false);
  108. ucl_object_insert_key (obj_tbl, ucl_object_fromdouble (priority),
  109. "priority", 0, false);
  110. rspamd_config_set_action_score (cfg, name, obj_tbl);
  111. ucl_object_unref (obj_tbl);
  112. }
  113. else {
  114. msg_info (
  115. "json action object has no mandatory 'name' and 'value' attributes");
  116. }
  117. }
  118. }
  119. else {
  120. ucl_object_t *arr;
  121. arr = ucl_object_typed_new (UCL_ARRAY);
  122. ucl_object_insert_key ((ucl_object_t *)cur_elt, arr, "actions",
  123. sizeof ("actions") - 1, false);
  124. }
  125. }
  126. }
  127. /* Callbacks for reading json dynamic rules */
  128. static gchar *
  129. json_config_read_cb (gchar * chunk,
  130. gint len,
  131. struct map_cb_data *data,
  132. gboolean final)
  133. {
  134. struct config_json_buf *jb, *pd;
  135. pd = data->prev_data;
  136. g_assert (pd != NULL);
  137. if (data->cur_data == NULL) {
  138. jb = g_malloc0 (sizeof (*jb));
  139. jb->cfg = pd->cfg;
  140. data->cur_data = jb;
  141. }
  142. else {
  143. jb = data->cur_data;
  144. }
  145. if (jb->buf == NULL) {
  146. /* Allocate memory for buffer */
  147. jb->buf = g_string_sized_new (MAX (len, BUFSIZ));
  148. }
  149. g_string_append_len (jb->buf, chunk, len);
  150. return NULL;
  151. }
  152. static void
  153. json_config_fin_cb (struct map_cb_data *data)
  154. {
  155. struct config_json_buf *jb;
  156. ucl_object_t *top;
  157. struct ucl_parser *parser;
  158. if (data->cur_data && data->prev_data) {
  159. jb = data->prev_data;
  160. /* Clean prev data */
  161. if (jb->buf) {
  162. g_string_free (jb->buf, TRUE);
  163. }
  164. g_free (jb);
  165. }
  166. /* Now parse json */
  167. if (data->cur_data) {
  168. jb = data->cur_data;
  169. }
  170. else {
  171. return;
  172. }
  173. if (jb->buf == NULL) {
  174. msg_err ("no data read");
  175. return;
  176. }
  177. parser = ucl_parser_new (0);
  178. if (!ucl_parser_add_chunk (parser, jb->buf->str, jb->buf->len)) {
  179. msg_err ("cannot load json data: parse error %s",
  180. ucl_parser_get_error (parser));
  181. ucl_parser_free (parser);
  182. return;
  183. }
  184. top = ucl_parser_get_object (parser);
  185. ucl_parser_free (parser);
  186. if (ucl_object_type (top) != UCL_ARRAY) {
  187. ucl_object_unref (top);
  188. msg_err ("loaded json is not an array");
  189. return;
  190. }
  191. ucl_object_unref (jb->cfg->current_dynamic_conf);
  192. apply_dynamic_conf (top, jb->cfg);
  193. jb->cfg->current_dynamic_conf = top;
  194. }
  195. static void
  196. json_config_dtor_cb (struct map_cb_data *data)
  197. {
  198. struct config_json_buf *jb;
  199. if (data->cur_data) {
  200. jb = data->cur_data;
  201. /* Clean prev data */
  202. if (jb->buf) {
  203. g_string_free (jb->buf, TRUE);
  204. }
  205. if (jb->cfg && jb->cfg->current_dynamic_conf) {
  206. ucl_object_unref (jb->cfg->current_dynamic_conf);
  207. }
  208. g_free (jb);
  209. }
  210. }
  211. /**
  212. * Init dynamic configuration using map logic and specific configuration
  213. * @param cfg config file
  214. */
  215. void
  216. init_dynamic_config (struct rspamd_config *cfg)
  217. {
  218. struct config_json_buf *jb, **pjb;
  219. if (cfg->dynamic_conf == NULL) {
  220. /* No dynamic conf has been specified, so do not try to load it */
  221. return;
  222. }
  223. /* Now try to add map with json data */
  224. jb = g_malloc (sizeof (struct config_json_buf));
  225. pjb = g_malloc (sizeof (struct config_json_buf *));
  226. jb->buf = NULL;
  227. jb->cfg = cfg;
  228. *pjb = jb;
  229. cfg->current_dynamic_conf = ucl_object_typed_new (UCL_ARRAY);
  230. rspamd_mempool_add_destructor (cfg->cfg_pool,
  231. (rspamd_mempool_destruct_t)g_free,
  232. pjb);
  233. if (!rspamd_map_add (cfg,
  234. cfg->dynamic_conf,
  235. "Dynamic configuration map",
  236. json_config_read_cb,
  237. json_config_fin_cb,
  238. json_config_dtor_cb,
  239. (void **)pjb)) {
  240. msg_err ("cannot add map for configuration %s", cfg->dynamic_conf);
  241. }
  242. }
  243. /**
  244. * Dump dynamic configuration to the disk
  245. * @param cfg
  246. * @return
  247. */
  248. gboolean
  249. dump_dynamic_config (struct rspamd_config *cfg)
  250. {
  251. struct stat st;
  252. gchar *dir, pathbuf[PATH_MAX];
  253. gint fd;
  254. if (cfg->dynamic_conf == NULL || cfg->current_dynamic_conf == NULL) {
  255. /* No dynamic conf has been specified, so do not try to dump it */
  256. msg_err ("cannot save dynamic conf as it is not specified");
  257. return FALSE;
  258. }
  259. dir = g_path_get_dirname (cfg->dynamic_conf);
  260. if (dir == NULL) {
  261. msg_err ("invalid path: %s", cfg->dynamic_conf);
  262. return FALSE;
  263. }
  264. if (stat (cfg->dynamic_conf, &st) == -1) {
  265. msg_debug ("%s is unavailable: %s", cfg->dynamic_conf,
  266. strerror (errno));
  267. st.st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  268. }
  269. if (access (dir, W_OK | R_OK) == -1) {
  270. msg_warn ("%s is inaccessible: %s", dir, strerror (errno));
  271. g_free (dir);
  272. return FALSE;
  273. }
  274. rspamd_snprintf (pathbuf,
  275. sizeof (pathbuf),
  276. "%s%crconf-XXXXXX",
  277. dir,
  278. G_DIR_SEPARATOR);
  279. g_free (dir);
  280. #ifdef HAVE_MKSTEMP
  281. /* Umask is set before */
  282. fd = mkstemp (pathbuf);
  283. #else
  284. fd = g_mkstemp_full (pathbuf, O_RDWR, S_IWUSR | S_IRUSR);
  285. #endif
  286. if (fd == -1) {
  287. msg_err ("mkstemp error: %s", strerror (errno));
  288. return FALSE;
  289. }
  290. if (!ucl_object_emit_full (cfg->current_dynamic_conf, UCL_EMIT_JSON,
  291. ucl_object_emit_fd_funcs (fd), NULL)) {
  292. msg_err ("cannot emit ucl object: %s", strerror (errno));
  293. close (fd);
  294. return FALSE;
  295. }
  296. (void)unlink (cfg->dynamic_conf);
  297. /* Rename old config */
  298. if (rename (pathbuf, cfg->dynamic_conf) == -1) {
  299. msg_err ("rename error: %s", strerror (errno));
  300. close (fd);
  301. unlink (pathbuf);
  302. return FALSE;
  303. }
  304. /* Set permissions */
  305. if (chmod (cfg->dynamic_conf, st.st_mode) == -1) {
  306. msg_warn ("chmod failed: %s", strerror (errno));
  307. }
  308. close (fd);
  309. return TRUE;
  310. }
  311. static ucl_object_t*
  312. new_dynamic_metric (const gchar *metric_name, ucl_object_t *top)
  313. {
  314. ucl_object_t *metric;
  315. metric = ucl_object_typed_new (UCL_OBJECT);
  316. ucl_object_insert_key (metric, ucl_object_fromstring (metric_name),
  317. "metric", sizeof ("metric") - 1, true);
  318. ucl_object_insert_key (metric, ucl_object_typed_new (UCL_ARRAY),
  319. "actions", sizeof ("actions") - 1, false);
  320. ucl_object_insert_key (metric, ucl_object_typed_new (UCL_ARRAY),
  321. "symbols", sizeof ("symbols") - 1, false);
  322. ucl_array_append (top, metric);
  323. return metric;
  324. }
  325. static ucl_object_t *
  326. dynamic_metric_find_elt (const ucl_object_t *arr, const gchar *name)
  327. {
  328. ucl_object_iter_t it = NULL;
  329. const ucl_object_t *cur, *n;
  330. it = ucl_object_iterate_new (arr);
  331. while ((cur = ucl_object_iterate_safe (it, true)) != NULL) {
  332. if (cur->type == UCL_OBJECT) {
  333. n = ucl_object_lookup (cur, "name");
  334. if (n && n->type == UCL_STRING &&
  335. strcmp (name, ucl_object_tostring (n)) == 0) {
  336. ucl_object_iterate_free (it);
  337. return (ucl_object_t *)ucl_object_lookup (cur, "value");
  338. }
  339. }
  340. }
  341. ucl_object_iterate_free (it);
  342. return NULL;
  343. }
  344. static ucl_object_t *
  345. dynamic_metric_find_metric (const ucl_object_t *arr, const gchar *metric)
  346. {
  347. ucl_object_iter_t it = NULL;
  348. const ucl_object_t *cur, *n;
  349. it = ucl_object_iterate_new (arr);
  350. while ((cur = ucl_object_iterate_safe (it, true)) != NULL) {
  351. if (cur->type == UCL_OBJECT) {
  352. n = ucl_object_lookup (cur, "metric");
  353. if (n && n->type == UCL_STRING &&
  354. strcmp (metric, ucl_object_tostring (n)) == 0) {
  355. ucl_object_iterate_free (it);
  356. return (ucl_object_t *)cur;
  357. }
  358. }
  359. }
  360. ucl_object_iterate_free (it);
  361. return NULL;
  362. }
  363. static ucl_object_t *
  364. new_dynamic_elt (ucl_object_t *arr, const gchar *name, gdouble value)
  365. {
  366. ucl_object_t *n;
  367. n = ucl_object_typed_new (UCL_OBJECT);
  368. ucl_object_insert_key (n, ucl_object_fromstring (name), "name",
  369. sizeof ("name") - 1, false);
  370. ucl_object_insert_key (n, ucl_object_fromdouble (value), "value",
  371. sizeof ("value") - 1, false);
  372. ucl_array_append (arr, n);
  373. return n;
  374. }
  375. static gint
  376. rspamd_maybe_add_lua_dynsym (struct rspamd_config *cfg,
  377. const gchar *sym,
  378. gdouble score)
  379. {
  380. lua_State *L = cfg->lua_state;
  381. gint ret = -1;
  382. struct rspamd_config **pcfg;
  383. lua_getglobal (L, "rspamd_plugins");
  384. if (lua_type (L, -1) == LUA_TTABLE) {
  385. lua_pushstring (L, "dynamic_conf");
  386. lua_gettable (L, -2);
  387. if (lua_type (L, -1) == LUA_TTABLE) {
  388. lua_pushstring (L, "add_symbol");
  389. lua_gettable (L, -2);
  390. if (lua_type (L, -1) == LUA_TFUNCTION) {
  391. pcfg = lua_newuserdata (L, sizeof (*pcfg));
  392. *pcfg = cfg;
  393. rspamd_lua_setclass (L, "rspamd{config}", -1);
  394. lua_pushstring (L, sym);
  395. lua_pushnumber (L, score);
  396. if (lua_pcall (L, 3, 1, 0) != 0) {
  397. msg_err_config ("cannot execute add_symbol script: %s",
  398. lua_tostring (L, -1));
  399. }
  400. else {
  401. ret = lua_toboolean (L, -1);
  402. }
  403. lua_pop (L, 1);
  404. }
  405. else {
  406. lua_pop (L, 1);
  407. }
  408. }
  409. lua_pop (L, 1);
  410. }
  411. lua_pop (L, 1);
  412. return ret;
  413. }
  414. static gint
  415. rspamd_maybe_add_lua_dynact (struct rspamd_config *cfg,
  416. const gchar *action,
  417. gdouble score)
  418. {
  419. lua_State *L = cfg->lua_state;
  420. gint ret = -1;
  421. struct rspamd_config **pcfg;
  422. lua_getglobal (L, "rspamd_plugins");
  423. if (lua_type (L, -1) == LUA_TTABLE) {
  424. lua_pushstring (L, "dynamic_conf");
  425. lua_gettable (L, -2);
  426. if (lua_type (L, -1) == LUA_TTABLE) {
  427. lua_pushstring (L, "add_action");
  428. lua_gettable (L, -2);
  429. if (lua_type (L, -1) == LUA_TFUNCTION) {
  430. pcfg = lua_newuserdata (L, sizeof (*pcfg));
  431. *pcfg = cfg;
  432. rspamd_lua_setclass (L, "rspamd{config}", -1);
  433. lua_pushstring (L, action);
  434. lua_pushnumber (L, score);
  435. if (lua_pcall (L, 3, 1, 0) != 0) {
  436. msg_err_config ("cannot execute add_action script: %s",
  437. lua_tostring (L, -1));
  438. }
  439. else {
  440. ret = lua_toboolean (L, -1);
  441. }
  442. lua_pop (L, 1);
  443. }
  444. else {
  445. lua_pop (L, 1);
  446. }
  447. }
  448. lua_pop (L, 1);
  449. }
  450. lua_pop (L, 1);
  451. return ret;
  452. }
  453. /**
  454. * Add symbol for specified metric
  455. * @param cfg config file object
  456. * @param metric metric's name
  457. * @param symbol symbol's name
  458. * @param value value of symbol
  459. * @return
  460. */
  461. gboolean
  462. add_dynamic_symbol (struct rspamd_config *cfg,
  463. const gchar *metric_name,
  464. const gchar *symbol,
  465. gdouble value)
  466. {
  467. ucl_object_t *metric, *syms;
  468. gint ret;
  469. if ((ret = rspamd_maybe_add_lua_dynsym (cfg, symbol, value)) != -1) {
  470. return ret == 0 ? FALSE : TRUE;
  471. }
  472. if (cfg->dynamic_conf == NULL) {
  473. msg_info ("dynamic conf is disabled");
  474. return FALSE;
  475. }
  476. metric = dynamic_metric_find_metric (cfg->current_dynamic_conf,
  477. metric_name);
  478. if (metric == NULL) {
  479. metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf);
  480. }
  481. syms = (ucl_object_t *)ucl_object_lookup (metric, "symbols");
  482. if (syms != NULL) {
  483. ucl_object_t *sym;
  484. sym = dynamic_metric_find_elt (syms, symbol);
  485. if (sym) {
  486. sym->value.dv = value;
  487. }
  488. else {
  489. new_dynamic_elt (syms, symbol, value);
  490. }
  491. }
  492. apply_dynamic_conf (cfg->current_dynamic_conf, cfg);
  493. return TRUE;
  494. }
  495. gboolean
  496. remove_dynamic_symbol (struct rspamd_config *cfg,
  497. const gchar *metric_name,
  498. const gchar *symbol)
  499. {
  500. ucl_object_t *metric, *syms;
  501. gboolean ret = FALSE;
  502. if (cfg->dynamic_conf == NULL) {
  503. msg_info ("dynamic conf is disabled");
  504. return FALSE;
  505. }
  506. metric = dynamic_metric_find_metric (cfg->current_dynamic_conf,
  507. metric_name);
  508. if (metric == NULL) {
  509. return FALSE;
  510. }
  511. syms = (ucl_object_t *)ucl_object_lookup (metric, "symbols");
  512. if (syms != NULL) {
  513. ucl_object_t *sym;
  514. sym = dynamic_metric_find_elt (syms, symbol);
  515. if (sym) {
  516. ret = ucl_array_delete ((ucl_object_t *)syms, sym) != NULL;
  517. if (ret) {
  518. ucl_object_unref (sym);
  519. }
  520. }
  521. }
  522. if (ret) {
  523. apply_dynamic_conf (cfg->current_dynamic_conf, cfg);
  524. }
  525. return ret;
  526. }
  527. /**
  528. * Add action for specified metric
  529. * @param cfg config file object
  530. * @param metric metric's name
  531. * @param action action's name
  532. * @param value value of symbol
  533. * @return
  534. */
  535. gboolean
  536. add_dynamic_action (struct rspamd_config *cfg,
  537. const gchar *metric_name,
  538. guint action,
  539. gdouble value)
  540. {
  541. ucl_object_t *metric, *acts;
  542. const gchar *action_name = rspamd_action_to_str (action);
  543. gint ret;
  544. if ((ret = rspamd_maybe_add_lua_dynact (cfg, action_name, value)) != -1) {
  545. return ret == 0 ? FALSE : TRUE;
  546. }
  547. if (cfg->dynamic_conf == NULL) {
  548. msg_info ("dynamic conf is disabled");
  549. return FALSE;
  550. }
  551. metric = dynamic_metric_find_metric (cfg->current_dynamic_conf,
  552. metric_name);
  553. if (metric == NULL) {
  554. metric = new_dynamic_metric (metric_name, cfg->current_dynamic_conf);
  555. }
  556. acts = (ucl_object_t *)ucl_object_lookup (metric, "actions");
  557. if (acts != NULL) {
  558. ucl_object_t *act;
  559. act = dynamic_metric_find_elt (acts, action_name);
  560. if (act) {
  561. act->value.dv = value;
  562. }
  563. else {
  564. new_dynamic_elt (acts, action_name, value);
  565. }
  566. }
  567. apply_dynamic_conf (cfg->current_dynamic_conf, cfg);
  568. return TRUE;
  569. }
  570. gboolean
  571. remove_dynamic_action (struct rspamd_config *cfg,
  572. const gchar *metric_name,
  573. guint action)
  574. {
  575. ucl_object_t *metric, *acts;
  576. const gchar *action_name = rspamd_action_to_str (action);
  577. gboolean ret = FALSE;
  578. if (cfg->dynamic_conf == NULL) {
  579. msg_info ("dynamic conf is disabled");
  580. return FALSE;
  581. }
  582. metric = dynamic_metric_find_metric (cfg->current_dynamic_conf,
  583. metric_name);
  584. if (metric == NULL) {
  585. return FALSE;
  586. }
  587. acts = (ucl_object_t *)ucl_object_lookup (metric, "actions");
  588. if (acts != NULL) {
  589. ucl_object_t *act;
  590. act = dynamic_metric_find_elt (acts, action_name);
  591. if (act) {
  592. ret = ucl_array_delete (acts, act) != NULL;
  593. }
  594. if (ret) {
  595. ucl_object_unref (act);
  596. }
  597. }
  598. if (ret) {
  599. apply_dynamic_conf (cfg->current_dynamic_conf, cfg);
  600. }
  601. return ret;
  602. }