Skip to content

send pseudo MODE for chm_hidden modes on oper_up #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions ircd/s_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,13 @@ void
oper_up(struct Client *source_p, struct oper_conf *oper_p)
{
unsigned int old = source_p->umodes, oldsnomask = source_p->snomask;
unsigned int i = 0;
rb_dlink_node *ptr;
struct membership *mscptr;
struct Channel *chptr;
unsigned char cmodes_hidden[256], cmodes_send[256];
unsigned char *cmode_ptr = cmodes_hidden;

hook_data_umode_changed hdata;

SetOper(source_p);
Expand Down Expand Up @@ -1469,6 +1476,30 @@ oper_up(struct Client *source_p, struct oper_conf *oper_p)
send_umode_out(source_p, source_p, old);
sendto_one_numeric(source_p, RPL_SNOMASK, form_str(RPL_SNOMASK),
construct_snobuf(source_p->snomask));

if (HasPrivilege(source_p, "auspex:cmodes"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't oper_up when your privset changes, so I think this is the wrong place to do anything that checks privs. Currently the best place is probably user_mode, hacky though it is, since we arrange to call it every time privs change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't it also get called for other stuff? how are we meant to know when /mode mynick isn't supposed to send out these MODEs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can :(

Maybe it's time to bite the bullet and add a standard mechanism for all privilege changes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this involve

{
for (i = 0; i < 256; i++)
if (chmode_table[i].set_func == chm_hidden)
*cmode_ptr++ = i;
*cmode_ptr = '\0';

RB_DLINK_FOREACH(ptr, source_p->user->channel.head)
{
mscptr = ptr->data;
chptr = mscptr->chptr;
cmode_ptr = cmodes_send;

for (i = 0; cmodes_hidden[i] != '\0'; i++)
if (chptr->mode.mode & chmode_flags[cmodes_hidden[i]])
*cmode_ptr++ = cmodes_hidden[i];
*cmode_ptr = '\0';

if (cmodes_send[0] != '\0')
sendto_one(source_p, ":%s MODE %s +%s", me.name, chptr->chname, cmodes_send);
}
}

sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
sendto_one_notice(source_p, ":*** Oper privilege set is %s", oper_p->privset->name);
sendto_one_notice(source_p, ":*** Oper privs are %s", oper_p->privset->privs);
Expand Down