/* * AUTHENTICATE message * * parv[0]: prefix * parv[1]: data */ static int m_authenticate(aClient *cptr, aClient *sptr, int parc, char *parv[]) { aClient *agent_p = NULL; /* Failing to use CAP REQ for sasl is a protocol violation. */ if (!SASL_SERVER || !MyConnect(sptr) || BadPtr(parv[1]) || !CHECKPROTO(sptr, PROTO_SASL)) return 0; if (sptr->sasl_complete) { sendto_one(sptr, err_str(ERR_SASLALREADY), me.name, BadPtr(sptr->name) ? "*" : sptr->name); return 0; } if ((parv[1][0] == ':') || strchr(parv[1], ' ')) { sendto_one(sptr, err_str(ERR_CANNOTDOCOMMAND), me.name, "*", "AUTHENTICATE", "Invalid parameter"); return 0; } if (strlen(parv[1]) > 400) { sendto_one(sptr, err_str(ERR_SASLTOOLONG), me.name, BadPtr(sptr->name) ? "*" : sptr->name); return 0; } if (*sptr->sasl_agent) agent_p = find_client(sptr->sasl_agent, NULL); if (agent_p == NULL) sendto_serv_butone_token(NULL, me.name, MSG_SASL, TOK_SASL, "%s %s S %s", SASL_SERVER, encode_puid(sptr), parv[1]); else sendto_serv_butone_token(NULL, me.name, MSG_SASL, TOK_SASL, "%s %s C %s", AGENT_SID(agent_p), encode_puid(sptr), parv[1]); sptr->sasl_out++; return 0; }
static int abort_sasl(struct Client *cptr) { if (cptr->sasl_out == 0 || cptr->sasl_complete) return 0; cptr->sasl_out = cptr->sasl_complete = 0; sendto_one(cptr, err_str(ERR_SASLABORTED), me.name, BadPtr(cptr->name) ? "*" : cptr->name); if (*cptr->sasl_agent) { aClient *agent_p = find_client(cptr->sasl_agent, NULL); if (agent_p != NULL) { sendto_serv_butone_token(NULL, me.name, MSG_SASL, TOK_SASL, "%s %s D A", AGENT_SID(agent_p), encode_puid(cptr)); return 0; } } sendto_serv_butone_token(NULL, me.name, MSG_SASL, TOK_SASL, "* %s D A", encode_puid(cptr)); return 0; }
static int abort_sasl(aClient *cptr) { if (cptr->local->sasl_out == 0 || cptr->local->sasl_complete) return 0; cptr->local->sasl_out = cptr->local->sasl_complete = 0; sendto_one(cptr, err_str(ERR_SASLABORTED), me.name, BadPtr(cptr->name) ? "*" : cptr->name); if (*cptr->local->sasl_agent) { aClient *agent_p = find_client(cptr->local->sasl_agent, NULL); if (agent_p != NULL) { sendto_server(NULL, 0, 0, ":%s SASL %s %s D A", me.name, AGENT_SID(agent_p), encode_puid(cptr)); return 0; } } sendto_server(NULL, 0, 0, ":%s SASL * %s D A", me.name, encode_puid(cptr)); return 0; }