diff --git a/ircd/newconf.c b/ircd/newconf.c index 62faf427..101942f9 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -768,7 +768,7 @@ conf_end_class(struct TopConf *tc) if(EmptyString(yy_class->class_name)) { - conf_report_error("Ignoring connect block -- missing name."); + conf_report_error("Ignoring class block -- missing name."); return 0; } @@ -1231,40 +1231,51 @@ conf_begin_connect(struct TopConf *tc) static int conf_end_connect(struct TopConf *tc) { - if(EmptyString(yy_server->name)) + if (EmptyString(yy_server->name)) { conf_report_error("Ignoring connect block -- missing name."); return 0; } - if(ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) + if (ServerInfo.name != NULL && !irccmp(ServerInfo.name, yy_server->name)) { - conf_report_error("Ignoring connect block for %s -- name is equal to my own name.", - yy_server->name); + conf_report_error("Ignoring connect block for %s -- name is " + "equal to my own name.", yy_server->name); return 0; } - if((EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) && EmptyString(yy_server->certfp)) + if ((EmptyString(yy_server->passwd) || EmptyString(yy_server->spasswd)) + && EmptyString(yy_server->certfp)) { - conf_report_error("Ignoring connect block for %s -- no fingerprint or password credentials provided.", - yy_server->name); + conf_report_error("Ignoring connect block for %s -- no " + "fingerprint or password credentials " + "provided.", yy_server->name); return 0; } - if((yy_server->flags & SERVER_SSL) && EmptyString(yy_server->certfp)) + if ((yy_server->flags & SERVER_SSL) && EmptyString(yy_server->certfp)) { - conf_report_error("Ignoring connect block for %s -- no fingerprint provided for SSL connection.", - yy_server->name); + conf_report_error("Ignoring connect block for %s -- no " + "fingerprint provided for SSL " + "connection.", yy_server->name); return 0; } - if(EmptyString(yy_server->connect_host) - && GET_SS_FAMILY(&yy_server->connect4) != AF_INET - && GET_SS_FAMILY(&yy_server->connect6) != AF_INET6 - ) + if (! (yy_server->flags & SERVER_SSL) && ! EmptyString(yy_server->certfp)) { - conf_report_error("Ignoring connect block for %s -- missing host.", - yy_server->name); + conf_report_error("Ignoring connect block for %s -- " + "fingerprint authentication has " + "been requested; but the ssl flag " + "is not set.", yy_server->name); + return 0; + } + + if (EmptyString(yy_server->connect_host) + && GET_SS_FAMILY(&yy_server->connect4) != AF_INET + && GET_SS_FAMILY(&yy_server->connect6) != AF_INET6) + { + conf_report_error("Ignoring connect block for %s -- missing " + "host.", yy_server->name); return 0; } @@ -1336,7 +1347,20 @@ conf_set_connect_send_password(void *data) rb_free(yy_server->spasswd); } - yy_server->spasswd = rb_strdup(data); + if (EmptyString((const char *) data)) + { + yy_server->spasswd = NULL; + conf_report_warning("Invalid send_password for connect " + "block; must not be empty if provided"); + } + else if (strpbrk(data, " :")) + { + yy_server->spasswd = NULL; + conf_report_error("Invalid send_password for connect " + "block; cannot contain spaces or colons"); + } + else + yy_server->spasswd = rb_strdup(data); } static void @@ -1347,7 +1371,21 @@ conf_set_connect_accept_password(void *data) memset(yy_server->passwd, 0, strlen(yy_server->passwd)); rb_free(yy_server->passwd); } - yy_server->passwd = rb_strdup(data); + + if (EmptyString((const char *) data)) + { + yy_server->passwd = NULL; + conf_report_warning("Invalid accept_password for connect " + "block; must not be empty if provided"); + } + else if (strpbrk(data, " :")) + { + yy_server->passwd = NULL; + conf_report_error("Invalid accept_password for connect " + "block; cannot contain spaces or colons"); + } + else + yy_server->passwd = rb_strdup(data); } static void diff --git a/modules/core/m_join.c b/modules/core/m_join.c index b155677c..18e9a1ca 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -1041,6 +1041,10 @@ send_join_error(struct Client *source_p, int numeric, const char *name) NORMAL_NUMERIC(ERR_NEEDREGGEDNICK); NORMAL_NUMERIC(ERR_THROTTLE); + case ERR_USERONCHANNEL: + sendto_one_numeric(source_p, ERR_USERONCHANNEL, + form_str(ERR_USERONCHANNEL), source_p->name, name); + break; default: sendto_one_numeric(source_p, numeric, "%s :Cannot join channel", name); diff --git a/modules/m_sasl.c b/modules/m_sasl.c index e4e87435..2b407a10 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -52,14 +52,8 @@ static void me_mechlist(struct MsgBuf *, struct Client *, struct Client *, int, static void abort_sasl(struct Client *); static void abort_sasl_exit(hook_data_client_exit *); -static void advertise_sasl_cap(bool); -static void advertise_sasl_new(struct Client *); -static void advertise_sasl_exit(void *); -static void advertise_sasl_config(void *); - static unsigned int CLICAP_SASL = 0; static char mechlist_buf[BUFSIZE]; -static bool sasl_agent_present = false; struct Message authenticate_msgtab = { "AUTHENTICATE", 0, 0, 0, 0, @@ -80,23 +74,9 @@ mapi_clist_av1 sasl_clist[] = { mapi_hfn_list_av1 sasl_hfnlist[] = { { "new_local_user", (hookfn) abort_sasl }, { "client_exit", (hookfn) abort_sasl_exit }, - { "new_remote_user", (hookfn) advertise_sasl_new }, - { "after_client_exit", (hookfn) advertise_sasl_exit }, - { "conf_read_end", (hookfn) advertise_sasl_config }, { NULL, NULL } }; -static bool -sasl_visible(struct Client *ignored) -{ - struct Client *agent_p = NULL; - - if (ConfigFileEntry.sasl_service) - agent_p = find_named_client(ConfigFileEntry.sasl_service); - - return agent_p != NULL && IsService(agent_p); -} - static const char * sasl_data(struct Client *client_p) { @@ -104,7 +84,6 @@ sasl_data(struct Client *client_p) } static struct ClientCapability capdata_sasl = { - .visible = sasl_visible, .data = sasl_data, .flags = CLICAP_FLAGS_STICKY | CLICAP_FLAGS_PRIORITY, }; @@ -118,19 +97,10 @@ static int _modinit(void) { memset(mechlist_buf, 0, sizeof mechlist_buf); - sasl_agent_present = false; - - advertise_sasl_config(NULL); return 0; } -static void -_moddeinit(void) -{ - advertise_sasl_cap(false); -} - -DECLARE_MODULE_AV2(sasl, _modinit, _moddeinit, sasl_clist, NULL, sasl_hfnlist, sasl_cap_list, NULL, sasl_desc); +DECLARE_MODULE_AV2(sasl, _modinit, NULL, sasl_clist, NULL, sasl_hfnlist, sasl_cap_list, NULL, sasl_desc); static void m_authenticate(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, @@ -366,45 +336,3 @@ abort_sasl_exit(hook_data_client_exit *data) if (data->target->localClient) abort_sasl(data->target); } - -static void -advertise_sasl_cap(bool available) -{ - if (sasl_agent_present != available) { - if (available) { - sendto_local_clients_with_capability(CLICAP_CAP_NOTIFY, ":%s CAP * NEW :sasl", me.name); - } else { - sendto_local_clients_with_capability(CLICAP_CAP_NOTIFY, ":%s CAP * DEL :sasl", me.name); - } - sasl_agent_present = available; - } -} - -static void -advertise_sasl_new(struct Client *client_p) -{ - if (!ConfigFileEntry.sasl_service) - return; - - if (irccmp(client_p->name, ConfigFileEntry.sasl_service)) - return; - - advertise_sasl_cap(IsService(client_p)); -} - -static void -advertise_sasl_exit(void *ignored) -{ - if (!ConfigFileEntry.sasl_service) - return; - - if (sasl_agent_present) { - advertise_sasl_cap(sasl_visible(NULL)); - } -} - -static void -advertise_sasl_config(void *ignored) -{ - advertise_sasl_cap(sasl_visible(NULL)); -}