else
u1 = NULL;
- /*
- * following block for the benefit of time-dependent K:-lines
- */
+ /* Check ban user { } blocks (K-lines in conf) */
if ((bconf = Find_ban(sptr, NULL, CONF_BAN_USER)))
{
ircstp->is_ref++;
KLINE_ADDRESS);
return exit_client(cptr, cptr, cptr, "You are banned");
}
+ /* Check ban realname { } blocks */
if ((bconf = Find_ban(NULL, sptr->info, CONF_BAN_REALNAME)))
{
ircstp->is_ref++;
return exit_client(cptr, sptr, &me,
"Your GECOS (real name) is banned from this server");
}
+ /* Check require sasl { } blocks */
+ if (!IsLoggedIn(sptr) && (bconf = Find_ban(sptr, NULL, CONF_BAN_UNAUTHENTICATED)))
+ {
+ ircstp->is_ref++;
+ sendto_one(cptr,
+ ":%s %d %s :*** You are not welcome on this server (%s)"
+ " Email %s for more information.",
+ me.name, ERR_YOUREBANNEDCREEP,
+ cptr->name, bconf->reason ? bconf->reason : "",
+ KLINE_ADDRESS);
+ return exit_client(cptr, cptr, cptr, "You are banned");
+ }
tkl_check_expire(NULL);
/* Check G/Z lines before shuns -- kill before quite -- codemastr */
if ((xx = find_tkline_match(sptr, 0)) < 0)
static int _conf_deny_link (ConfigFile *conf, ConfigEntry *ce);
static int _conf_deny_channel (ConfigFile *conf, ConfigEntry *ce);
static int _conf_deny_version (ConfigFile *conf, ConfigEntry *ce);
+static int _conf_require (ConfigFile *conf, ConfigEntry *ce);
+static int _conf_require_sasl (ConfigFile *conf, ConfigEntry *ce);
static int _conf_allow_channel (ConfigFile *conf, ConfigEntry *ce);
static int _conf_allow_dcc (ConfigFile *conf, ConfigEntry *ce);
static int _conf_loadmodule (ConfigFile *conf, ConfigEntry *ce);
static int _test_vhost (ConfigFile *conf, ConfigEntry *ce);
static int _test_link (ConfigFile *conf, ConfigEntry *ce);
static int _test_ban (ConfigFile *conf, ConfigEntry *ce);
+static int _test_require (ConfigFile *conf, ConfigEntry *ce);
static int _test_set (ConfigFile *conf, ConfigEntry *ce);
static int _test_deny (ConfigFile *conf, ConfigEntry *ce);
static int _test_allow_channel (ConfigFile *conf, ConfigEntry *ce);
{ "official-channels", _conf_offchans, _test_offchans },
{ "oper", _conf_oper, _test_oper },
{ "operclass", _conf_operclass, _test_operclass },
+ { "require", _conf_require, _test_require },
{ "set", _conf_set, _test_set },
{ "sni", _conf_sni, _test_sni },
{ "spamfilter", _conf_spamfilter, _test_spamfilter },
return errors;
}
+int _conf_require(ConfigFile *conf, ConfigEntry *ce)
+{
+ ConfigEntry *cep;
+ ConfigItem_ban *ca;
+ Hook *h;
+
+ ca = MyMallocEx(sizeof(ConfigItem_ban));
+ if (!strcmp(ce->ce_vardata, "sasl"))
+ {
+ ca->flag.type = CONF_BAN_UNAUTHENTICATED;
+ }
+ else {
+ int value;
+ free(ca); /* ca isn't used, modules have their own list. */
+ for (h = Hooks[HOOKTYPE_CONFIGRUN]; h; h = h->next)
+ {
+ value = (*(h->func.intfunc))(conf,ce,CONFIG_REQUIRE);
+ if (value == 1)
+ break;
+ }
+ return 0;
+ }
+ for (cep = ce->ce_entries; cep; cep = cep->ce_next)
+ {
+ if (!strcmp(cep->ce_varname, "mask"))
+ {
+ ca->mask = strdup(cep->ce_vardata);
+ }
+ else if (!strcmp(cep->ce_varname, "reason"))
+ ca->reason = strdup(cep->ce_vardata);
+ else if (!strcmp(cep->ce_varname, "action"))
+ ca ->action = banact_stringtoval(cep->ce_vardata);
+ }
+ AddListItem(ca, conf_ban);
+ return 0;
+}
+
+int _test_require(ConfigFile *conf, ConfigEntry *ce)
+{
+ ConfigEntry *cep;
+ int errors = 0;
+ Hook *h;
+ char type = 0;
+ char has_mask = 0, has_action = 0, has_reason = 0;
+
+ if (!ce->ce_vardata)
+ {
+ config_error("%s:%i: require without type, did you mean 'require sasl'?",
+ ce->ce_fileptr->cf_filename, ce->ce_varlinenum);
+ return 1;
+ }
+ if (!strcmp(ce->ce_vardata, "sasl"))
+ {}
+ else
+ {
+ int used = 0;
+ for (h = Hooks[HOOKTYPE_CONFIGTEST]; h; h = h->next)
+ {
+ int value, errs = 0;
+ if (h->owner && !(h->owner->flags & MODFLAG_TESTING)
+ && !(h->owner->options & MOD_OPT_PERM))
+ continue;
+ value = (*(h->func.intfunc))(conf,ce,CONFIG_REQUIRE, &errs);
+ if (value == 2)
+ used = 1;
+ if (value == 1)
+ {
+ used = 1;
+ break;
+ }
+ if (value == -1)
+ {
+ used = 1;
+ errors += errs;
+ break;
+ }
+ if (value == -2)
+ {
+ used = 1;
+ errors += errs;
+ }
+ }
+ if (!used) {
+ config_error("%s:%i: unknown require type '%s'",
+ ce->ce_fileptr->cf_filename, ce->ce_varlinenum,
+ ce->ce_vardata);
+ return 1;
+ }
+ return errors;
+ }
+
+ for (cep = ce->ce_entries; cep; cep = cep->ce_next)
+ {
+ if (config_is_blankorempty(cep, "require"))
+ {
+ errors++;
+ continue;
+ }
+ if (!strcmp(cep->ce_varname, "mask"))
+ {
+ if (has_mask)
+ {
+ config_warn_duplicate(cep->ce_fileptr->cf_filename,
+ cep->ce_varlinenum, "require::mask");
+ continue;
+ }
+ has_mask = 1;
+ }
+ else if (!strcmp(cep->ce_varname, "reason"))
+ {
+ if (has_reason)
+ {
+ config_warn_duplicate(cep->ce_fileptr->cf_filename,
+ cep->ce_varlinenum, "require::reason");
+ continue;
+ }
+ has_reason = 1;
+ }
+ }
+
+ if (!has_mask)
+ {
+ config_error_missing(ce->ce_fileptr->cf_filename, ce->ce_varlinenum,
+ "require::mask");
+ errors++;
+ }
+ if (!has_reason)
+ {
+ config_error_missing(ce->ce_fileptr->cf_filename, ce->ce_varlinenum,
+ "require::reason");
+ errors++;
+ }
+ return errors;
+}
+
#define CheckNull(x) if ((!(x)->ce_vardata) || (!(*((x)->ce_vardata)))) { config_error("%s:%i: missing parameter", (x)->ce_fileptr->cf_filename, (x)->ce_varlinenum); errors++; continue; }
#define CheckNullAllowEmpty(x) if ((!(x)->ce_vardata)) { config_error("%s:%i: missing parameter", (x)->ce_fileptr->cf_filename, (x)->ce_varlinenum); errors++; continue; }
#define CheckDuplicate(cep, name, display) if (settings.has_##name) { config_warn_duplicate((cep)->ce_fileptr->cf_filename, cep->ce_varlinenum, "set::" display); continue; } else settings.has_##name = 1