/*- * Copyright 2016 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "config.h" #include "cfg_file.h" #include "rspamd.h" #include "cfg_file_private.h" #include "scan_result.h" #include "lua/lua_common.h" #include "lua/lua_thread_pool.h" #include "maps/map.h" #include "maps/map_helpers.h" #include "maps/map_private.h" #include "dynamic_cfg.h" #include "utlist.h" #include "stat_api.h" #include "unix-std.h" #include "libutil/multipattern.h" #include "monitored.h" #include "ref.h" #include "cryptobox.h" #include "ssl_util.h" #include "contrib/libottery/ottery.h" #include "contrib/fastutf8/fastutf8.h" #define ZSTD_STATIC_LINKING_ONLY #include "contrib/zstd/zstd.h" #ifdef HAVE_OPENSSL #include <openssl/rand.h> #include <openssl/err.h> #include <openssl/evp.h> #include <openssl/ssl.h> #include <openssl/conf.h> #endif #ifdef HAVE_LOCALE_H #include <locale.h> #endif #ifdef HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif #include <math.h> #include "blas-config.h" #define DEFAULT_SCORE 10.0 #define DEFAULT_RLIMIT_NOFILE 2048 #define DEFAULT_RLIMIT_MAXCORE 0 #define DEFAULT_MAP_TIMEOUT 60.0 * 5 #define DEFAULT_MAP_FILE_WATCH_MULTIPLIER 1 #define DEFAULT_MIN_WORD 0 #define DEFAULT_MAX_WORD 40 #define DEFAULT_WORDS_DECAY 600 #define DEFAULT_MAX_MESSAGE (50 * 1024 * 1024) #define DEFAULT_MAX_PIC (1 * 1024 * 1024) #define DEFAULT_MAX_SHOTS 100 #define DEFAULT_MAX_SESSIONS 100 #define DEFAULT_MAX_WORKERS 4 /* Timeout for task processing */ #define DEFAULT_TASK_TIMEOUT 8.0 #define DEFAULT_LUA_GC_STEP 200 #define DEFAULT_LUA_GC_PAUSE 200 #define DEFAULT_GC_MAXITERS 0 struct rspamd_ucl_map_cbdata { struct rspamd_config *cfg; GString *buf; }; static gchar * rspamd_ucl_read_cb (gchar * chunk, gint len, struct map_cb_data *data, gboolean final); static void rspamd_ucl_fin_cb (struct map_cb_data *data, void **target); static void rspamd_ucl_dtor_cb (struct map_cb_data *data); guint rspamd_config_log_id = (guint)-1; RSPAMD_CONSTRUCTOR(rspamd_config_log_init) { rspamd_config_log_id = rspamd_logger_add_debug_module("config"); } gboolean rspamd_parse_bind_line (struct rspamd_config *cfg, struct rspamd_worker_conf *cf, const gchar *str) { struct rspamd_worker_bind_conf *cnf; const gchar *fdname; gboolean ret = TRUE; if (str == NULL) { return FALSE; } cnf = g_malloc0 (sizeof (struct rspamd_worker_bind_conf)); cnf->cnt = 1024; cnf->bind_line = g_strdup (str); 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->addrs = g_ptr_array_new_full (1, g_free); 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); } else { msg_err_config ("cannot parse bind line: %s", str); ret = FALSE; } } else { if (rspamd_parse_host_port_priority (str, &cnf->addrs, NULL, &cnf->name, DEFAULT_BIND_PORT, TRUE, NULL) == RSPAMD_PARSE_ADDR_FAIL) { msg_err_config ("cannot parse bind line: %s", str); ret = FALSE; } else { cnf->cnt = cnf->addrs->len; LL_PREPEND (cf->bind_conf, cnf); } } if (!ret) { if (cnf->addrs) { g_ptr_array_free (cnf->addrs, TRUE); } g_free (cnf->name); g_free (cnf); } return ret; } struct rspamd_config * rspamd_config_new (enum rspamd_config_init_flags flags) { struct rspamd_config *cfg; rspamd_mempool_t *pool; pool = rspamd_mempool_new (8 * 1024 * 1024, "cfg", 0); cfg = rspamd_mempool_alloc0 (pool, sizeof (*cfg)); /* Allocate larger pool for cfg */ cfg->cfg_pool = pool; cfg->dns_timeout = 1.0; cfg->dns_retransmits = 5; /* 16 sockets per DNS server */ cfg->dns_io_per_server = 16; /* Add all internal actions to keep compatibility */ for (int i = METRIC_ACTION_REJECT; i < METRIC_ACTION_MAX; i ++) { struct rspamd_action *action; action = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*action)); action->threshold = NAN; action->name = rspamd_mempool_strdup (cfg->cfg_pool, rspamd_action_to_str (i)); action->action_type = i; if (i == METRIC_ACTION_SOFT_REJECT) { action->flags |= RSPAMD_ACTION_NO_THRESHOLD|RSPAMD_ACTION_HAM; } else if (i == METRIC_ACTION_GREYLIST) { action->flags |= RSPAMD_ACTION_THRESHOLD_ONLY|RSPAMD_ACTION_HAM; } else if (i == METRIC_ACTION_NOACTION) { action->flags |= RSPAMD_ACTION_HAM; } HASH_ADD_KEYPTR (hh, cfg->actions, action->name, strlen (action->name), action); } /* Disable timeout */ cfg->pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */OC.L10N.register( "federatedfilesharing", { "Do you want to add the remote share {name} from {owner}@{remote}?" : "Ar norite pridėti nuotolinį viešinį {name} iš {owner}@{remote}?", "Remote share" : "Nuotolinis viešinys", "Remote share password" : "Nuotolinio viešinio slaptažodis", "Cancel" : "Atsisakyti", "Add remote share" : "Pridėti nuotolinį viešinį", "Copy" : "Kopijuoti", "Copied!" : "Nukopijuota!", "Not supported!" : "Nepalaikoma!", "Press ⌘-C to copy." : "Norėdami nukopijuoti, paspauskite ⌘-C.", "Press Ctrl-C to copy." : "Paspauskite Vald-C, norėdami nukopijuoti.", "Invalid Federated Cloud ID" : "Neteisingas federacinės debesijos ID", "Server to server sharing is not enabled on this server" : "Dalinimasis tarp serverių yra neleidžiamas šiame serveryje", "Couldn't establish a federated share." : "Nepavyko užmegzti federacinio viešinio.", "Couldn't establish a federated share, maybe the password was wrong." : "Nepavyko užmegzti federacinio viešinio, galbūt, neteisingas slaptažodis.", "Federated Share request sent, you will receive an invitation. Check your notifications." : "Federacinio viešinio užklausa išsiųsta, jūs gausite pakvietimą. Tikrinkite savo pranešimus.", "Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)." : "Nepavyko užmegzti federacinio viešinio, atrodo, kad serveris su kuriuo ketinama jungtis į federaciją yra per senas (Nextcloud <= 9).", "Not allowed to create a federated share with the same user" : "Negalima sukurti federacinį viešinį su tuo pačiu naudotoju", "File is already shared with %s" : "Failas jau yra bendrinamas su %s", "Could not find share" : "Nepavyko rasti bendrinamų duomenų", "Federated sharing" : "Federacinis bendrinimas", "You received \"%3$s\" as a remote share from %1$s (on behalf of %2$s)" : "Gavote galimybę peržiūrėti duomenis \"%3$s\", kuriuos pasidalino %1$s (%2$s vardu) esantis kitame serveryje", "You received {share} as a remote share from {user} (on behalf of {behalf})" : "Gavote galimybę peržiūrėti duomenis \"{share}\", kuriuos pasidalino {user} ({behalf} vardu) esantis kitame serveryje", "You received \"%3$s\" as a remote share from %1$s" : "Gavote galimybę peržiūrėti duomenis \"%3$s\", kuriuos pasidalino %1$s", "You received {share} as a remote share from {user}" : "Gavote galimybę peržiūrėti duomenis \"{share}\", kuriuos pasidalino {user}", "Accept" : "Priimti", "Decline" : "Atmesti", "Share with me through my #Nextcloud Federated Cloud ID" : "Bendrinti su manimi per mano #Nextcloud federacinės debesijos ID", "Sharing" : "Duomenų bendrinimas", "Federated file sharing" : "Federacinis failų bendrinimas", "Open documentation" : "Atverti dokumentaciją", "Allow users on this server to send shares to other servers" : "Leisti naudotojams šiame serveryje siųsti viešinius į kitus serverius", "Allow users on this server to receive shares from other servers" : "Leisti naudotojams šiame serveryje gauti viešinius iš kitų serverių", "Allow users on this server to send shares to groups on other servers" : "Leisti naudotojams šiame serveryje siųsti viešinius į grupes kituose serveriuose", "Allow users on this server to receive group shares from other servers" : "Leisti naudotojams šiame serveryje gauti grupių viešinius iš kitų serverių", "Federated Cloud" : "Federacinė debesija", "Your Federated Cloud ID:" : "Jūsų federacinės debesijos ID:", "HTML Code:" : "HTML kodas:" }, "nplurals=4; plural=(n % 10 == 1 && (n % 100 > 19 || n % 100 < 11) ? 0 : (n % 10 >= 2 && n % 10 <=9) && (n % 100 > 19 || n % 100 < 11) ? 1 : n % 1 != 0 ? 2: 3);");
OC.L10N.register( "federatedfilesharing", { "Do you want to add the remote share {name} from {owner}@{remote}?" : "Ar norite pridėti nuotolinį viešinį {name} iš {owner}@{remote}?", "Remote share" : "Nuotolinis viešinys", "Remote share password" : "Nuotolinio viešinio slaptažodis", "Cancel" : "Atsisakyti", "Add remote share" : "Pridėti nuotolinį viešinį", "Copy" : "Kopijuoti", "Copied!" : "Nukopijuota!", "Not supported!" : "Nepalaikoma!", "Press ⌘-C to copy." : "Norėdami nukopijuoti, paspauskite ⌘-C.", "Press Ctrl-C to copy." : "Paspauskite Vald-C, norėdami nukopijuoti.", "Invalid Federated Cloud ID" : "Neteisingas federacinės debesijos ID", "Server to server sharing is not enabled on this server" : "Dalinimasis tarp serverių yra neleidžiamas šiame serveryje", "Couldn't establish a federated share." : "Nepavyko užmegzti federacinio viešinio.", "Couldn't establish a federated share, maybe the password was wrong." : "Nepavyko užmegzti federacinio viešinio, galbūt, neteisingas slaptažodis.", "Federated Share request sent, you will receive an invitation. Check your notifications." : "Federacinio viešinio užklausa išsiųsta, jūs gausite pakvietimą. Tikrinkite savo pranešimus.", "Couldn't establish a federated share, it looks like the server to federate with is too old (Nextcloud <= 9)." : "Nepavyko užmegzti federacinio viešinio, atrodo, kad serveris su kuriuo ketinama jungtis į federaciją yra per senas (Nextcloud <= 9).", "Not allowed to create a federated share with the same user" : "Negalima sukurti federacinį viešinį su tuo pačiu naudotoju", "File is already shared with %s" : "Failas jau yra bendrinamas su %s", "Could not find share" : "Nepavyko rasti bendrinamų duomenų", "Federated sharing" : "Federacinis bendrinimas", "You received \"%3$s\" as a remote share from %1$s (on behalf of %2$s)" : "Gavote galimybę peržiūrėti duomenis \"%3$s\", kuriuos pasidalino %1$s (%2$s vardu) esantis kitame serveryje", "You received {share} as a remote share from {user} (on behalf of {behalf})" : "Gavote galimybę peržiūrėti duomenis \"{share}\", kuriuos pasidalino {user} ({behalf} vardu) esantis kitame serveryje", "You received \"%3$s\" as a remote share from %1$s" : "Gavote galimybę peržiūrėti duomenis \"%3$s\", kuriuos pasidalino %1$s", "You received {share} as a remote share from {user}" : "Gavote galimybę peržiūrėti duomenis \"{share}\", kuriuos pasidalino {user}", "Accept" : "Priimti", "Decline" : "Atmesti", "Share with me through my #Nextcloud Federated Cloud ID" : "Bendrinti su manimi per mano #Nextcloud federacinės debesijos ID", "Sharing" : "Duomenų bendrinimas", "Federated file sharing" : "Federacinis failų bendrinimas", "Open documentation" : "Atverti dokumentaciją", "Allow users on this server to send shares to other servers" : "Leisti naudotojams šiame serveryje siųsti viešinius į kitus serverius", "Allow users on this server to receive shares from other servers" : "Leisti naudotojams šiame serveryje gauti viešinius iš kitų serverių", "Allow users on this server to send shares to groups on other servers" : "Leisti naudotojams šiame serveryje siųsti viešinius į grupes kituose serveriuose", "Allow users on this server to receive group shares from other servers" : "Leisti naudotojams šiame serveryje gauti grupių viešinius iš kitų serverių", "Federated Cloud" : "Federacinė debesija", "Your Federated Cloud ID:" : "Jūsų federacinės debesijos ID:", "HTML Code:" : "HTML kodas:" }, "nplurals=4; plural=(n % 10 == 1 && (n % 100 > 19 || n % 100 < 11) ? 0 : (n % 10 >= 2 && n % 10 <=9) && (n % 100 > 19 || n % 100 < 11) ? 1 : n % 1 != 0 ? 2: 3);");