Allow privset-less OPER bursting

This commit is contained in:
Ed Kellett 2021-04-12 10:59:01 +01:00
parent 53b209c748
commit eeaea74616
2 changed files with 35 additions and 20 deletions

View file

@ -622,11 +622,18 @@ burst_TS6(struct Client *client_p)
use_id(target_p),
target_p->user->away);
if(IsOper(target_p) && target_p->user && target_p->user->opername && target_p->user->privset)
sendto_one(client_p, ":%s OPER %s %s",
use_id(target_p),
target_p->user->opername,
target_p->user->privset->name);
if (IsOper(target_p) && target_p->user && target_p->user->opername)
{
if (target_p->user->privset)
sendto_one(client_p, ":%s OPER %s %s",
use_id(target_p),
target_p->user->opername,
target_p->user->privset->name);
else
sendto_one(client_p, ":%s OPER %s",
use_id(target_p),
target_p->user->opername);
}
hclientinfo.target = target_p;
call_hook(h_burst_client, &hclientinfo);

View file

@ -49,7 +49,7 @@ static bool match_oper_password(const char *password, struct oper_conf *oper_p);
struct Message oper_msgtab = {
"OPER", 0, 0, 0, 0,
{mg_unreg, {m_oper, 3}, {mc_oper, 3}, mg_ignore, {me_oper, 2}, {m_oper, 3}}
{mg_unreg, {m_oper, 3}, {mc_oper, 2}, mg_ignore, {me_oper, 2}, {m_oper, 3}}
};
mapi_clist_av1 oper_clist[] = { &oper_msgtab, NULL };
@ -185,23 +185,31 @@ static void
mc_oper(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct PrivilegeSet *privset;
sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPER %s %s", use_id(source_p), parv[1], parv[2]);
privset = privilegeset_get(parv[2]);
if(privset == NULL)
if (parc >= 3)
{
/* if we don't have a matching privset, we'll create an empty one and
* mark it illegal, so it gets picked up on a rehash later */
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Received OPER for %s with unknown privset %s", source_p->name, parv[2]);
privset = privilegeset_set_new(parv[2], "", 0);
privset->status |= CONF_ILLEGAL;
sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPER %s %s", use_id(source_p), parv[1], parv[2]);
privset = privilegeset_get(parv[2]);
if(privset == NULL)
{
/* if we don't have a matching privset, we'll create an empty one and
* mark it illegal, so it gets picked up on a rehash later */
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Received OPER for %s with unknown privset %s", source_p->name, parv[2]);
privset = privilegeset_set_new(parv[2], "", 0);
privset->status |= CONF_ILLEGAL;
}
privset = privilegeset_ref(privset);
if (source_p->user->privset != NULL)
privilegeset_unref(source_p->user->privset);
source_p->user->privset = privset;
}
else
{
sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s OPER %s", use_id(source_p), parv[1]);
}
privset = privilegeset_ref(privset);
if (source_p->user->privset != NULL)
privilegeset_unref(source_p->user->privset);
source_p->user->privset = privset;
rb_free(source_p->user->opername);
source_p->user->opername = rb_strdup(parv[1]);