X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/3ed61fba8c2b27ce783e79c3309a880f519bc273..1c78029cd4a17c75b0cf8197736493860c46bfd1:/modules/um_callerid.c diff --git a/modules/um_callerid.c b/modules/um_callerid.c index 943b58a9..89743598 100644 --- a/modules/um_callerid.c +++ b/modules/um_callerid.c @@ -80,44 +80,32 @@ um_callerid_moddeinit(void) delete_isupport("CALLERID"); } -#define IsSetCallerID(c) ((c->umodes & user_modes['g']) == user_modes['g']) +#define IsSetStrictCallerID(c) ((c->umodes & user_modes['g']) == user_modes['g']) #define IsSetRelaxedCallerID(c) ((c->umodes & user_modes['G']) == user_modes['G']) +#define IsSetAnyCallerID(c) (IsSetStrictCallerID(c) || IsSetRelaxedCallerID(c)) static const char um_callerid_desc[] = "Provides usermodes +g and +G which restrict messages from unauthorized users."; -static bool -has_common_channel(struct Client *source_p, struct Client *target_p) -{ - rb_dlink_node *ptr; - - RB_DLINK_FOREACH(ptr, source_p->user->channel.head) - { - struct membership *msptr = ptr->data; - if (IsMember(target_p, msptr->chptr)) - return true; - } - - return false; -} - static bool allow_message(struct Client *source_p, struct Client *target_p) { if (!MyClient(target_p)) return true; - if (!IsSetCallerID(target_p)) + if (!IsSetAnyCallerID(target_p)) return true; - if (IsSetRelaxedCallerID(target_p) && has_common_channel(source_p, target_p)) + if (!IsPerson(source_p)) return true; - if (IsServer(source_p)) + if (IsSetRelaxedCallerID(target_p) && + !IsSetStrictCallerID(target_p) && + has_common_channel(source_p, target_p)) return true; /* XXX: controversial? allow opers to send through +g */ - if (IsOper(source_p)) + if (MayHavePrivilege(source_p, "oper:message")) return true; if (accept_message(source_p, target_p)) @@ -136,7 +124,7 @@ send_callerid_notice(enum message_type msgtype, struct Client *source_p, struct return; sendto_one_numeric(source_p, ERR_TARGUMODEG, form_str(ERR_TARGUMODEG), - target_p->name); + target_p->name, IsSetStrictCallerID(target_p) ? "+g" : "+G"); if ((target_p->localClient->last_caller_id_time + ConfigFileEntry.caller_id_wait) < rb_current_time()) { @@ -145,7 +133,7 @@ send_callerid_notice(enum message_type msgtype, struct Client *source_p, struct sendto_one(target_p, form_str(RPL_UMODEGMSG), me.name, target_p->name, source_p->name, - source_p->username, source_p->host); + source_p->username, source_p->host, IsSetStrictCallerID(target_p) ? "+g" : "+G"); target_p->localClient->last_caller_id_time = rb_current_time(); } @@ -154,6 +142,10 @@ send_callerid_notice(enum message_type msgtype, struct Client *source_p, struct static bool add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_p, struct Client *target_p) { + /* only do this on source_p's server */ + if (!MyClient(source_p)) + return true; + /* * XXX: Controversial? Allow target users to send replies * through a +g. Rationale is that people can presently use +g @@ -161,9 +153,9 @@ add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_ * as a way of griefing. --nenolod */ if(msgtype != MESSAGE_TYPE_NOTICE && - IsSetCallerID(source_p) && - !accept_message(target_p, source_p) && - !IsOper(target_p)) + IsSetAnyCallerID(source_p) && + !accept_message(target_p, source_p) && + !IsOperGeneral(target_p)) { if(rb_dlink_list_length(&source_p->localClient->allow_list) < (unsigned long)ConfigFileEntry.max_accept) @@ -175,7 +167,7 @@ add_callerid_accept_for_source(enum message_type msgtype, struct Client *source_ { sendto_one_numeric(source_p, ERR_OWNMODE, form_str(ERR_OWNMODE), - target_p->name, "+g"); + target_p->name, IsSetStrictCallerID(target_p) ? "+g" : "+G"); return false; } } @@ -204,7 +196,7 @@ h_hdl_invite(void *vdata) return; snprintf(errorbuf, sizeof errorbuf, form_str(ERR_TARGUMODEG), - target_p->name); + target_p->name, IsSetStrictCallerID(target_p) ? "+g" : "+G"); data->approved = ERR_TARGUMODEG; data->error = errorbuf;