diff --git a/include/h.h b/include/h.h index 206c87ac1..ca6fcbcbb 100644 --- a/include/h.h +++ b/include/h.h @@ -233,7 +233,7 @@ extern int verify_hostname(char *name); extern void report_error(char *, Client *); extern int setup_ping(); -extern void set_channel_mlock(Client *, Client *, Channel *, const char *, int); +extern void set_channel_mlock(Client *, Channel *, const char *, int); extern void restart(char *); extern void server_reboot(char *); @@ -297,8 +297,7 @@ extern char *make_nick_user_host(char *, char *, char *); extern char *make_nick_user_host_r(char *namebuf, char *nick, char *name, char *host); extern char *make_user_host(char *, char *); extern int parse(Client *cptr, char *buffer, int length); -extern int do_numeric(int, Client *, Client *, MessageTag *, int, char **); -extern int hunt_server(Client *, Client *, MessageTag *, char *, int, int, char **); +extern int hunt_server(Client *, MessageTag *, char *, int, int, char **); extern int cmd_server_estab(Client *); extern void umode_init(void); #define UMODE_GLOBAL 1 @@ -308,8 +307,8 @@ extern int umode_allow_unset(Client *sptr, int what); extern int umode_allow_opers(Client *sptr, int what); extern int umode_allow_none(Client *sptr, int what); extern int umode_delete(char ch, long val); -extern void send_umode(Client *, Client *, long, long, char *); -extern void send_umode_out(Client *, Client *, long); +extern void build_umode_string(Client *sptr, long old, long sendmask, char *umode_buf); +extern void send_umode_out(Client *sptr, int show_to_user, long old); extern void free_client(Client *); extern void free_link(Link *); @@ -466,7 +465,7 @@ extern void report_dynconf(Client *sptr); extern void count_memory(Client *cptr, char *nick); extern void list_scache(Client *sptr); extern char *oflagstr(long oflag); -extern int rehash(Client *cptr, Client *sptr, int sig); +extern int rehash(Client *sptr, int sig); extern int match_simple(const char *mask, const char *name); extern int match_esc(const char *mask, const char *name); extern int add_listener(ConfigItem_listen *conf); @@ -655,7 +654,7 @@ extern void efunctions_switchover(void); extern char *encode_ip(char *); extern char *decode_ip(char *); extern void sendto_fconnectnotice(Client *sptr, int disconnect, char *comment); -extern void sendto_one_nickcmd(Client *cptr, Client *sptr, char *umodes); +extern void sendto_one_nickcmd(Client *server, Client *client, char *umodes) extern int on_dccallow_list(Client *to, Client *from); extern int add_dccallow(Client *sptr, Client *optr); extern int del_dccallow(Client *sptr, Client *optr); @@ -665,20 +664,20 @@ extern void del_async_connects(void); extern void isupport_init(void); extern void clicap_init(void); extern void efunctions_init(void); -extern int do_cmd(Client *cptr, Client *sptr, MessageTag *mtags, char *cmd, int parc, char *parv[]); +extern int do_cmd(Client *sptr, MessageTag *mtags, char *cmd, int parc, char *parv[]); extern MODVAR char *me_hash; extern MODVAR int dontspread; extern MODVAR int labeled_response_inhibit; /* Efuncs */ -extern MODVAR int (*do_join)(Client *, Client *, int, char **); -extern MODVAR void (*join_channel)(Channel *chptr, Client *cptr, Client *sptr, MessageTag *mtags, int flags); -extern MODVAR int (*can_join)(Client *cptr, Client *sptr, Channel *chptr, char *key, char *parv[]); -extern MODVAR void (*do_mode)(Channel *chptr, Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[], time_t sendts, int samode); +extern MODVAR int (*do_join)(Client *, int, char **); +extern MODVAR void (*join_channel)(Channel *chptr, Client *sptr, MessageTag *mtags, int flags); +extern MODVAR int (*can_join)(Client *sptr, Channel *chptr, char *key, char *parv[]); +extern MODVAR void (*do_mode)(Channel *chptr, Client *sptr, MessageTag *mtags, int parc, char *parv[], time_t sendts, int samode); extern MODVAR void (*set_mode)(Channel *chptr, Client *cptr, int parc, char *parv[], u_int *pcount, char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], int bounce); -extern MODVAR int (*cmd_umode)(Client *, Client *, MessageTag *, int, char **); -extern MODVAR int (*register_user)(Client *cptr, Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip); +extern MODVAR int (*cmd_umode)(Client *, MessageTag *, int, char **); +extern MODVAR int (*register_user)(Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip); extern MODVAR int (*tkl_hash)(unsigned int c); extern MODVAR char (*tkl_typetochar)(int type); extern MODVAR int (*tkl_chartotype)(char c); @@ -709,7 +708,7 @@ extern MODVAR TKL *(*find_qline)(Client *cptr, char *nick, int *ishold); extern MODVAR TKL *(*find_tkline_match_zap)(Client *cptr); extern MODVAR void (*tkl_stats)(Client *cptr, int type, char *para); extern MODVAR void (*tkl_synch)(Client *sptr); -extern MODVAR int (*cmd_tkl)(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]); +extern MODVAR int (*cmd_tkl)(Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]); extern MODVAR int (*place_host_ban)(Client *sptr, BanAction action, char *reason, long duration); extern MODVAR int (*run_spamfilter)(Client *sptr, char *str_in, int type, char *target, int flags, TKL **rettk); extern MODVAR int (*join_viruschan)(Client *sptr, TKL *tk, int type); @@ -717,7 +716,7 @@ extern MODVAR unsigned char *(*StripColors)(unsigned char *text); extern MODVAR const char *(*StripControlCodes)(unsigned char *text); extern MODVAR void (*spamfilter_build_user_string)(char *buf, char *nick, Client *acptr); extern MODVAR void (*send_protoctl_servers)(Client *sptr, int response); -extern MODVAR int (*verify_link)(Client *cptr, Client *sptr, char *servername, ConfigItem_link **link_out); +extern MODVAR int (*verify_link)(Client *sptr, char *servername, ConfigItem_link **link_out); extern MODVAR void (*send_server_message)(Client *sptr); extern MODVAR void (*broadcast_md_client)(ModDataInfo *mdi, Client *acptr, ModData *md); extern MODVAR void (*broadcast_md_channel)(ModDataInfo *mdi, Channel *chptr, ModData *md); @@ -860,7 +859,7 @@ extern CMD_FUNC(cmd_module); extern CMD_FUNC(cmd_rehash); extern CMD_FUNC(cmd_die); extern CMD_FUNC(cmd_restart); -extern int cmd_alias(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], char *cmd); /* special! */ +extern int cmd_alias(Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], char *cmd); /* special! */ extern int ban_flooder(Client *cptr); extern char *pcre2_version(void); extern int has_common_channels(Client *c1, Client *c2); diff --git a/include/modules.h b/include/modules.h index bdf942ac5..87123fe55 100644 --- a/include/modules.h +++ b/include/modules.h @@ -803,7 +803,7 @@ extern int CommandExists(char *name); extern CommandOverride *CommandOverrideAdd(Module *module, char *cmd, OverrideCmdFunc func); extern CommandOverride *CommandOverrideAddEx(Module *module, char *name, int priority, OverrideCmdFunc func); extern void CommandOverrideDel(CommandOverride *ovr); -extern int CallCommandOverride(CommandOverride *ovr, Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); +extern int CallCommandOverride(CommandOverride *ovr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); extern void moddata_free_client(Client *acptr); extern void moddata_free_local_client(Client *acptr); @@ -954,30 +954,30 @@ int hooktype_unkuser_quit(Client *sptr, MessageTag *mtags, char *comment); int hooktype_pre_local_connect(Client *sptr); int hooktype_server_quit(Client *sptr, MessageTag *mtags); int hooktype_local_nickchange(Client *sptr, char *newnick); -int hooktype_remote_nickchange(Client *cptr, Client *sptr, char *newnick); +int hooktype_remote_nickchange(Client *sptr, char *newnick); int hooktype_can_join(Client *sptr, Channel *chptr, char *key, char *parv[]); int hooktype_pre_local_join(Client *sptr, Channel *chptr, char *parv[]); -int hooktype_local_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); -int hooktype_remote_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); +int hooktype_local_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); +int hooktype_remote_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); char *hooktype_pre_local_part(Client *sptr, Channel *chptr, char *comment); -int hooktype_local_part(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); -int hooktype_remote_part(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); +int hooktype_local_part(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); +int hooktype_remote_part(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); char *hooktype_pre_local_kick(Client *sptr, Client *victim, Channel *chptr, char *comment); int hooktype_can_kick(Client *sptr, Client *victim, Channel *chptr, char *comment, long sptr_flags, long victim_flags, char **error); -int hooktype_local_kick(Client *cptr, Client *sptr, Client *victim, Channel *chptr, MessageTag *mtags, char *comment); -int hooktype_remote_kick(Client *cptr, Client *sptr, Client *victim, Channel *chptr, MessageTag *mtags, char *comment); +int hooktype_local_kick(Client *sptr, Client *victim, Channel *chptr, MessageTag *mtags, char *comment); +int hooktype_remote_kick(Client *sptr, Client *victim, Channel *chptr, MessageTag *mtags, char *comment); char *hooktype_pre_usermsg(Client *sptr, Client *to, char *text, int notice); int hooktype_usermsg(Client *sptr, Client *to, MessageTag *mtags, char *text, int notice); int hooktype_can_send(Client *sptr, Channel *chptr, Membership *member, char **text, char **errmsg, int notice); char *hooktype_pre_chanmsg(Client *sptr, Channel *chptr, MessageTag *mtags, char *text, int notice); int hooktype_chanmsg(Client *sptr, Channel *chptr, int sendflags, int prefix, char *target, MessageTag *mtags, char *text, int notice); -char *hooktype_pre_local_topic(Client *cptr, Client *sptr, Channel *chptr, char *topic); -int hooktype_local_topic(Client *cptr, Client *sptr, Channel *chptr, char *topic); -int hooktype_topic(Client *cptr, Client *sptr, Channel *chptr, char *topic); -int hooktype_pre_local_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); -int hooktype_pre_remote_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); -int hooktype_local_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); -int hooktype_remote_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); +char *hooktype_pre_local_topic(Client *sptr, Channel *chptr, char *topic); +int hooktype_local_topic(Client *sptr, Channel *chptr, char *topic); +int hooktype_topic(Client *sptr, Channel *chptr, char *topic); +int hooktype_pre_local_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); +int hooktype_pre_remote_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); +int hooktype_local_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); +int hooktype_remote_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); int hooktype_modechar_del(Channel *chptr, int modechar); int hooktype_modechar_add(Channel *chptr, int modechar); int hooktype_away(Client *sptr, MessageTag *mtags, char *reason); @@ -989,7 +989,7 @@ int hooktype_whois(Client *sptr, Client *target); int hooktype_who_status(Client *sptr, Client *target, Channel *chptr, Member *member, char *status, int cansee); int hooktype_pre_kill(Client *sptr, Client *victim, char *killpath); int hooktype_local_kill(Client *sptr, Client *victim, char *comment); -int hooktype_rehashflag(Client *cptr, Client *sptr, char *str); +int hooktype_rehashflag(Client *sptr, char *str); int hooktype_configposttest(int *errors); int hooktype_rehash(void); int hooktype_stats(Client *sptr, char *str); @@ -1003,11 +1003,11 @@ int hooktype_channel_destroy(Channel *chptr, int *should_destroy); int hooktype_tkl_except(Client *cptr, int ban_type); int hooktype_umode_change(Client *sptr, long setflags, long newflags); int hooktype_rehash_complete(void); -int hooktype_tkl_add(Client *cptr, Client *sptr, TKL *tkl); -int hooktype_tkl_del(Client *cptr, Client *sptr, TKL *tkl); +int hooktype_tkl_add(Client *sptr, TKL *tkl); +int hooktype_tkl_del(Client *sptr, TKL *tkl); int hooktype_log(int flags, char *timebuf, char *buf); int hooktype_local_spamfilter(Client *acptr, char *str, char *str_in, int type, char *target, TKL *tkl); -int hooktype_silenced(Client *cptr, Client *sptr, Client *to, int notice); +int hooktype_silenced(Client *sptr, Client *to, int notice); int hooktype_rawpacket_in(Client *sptr, char *readbuf, int *length); int hooktype_local_nickpass(Client *sptr, Client *nickserv); int hooktype_packet(Client *from, Client *to, Client *intended_to, char **msg, int *length); diff --git a/include/struct.h b/include/struct.h index c76c533e4..da7068977 100644 --- a/include/struct.h +++ b/include/struct.h @@ -829,45 +829,13 @@ struct SWhois { * @param recv_mtags Received message tags for this command. * @param parc Parameter count *plus* 1. * @param parv Parameter values. - * @note The use of sptr and cptr often confuse people. The short answer is that in most cases you - * will use 'sptr' (source client pointer) since that is the actual client that you should be - * dealing with. The 'cptr' is the connected client from which the command was received. - * This is best illustrated with an example. Consider the following toplogy: - * - * serverA--serverB--serverC - * | | - * clientA clientC - * - * - * Say, *clientA* sends a message to a channel, the IRC protocol message is - * `PRIVMSG #test :hi`. When *serverA* receives this message and calls the cmd_message() - * command handler, *sptr* will point to clientA, and *cptr* will point to clientA as well. - * - * Now, *serverA* will send the channel message to serverB to deliver it to other clients. - * The IRC protocol message is `:clientA PRIVMSG #test :hi`. When *serverB* receives this - * message and calls the cmd_message() command handler, *sptr* will point to *clientA*, - * but this time *cptr* will point to *serverA* (!!). That is because cptr points to the - * local client on which this message was received, which is *serverA* in this case. - * - * Let's continue this example: *serverB* will send the channel message to *serverC*, - * sending `:clientA PRIVMSG #test :hi`. On *serverC*, when it receives this - * message it will call cmd_message() with *sptr* pointing to *clientA*, and - * *cptr* pointing to *serverB*. It will point *cptr* to *serverB* because *serverB* is - * the directly connected client from which this message was received. - * - * As you can see, **cptr says nothing about which server the client (*sptr*) is on**, - * the only thing it specifies is the *direction* from which the message was received. - * - * In almost all cases you will use *sptr*. It's just that sometimes you need the direction - * as well, such as for sending functions. - * * @note Slightly confusing, but parc will be 2 if 1 parameter was provided. * It is two because parv will still have 2 elements, parv[1] will be your first parameter, * and parv[2] will be NULL. * Note that reading parv[parc] and beyond is OUT OF BOUNDS and will cause a crash. * E.g. parv[3] in the above example is out of bounds. */ -#define CMD_FUNC(x) int (x) (Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]) +#define CMD_FUNC(x) int (x) (Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]) /* @} */ /** Command override function - used by all command override handlers. @@ -884,13 +852,13 @@ struct SWhois { * Note that reading parv[parc] and beyond is OUT OF BOUNDS and will cause a crash. * E.g. parv[3] in the above example. */ -#define CMD_OVERRIDE_FUNC(x) int (x)(CommandOverride *ovr, Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]) +#define CMD_OVERRIDE_FUNC(x) int (x)(CommandOverride *ovr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]) -typedef int (*CmdFunc)(Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); -typedef int (*AliasCmdFunc)(Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[], char *cmd); -typedef int (*OverrideCmdFunc)(CommandOverride *ovr, Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); +typedef int (*CmdFunc)(Client *sptr, MessageTag *mtags, int parc, char *parv[]); +typedef int (*AliasCmdFunc)(Client *sptr, MessageTag *mtags, int parc, char *parv[], char *cmd); +typedef int (*OverrideCmdFunc)(CommandOverride *ovr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); /* tkl: diff --git a/src/aliases.c b/src/aliases.c index 0bdf2d589..49731ddf3 100644 --- a/src/aliases.c +++ b/src/aliases.c @@ -41,7 +41,8 @@ void strrangetok(char *in, char *out, char tok, short first, short last) { /* cmd_alias is a special type of command, it has an extra argument 'cmd'. */ static int recursive_alias = 0; -int cmd_alias(Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[], char *cmd) + +int cmd_alias(Client *sptr, MessageTag *mtags, int parc, char *parv[], char *cmd) { ConfigItem_alias *alias; Client *acptr; diff --git a/src/api-efunctions.c b/src/api-efunctions.c index 447c919cb..69227f16c 100644 --- a/src/api-efunctions.c +++ b/src/api-efunctions.c @@ -34,14 +34,14 @@ static Efunction *Efunctions[MAXEFUNCTIONS]; /* Efunction objects (used for reha static EfunctionsList efunction_table[MAXEFUNCTIONS]; /* Efuncs */ -int (*do_join)(Client *cptr, Client *sptr, int parc, char *parv[]); -void (*join_channel)(Channel *chptr, Client *cptr, Client *sptr, MessageTag *mtags, int flags); -int (*can_join)(Client *cptr, Client *sptr, Channel *chptr, char *key, char *parv[]); -void (*do_mode)(Channel *chptr, Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[], time_t sendts, int samode); +int (*do_join)(Client *sptr, int parc, char *parv[]); +void (*join_channel)(Channel *chptr, Client *sptr, MessageTag *mtags, int flags); +int (*can_join)(Client *sptr, Channel *chptr, char *key, char *parv[]); +void (*do_mode)(Channel *chptr, Client *sptr, MessageTag *mtags, int parc, char *parv[], time_t sendts, int samode); void (*set_mode)(Channel *chptr, Client *cptr, int parc, char *parv[], u_int *pcount, char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], int bounce); -int (*cmd_umode)(Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); -int (*register_user)(Client *cptr, Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip); +int (*cmd_umode)(Client *sptr, MessageTag *mtags, int parc, char *parv[]); +int (*register_user)(Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip); int (*tkl_hash)(unsigned int c); char (*tkl_typetochar)(int type); int (*tkl_chartotype)(char c); @@ -65,7 +65,7 @@ TKL *(*find_qline)(Client *cptr, char *nick, int *ishold); TKL *(*find_tkline_match_zap)(Client *cptr); void (*tkl_stats)(Client *cptr, int type, char *para); void (*tkl_synch)(Client *sptr); -int (*cmd_tkl)(Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[]); +int (*cmd_tkl)(Client *sptr, MessageTag *mtags, int parc, char *parv[]); int (*place_host_ban)(Client *sptr, BanAction action, char *reason, long duration); int (*run_spamfilter)(Client *sptr, char *str_in, int type, char *target, int flags, TKL **rettk); int (*join_viruschan)(Client *sptr, TKL *tk, int type); @@ -73,7 +73,7 @@ unsigned char *(*StripColors)(unsigned char *text); const char *(*StripControlCodes)(unsigned char *text); void (*spamfilter_build_user_string)(char *buf, char *nick, Client *acptr); void (*send_protoctl_servers)(Client *sptr, int response); -int (*verify_link)(Client *cptr, Client *sptr, char *servername, ConfigItem_link **link_out); +int (*verify_link)(Client *sptr, char *servername, ConfigItem_link **link_out); void (*introduce_user)(Client *to, Client *acptr); void (*send_server_message)(Client *sptr); void (*broadcast_md_client)(ModDataInfo *mdi, Client *acptr, ModData *md); diff --git a/src/api-usermode.c b/src/api-usermode.c index 459410d3a..ce8c0398f 100644 --- a/src/api-usermode.c +++ b/src/api-usermode.c @@ -234,7 +234,7 @@ void UmodeDel(Umode *umode) oldumode = cptr->umodes; cptr->umodes &= ~umode->mode; if (MyUser(cptr)) - send_umode_out(cptr, cptr, oldumode); + send_umode_out(cptr, 1, oldumode); } umode->flag = '\0'; AllUmodes &= ~(umode->mode); @@ -398,7 +398,7 @@ void unload_all_unused_umodes(void) oldumode = cptr->umodes; cptr->umodes &= ~(removed_umode); if (MyUser(cptr)) - send_umode_out(cptr, cptr, oldumode); + send_umode_out(cptr, 1, oldumode); } for (i = 0; i < UMODETABLESZ; i++) { @@ -477,7 +477,7 @@ void remove_oper_privileges(Client *sptr, int broadcast_mode_change) remove_oper_modes(sptr); remove_oper_snomasks(sptr); if (broadcast_mode_change && (sptr->umodes != oldumodes)) - send_umode_out(sptr, sptr, oldumodes); + send_umode_out(sptr, 1, oldumodes); if (MyUser(sptr)) /* only do if it's our client, remote servers will send a SWHOIS cmd */ swhois_delete(sptr, "oper", "*", &me, NULL); } diff --git a/src/channel.c b/src/channel.c index 21497aace..0a5bf771f 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1157,14 +1157,14 @@ void send_user_joins(Client *cptr, Client *user) * output - * side effects - channel mlock is changed / MLOCK is propagated */ -void set_channel_mlock(Client *cptr, Client *sptr, Channel *chptr, const char *newmlock, int propagate) +void set_channel_mlock(Client *sptr, Channel *chptr, const char *newmlock, int propagate) { safe_strdup(chptr->mode_lock, newmlock); if (propagate) { - sendto_server(cptr, 0, 0, NULL, ":%s MLOCK %lld %s :%s", - cptr->name, (long long)chptr->creationtime, chptr->chname, + sendto_server(sptr, 0, 0, NULL, ":%s MLOCK %lld %s :%s", + sptr->name, (long long)chptr->creationtime, chptr->chname, BadPtr(chptr->mode_lock) ? "" : chptr->mode_lock); } } diff --git a/src/conf.c b/src/conf.c index 662d4b5f7..0d8ce2717 100644 --- a/src/conf.c +++ b/src/conf.c @@ -283,7 +283,7 @@ int remote_include(ConfigEntry *ce); void unload_notloaded_includes(void); void load_includes(void); void unload_loaded_includes(void); -int rehash_internal(Client *cptr, Client *sptr, int sig); +int rehash_internal(Client *sptr, int sig); int is_blacklisted_module(char *name); /** Return the printable string of a 'cep' location, such as set::something::xyz */ @@ -9954,11 +9954,11 @@ static void conf_download_complete(const char *url, const char *file, const char if (inc->flag.type & INCLUDE_DLQUEUED) return; } - rehash_internal(loop.rehash_save_cptr, loop.rehash_save_sptr, loop.rehash_save_sig); + rehash_internal(loop.rehash_save_sptr, loop.rehash_save_sig); } #endif -int rehash(Client *cptr, Client *sptr, int sig) +int rehash(Client *sptr, int sig) { #ifdef USE_LIBCURL ConfigItem_include *inc; @@ -9971,7 +9971,6 @@ int rehash(Client *cptr, Client *sptr, int sig) } loop.ircd_rehashing = 1; - loop.rehash_save_cptr = cptr; loop.rehash_save_sptr = sptr; loop.rehash_save_sig = sig; for (inc = conf_include; inc; inc = inc->next) @@ -9993,15 +9992,15 @@ int rehash(Client *cptr, Client *sptr, int sig) download_file_async(inc->url, modtime, conf_download_complete, (void *)inc); } if (!found_remote) - return rehash_internal(cptr, sptr, sig); + return rehash_internal(sptr, sig); return 0; #else loop.ircd_rehashing = 1; - return rehash_internal(cptr, sptr, sig); + return rehash_internal(sptr, sig); #endif } -int rehash_internal(Client *cptr, Client *sptr, int sig) +int rehash_internal(Client *sptr, int sig) { if (sig == 1) sendto_ops("Got signal SIGHUP, reloading %s file", configfile); diff --git a/src/ircd.c b/src/ircd.c index 461706b7f..013635eea 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1422,7 +1422,7 @@ void SocketLoop(void *dummy) */ if (dorehash) { - (void)rehash(&me, &me, 1); + (void)rehash(&me, 1); dorehash = 0; } if (dorestart) diff --git a/src/modules.c b/src/modules.c index 478f3d2c5..35e01264e 100644 --- a/src/modules.c +++ b/src/modules.c @@ -794,10 +794,10 @@ CMD_FUNC(cmd_module) if (MyUser(sptr) && !IsOper(sptr) && all) sptr->local->since += 7; /* Lag them up. Big list. */ - if ((parc > 2) && (hunt_server(cptr, sptr, recv_mtags, ":%s MODULE %s :%s", 2, parc, parv) != HUNTED_ISME)) + if ((parc > 2) && (hunt_server(sptr, recv_mtags, ":%s MODULE %s :%s", 2, parc, parv) != HUNTED_ISME)) return 0; - if ((parc == 2) && (parv[1][0] != '-') && (hunt_server(cptr, sptr, recv_mtags, ":%s MODULE :%s", 1, parc, parv) != HUNTED_ISME)) + if ((parc == 2) && (parv[1][0] != '-') && (hunt_server(sptr, recv_mtags, ":%s MODULE :%s", 1, parc, parv) != HUNTED_ISME)) return 0; if (all) @@ -1162,11 +1162,11 @@ void CommandOverrideDel(CommandOverride *cmd) safe_free(cmd); } -int CallCommandOverride(CommandOverride *ovr, Client *cptr, Client *sptr, MessageTag *mtags, int parc, char *parv[]) +int CallCommandOverride(CommandOverride *ovr, Client *sptr, MessageTag *mtags, int parc, char *parv[]) { if (ovr->next) - return ovr->next->func(ovr->next, cptr, sptr, mtags, parc, parv); - return ovr->command->func(cptr, sptr, mtags, parc, parv); + return ovr->next->func(ovr->next, sptr, mtags, parc, parv); + return ovr->command->func(sptr, mtags, parc, parv); } EVENT(e_unload_module_delayed) diff --git a/src/modules/admin.c b/src/modules/admin.c index e9e567f49..7a922b72d 100644 --- a/src/modules/admin.c +++ b/src/modules/admin.c @@ -37,7 +37,7 @@ ModuleHeader MOD_HEADER MOD_INIT() { - CommandAdd(modinfo->handle, MSG_ADMIN, cmd_admin, MAXPARA, CMD_UNREGISTERED|CMD_USER|CMD_SHUN|CMD_VIRUS); + CommandAdd(modinfo->handle, MSG_ADMIN, cmd_admin, MAXPARA, CMD_USER|CMD_SHUN|CMD_VIRUS); MARK_AS_OFFICIAL_MODULE(modinfo); return MOD_SUCCESS; } @@ -52,19 +52,18 @@ MOD_UNLOAD() return MOD_SUCCESS; } -/* -** cmd_admin -** parv[1] = servername -*/ +/** ADMIN [servername]. + * Shows administrative information about this server to users. + */ CMD_FUNC(cmd_admin) { ConfigItem_admin *admin; - /* Users may want to get the address in case k-lined, etc. -- Barubary - * Only allow remote ADMINs if registered -- Barubary */ - if (IsUser(sptr) || IsServer(cptr)) - if (hunt_server(cptr, sptr, recv_mtags, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) + if (IsUser(sptr)) + { + if (hunt_server(sptr, recv_mtags, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME) return 0; + } if (!conf_admin_tail) { diff --git a/src/modules/antimixedutf8.c b/src/modules/antimixedutf8.c index b26bc53c5..82544c640 100644 --- a/src/modules/antimixedutf8.c +++ b/src/modules/antimixedutf8.c @@ -177,7 +177,7 @@ CMD_OVERRIDE_FUNC(override_msg) if (!MyUser(sptr) || (parc < 3) || BadPtr(parv[2])) { /* Short circuit for: remote clients or insufficient parameters */ - return CallCommandOverride(ovr, cptr, sptr, recv_mtags, parc, parv); + return CallCommandOverride(ovr, sptr, recv_mtags, parc, parv); } score = lookalikespam_score(StripControlCodes(parv[2])); @@ -202,7 +202,7 @@ CMD_OVERRIDE_FUNC(override_msg) } } - return CallCommandOverride(ovr, cptr, sptr, recv_mtags, parc, parv); + return CallCommandOverride(ovr, sptr, recv_mtags, parc, parv); } /*** rest is module and config stuff ****/ diff --git a/src/modules/authprompt.c b/src/modules/authprompt.c index 123b4491d..80fba61ca 100644 --- a/src/modules/authprompt.c +++ b/src/modules/authprompt.c @@ -515,7 +515,7 @@ int authprompt_sasl_result(Client *sptr, int success) /* Authentication was a success */ if (*sptr->name && sptr->user && *sptr->user->username && IsNotSpoof(sptr)) { - register_user(sptr, sptr, sptr->name, sptr->user->username, NULL, NULL, NULL); + register_user(sptr, sptr->name, sptr->user->username, NULL, NULL, NULL); /* NOTE: register_user() may return FLUSH_BUFFER here, but since the caller * won't continue processing (won't touch 'sptr') it's safe. * That is, as long as we 'return 1'. diff --git a/src/modules/away.c b/src/modules/away.c index bb2c67485..0cd9497af 100644 --- a/src/modules/away.c +++ b/src/modules/away.c @@ -53,21 +53,8 @@ MOD_UNLOAD() { return MOD_SUCCESS; } -/*********************************************************************** - * cmd_away() - Added 14 Dec 1988 by jto. - * Not currently really working, I don't like this - * call at all... - * - * ...trying to make it work. I don't like it either, - * but perhaps it's worth the load it causes to net. - * This requires flooding of the whole net like NICK, - * USER, MODE, etc messages... --msa - ***********************************************************************/ -/* -** cmd_away -** parv[1] = away message -*/ +/** Mark client as AWAY or mark them as back (in case of empty reason) */ CMD_FUNC(cmd_away) { char *new_reason = parv[1]; @@ -85,8 +72,8 @@ CMD_FUNC(cmd_away) safe_free(sptr->user->away); new_message(sptr, recv_mtags, &mtags); - sendto_server(cptr, 0, 0, mtags, ":%s AWAY", sptr->name); - hash_check_watch(cptr, RPL_NOTAWAY); + sendto_server(sptr, 0, 0, mtags, ":%s AWAY", sptr->name); + hash_check_watch(sptr, RPL_NOTAWAY); sendto_local_common_channels(sptr, sptr, ClientCapabilityBit("away-notify"), mtags, ":%s AWAY", sptr->name); RunHook3(HOOKTYPE_AWAY, sptr, mtags, NULL); @@ -137,7 +124,7 @@ CMD_FUNC(cmd_away) new_message(sptr, recv_mtags, &mtags); - sendto_server(cptr, 0, 0, mtags, ":%s AWAY :%s", sptr->name, new_reason); + sendto_server(sptr, 0, 0, mtags, ":%s AWAY :%s", sptr->name, new_reason); if (sptr->user->away) { @@ -150,7 +137,7 @@ CMD_FUNC(cmd_away) if (MyConnect(sptr)) sendnumeric(sptr, RPL_NOWAWAY); - hash_check_watch(cptr, already_as_away ? RPL_REAWAY : RPL_GONEAWAY); + hash_check_watch(sptr, already_as_away ? RPL_REAWAY : RPL_GONEAWAY); sendto_local_common_channels(sptr, sptr, ClientCapabilityBit("away-notify"), mtags, diff --git a/src/modules/batch.c b/src/modules/batch.c index fcfd0d438..05c11cfed 100644 --- a/src/modules/batch.c +++ b/src/modules/batch.c @@ -80,7 +80,7 @@ CMD_FUNC(cmd_batch) Client *acptr; char buf[512]; - if (!IsServer(cptr) || (parc < 3)) + if (MyUser(sptr) || (parc < 3)) return 0; acptr = find_client(parv[1], NULL); diff --git a/src/modules/botmotd.c b/src/modules/botmotd.c index ad12710df..e9f834137 100644 --- a/src/modules/botmotd.c +++ b/src/modules/botmotd.c @@ -60,7 +60,7 @@ CMD_FUNC(cmd_botmotd) MOTDLine *motdline; ConfigItem_tld *tld; - if (hunt_server(cptr, sptr, recv_mtags, ":%s BOTMOTD :%s", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s BOTMOTD :%s", 1, parc, parv) != HUNTED_ISME) return 0; if (!IsUser(sptr)) diff --git a/src/modules/cap.c b/src/modules/cap.c index 752f4173a..0fc3d11ed 100644 --- a/src/modules/cap.c +++ b/src/modules/cap.c @@ -240,7 +240,7 @@ static int cap_end(Client *sptr, const char *arg) ClearCapabilityFast(sptr, CAP_IN_PROGRESS); if (*sptr->name && sptr->user && *sptr->user->username && IsNotSpoof(sptr)) - return register_user(sptr, sptr, sptr->name, sptr->user->username, NULL, NULL, NULL); + return register_user(sptr, sptr->name, sptr->user->username, NULL, NULL, NULL); return 0; } @@ -351,7 +351,7 @@ static int cap_req(Client *sptr, const char *arg) struct clicap_cmd { const char *cmd; - int (*func)(struct Client *source_p, const char *arg); + int (*func)(Client *source_p, const char *arg); }; static struct clicap_cmd clicap_cmdtable[] = { @@ -392,7 +392,7 @@ CMD_FUNC(cmd_cap) * This will speed up connections considerably. */ if (sptr->local->receiveM > 15) - cptr->local->since++; + sptr->local->since++; if (DISABLE_CAP) { diff --git a/src/modules/chanmodes/delayjoin.c b/src/modules/chanmodes/delayjoin.c index 5f040bfe0..93f941a4b 100644 --- a/src/modules/chanmodes/delayjoin.c +++ b/src/modules/chanmodes/delayjoin.c @@ -26,9 +26,9 @@ static Cmode_t EXTMODE_POST_DELAYED; int visible_in_channel( Client *cptr, Channel *chptr); int moded_check_part( Client *cptr, Channel *chptr); int moded_join(Client *cptr, Channel *chptr); -int moded_part(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); +int moded_part(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); int deny_all(Client *cptr, Channel *chptr, char mode, char *para, int checkt, int what); -int moded_chanmode(Client *cptr, Client *sptr, Channel *chptr, +int moded_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); char *moded_prechanmsg(Client *sptr, Channel *chptr, MessageTag *mtags, char *text, int notice); char *moded_serialize(ModData *m); @@ -272,16 +272,15 @@ int moded_join(Client *cptr, Channel *chptr) return 0; } -int moded_part(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *comment) +int moded_part(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment) { if (channel_is_delayed(chptr) || channel_is_post_delayed(chptr)) - clear_user_invisible(chptr,cptr); + clear_user_invisible(chptr, sptr); return 0; } -int moded_chanmode(Client *cptr, Client *sptr, Channel *chptr, - MessageTag *recv_mtags, char *modebuf, char *parabuf, time_t sendts, int samode) +int moded_chanmode(Client *sptr, Channel *chptr, MessageTag *recv_mtags, char *modebuf, char *parabuf, time_t sendts, int samode) { long CAP_EXTENDED_JOIN = ClientCapabilityBit("extended-join"); diff --git a/src/modules/chanmodes/floodprot.c b/src/modules/chanmodes/floodprot.c index 77293fdae..d8f8e54cd 100644 --- a/src/modules/chanmodes/floodprot.c +++ b/src/modules/chanmodes/floodprot.c @@ -115,14 +115,14 @@ char *cmodef_conv_param(char *param_in, Client *cptr); void cmodef_free_param(void *r); void *cmodef_dup_struct(void *r_in); int cmodef_sjoin_check(Channel *chptr, void *ourx, void *theirx); -int floodprot_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); +int floodprot_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); EVENT(modef_event); int cmodef_channel_destroy(Channel *chptr, int *should_destroy); char *floodprot_pre_chanmsg(Client *sptr, Channel *chptr, MessageTag *mtags, char *text, int notice); int floodprot_post_chanmsg(Client *sptr, Channel *chptr, int sendflags, int prefix, char *target, MessageTag *mtags, char *text, int notice); int floodprot_knock(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); int floodprot_local_nickchange(Client *sptr, char *oldnick); -int floodprot_remote_nickchange(Client *cptr, Client *sptr, char *oldnick); +int floodprot_remote_nickchange(Client *sptr, char *oldnick); int floodprot_chanmode_del(Channel *chptr, int m); void memberflood_free(ModData *md); int floodprot_stats(Client *sptr, char *flag); @@ -849,7 +849,7 @@ int cmodef_sjoin_check(Channel *chptr, void *ourx, void *theirx) return EXSJ_MERGE; } -int floodprot_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) +int floodprot_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) { /* I'll explain this only once: * 1. if channel is +f @@ -997,7 +997,7 @@ int floodprot_local_nickchange(Client *sptr, char *oldnick) return gotnickchange(sptr); } -int floodprot_remote_nickchange(Client *cptr, Client *sptr, char *oldnick) +int floodprot_remote_nickchange(Client *sptr, char *oldnick) { if (IsULine(sptr)) return 0; diff --git a/src/modules/chanmodes/history.c b/src/modules/chanmodes/history.c index aa2d1bd47..291ca9fca 100644 --- a/src/modules/chanmodes/history.c +++ b/src/modules/chanmodes/history.c @@ -63,7 +63,7 @@ void *history_chanmode_dup_struct(void *r_in); int history_chanmode_sjoin_check(Channel *chptr, void *ourx, void *theirx); int history_channel_destroy(Channel *chptr, int *should_destroy); int history_chanmsg(Client *sptr, Channel *chptr, int sendflags, int prefix, char *target, MessageTag *mtags, char *text, int notice); -int history_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); +int history_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); EVENT(history_clean); MOD_TEST() @@ -506,7 +506,7 @@ int history_chanmsg(Client *sptr, Channel *chptr, int sendflags, int prefix, cha return 0; } -int history_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) +int history_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) { if (!HistoryEnabled(chptr)) return 0; diff --git a/src/modules/chanmodes/issecure.c b/src/modules/chanmodes/issecure.c index 392bdd6f2..0b8f123a4 100644 --- a/src/modules/chanmodes/issecure.c +++ b/src/modules/chanmodes/issecure.c @@ -43,11 +43,11 @@ Cmode_t EXTCMODE_ISSECURE; int IsSecureJoin(Channel *chptr); int modeZ_is_ok(Client *sptr, Channel *chptr, char mode, char *para, int checkt, int what); -int issecure_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); -int issecure_part(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); +int issecure_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); +int issecure_part(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment); int issecure_quit(Client *acptr, MessageTag *mtags, char *comment); -int issecure_kick(Client *cptr, Client *sptr, Client *acptr, Channel *chptr, MessageTag *mtags, char *comment); -int issecure_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, +int issecure_kick(Client *sptr, Client *acptr, Channel *chptr, MessageTag *mtags, char *comment); +int issecure_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); @@ -199,7 +199,7 @@ void issecure_set(Channel *chptr, Client *sptr, MessageTag *recv_mtags, int noti * so while they can be written shorter, they would only take longer to execute! */ -int issecure_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) +int issecure_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) { /* Check only if chan already +zZ and the user joining is insecure (no need to count) */ if (IsSecureJoin(chptr) && IsSecureChanIndicated(chptr) && !IsSecureConnect(sptr) && !IsULine(sptr)) @@ -212,7 +212,7 @@ int issecure_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, return 0; } -int issecure_part(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *comment) +int issecure_part(Client *sptr, Channel *chptr, MessageTag *mtags, char *comment) { /* Only care if chan is +z-Z and the user leaving is insecure, then count */ if (IsSecureJoin(chptr) && !IsSecureChanIndicated(chptr) && !IsSecureConnect(sptr) && @@ -237,7 +237,7 @@ Channel *chptr; return 0; } -int issecure_kick(Client *cptr, Client *sptr, Client *victim, Channel *chptr, MessageTag *mtags, char *comment) +int issecure_kick(Client *sptr, Client *victim, Channel *chptr, MessageTag *mtags, char *comment) { /* Identical to part&quit, except we care about 'victim' and not 'sptr' */ if (IsSecureJoin(chptr) && !IsSecureChanIndicated(chptr) && @@ -246,7 +246,7 @@ int issecure_kick(Client *cptr, Client *sptr, Client *victim, Channel *chptr, Me return 0; } -int issecure_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, +int issecure_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode) { if (!strchr(modebuf, 'z')) diff --git a/src/modules/chanmodes/link.c b/src/modules/chanmodes/link.c index c7bbb59c1..03e1048da 100644 --- a/src/modules/chanmodes/link.c +++ b/src/modules/chanmodes/link.c @@ -354,7 +354,7 @@ int link_doforward(Client *sptr, Channel *chptr, char *linked, linkType type) parv[0] = sptr->name; parv[1] = linked; parv[2] = NULL; - do_join(sptr, sptr, 2, parv); + do_join(sptr, 2, parv); return HOOK_DENY; // Original channel join = ignored } @@ -393,7 +393,7 @@ int link_pre_localjoin_cb(Client *sptr, Channel *chptr, char *parv[]) return HOOK_CONTINUE; // can_join() actually returns 0 if we *can* join a channel, so we don't need to bother checking any further conditions - if (!(canjoin = can_join(sptr, sptr, chptr, NULL, parv))) + if (!(canjoin = can_join(sptr, chptr, NULL, parv))) return HOOK_CONTINUE; // Oper only channel diff --git a/src/modules/chanmodes/permanent.c b/src/modules/chanmodes/permanent.c index bfb1e582a..ef2759d45 100644 --- a/src/modules/chanmodes/permanent.c +++ b/src/modules/chanmodes/permanent.c @@ -51,7 +51,7 @@ static int permanent_is_ok(Client *cptr, Channel *chptr, char mode, char *para, return EX_ALLOW; } -int permanent_chanmode(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode) +int permanent_chanmode(Client *sptr, Channel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode) { /* Destroy the channel if it was set '(SA)MODE #chan -P' with nobody in it (#4442) */ if (!(chptr->mode.extmode & EXTMODE_PERMANENT) && (chptr->users <= 0)) diff --git a/src/modules/channeldb.c b/src/modules/channeldb.c index 53aee6b05..63eaecae1 100644 --- a/src/modules/channeldb.c +++ b/src/modules/channeldb.c @@ -482,9 +482,10 @@ static void set_channel_mode(Channel *chptr, char *modes, char *parameters) myparv[myparc] = NULL; SetULine(&me); // hack for crash.. set ulined so no access checks. - do_mode(chptr, &me, &me, NULL, myparc, myparv, 0, 0); + do_mode(chptr, &me, NULL, myparc, myparv, 0, 0); SetULine(&me); // and clear it again.. for (i = 0; i < myparc; i++) safe_free(myparv[i]); } +// FIXME: move above function to m_mode and make efunc, available for all modules anyway diff --git a/src/modules/chghost.c b/src/modules/chghost.c index 30890426f..03d01a2e2 100644 --- a/src/modules/chghost.c +++ b/src/modules/chghost.c @@ -144,7 +144,7 @@ CMD_FUNC(cmd_chghost) acptr->umodes |= UMODE_HIDE; acptr->umodes |= UMODE_SETHOST; - sendto_server(cptr, 0, 0, NULL, ":%s CHGHOST %s %s", sptr->name, acptr->name, parv[2]); + sendto_server(sptr, 0, 0, NULL, ":%s CHGHOST %s %s", sptr->name, acptr->name, parv[2]); safe_strdup(acptr->user->virthost, parv[2]); userhost_changed(acptr); diff --git a/src/modules/chgident.c b/src/modules/chgident.c index 27345cf05..c5b685559 100644 --- a/src/modules/chgident.c +++ b/src/modules/chgident.c @@ -142,7 +142,7 @@ CMD_FUNC(cmd_chgident) GetHost(acptr), parv[2]); } - sendto_server(cptr, 0, 0, NULL, ":%s CHGIDENT %s %s", + sendto_server(sptr, 0, 0, NULL, ":%s CHGIDENT %s %s", sptr->name, acptr->name, parv[2]); ircsnprintf(acptr->user->username, sizeof(acptr->user->username), "%s", parv[2]); diff --git a/src/modules/chgname.c b/src/modules/chgname.c index e6e409c49..5e6895abe 100644 --- a/src/modules/chgname.c +++ b/src/modules/chgname.c @@ -120,7 +120,7 @@ CMD_FUNC(cmd_chgname) } } - sendto_server(cptr, 0, 0, NULL, ":%s CHGNAME %s :%s", + sendto_server(sptr, 0, 0, NULL, ":%s CHGNAME %s :%s", sptr->name, acptr->name, parv[2]); return 0; } diff --git a/src/modules/connect.c b/src/modules/connect.c index d1a90feaa..0d4bf3175 100644 --- a/src/modules/connect.c +++ b/src/modules/connect.c @@ -65,7 +65,6 @@ CMD_FUNC(cmd_connect) ConfigItem_deny_link *deny; Client *acptr; - if (!IsServer(sptr) && MyConnect(sptr) && !ValidatePermissionsForPath("route:global",sptr,NULL,NULL,NULL) && parc > 3) { /* Only allow LocOps to make */ /* local CONNECTS --SRB */ @@ -77,7 +76,7 @@ CMD_FUNC(cmd_connect) sendnumeric(sptr, ERR_NOPRIVILEGES); return 0; } - if (hunt_server(cptr, sptr, recv_mtags, ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s CONNECT %s %s :%s", 3, parc, parv) != HUNTED_ISME) return 0; if (parc < 2 || *parv[1] == '\0') @@ -128,7 +127,7 @@ CMD_FUNC(cmd_connect) } /* Notify all operators about remote connect requests */ - if (!MyUser(cptr)) + if (!MyUser(sptr)) { sendto_server(&me, 0, 0, NULL, ":%s GLOBOPS :Remote CONNECT %s %s from %s", diff --git a/src/modules/cycle.c b/src/modules/cycle.c index 491d85aa0..28805e553 100644 --- a/src/modules/cycle.c +++ b/src/modules/cycle.c @@ -69,10 +69,10 @@ CMD_FUNC(cmd_cycle) parv[2] = "cycling"; strlcpy(channels, parv[1], sizeof(channels)); - n = do_cmd(cptr, sptr, recv_mtags, "PART", 3, parv); + n = do_cmd(sptr, recv_mtags, "PART", 3, parv); if (n == FLUSH_BUFFER) return n; parv[1] = channels; parv[2] = NULL; - return do_cmd(cptr, sptr, recv_mtags, "JOIN", 2, parv); + return do_cmd(sptr, recv_mtags, "JOIN", 2, parv); } diff --git a/src/modules/eos.c b/src/modules/eos.c index 2818a91e8..aa544fa14 100644 --- a/src/modules/eos.c +++ b/src/modules/eos.c @@ -66,11 +66,11 @@ CMD_FUNC(cmd_eos) sptr->serv->flags.synced = 1; /* pass it on ^_- */ #ifdef DEBUGMODE - ircd_log(LOG_ERROR, "[EOSDBG] cmd_eos: got sync from %s (path:%s)", sptr->name, cptr->name); - ircd_log(LOG_ERROR, "[EOSDBG] cmd_eos: broadcasting it back to everyone except route from %s", cptr->name); + ircd_log(LOG_ERROR, "[EOSDBG] cmd_eos: got sync from %s (path:%s)", sptr->name, sptr->direction->name); + ircd_log(LOG_ERROR, "[EOSDBG] cmd_eos: broadcasting it back to everyone except route from %s", sptr->direction->name); #endif - sendto_server(cptr, 0, 0, NULL, ":%s EOS", sptr->name); + sendto_server(sptr, 0, 0, NULL, ":%s EOS", sptr->name); - RunHook(HOOKTYPE_SERVER_SYNCHED, cptr); + RunHook(HOOKTYPE_SERVER_SYNCHED, sptr); return 0; } diff --git a/src/modules/globops.c b/src/modules/globops.c index 2bad1fa48..f3ecc7342 100644 --- a/src/modules/globops.c +++ b/src/modules/globops.c @@ -81,7 +81,7 @@ CMD_FUNC(cmd_globops) { /* Backward-compatible (3.2.x) */ sendto_umode(UMODE_OPER, "from %s: %s", sptr->name, message); - sendto_server(cptr, 0, 0, NULL, ":%s SENDUMODE o :from %s: %s", + sendto_server(sptr, 0, 0, NULL, ":%s SENDUMODE o :from %s: %s", me.name, sptr->name, message); } diff --git a/src/modules/hideserver.c b/src/modules/hideserver.c index f16d5a8d1..90b54a294 100644 --- a/src/modules/hideserver.c +++ b/src/modules/hideserver.c @@ -326,7 +326,7 @@ CMD_OVERRIDE_FUNC(override_map) parv[1] = "*"; if (IsOper(sptr)) - return CallCommandOverride(ovr, cptr, sptr, recv_mtags, parc, parv); + return CallCommandOverride(ovr, sptr, recv_mtags, parc, parv); if (Settings.disable_map) { @@ -366,7 +366,7 @@ CMD_OVERRIDE_FUNC(override_links) int flat = (FLAT_MAP && !IsOper(sptr)) ? 1 : 0; if (IsOper(sptr)) - return CallCommandOverride(ovr, cptr, sptr, recv_mtags, parc, parv); + return CallCommandOverride(ovr, sptr, recv_mtags, parc, parv); if (Settings.disable_links) { @@ -381,7 +381,7 @@ CMD_OVERRIDE_FUNC(override_links) list_for_each_entry(acptr, &global_server_list, client_node) { /* Some checks */ - if (HIDE_ULINES && IsULine(acptr) && !ValidatePermissionsForPath("server:info:map:ulines",cptr,NULL,NULL,NULL)) + if (HIDE_ULINES && IsULine(acptr) && !ValidatePermissionsForPath("server:info:map:ulines",sptr,NULL,NULL,NULL)) continue; if (FindHiddenServer(acptr->name)) continue; diff --git a/src/modules/join.c b/src/modules/join.c index 1d1cca255..864ab7e4a 100644 --- a/src/modules/join.c +++ b/src/modules/join.c @@ -24,9 +24,9 @@ /* Forward declarations */ CMD_FUNC(cmd_join); -void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *mtags, int flags); -int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]); -int _can_join(Client *cptr, Client *sptr, Channel *chptr, char *key, char *parv[]); +void _join_channel(Channel *chptr, Client *sptr, MessageTag *mtags, int flags); +int _do_join(Client *sptr, int parc, char *parv[]); +int _can_join(Client *sptr, Channel *chptr, char *key, char *parv[]); void _userhost_save_current(Client *sptr); void _userhost_changed(Client *sptr); void _send_join_to_local_users(Client *sptr, Channel *chptr, MessageTag *mtags); @@ -87,12 +87,12 @@ MOD_UNLOAD() * (eg: bans at the end), so don't change it unless you have a good reason * to do so -- Syzop. */ -int _can_join(Client *cptr, Client *sptr, Channel *chptr, char *key, char *parv[]) +int _can_join(Client *sptr, Channel *chptr, char *key, char *parv[]) { -Link *lp; -Ban *banned; -Hook *h; -int i=0,j=0; + Link *lp; + Ban *banned; + Hook *h; + int i=0, j=0; for (h = Hooks[HOOKTYPE_CAN_JOIN]; h; h = h->next) { @@ -176,7 +176,7 @@ CMD_FUNC(cmd_join) bouncedtimes = 0; if (IsServer(sptr)) return 0; - r = do_join(cptr, sptr, parc, parv); + r = do_join(sptr, parc, parv); bouncedtimes = 0; return r; @@ -233,7 +233,7 @@ void _send_join_to_local_users(Client *sptr, Channel *chptr, MessageTag *mtags) /* Routine that actually makes a user join the channel * this does no actual checking (banned, etc.) it just adds the user */ -void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags, int flags) +void _join_channel(Channel *chptr, Client *sptr, MessageTag *recv_mtags, int flags) { MessageTag *mtags = NULL; /** Message tags to send to local users (sender is :user) */ MessageTag *mtags_sjoin = NULL; /* Message tags to send to remote servers for SJOIN (sender is :me.name) */ @@ -249,15 +249,15 @@ void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_ send_join_to_local_users(sptr, chptr, mtags); /* old non-SJOINv3 servers */ - sendto_server(cptr, 0, PROTO_SJ3, mtags, ":%s JOIN :%s", sptr->name, chptr->chname); + sendto_server(sptr, 0, PROTO_SJ3, mtags, ":%s JOIN :%s", sptr->name, chptr->chname); /* I _know_ that the "@%s " look a bit wierd with the space and all .. but its to get around a SJOIN bug --stskeeps */ - sendto_server(cptr, PROTO_SID | PROTO_SJ3, 0, mtags_sjoin, ":%s SJOIN %lld %s :%s%s ", + sendto_server(sptr, PROTO_SID | PROTO_SJ3, 0, mtags_sjoin, ":%s SJOIN %lld %s :%s%s ", me.id, (long long)chptr->creationtime, chptr->chname, chfl_to_sjoin_symbol(flags), ID(sptr)); - sendto_server(cptr, PROTO_SJ3, PROTO_SID, mtags_sjoin, ":%s SJOIN %lld %s :%s%s ", + sendto_server(sptr, PROTO_SJ3, PROTO_SID, mtags_sjoin, ":%s SJOIN %lld %s :%s%s ", me.name, (long long)chptr->creationtime, chptr->chname, chfl_to_sjoin_symbol(flags), sptr->name); @@ -271,7 +271,7 @@ void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_ if (chptr->creationtime == 0) { chptr->creationtime = TStime(); - sendto_server(cptr, 0, 0, NULL, ":%s MODE %s + %lld", + sendto_server(sptr, 0, 0, NULL, ":%s MODE %s + %lld", me.name, chptr->chname, (long long)chptr->creationtime); } del_invite(sptr, chptr); @@ -285,14 +285,14 @@ void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_ if ((flags & CHFL_CHANOWNER) || (flags & CHFL_CHANADMIN)) { /* +ao / +qo for when PREFIX_AQ is off */ - sendto_server(cptr, 0, PROTO_SJ3, NULL, ":%s MODE %s +o%c %s %s %lld", + sendto_server(sptr, 0, PROTO_SJ3, NULL, ":%s MODE %s +o%c %s %s %lld", me.name, chptr->chname, chfl_to_chanmode(flags), sptr->name, sptr->name, (long long)chptr->creationtime); } else { #endif /* +v/+h/+o (and +a/+q if PREFIX_AQ is on) */ - sendto_server(cptr, 0, PROTO_SJ3, NULL, ":%s MODE %s +%c %s %lld", + sendto_server(sptr, 0, PROTO_SJ3, NULL, ":%s MODE %s +%c %s %lld", me.name, chptr->chname, chfl_to_chanmode(flags), sptr->name, (long long)chptr->creationtime); @@ -342,11 +342,11 @@ void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_ parv[0] = sptr->name; parv[1] = chptr->chname; - (void)do_cmd(cptr, sptr, NULL, "NAMES", 2, parv); + (void)do_cmd(sptr, NULL, "NAMES", 2, parv); - RunHook5(HOOKTYPE_LOCAL_JOIN, cptr, sptr, chptr, mtags, parv); + RunHook4(HOOKTYPE_LOCAL_JOIN, sptr, chptr, mtags, parv); } else { - RunHook5(HOOKTYPE_REMOTE_JOIN, cptr, sptr, chptr, mtags, parv); + RunHook4(HOOKTYPE_REMOTE_JOIN, sptr, chptr, mtags, parv); } free_message_tags(mtags); @@ -360,7 +360,7 @@ void _join_channel(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_ * increased every time we enter this loop and decreased anytime we leave the * loop. So be carefull not to use a simple 'return' after bouncedtimes++. -- Syzop */ -int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]) +int _do_join(Client *sptr, int parc, char *parv[]) { char jbuf[BUFSIZE]; Membership *lp; @@ -467,10 +467,10 @@ int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]) sendto_channel(chptr, sptr, NULL, 0, 0, SEND_LOCAL, NULL, ":%s PART %s :%s", sptr->name, chptr->chname, "Left all channels"); - sendto_server(cptr, 0, 0, mtags, ":%s PART %s :Left all channels", sptr->name, chptr->chname); + sendto_server(sptr, 0, 0, mtags, ":%s PART %s :Left all channels", sptr->name, chptr->chname); if (MyConnect(sptr)) - RunHook5(HOOKTYPE_LOCAL_PART, cptr, sptr, chptr, mtags, "Left all channels"); + RunHook4(HOOKTYPE_LOCAL_PART, sptr, chptr, mtags, "Left all channels"); remove_user_from_channel(sptr, chptr); free_message_tags(mtags); @@ -506,7 +506,7 @@ int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]) if (!ValidatePermissionsForPath("immune:server-ban:deny-channel",sptr,NULL,NULL,NULL)) { ConfigItem_deny_channel *d; - if ((d = Find_channel_allowed(cptr, name))) + if ((d = Find_channel_allowed(sptr, name))) { if (d->warn) { @@ -520,7 +520,7 @@ int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]) sendnotice(sptr, "*** Redirecting you to %s", d->redirect); parv[0] = sptr->name; parv[1] = d->redirect; - do_join(cptr, sptr, 2, parv); + do_join(sptr, 2, parv); } if (d->class) sendnotice(sptr, "*** Can not join %s: Your class is not allowed", name); @@ -586,7 +586,7 @@ int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]) } /* If they are allowed, don't check can_join */ if (i != HOOK_ALLOW && - (i = can_join(cptr, sptr, chptr, key, parv))) + (i = can_join(sptr, chptr, key, parv))) { if (i != -1) { @@ -607,7 +607,7 @@ int _do_join(Client *cptr, Client *sptr, int parc, char *parv[]) * and so on, each with their own unique msgid and such. */ new_message(sptr, NULL, &mtags); - join_channel(chptr, cptr, sptr, mtags, flags); + join_channel(chptr, sptr, mtags, flags); free_message_tags(mtags); } RET(0) diff --git a/src/modules/jointhrottle.c b/src/modules/jointhrottle.c index 23c41c6dc..7043d8326 100644 --- a/src/modules/jointhrottle.c +++ b/src/modules/jointhrottle.c @@ -59,7 +59,7 @@ int jointhrottle_config_test(ConfigFile *, ConfigEntry *, int, int *); int jointhrottle_config_run(ConfigFile *, ConfigEntry *, int); void jointhrottle_md_free(ModData *m); int jointhrottle_can_join(Client *sptr, Channel *chptr, char *key, char *parv[]); -int jointhrottle_local_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); +int jointhrottle_local_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]); static int isjthrottled(Client *cptr, Channel *chptr); static void jointhrottle_increase_usercounter(Client *cptr, Channel *chptr); EVENT(jointhrottle_cleanup_structs); @@ -214,9 +214,9 @@ int jointhrottle_can_join(Client *sptr, Channel *chptr, char *key, char *parv[]) } -int jointhrottle_local_join(Client *cptr, Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) +int jointhrottle_local_join(Client *sptr, Channel *chptr, MessageTag *mtags, char *parv[]) { - jointhrottle_increase_usercounter(cptr, chptr); + jointhrottle_increase_usercounter(sptr, chptr); return 0; } diff --git a/src/modules/kick.c b/src/modules/kick.c index 5e81d0941..e20864322 100644 --- a/src/modules/kick.c +++ b/src/modules/kick.c @@ -101,7 +101,7 @@ CMD_FUNC(cmd_kick) /* Store "sptr" access flags */ if (IsUser(sptr)) sptr_flags = get_access(sptr, chptr); - if (!IsServer(cptr) && !IsULine(sptr) && !op_can_override("channel:override:kick:no-ops",sptr,chptr,NULL) + if (MyUser(sptr) && !IsULine(sptr) && !op_can_override("channel:override:kick:no-ops",sptr,chptr,NULL) && !(sptr_flags & CHFL_ISOP) && !(sptr_flags & CHFL_HALFOP)) { sendnumeric(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname); @@ -287,9 +287,9 @@ CMD_FUNC(cmd_kick) /* The same message is actually sent at 5 places below (though max 4 at most) */ if (MyUser(sptr)) - RunHook6(HOOKTYPE_LOCAL_KICK, cptr, sptr, who, chptr, mtags, comment); + RunHook5(HOOKTYPE_LOCAL_KICK, sptr, who, chptr, mtags, comment); else - RunHook6(HOOKTYPE_REMOTE_KICK, cptr, sptr, who, chptr, mtags, comment); + RunHook5(HOOKTYPE_REMOTE_KICK, sptr, who, chptr, mtags, comment); if (lp) { @@ -314,9 +314,9 @@ CMD_FUNC(cmd_kick) sptr->name, chptr->chname, who->name, comment); } } - sendto_server(cptr, PROTO_SID, 0, mtags, ":%s KICK %s %s :%s", + sendto_server(sptr, PROTO_SID, 0, mtags, ":%s KICK %s %s :%s", ID(sptr), chptr->chname, ID(who), comment); - sendto_server(cptr, 0, PROTO_SID, mtags, ":%s KICK %s %s :%s", + sendto_server(sptr, 0, PROTO_SID, mtags, ":%s KICK %s %s :%s", sptr->name, chptr->chname, who->name, comment); free_message_tags(mtags); if (lp) @@ -327,7 +327,7 @@ CMD_FUNC(cmd_kick) else if (MyUser(sptr)) sendnumeric(sptr, ERR_USERNOTINCHANNEL, user, name); } /* loop on parv[2] */ - if (MyUser(cptr)) + if (MyUser(sptr)) break; } /* loop on parv[1] */ diff --git a/src/modules/kill.c b/src/modules/kill.c index 4cad275c8..69a0f1bf0 100644 --- a/src/modules/kill.c +++ b/src/modules/kill.c @@ -66,7 +66,7 @@ CMD_FUNC(cmd_kill) { Client *acptr; char inpath[HOSTLEN * 2 + USERLEN + 5]; - char *oinpath = get_client_name(cptr, FALSE); + char *oinpath = get_client_name(sptr->direction, FALSE); char *user, *path, *killer, *nick, *p, *s; int kcount = 0; Hook *h; @@ -79,15 +79,19 @@ CMD_FUNC(cmd_kill) return 0; } + // FIXME: clean all this killpath shit, nobody cares anymore these days. + // FYI, I just replaced 'cptr' with 'sptr->direction' for now, but + // we should clean up this mess later, see the FIXME. + user = parv[1]; path = parv[2]; /* Either defined or NULL (parc >= 2!!) */ strlcpy(inpath, oinpath, sizeof inpath); - if (IsServer(cptr) && (s = strchr(inpath, '.')) != NULL) + if (IsServer(sptr->direction) && (s = strchr(inpath, '.')) != NULL) *s = '\0'; /* Truncate at first "." -- hmm... why ? */ - if (!IsServer(cptr) && !ValidatePermissionsForPath("kill:global",sptr,NULL,NULL,NULL) && !ValidatePermissionsForPath("kill:local",sptr,NULL,NULL,NULL)) + if (!IsServer(sptr->direction) && !ValidatePermissionsForPath("kill:global",sptr,NULL,NULL,NULL) && !ValidatePermissionsForPath("kill:local",sptr,NULL,NULL,NULL)) { sendnumeric(sptr, ERR_NOPRIVILEGES); return 0; @@ -134,8 +138,8 @@ CMD_FUNC(cmd_kill) continue; } - if ((!MyConnect(acptr) && MyUser(cptr) && !ValidatePermissionsForPath("kill:global",sptr,acptr,NULL,NULL)) - || (MyConnect(acptr) && MyUser(cptr) + if ((!MyConnect(acptr) && MyUser(sptr) && !ValidatePermissionsForPath("kill:global",sptr,acptr,NULL,NULL)) + || (MyConnect(acptr) && MyUser(sptr) && !ValidatePermissionsForPath("kill:local",sptr,acptr,NULL,NULL))) { sendnumeric(sptr, ERR_NOPRIVILEGES); @@ -169,7 +173,7 @@ CMD_FUNC(cmd_kill) break; } - if (!IsServer(cptr)) + if (!IsServer(sptr->direction)) { /* ** The kill originates from this server, initialize path. @@ -179,10 +183,10 @@ CMD_FUNC(cmd_kill) ** ...!operhost!oper ** ...!operhost!oper (comment) */ - strlcpy(inpath, GetHost(cptr), sizeof inpath); + strlcpy(inpath, GetHost(sptr->direction), sizeof inpath); if (kcount == 1) { - ircsnprintf(buf, sizeof(buf), "%s (%s)", cptr->name, path); + ircsnprintf(buf, sizeof(buf), "%s (%s)", sptr->direction->name, path); path = buf; } } @@ -227,9 +231,9 @@ CMD_FUNC(cmd_kill) /* Kill from one server to another (we may be src, victim or something in-between) */ /* Broadcast it to other SID and non-SID servers (may be a NOOP, obviously) */ - sendto_server(cptr, PROTO_SID, 0, mtags, ":%s KILL %s :%s!%s", + sendto_server(sptr, PROTO_SID, 0, mtags, ":%s KILL %s :%s!%s", sptr->name, ID(acptr), inpath, path); - sendto_server(cptr, 0, PROTO_SID, mtags, ":%s KILL %s :%s!%s", + sendto_server(sptr, 0, PROTO_SID, mtags, ":%s KILL %s :%s!%s", sptr->name, acptr->name, inpath, path); /* Don't send a QUIT for this */ @@ -253,7 +257,7 @@ CMD_FUNC(cmd_kill) if (MyUser(sptr)) RunHook3(HOOKTYPE_LOCAL_KILL, sptr, acptr, parv[2]); - n = exit_client(cptr, acptr, sptr, mtags, buf2); + n = exit_client(sptr->direction, acptr, sptr, mtags, buf2); free_message_tags(mtags); diff --git a/src/modules/lag.c b/src/modules/lag.c index 7b3d57827..fabfc8837 100644 --- a/src/modules/lag.c +++ b/src/modules/lag.c @@ -76,7 +76,7 @@ CMD_FUNC(cmd_lag) sendnumeric(sptr, ERR_NEEDMOREPARAMS, "LAG"); return 0; } - if (hunt_server(cptr, sptr, recv_mtags, ":%s LAG :%s", 1, parc, parv) == HUNTED_NOSUCH) + if (hunt_server(sptr, recv_mtags, ":%s LAG :%s", 1, parc, parv) == HUNTED_NOSUCH) { return 0; } diff --git a/src/modules/links.c b/src/modules/links.c index 22f985eba..40348eae3 100644 --- a/src/modules/links.c +++ b/src/modules/links.c @@ -57,10 +57,13 @@ CMD_FUNC(cmd_links) Client *acptr; int flat = (FLAT_MAP && !IsOper(sptr)) ? 1 : 0; + if (!MyUser(sptr)) + return 0; + list_for_each_entry(acptr, &global_server_list, client_node) { /* Some checks */ - if (HIDE_ULINES && IsULine(acptr) && !ValidatePermissionsForPath("server:info:map:ulines",cptr,NULL,NULL,NULL)) + if (HIDE_ULINES && IsULine(acptr) && !ValidatePermissionsForPath("server:info:map:ulines",sptr,NULL,NULL,NULL)) continue; if (flat) sendnumeric(sptr, RPL_LINKS, acptr->name, me.name, diff --git a/src/modules/list.c b/src/modules/list.c index e0ef6f159..6faf09167 100644 --- a/src/modules/list.c +++ b/src/modules/list.c @@ -143,8 +143,8 @@ CMD_FUNC(cmd_list) NULL }; - /* Some starting san checks -- No interserver lists allowed. */ - if (cptr != sptr || !sptr->user) + /* Remote /LIST is not supported */ + if (!MyUser(sptr)) return 0; /* If a /LIST is in progress then a new one will cancel it */ @@ -161,8 +161,8 @@ CMD_FUNC(cmd_list) ALLOCATE_CHANNELLISTOPTIONS(sptr); CHANNELLISTOPTIONS(sptr)->showall = 1; - if (DBufLength(&cptr->local->sendQ) < 2048) - send_list(cptr); + if (DBufLength(&sptr->local->sendQ) < 2048) + send_list(sptr); return 0; } @@ -298,8 +298,8 @@ CMD_FUNC(cmd_list) CHANNELLISTOPTIONS(sptr)->nolist = nolist; CHANNELLISTOPTIONS(sptr)->yeslist = yeslist; - if (DBufLength(&cptr->local->sendQ) < 2048) - send_list(cptr); + if (DBufLength(&sptr->local->sendQ) < 2048) + send_list(sptr); return 0; } diff --git a/src/modules/lusers.c b/src/modules/lusers.c index 5f7187edc..34ad4be26 100644 --- a/src/modules/lusers.c +++ b/src/modules/lusers.c @@ -59,7 +59,7 @@ CMD_FUNC(cmd_lusers) { char flatmap; - if (hunt_server(cptr, sptr, recv_mtags, ":%s LUSERS :%s", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s LUSERS :%s", 1, parc, parv) != HUNTED_ISME) return 0; flatmap = (FLAT_MAP && !ValidatePermissionsForPath("server:info:lusers",sptr,NULL,NULL,NULL)) ? 1 : 0; diff --git a/src/modules/md.c b/src/modules/md.c index 1b72f4eb8..3a57d1e21 100644 --- a/src/modules/md.c +++ b/src/modules/md.c @@ -114,7 +114,7 @@ CMD_FUNC(cmd_md) memset(&moddata_client(acptr, md), 0, sizeof(ModData)); } /* Pass on to other servers */ - broadcast_md_client_cmd(cptr, sptr, acptr, varname, value); + broadcast_md_client_cmd(sptr->direction, sptr, acptr, varname, value); } else if (!strcmp(type, "channel")) { @@ -131,7 +131,7 @@ CMD_FUNC(cmd_md) memset(&moddata_channel(chptr, md), 0, sizeof(ModData)); } /* Pass on to other servers */ - broadcast_md_channel_cmd(cptr, sptr, chptr, varname, value); + broadcast_md_channel_cmd(sptr->direction, sptr, chptr, varname, value); } else if (!strcmp(type, "member")) { @@ -171,7 +171,7 @@ CMD_FUNC(cmd_md) memset(&moddata_member(m, md), 0, sizeof(ModData)); } /* Pass on to other servers */ - broadcast_md_member_cmd(cptr, sptr, chptr, acptr, varname, value); + broadcast_md_member_cmd(sptr->direction, sptr, chptr, acptr, varname, value); } else if (!strcmp(type, "membership")) { @@ -211,7 +211,7 @@ CMD_FUNC(cmd_md) memset(&moddata_membership(m, md), 0, sizeof(ModData)); } /* Pass on to other servers */ - broadcast_md_membership_cmd(cptr, sptr, acptr, chptr, varname, value); + broadcast_md_membership_cmd(sptr->direction, sptr, acptr, chptr, varname, value); } else if (!strcmp(type, "globalvar")) { @@ -228,7 +228,7 @@ CMD_FUNC(cmd_md) memset(&moddata_global_variable(md), 0, sizeof(ModData)); } /* Pass on to other servers */ - broadcast_md_globalvar_cmd(cptr, sptr, varname, value); + broadcast_md_globalvar_cmd(sptr->direction, sptr, varname, value); } return 0; } diff --git a/src/modules/message.c b/src/modules/message.c index 0a8d01af4..b31d85ee3 100644 --- a/src/modules/message.c +++ b/src/modules/message.c @@ -27,8 +27,8 @@ int ban_version(Client *sptr, char *text); CMD_FUNC(cmd_private); CMD_FUNC(cmd_notice); -int cmd_message(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], int notice); -int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int notice); +int cmd_message(Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], int notice); +int _can_send(Client *sptr, Channel *chptr, char **msgtext, char **errmsg, int notice); /* Place includes here */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */ @@ -79,8 +79,7 @@ static int check_dcc_soft(Client *from, Client *to, char *text); #define CANPRIVMSG_CONTINUE 100 #define CANPRIVMSG_SEND 101 /** Check if PRIVMSG's are permitted from a person to another person. - * cptr: .. - * sptr: .. + * sptr: source client * acptr: target client * notice: 1 if notice, 0 if privmsg * text: Pointer to a pointer to a text [in, out] @@ -91,7 +90,7 @@ static int check_dcc_soft(Client *from, Client *to, char *text); * CANPRIVMSG_SEND: send the message (use text/newcmd!) * Other: return with this value (can be anything like 0, -1, FLUSH_BUFFER, etc) */ -static int can_privmsg(Client *cptr, Client *sptr, Client *acptr, int notice, char **text, char **cmd) +static int can_privmsg(Client *sptr, Client *acptr, int notice, char **text, char **cmd) { int ret; @@ -143,7 +142,7 @@ int ret; return CANPRIVMSG_SEND; } else { /* Silenced */ - RunHook4(HOOKTYPE_SILENCED, cptr, sptr, acptr, notice); + RunHook3(HOOKTYPE_SILENCED, sptr, acptr, notice); } return CANPRIVMSG_CONTINUE; } @@ -159,7 +158,7 @@ int ret; ** rev argv 6/91 ** */ -int cmd_message(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], int notice) +int cmd_message(Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], int notice) { Client *acptr; Channel *chptr; @@ -365,7 +364,7 @@ int cmd_message(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, ch continue; } - sendto_channel(chptr, sptr, cptr, + sendto_channel(chptr, sptr, sptr, prefix, 0, sendflags, mtags, notice ? ":%s NOTICE %s :%s" : ":%s PRIVMSG %s :%s", sptr->name, nick, text); @@ -398,7 +397,7 @@ int cmd_message(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, ch continue; } new_message(sptr, recv_mtags, &mtags); - sendto_match_butone(IsServer(cptr) ? cptr : NULL, + sendto_match_butone(IsServer(sptr->direction) ? sptr->direction : NULL, sptr, nick + 1, (*nick == '#') ? MATCH_HOST : MATCH_SERVER, @@ -414,7 +413,7 @@ int cmd_message(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, ch { text = parv[2]; newcmd = cmd; - ret = can_privmsg(cptr, sptr, acptr, notice, &text, &newcmd); + ret = can_privmsg(sptr, acptr, notice, &text, &newcmd); if (ret == CANPRIVMSG_SEND) { MessageTag *mtags = NULL; @@ -461,7 +460,7 @@ int cmd_message(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, ch */ CMD_FUNC(cmd_private) { - return cmd_message(cptr, sptr, recv_mtags, parc, parv, 0); + return cmd_message(sptr, recv_mtags, parc, parv, 0); } /* @@ -471,7 +470,7 @@ CMD_FUNC(cmd_private) */ CMD_FUNC(cmd_notice) { - return cmd_message(cptr, sptr, recv_mtags, parc, parv, 1); + return cmd_message(sptr, recv_mtags, parc, parv, 1); } /** Make a viewable dcc filename. @@ -857,7 +856,7 @@ int ban_version(Client *sptr, char *text) } /** Can user send a message to this channel? - * @param cptr The client + * @param sptr The client * @param chptr The channel * @param msgtext The message to send (MAY be changed, even if user is allowed to send) * @param errmsg The error message (will be filled in) @@ -865,18 +864,18 @@ int ban_version(Client *sptr, char *text) * @returns Returns 1 if the user is allowed to send, otherwise 0. * (note that this behavior was reversed in UnrealIRCd versions <5.x. */ -int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int notice) +int _can_send(Client *sptr, Channel *chptr, char **msgtext, char **errmsg, int notice) { Membership *lp; int member, i = 0; Hook *h; - if (!MyUser(cptr)) + if (!MyUser(sptr)) return 1; *errmsg = NULL; - member = IsMember(cptr, chptr); + member = IsMember(sptr, chptr); if (chptr->mode.mode & MODE_NOPRIVMSGS && !member) { @@ -885,7 +884,7 @@ int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int n */ for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next) { - i = (*(h->func.intfunc))(cptr, chptr, BYPASS_CHANMSG_EXTERNAL); + i = (*(h->func.intfunc))(sptr, chptr, BYPASS_CHANMSG_EXTERNAL); if (i != HOOK_CONTINUE) break; } @@ -896,9 +895,9 @@ int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int n } } - lp = find_membership_link(cptr->user->channel, chptr); + lp = find_membership_link(sptr->user->channel, chptr); if (chptr->mode.mode & MODE_MODERATED && - !op_can_override("channel:override:message:moderated",cptr,chptr,NULL) && + !op_can_override("channel:override:message:moderated",sptr,chptr,NULL) && (!lp /* FIXME: UGLY */ || !(lp->flags & (CHFL_CHANOP | CHFL_VOICE | CHFL_CHANOWNER | CHFL_HALFOP | CHFL_CHANADMIN)))) { @@ -907,7 +906,7 @@ int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int n */ for (h = Hooks[HOOKTYPE_CAN_BYPASS_CHANNEL_MESSAGE_RESTRICTION]; h; h = h->next) { - i = (*(h->func.intfunc))(cptr, chptr, BYPASS_CHANMSG_MODERATED); + i = (*(h->func.intfunc))(sptr, chptr, BYPASS_CHANMSG_MODERATED); if (i != HOOK_CONTINUE) break; } @@ -921,7 +920,7 @@ int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int n /* Modules can plug in as well */ for (h = Hooks[HOOKTYPE_CAN_SEND]; h; h = h->next) { - i = (*(h->func.intfunc))(cptr, chptr, lp, msgtext, errmsg, notice); + i = (*(h->func.intfunc))(sptr, chptr, lp, msgtext, errmsg, notice); if (i != HOOK_CONTINUE) { #ifdef DEBUGMODE @@ -944,13 +943,13 @@ int _can_send(Client *cptr, Channel *chptr, char **msgtext, char **errmsg, int n /* Now we are going to check bans */ /* ..but first: exempt ircops */ - if (op_can_override("channel:override:message:ban",cptr,chptr,NULL)) + if (op_can_override("channel:override:message:ban",sptr,chptr,NULL)) return 1; if ((!lp || !(lp->flags & (CHFL_CHANOP | CHFL_VOICE | CHFL_CHANOWNER | - CHFL_HALFOP | CHFL_CHANADMIN))) && MyUser(cptr) - && is_banned(cptr, chptr, BANCHK_MSG, msgtext, errmsg)) + CHFL_HALFOP | CHFL_CHANADMIN))) && MyUser(sptr) + && is_banned(sptr, chptr, BANCHK_MSG, msgtext, errmsg)) { /* Modules can set 'errmsg', otherwise we default to this: */ if (!*errmsg) diff --git a/src/modules/mode.c b/src/modules/mode.c index d98b27185..99bdad22c 100644 --- a/src/modules/mode.c +++ b/src/modules/mode.c @@ -25,7 +25,7 @@ /* Forward declarations */ CMD_FUNC(cmd_mode); CMD_FUNC(cmd_mlock); -void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], time_t sendts, int samode); +void _do_mode(Channel *chptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], time_t sendts, int samode); void _set_mode(Channel *chptr, Client *cptr, int parc, char *parv[], u_int *pcount, char pvar[MAXMODEPARAMS][MODEBUFLEN + 3], int bounce); CMD_FUNC(_cmd_umode); @@ -108,11 +108,11 @@ CMD_FUNC(cmd_mode) chptr = find_channel(parv[1], NULL); if (!chptr) { - return cmd_umode(cptr, sptr, recv_mtags, parc, parv); + return cmd_umode(sptr, recv_mtags, parc, parv); } } else - return cmd_umode(cptr, sptr, recv_mtags, parc, parv); + return cmd_umode(sptr, recv_mtags, parc, parv); } else { @@ -129,90 +129,81 @@ CMD_FUNC(cmd_mode) modebuf[1] = '\0'; channel_modes(sptr, modebuf, parabuf, sizeof(modebuf), sizeof(parabuf), chptr); - sendnumeric(sptr, RPL_CHANNELMODEIS, - chptr->chname, modebuf, parabuf); - sendnumeric(sptr, RPL_CREATIONTIME, - chptr->chname, chptr->creationtime); + sendnumeric(sptr, RPL_CHANNELMODEIS, chptr->chname, modebuf, parabuf); + sendnumeric(sptr, RPL_CREATIONTIME, chptr->chname, chptr->creationtime); return 0; } - if (IsUser(sptr) && strstr(parv[2], "b") && BadPtr(parv[3])) + if (MyUser(sptr)) { - if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remotebanlist",sptr,NULL,chptr,NULL)) + /* Deal with information requests from local users, such as: + * MODE #chan b Show the ban list + * MODE #chan e Show the ban exemption list + * MODE #chan I Show the invite exception list + * MODE #chan q Show list of channel owners + * MODE #chan a Show list of channel admins + */ + if (strstr(parv[2], "b") && BadPtr(parv[3])) + { + if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remotebanlist",sptr,NULL,chptr,NULL)) + return 0; + /* send ban list */ + for (ban = chptr->banlist; ban; ban = ban->next) + sendnumeric(sptr, RPL_BANLIST, chptr->chname, ban->banstr, ban->who, ban->when); + sendnumeric(sptr, RPL_ENDOFBANLIST, chptr->chname); return 0; - /* send ban list */ - for (ban = chptr->banlist; ban; ban = ban->next) - sendnumeric(sptr, RPL_BANLIST, chptr->chname, ban->banstr, - ban->who, ban->when); - sendnumeric(cptr, RPL_ENDOFBANLIST, - chptr->chname); - return 0; - } + } - if (IsUser(sptr) && strstr(parv[2], "e") && BadPtr(parv[3])) - { - if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remotebanlist",sptr,NULL,chptr,NULL)) + if (strstr(parv[2], "e") && BadPtr(parv[3])) + { + if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remotebanlist",sptr,NULL,chptr,NULL)) + return 0; + /* send exban list */ + for (ban = chptr->exlist; ban; ban = ban->next) + sendnumeric(sptr, RPL_EXLIST, chptr->chname, ban->banstr, ban->who, ban->when); + sendnumeric(sptr, RPL_ENDOFEXLIST, chptr->chname); return 0; - /* send exban list */ - for (ban = chptr->exlist; ban; ban = ban->next) - sendnumeric(sptr, RPL_EXLIST, chptr->chname, ban->banstr, - ban->who, ban->when); - sendnumeric(cptr, RPL_ENDOFEXLIST, - chptr->chname); - return 0; - } + } - if (IsUser(sptr) && strstr(parv[2], "I") && BadPtr(parv[3])) - { - if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remoteinvexlist",sptr,NULL,chptr,NULL)) + if (strstr(parv[2], "I") && BadPtr(parv[3])) + { + if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remoteinvexlist",sptr,NULL,chptr,NULL)) + return 0; + for (ban = chptr->invexlist; ban; ban = ban->next) + sendnumeric(sptr, RPL_INVEXLIST, chptr->chname, ban->banstr, ban->who, ban->when); + sendnumeric(sptr, RPL_ENDOFINVEXLIST, chptr->chname); return 0; - for (ban = chptr->invexlist; ban; ban = ban->next) - sendnumeric(sptr, RPL_INVEXLIST, chptr->chname, ban->banstr, - ban->who, ban->when); - sendnumeric(sptr, RPL_ENDOFINVEXLIST, chptr->chname); - return 0; - } + } - if (IsUser(sptr) && strstr(parv[2], "q") && BadPtr(parv[3])) - { - if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remoteownerlist",sptr,NULL,chptr,NULL)) - return 0; + if (strstr(parv[2], "q") && BadPtr(parv[3])) { Member *member; - /* send chanowner list */ - /* [Whole story about bad loops removed, sorry ;)] - * Now rewritten so it works (was: bad logic) -- Syzop - */ + + if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remoteownerlist",sptr,NULL,chptr,NULL)) + return 0; + for (member = chptr->members; member; member = member->next) { if (is_chanowner(member->cptr, chptr)) - sendnumeric(sptr, RPL_QLIST, chptr->chname, - member->cptr->name); + sendnumeric(sptr, RPL_QLIST, chptr->chname, member->cptr->name); } - sendnumeric(cptr, RPL_ENDOFQLIST, - chptr->chname); + sendnumeric(sptr, RPL_ENDOFQLIST, chptr->chname); return 0; } - } - if (IsUser(sptr) && strstr(parv[2], "a") && BadPtr(parv[3])) - { - if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remoteownerlist",sptr,NULL,chptr,NULL)) - return 0; + if (strstr(parv[2], "a") && BadPtr(parv[3])) { Member *member; - /* send chanowner list */ - /* [Whole story about bad loops removed, sorry ;)] - * Now rewritten so it works (was: bad logic) -- Syzop - */ + + if (!IsMember(sptr, chptr) && !ValidatePermissionsForPath("channel:see:mode:remoteownerlist",sptr,NULL,chptr,NULL)) + return 0; + for (member = chptr->members; member; member = member->next) { if (is_chanadmin(member->cptr, chptr)) - sendnumeric(sptr, RPL_ALIST, chptr->chname, - member->cptr->name); + sendnumeric(sptr, RPL_ALIST, chptr->chname, member->cptr->name); } - sendnumeric(cptr, RPL_ENDOFALIST, - chptr->chname); + sendnumeric(sptr, RPL_ENDOFALIST, chptr->chname); return 0; } } @@ -236,20 +227,21 @@ CMD_FUNC(cmd_mode) } #endif + /* User does not have permission to use the MODE command */ if (IsUser(sptr) && !IsULine(sptr) && !is_chan_op(sptr, chptr) && !is_half_op(sptr, chptr) && - (cptr == sptr || !ValidatePermissionsForPath("channel:override:mode",sptr,NULL,chptr,NULL))) + !ValidatePermissionsForPath("channel:override:mode",sptr,NULL,chptr,NULL)) { - if (cptr == sptr) + if (MyUser(sptr)) { sendnumeric(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname); return 0; } - sendto_one(cptr, NULL, ":%s MODE %s -oh %s %s 0", + sendto_one(sptr, NULL, ":%s MODE %s -oh %s %s 0", me.name, chptr->chname, sptr->name, sptr->name); /* Tell the other server that the user is * de-opped. Fix op desyncs. */ - bounce_mode(chptr, cptr, parc - 2, parv + 2); + bounce_mode(chptr, sptr, parc - 2, parv + 2); return 0; } @@ -264,7 +256,7 @@ CMD_FUNC(cmd_mode) "*** TS bounce for %s - %lld(ours) %lld(theirs)", chptr->chname, (long long)chptr->creationtime, (long long)sendts); - bounce_mode(chptr, cptr, parc - 2, parv + 2); + bounce_mode(chptr, sptr, parc - 2, parv + 2); } return 0; } @@ -285,7 +277,7 @@ aftercheck: /* Filter out the unprivileged FIRST. * * Now, we can actually do the mode. */ - (void)do_mode(chptr, cptr, sptr, recv_mtags, parc - 2, parv + 2, sendts, 0); + (void)do_mode(chptr, sptr, recv_mtags, parc - 2, parv + 2, sendts, 0); /* After this don't touch 'chptr' anymore, as permanent module may have destroyed the channel */ opermode = 0; /* Important since sometimes forgotten. -- Syzop */ return 0; @@ -392,7 +384,7 @@ static void bounce_mode(Channel *chptr, Client *cptr, int parc, char *parv[]) * User or server is authorized to do the mode. This takes care of * setting the mode and relaying it to other users and servers. */ -void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], time_t sendts, int samode) +void _do_mode(Channel *chptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], time_t sendts, int samode) { char pvar[MAXMODEPARAMS][MODEBUFLEN + 3]; int pcount; @@ -412,9 +404,9 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags samode_in_progress = 0; if (MyConnect(sptr)) - RunHook8(HOOKTYPE_PRE_LOCAL_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); + RunHook7(HOOKTYPE_PRE_LOCAL_CHANMODE, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); else - RunHook8(HOOKTYPE_PRE_REMOTE_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); + RunHook7(HOOKTYPE_PRE_REMOTE_CHANMODE, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); if (IsServer(sptr)) { @@ -428,9 +420,9 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags { sendto_realops( "Warning! Possible desynch: MODE for channel %s ('%s %s') has fishy timestamp (%lld) (from %s/%s)", - chptr->chname, modebuf, parabuf, (long long)sendts, cptr->name, sptr->name); + chptr->chname, modebuf, parabuf, (long long)sendts, sptr->direction->name, sptr->name); ircd_log(LOG_ERROR, "Possible desynch: MODE for channel %s ('%s %s') has fishy timestamp (%lld) (from %s/%s)", - chptr->chname, modebuf, parabuf, (long long)sendts, cptr->name, sptr->name); + chptr->chname, modebuf, parabuf, (long long)sendts, sptr->direction->name, sptr->name); } /* new chan or our timestamp is wrong */ /* now works for double-bounce prevention */ @@ -440,7 +432,7 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags { /* theirs is wrong but we let it pass anyway */ sendts = chptr->creationtime; - sendto_one(cptr, NULL, ":%s MODE %s + %lld", me.name, + sendto_one(sptr, NULL, ":%s MODE %s + %lld", me.name, chptr->chname, (long long)chptr->creationtime); } } @@ -455,11 +447,11 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags /* relay bounce time changes */ if (chptr->creationtime) { - sendto_server(cptr, 0, 0, NULL, ":%s MODE %s %s+ %lld", + sendto_server(sptr, 0, 0, NULL, ":%s MODE %s %s+ %lld", me.name, chptr->chname, isbounce ? "&" : "", (long long)chptr->creationtime); } else { - sendto_server(cptr, 0, 0, NULL, ":%s MODE %s %s+", + sendto_server(sptr, 0, 0, NULL, ":%s MODE %s %s+", me.name, chptr->chname, isbounce ? "&" : ""); } free_message_tags(mtags); @@ -511,7 +503,7 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags if (IsServer(sptr) && sendts != -1) { - sendto_server(cptr, 0, 0, mtags, + sendto_server(sptr, 0, 0, mtags, ":%s MODE %s %s%s %s %lld", sptr->name, chptr->chname, isbounce ? "&" : "", modebuf, parabuf, @@ -520,12 +512,12 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags if (samode && IsMe(sptr)) { /* SAMODE is a special case: always send a TS of 0 (omitting TS==desynch) */ - sendto_server(cptr, 0, 0, mtags, + sendto_server(sptr, 0, 0, mtags, ":%s MODE %s %s %s 0", sptr->name, chptr->chname, modebuf, parabuf); } else { - sendto_server(cptr, 0, 0, mtags, + sendto_server(sptr, 0, 0, mtags, ":%s MODE %s %s%s %s", sptr->name, chptr->chname, isbounce ? "&" : "", modebuf, parabuf); /* tell them it's not a timestamp, in case the last param @@ -533,9 +525,9 @@ void _do_mode(Channel *chptr, Client *cptr, Client *sptr, MessageTag *recv_mtags } if (MyConnect(sptr)) - RunHook8(HOOKTYPE_LOCAL_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); + RunHook7(HOOKTYPE_LOCAL_CHANMODE, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); else - RunHook8(HOOKTYPE_REMOTE_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); + RunHook7(HOOKTYPE_REMOTE_CHANMODE, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); /* After this, don't touch 'chptr' anymore! As permanent module may have destroyed the channel. */ @@ -921,8 +913,7 @@ process_listmode: { char errbuf[NICKLEN+30]; ircsnprintf(errbuf, sizeof(errbuf), "%s is a channel owner", member->cptr->name); - sendnumeric(cptr, ERR_CANNOTCHANGECHANMODE, - modechar, errbuf); + sendnumeric(cptr, ERR_CANNOTCHANGECHANMODE, modechar, errbuf); break; } } else { @@ -948,8 +939,7 @@ process_listmode: { char errbuf[NICKLEN+30]; ircsnprintf(errbuf, sizeof(errbuf), "%s is a channel admin", member->cptr->name); - sendnumeric(cptr, ERR_CANNOTCHANGECHANMODE, - modechar, errbuf); + sendnumeric(cptr, ERR_CANNOTCHANGECHANMODE, modechar, errbuf); break; } } else { @@ -1672,7 +1662,7 @@ CMD_FUNC(_cmd_umode) { sendto_realops("QUARANTINE: Oper %s on server %s killed, due to quarantine", sptr->name, sptr->srvptr->name); sendto_server(NULL, 0, 0, NULL, ":%s KILL %s :%s (Quarantined: no oper privileges allowed)", me.name, sptr->name, me.name); - return exit_client(cptr, sptr, &me, NULL, "Quarantined: no oper privileges allowed"); + return exit_client(sptr->direction, sptr, &me, NULL, "Quarantined: no oper privileges allowed"); } /* A local user trying to set himself +o/+O is denied here. * A while later (outside this loop) it is handled as well (and +C, +N, etc too) @@ -1808,7 +1798,7 @@ CMD_FUNC(_cmd_umode) ((oldumodes & UMODE_SETHOST) && !IsSetHost(sptr) && IsHidden(sptr))) { if (!dontspread) - sendto_server(cptr, PROTO_VHP, 0, NULL, ":%s SETHOST :%s", + sendto_server(sptr, PROTO_VHP, 0, NULL, ":%s SETHOST :%s", sptr->name, sptr->user->virthost); /* Set the vhost */ @@ -1885,7 +1875,7 @@ CMD_FUNC(_cmd_umode) if (oldumodes != sptr->umodes) RunHook3(HOOKTYPE_UMODE_CHANGE, sptr, oldumodes, sptr->umodes); if (dontspread == 0) - send_umode_out(cptr, sptr, oldumodes); + send_umode_out(sptr, 1, oldumodes); if (MyConnect(sptr) && setsnomask != sptr->user->snomask) sendnumeric(sptr, RPL_SNOMASK, get_sno_str(sptr)); @@ -1913,7 +1903,7 @@ CMD_FUNC(cmd_mlock) return 0; if (IsServer(sptr)) - set_channel_mlock(cptr, sptr, chptr, parv[3], TRUE); + set_channel_mlock(sptr, chptr, parv[3], TRUE); return 0; } diff --git a/src/modules/motd.c b/src/modules/motd.c index 4814b0de5..c37f9897d 100644 --- a/src/modules/motd.c +++ b/src/modules/motd.c @@ -67,7 +67,7 @@ CMD_FUNC(cmd_motd) if (IsServer(sptr)) return 0; - if (hunt_server(cptr, sptr, recv_mtags, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s MOTD :%s", 1, parc, parv) != HUNTED_ISME) { if (MyUser(sptr)) sptr->local->since += 15; diff --git a/src/modules/netinfo.c b/src/modules/netinfo.c index b371a2b29..e6b004ee2 100644 --- a/src/modules/netinfo.c +++ b/src/modules/netinfo.c @@ -77,9 +77,13 @@ CMD_FUNC(cmd_netinfo) if (parc < 9) return 0; - if (IsNetInfo(cptr)) + /* Only allow from directly connected servers */ + if (!MyConnect(sptr)) + return 0; + + if (IsNetInfo(sptr)) { - sendto_realops("Already got NETINFO from Link %s", cptr->name); + sendto_realops("Already got NETINFO from Link %s", sptr->name); return 0; } @@ -93,7 +97,7 @@ CMD_FUNC(cmd_netinfo) { irccounts.global_max = lmax; sendto_realops("Max Global Count is now %li (set by link %s)", - lmax, cptr->name); + lmax, sptr->name); } xx = TStime(); @@ -106,38 +110,38 @@ CMD_FUNC(cmd_netinfo) } sendto_realops ("Possible negative TS split at link %s (%lld - %lld = %lld)%s", - cptr->name, (long long)(xx), (long long)(endsync), (long long)(xx - endsync), emsg); + sptr->name, (long long)(xx), (long long)(endsync), (long long)(xx - endsync), emsg); sendto_server(&me, 0, 0, NULL, ":%s SMO o :\2(sync)\2 Possible negative TS split at link %s (%lld - %lld = %lld)%s", - me.name, cptr->name, (long long)(xx), (long long)(endsync), (long long)(xx - endsync), emsg); + me.name, sptr->name, (long long)(xx), (long long)(endsync), (long long)(xx - endsync), emsg); } sendto_realops ("Link %s -> %s is now synced [secs: %lld recv: %ld.%hu sent: %ld.%hu]", - cptr->name, me.name, (long long)(TStime() - endsync), sptr->local->receiveK, + sptr->name, me.name, (long long)(TStime() - endsync), sptr->local->receiveK, sptr->local->receiveB, sptr->local->sendK, sptr->local->sendB); sendto_server(&me, 0, 0, NULL, ":%s SMO o :\2(sync)\2 Link %s -> %s is now synced [secs: %lld recv: %ld.%hu sent: %ld.%hu]", - me.name, cptr->name, me.name, (long long)(TStime() - endsync), sptr->local->receiveK, + me.name, sptr->name, me.name, (long long)(TStime() - endsync), sptr->local->receiveK, sptr->local->receiveB, sptr->local->sendK, sptr->local->sendB); if (!(strcmp(ircnetwork, parv[8]) == 0)) { sendto_realops("Network name mismatch from link %s (%s != %s)", - cptr->name, parv[8], ircnetwork); + sptr->name, parv[8], ircnetwork); sendto_server(&me, 0, 0, NULL, ":%s SMO o :\2(sync)\2 Network name mismatch from link %s (%s != %s)", - me.name, cptr->name, parv[8], ircnetwork); + me.name, sptr->name, parv[8], ircnetwork); } if ((protocol != UnrealProtocol) && (protocol != 0)) { sendto_realops ("Link %s is running Protocol u%li while we are running %d!", - cptr->name, protocol, UnrealProtocol); + sptr->name, protocol, UnrealProtocol); sendto_server(&me, 0, 0, NULL, ":%s SMO o :\2(sync)\2 Link %s is running u%li while %s is running %d!", - me.name, cptr->name, protocol, me.name, UnrealProtocol); + me.name, sptr->name, protocol, me.name, UnrealProtocol); } strlcpy(buf, CLOAK_KEYCRC, sizeof(buf)); @@ -145,8 +149,8 @@ CMD_FUNC(cmd_netinfo) { sendto_realops ("Link %s has a DIFFERENT CLOAK KEY - %s != %s. \002YOU SHOULD CORRECT THIS ASAP\002.", - cptr->name, parv[4], buf); + sptr->name, parv[4], buf); } - SetNetInfo(cptr); + SetNetInfo(sptr); return 0; } diff --git a/src/modules/nick.c b/src/modules/nick.c index 453ef798f..f9da3e846 100644 --- a/src/modules/nick.c +++ b/src/modules/nick.c @@ -36,8 +36,8 @@ ModuleHeader MOD_HEADER /* Forward declarations */ CMD_FUNC(cmd_nick); CMD_FUNC(cmd_uid); -int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip); -int AllowClient(Client *cptr, struct hostent *hp, char *sockhost, char *username); +int _register_user(Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip); +int AllowClient(Client *cptr, struct hostent *hp, char *sockhost, char *username); int check_client(Client *cptr, char *username); MOD_TEST() @@ -95,7 +95,7 @@ void nick_collision(Client *cptr, char *newnick, char *newid, Client *new, Clien (type == NICKCOL_EQUAL) ? "None (equal)" : ((type == NICKCOL_NEW_WON) ? "New won" : "Existing won"), new ? "nick-change" : "new user connecting"); - new_server = cptr->name; // not correct, should be sptr + new_server = cptr->name; existing_server = (existing == existing->direction) ? me.name : existing->direction->name; if (type == NICKCOL_EXISTING_WON) snprintf(comment, sizeof(comment), "Nick collision: %s <- %s", new_server, existing_server); @@ -104,6 +104,9 @@ void nick_collision(Client *cptr, char *newnick, char *newid, Client *new, Clien else snprintf(comment, sizeof(comment), "Nick collision: %s <-> %s", existing_server, new_server); + /* We only care about the direction from this point, not about the originally sending server */ + cptr = cptr->direction; + if ((type == NICKCOL_EQUAL) || (type == NICKCOL_EXISTING_WON)) { /* Kill 'new': @@ -264,9 +267,9 @@ CMD_FUNC(cmd_uid) int ishold; Client *acptr, *serv = NULL; Client *acptrs; - char nick[NICKLEN + 2]; + char nick[NICKLEN + 2]; // FIXME: why +2 and not +1? long lastnick = 0l; - int differ = 1; + int differ = 1; if (parc < 13) { @@ -274,100 +277,56 @@ CMD_FUNC(cmd_uid) return 0; } - if (!IsServer(cptr)) - strlcpy(nick, parv[1], iConf.nick_length + 1); - else - strlcpy(nick, parv[1], NICKLEN + 1); - - /* For a local clients, do proper nickname checking via do_nick_name() - * and reject the nick if it returns false. - * For remote clients, do a quick check by using do_remote_nick_name(), - * if this returned false then reject and kill it. -- Syzop + /* It's not just the directly attached client which must be a + * server. The source itself needs to be a server. */ - if (IsServer(cptr) && !do_remote_nick_name(nick)) + if (!IsServer(sptr)) + { + sendnumeric(sptr, ERR_NOTFORUSERS, "UID"); + return 0; + } + + strlcpy(nick, parv[1], NICKLEN + 1); + + /* Do some *MINIMAL* nick name checking for remote nicknames. + * This will only catch things that severely break things. -- Syzop + */ + if (!do_remote_nick_name(nick)) { sendnumeric(sptr, ERR_ERRONEUSNICKNAME, parv[1], "Illegal characters"); - if (IsServer(cptr)) - { - ircstats.is_kill++; - sendto_umode(UMODE_OPER, "Bad Nick: %s From: %s %s", - parv[1], sptr->name, get_client_name(cptr, FALSE)); - sendto_one(cptr, NULL, ":%s KILL %s :%s (%s <- %s[%s])", - me.name, parv[1], me.name, parv[1], - nick, cptr->name); - if (sptr != cptr) - { - /* bad nick change */ - MessageTag *mtags = NULL; - int n; - - new_message(sptr, NULL, &mtags); - - sendto_server(cptr, 0, 0, mtags, - ":%s KILL %s :%s (%s <- %s!%s@%s)", - me.name, sptr->name, me.name, - get_client_name(cptr, FALSE), - sptr->name, - sptr->user ? sptr->ident : "", - sptr->user ? sptr->user->server : - cptr->name); - SetKilled(sptr); - n = exit_client(cptr, sptr, &me, mtags, "BadNick"); - - free_message_tags(mtags); - - return n; - } - } + ircstats.is_kill++; + sendto_umode(UMODE_OPER, "Bad Nick: %s From: %s %s", + parv[1], sptr->name, get_client_name(sptr, FALSE)); + /* Send kill to uplink only, hasn't been broadcasted to the rest, anyway */ + sendto_one(sptr, NULL, ":%s KILL %s :%s (%s <- %s[%s])", + me.name, parv[1], me.name, parv[1], + nick, sptr->name); return 0; } /* Kill quarantined opers early... */ - if (IsServer(cptr) && IsQuarantined(sptr->direction) && - (parc >= 11) && strchr(parv[8], 'o')) + if (IsQuarantined(sptr->direction) && strchr(parv[8], 'o')) { ircstats.is_kill++; /* Send kill to uplink only, hasn't been broadcasted to the rest, anyway */ - sendto_one(cptr, NULL, ":%s KILL %s :%s (Quarantined: no oper privileges allowed)", + sendto_one(sptr, NULL, ":%s KILL %s :%s (Quarantined: no oper privileges allowed)", me.name, parv[1], me.name); sendto_realops("QUARANTINE: Oper %s on server %s killed, due to quarantine", parv[1], sptr->name); - /* (nothing to exit_client or to free, since user was never added) */ return 0; } - /* - ** Protocol 4 doesn't send the server as prefix, so it is possible - ** the server doesn't exist (a lagged net.burst), in which case - ** we simply need to ignore the NICK. Also when we got that server - ** name (again) but from another direction. --Run - */ - /* - ** We should really only deal with this for msgs from servers. - ** -- Aeto - */ - if (IsServer(cptr) && - (parc > 7 - && (!(serv = find_server(sptr->name, NULL)) - || serv->direction != cptr->direction))) - { - sendto_realops("Cannot find SID for %s (%s)", sptr->name, - backupbuf); - return 0; - } - - /* - ** Check for a Q-lined nickname. If we find it, and it's our - ** client, just reject it. -Lefler - ** Allow opers to use Q-lined nicknames. -Russell - */ + /* This one is never allowed, even from remotes */ if (!strcasecmp("ircd", nick) || !strcasecmp("irc", nick)) { - sendnumeric(sptr, ERR_ERRONEUSNICKNAME, nick, - "Reserved for internal IRCd purposes"); + sendnumeric(sptr, ERR_ERRONEUSNICKNAME, nick, "Reserved for internal IRCd purposes"); + sendto_one(sptr, NULL, ":%s KILL %s :%s (%s <- %s[%s])", + me.name, parv[1], me.name, parv[1], + nick, sptr->name); return 0; } + if (!IsULine(sptr) && (tklban = find_qline(sptr, nick, &ishold))) { if (IsServer(sptr) && !ishold) /* server introducing new client */ @@ -380,49 +339,28 @@ CMD_FUNC(cmd_uid) && !IsServer(sptr) ? sptr->name : ""), acptrs ? acptrs->name : "unknown server"); } - - if (IsServer(cptr) && IsUser(sptr) && !ishold) /* remote user changing nick */ - { - sendto_snomask(SNO_QLINE, "Q-Lined nick %s from %s on %s", nick, - sptr->name, sptr->srvptr ? sptr->srvptr->name : ""); - } } - /* - ** acptr already has result from previous find_server() - */ + /* Now check if 'nick' already exists - first, collisions with server names/ids (extremely rare) */ if ((acptr = find_server(nick, NULL)) != NULL) { - /* - ** We have a nickname trying to use the same name as - ** a server. Send out a nick collision KILL to remove - ** the nickname. As long as only a KILL is sent out, - ** there is no danger of the server being disconnected. - ** Ultimate way to jupiter a nick ? >;-). -avalon - */ sendto_umode(UMODE_OPER, "Nick collision on %s(%s <- %s)", sptr->name, acptr->direction->name, - get_client_name(cptr, FALSE)); + get_client_name(sptr, FALSE)); ircstats.is_kill++; - sendto_one(cptr, NULL, ":%s KILL %s :%s (%s <- %s)", + sendto_one(sptr, NULL, ":%s KILL %s :%s (%s <- %s)", me.name, sptr->name, me.name, acptr->direction->name, - /* NOTE: Cannot use get_client_name - ** twice here, it returns static - ** string pointer--the other info - ** would be lost - */ - get_client_name(cptr, FALSE)); + get_client_name(sptr, FALSE)); SetKilled(sptr); - return exit_client(cptr, sptr, &me, NULL, "Nick/Server collision"); + return exit_client(sptr->direction, sptr, &me, NULL, "Nick/Server collision"); } + /* Now check if 'nick' already exists - collision with a user (or still in handshake, unknown) */ if ((acptr = find_client(nick, NULL)) != NULL) { - /* - ** A new NICK being introduced by a neighbouring - ** server (e.g. message type "NICK new" received) + /* If there's a collision with a user that is still in handshake, on our side, + * then we can just kill our client and continue. */ - if (MyConnect(acptr) && IsUnknown(acptr)) { SetKilled(acptr); @@ -430,33 +368,11 @@ CMD_FUNC(cmd_uid) goto nickkill2done; } - if (acptr->user == NULL) - { - /* This is a Bad Thing */ - sendto_umode(UMODE_OPER, "Lost user field for %s in change from %s", - acptr->name, get_client_name(cptr, FALSE)); - ircstats.is_kill++; - sendto_one(acptr, NULL, ":%s KILL %s :%s (Lost user field!)", - me.name, acptr->name, me.name); - SetKilled(acptr); - /* Here's the previous versions' desynch. If the old one is - messed up, trash the old one and accept the new one. - Remember - at this point there is a new nick coming in! - Handle appropriately. -- Barubary */ - exit_client(NULL, acptr, &me, NULL, "Lost user field"); - goto nickkill2done; - } - - if (parc > 3) - { - lastnick = atol(parv[3]); - if (parc > 5) - differ = (mycmp(acptr->user->username, parv[4]) - || mycmp(acptr->user->realhost, parv[5])); - } + lastnick = atol(parv[3]); + differ = (mycmp(acptr->user->username, parv[4]) || mycmp(acptr->user->realhost, parv[5])); sendto_umode(UMODE_OPER, "Nick collision on %s (%s %lld <- %s %lld)", acptr->name, acptr->direction->name, (long long)acptr->lastnick, - cptr->name, (long long)lastnick); + sptr->direction->name, (long long)lastnick); /* ** I'm putting the KILL handling here just to make it easier ** to read, it's hard to follow it the way it used to be. @@ -470,69 +386,48 @@ CMD_FUNC(cmd_uid) ** would kill their user. Not anymore. ** -- binary */ - if (!(parc > 3) || (acptr->lastnick == lastnick)) + if (acptr->lastnick == lastnick) { - nick_collision(cptr, parv[1], ((parc > 6) ? parv[6] : NULL), NULL, acptr, NICKCOL_EQUAL); + nick_collision(sptr, parv[1], ((parc > 6) ? parv[6] : NULL), NULL, acptr, NICKCOL_EQUAL); return 0; /* We killed both users, now stop the process. */ } if ((differ && (acptr->lastnick > lastnick)) || - (!differ && (acptr->lastnick < lastnick)) || acptr->direction == cptr) /* we missed a QUIT somewhere ? */ + (!differ && (acptr->lastnick < lastnick)) || acptr->direction == sptr->direction) /* we missed a QUIT somewhere ? */ { - nick_collision(cptr, parv[1], ((parc > 6) ? parv[6] : NULL), NULL, acptr, NICKCOL_NEW_WON); + nick_collision(sptr, parv[1], ((parc > 6) ? parv[6] : NULL), NULL, acptr, NICKCOL_NEW_WON); /* We got rid of the "wrong" user. Introduce the correct one. */ /* ^^ hmm.. why was this absent in nenolod's code, resulting in a 'return 0'? seems wrong. */ goto nickkill2done; } - if ((differ && (acptr->lastnick < lastnick)) || - (!differ && (acptr->lastnick > lastnick))) + if ((differ && (acptr->lastnick < lastnick)) || (!differ && (acptr->lastnick > lastnick))) { - nick_collision(cptr, parv[1], ((parc > 6) ? parv[6] : NULL), NULL, acptr, NICKCOL_EXISTING_WON); + nick_collision(sptr, parv[1], ((parc > 6) ? parv[6] : NULL), NULL, acptr, NICKCOL_EXISTING_WON); return 0; /* Ignore the NICK */ } return 0; /* just in case */ } nickkill2done: - if (IsServer(sptr)) - { - /* A server introducing a new client, change source */ + /* Proceed with introducing the new client, change source (replace sptr) */ - if (serv == NULL) - serv = sptr; - sptr = make_client(cptr, serv); - strlcpy(sptr->id, parv[6], IDLEN); - add_client_to_list(sptr); - add_to_id_hash_table(sptr->id, sptr); - if (parc > 2) - sptr->hopcount = atol(parv[2]); - if (parc > 3) - sptr->lastnick = atol(parv[3]); - else /* Little bit better, as long as not all upgraded */ - sptr->lastnick = TStime(); - if (sptr->lastnick < 0) - { - sendto_realops - ("Negative timestamp recieved from %s, resetting to TStime (%s)", - cptr->name, backupbuf); - sptr->lastnick = TStime(); - } - } + serv = sptr; + sptr = make_client(serv->direction, serv); + strlcpy(sptr->id, parv[6], IDLEN); + add_client_to_list(sptr); + add_to_id_hash_table(sptr->id, sptr); + sptr->lastnick = atol(parv[3]); + strlcpy(sptr->name, nick, NICKLEN+1); + add_to_client_hash_table(nick, sptr); - (void)strlcpy(sptr->name, nick, NICKLEN+1); - (void)add_to_client_hash_table(nick, sptr); - - if (IsServer(cptr) && parc > 7) - { - /* XXX: we need to split this out into register_remote_user() or something. */ - parv[3] = nick; - parv[6] = sptr->name; - if (do_cmd(cptr, sptr, recv_mtags, "USER", parc - 3, &parv[3]) == FLUSH_BUFFER) - return FLUSH_BUFFER; - if (IsNetInfo(cptr) && !IsULine(sptr)) - sendto_fconnectnotice(sptr, 0, NULL); - } + /* FIXME: we need to split this out into register_remote_user() or something. */ + parv[3] = nick; + parv[6] = sptr->name; + if (do_cmd(sptr, recv_mtags, "USER", parc - 3, &parv[3]) == FLUSH_BUFFER) + return FLUSH_BUFFER; + if (!IsULine(serv) && IsSynched(serv)) + sendto_fconnectnotice(sptr, 0, NULL); RunHook(HOOKTYPE_REMOTE_CONNECT, sptr); @@ -577,6 +472,7 @@ CMD_FUNC(cmd_nick) Hook *h; int i = 0; char *nickid = (IsUser(sptr) && *sptr->id) ? sptr->id : NULL; + Client *cptr = sptr->direction; /* Pending a complete overhaul... (TODO) */ /* * If the user didn't specify a nickname, complain */ @@ -637,7 +533,7 @@ CMD_FUNC(cmd_nick) new_message(sptr, NULL, &mtags); - sendto_server(cptr, 0, 0, mtags, + sendto_server(sptr, 0, 0, mtags, ":%s KILL %s :%s (%s <- %s!%s@%s)", me.name, sptr->name, me.name, get_client_name(cptr, FALSE), @@ -911,14 +807,14 @@ CMD_FUNC(cmd_nick) */ if (!(parc > 3) || (acptr->lastnick == lastnick)) { - nick_collision(cptr, parv[1], nickid, NULL, acptr, NICKCOL_EQUAL); + nick_collision(sptr, parv[1], nickid, NULL, acptr, NICKCOL_EQUAL); return 0; /* We killed both users, now stop the process. */ } if ((differ && (acptr->lastnick > lastnick)) || (!differ && (acptr->lastnick < lastnick)) || acptr->direction == cptr) /* we missed a QUIT somewhere ? */ { - nick_collision(cptr, parv[1], nickid, NULL, acptr, NICKCOL_NEW_WON); + nick_collision(sptr, parv[1], nickid, NULL, acptr, NICKCOL_NEW_WON); /* OK, we got rid of the "wrong" user, now we're going to add the * user the other server introduced. */ @@ -928,7 +824,7 @@ CMD_FUNC(cmd_nick) if ((differ && (acptr->lastnick < lastnick)) || (!differ && (acptr->lastnick > lastnick))) { - nick_collision(cptr, parv[1], nickid, NULL, acptr, NICKCOL_EXISTING_WON); + nick_collision(sptr, parv[1], nickid, NULL, acptr, NICKCOL_EXISTING_WON); return 0; /* Ignore the NICK. */ } return 0; @@ -948,19 +844,19 @@ CMD_FUNC(cmd_nick) sptr->direction->name, (long long)lastnick); if (!(parc > 2) || lastnick == acptr->lastnick) { - nick_collision(cptr, parv[1], nickid, sptr, acptr, NICKCOL_EQUAL); + nick_collision(sptr, parv[1], nickid, sptr, acptr, NICKCOL_EQUAL); return 0; /* Now that I killed them both, ignore the NICK */ } if ((differ && (acptr->lastnick > lastnick)) || (!differ && (acptr->lastnick < lastnick))) { - nick_collision(cptr, parv[1], nickid, sptr, acptr, NICKCOL_NEW_WON); + nick_collision(sptr, parv[1], nickid, sptr, acptr, NICKCOL_NEW_WON); goto nickkilldone; /* their user won, introduce new nick */ } if ((differ && (acptr->lastnick < lastnick)) || (!differ && (acptr->lastnick > lastnick))) { - nick_collision(cptr, parv[1], nickid, sptr, acptr, NICKCOL_EXISTING_WON); + nick_collision(sptr, parv[1], nickid, sptr, acptr, NICKCOL_EXISTING_WON); return 0; /* their user lost, ignore the NICK */ } @@ -1048,7 +944,7 @@ CMD_FUNC(cmd_nick) sendto_snomask(SNO_FNICKCHANGE, "*** %s (%s@%s) has changed their nickname to %s", sptr->name, sptr->user->username, sptr->user->realhost, nick); - RunHook3(HOOKTYPE_REMOTE_NICKCHANGE, cptr, sptr, nick); + RunHook2(HOOKTYPE_REMOTE_NICKCHANGE, sptr, nick); } /* * Client just changing their nick. If he/she is @@ -1068,9 +964,9 @@ CMD_FUNC(cmd_nick) } add_history(sptr, 1); new_message(sptr, recv_mtags, &mtags); - sendto_server(cptr, PROTO_SID, 0, mtags, ":%s NICK %s %lld", + sendto_server(sptr, PROTO_SID, 0, mtags, ":%s NICK %s %lld", ID(sptr), nick, (long long)sptr->lastnick); - sendto_server(cptr, 0, PROTO_SID, mtags, ":%s NICK %s %lld", + sendto_server(sptr, 0, PROTO_SID, mtags, ":%s NICK %s %lld", sptr->name, nick, (long long)sptr->lastnick); sendto_local_common_channels(sptr, NULL, 0, mtags, ":%s NICK :%s", sptr->name, nick); free_message_tags(mtags); @@ -1107,7 +1003,7 @@ CMD_FUNC(cmd_nick) me.name, nick); sptr->lastnick = TStime(); - if (register_user(cptr, sptr, nick, sptr->user->username, NULL, NULL, NULL) == FLUSH_BUFFER) + if (register_user(sptr, nick, sptr->user->username, NULL, NULL, NULL) == FLUSH_BUFFER) return FLUSH_BUFFER; strlcpy(nick, sptr->name, sizeof(nick)); /* don't ask, but I need this. do not remove! -- Syzop */ update_watch = 0; @@ -1136,9 +1032,9 @@ CMD_FUNC(cmd_nick) if (IsServer(cptr) && parc > 7) { parv[3] = nick; - if (do_cmd(cptr, sptr, recv_mtags, "USER", parc - 3, &parv[3]) == FLUSH_BUFFER) + if (do_cmd(sptr, recv_mtags, "USER", parc - 3, &parv[3]) == FLUSH_BUFFER) return FLUSH_BUFFER; - if (IsNetInfo(cptr) && !IsULine(sptr)) + if (IsNetInfo(cptr) && !IsULine(sptr)) // FIXME: use IsSynced here too to match cmd_uid sendto_fconnectnotice(sptr, 0, NULL); } else if (IsUser(sptr) && update_watch) @@ -1180,7 +1076,7 @@ CMD_FUNC(cmd_nick) extern int short_motd(Client *sptr); -int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip) +int _register_user(Client *sptr, char *nick, char *username, char *umode, char *virthost, char *ip) { ConfigItem_ban *bconf; char *tmpstr; @@ -1203,7 +1099,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char }; TKL *savetkl = NULL; ConfigItem_tld *tlds; - cptr->local->last = TStime(); + nick = sptr->name; /* <- The data is always the same, but the pointer is sometimes not, * I need this for one of my modules, so do not remove! ;) -- Syzop */ @@ -1219,7 +1115,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char * so have a generic exit_client() here to be safe. */ if (i != FLUSH_BUFFER) - return exit_client(cptr, sptr, &me, NULL, "Rejected"); + return exit_client(sptr->direction, sptr, &me, NULL, "Rejected"); return FLUSH_BUFFER; } @@ -1316,7 +1212,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char { if (stripuser[0] == '\0') { - return exit_client(cptr, cptr, cptr, NULL, "Hostile username. Please use only 0-9 a-z A-Z _ - and . in your username."); + return exit_client(sptr, sptr, sptr, NULL, "Hostile username. Please use only 0-9 a-z A-Z _ - and . in your username."); } strlcpy(olduser, user->username + noident, USERLEN+1); @@ -1431,7 +1327,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char char *parv[2]; parv[0] = sptr->name; parv[1] = NULL; - if (do_cmd(sptr, sptr, NULL, "LUSERS", 1, parv) == FLUSH_BUFFER) + if (do_cmd(sptr, NULL, "LUSERS", 1, parv) == FLUSH_BUFFER) return FLUSH_BUFFER; } @@ -1454,16 +1350,15 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char if (u1) sendnumeric(sptr, ERR_HOSTILENAME, olduser, userbad, stripuser); } - else if (IsServer(cptr)) + else if (IsServer(sptr)) { Client *acptr; if (!(acptr = find_server_quick(user->server))) { - sendto_ops - ("Bad USER [%s] :%s USER %s %s : No such server", - cptr->name, nick, user->username, user->server); - sendto_one(cptr, NULL, ":%s KILL %s :%s (No such server: %s)", + sendto_ops("Bad USER [%s] :%s USER %s %s : No such server", + sptr->name, nick, user->username, user->server); + sendto_one(sptr, NULL, ":%s KILL %s :%s (No such server: %s)", me.name, sptr->name, me.name, user->server); SetKilled(sptr); return exit_client(sptr, sptr, &me, NULL, @@ -1472,19 +1367,19 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char else if (acptr->direction != sptr->direction) { sendto_ops("Bad User [%s] :%s USER %s %s, != %s[%s]", - cptr->name, nick, user->username, user->server, + sptr->name, nick, user->username, user->server, acptr->name, acptr->direction->name); - sendto_one(cptr, NULL, ":%s KILL %s :%s (%s != %s[%s])", + sendto_one(sptr, NULL, ":%s KILL %s :%s (%s != %s[%s])", me.name, sptr->name, me.name, user->server, acptr->direction->name, acptr->direction->local->sockhost); SetKilled(sptr); return exit_client(sptr, sptr, &me, NULL, "USER server wrong direction"); - } - else + } else + { sptr->flags |= acptr->flags; - /* *FINALL* this gets in ircd... -- Barubary */ - /* We change this a bit .. */ + } + if (IsULine(sptr->srvptr)) SetULine(sptr); } @@ -1521,7 +1416,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char tkllayer[2] = umode; tkllayer[3] = NULL; dontspread = 1; - do_cmd(cptr, sptr, NULL, "MODE", 3, tkllayer); + do_cmd(sptr, NULL, "MODE", 3, tkllayer); dontspread = 0; /* Set the vhost */ @@ -1530,10 +1425,10 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char } hash_check_watch(sptr, RPL_LOGON); /* Uglier hack */ - send_umode(NULL, sptr, 0, SEND_UMODES|UMODE_SERVNOTICE, buf); + build_umode_string(sptr, 0, SEND_UMODES|UMODE_SERVNOTICE, buf); /* NICKv2 Servers ! */ - sendto_serv_butone_nickcmd(cptr, sptr, (*buf == '\0' ? "+" : buf)); + sendto_serv_butone_nickcmd(sptr->direction, sptr, (*buf == '\0' ? "+" : buf)); if (MyConnect(sptr)) { @@ -1563,8 +1458,8 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char NickServ, SERVICES_NAME, sptr->local->passwd); } if (buf[0] != '\0' && buf[1] != '\0') - sendto_one(cptr, NULL, ":%s MODE %s :%s", cptr->name, - cptr->name, buf); + sendto_one(sptr, NULL, ":%s MODE %s :%s", sptr->name, + sptr->name, buf); if (user->snomask) sendnumeric(sptr, RPL_SNOMASK, get_snostr(user->snomask)); @@ -1602,7 +1497,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char tlds->channel, NULL }; - if (do_cmd(sptr, sptr, NULL, "JOIN", 3, chans) == FLUSH_BUFFER) + if (do_cmd(sptr, NULL, "JOIN", 3, chans) == FLUSH_BUFFER) return FLUSH_BUFFER; } else if (!BadPtr(AUTO_JOIN_CHANS) && strcmp(AUTO_JOIN_CHANS, "0")) @@ -1612,7 +1507,7 @@ int _register_user(Client *cptr, Client *sptr, char *nick, char *username, char AUTO_JOIN_CHANS, NULL }; - if (do_cmd(sptr, sptr, NULL, "JOIN", 3, chans) == FLUSH_BUFFER) + if (do_cmd(sptr, NULL, "JOIN", 3, chans) == FLUSH_BUFFER) return FLUSH_BUFFER; } /* NOTE: If you add something here.. be sure to check the 'if (savetkl)' note above */ diff --git a/src/modules/oper.c b/src/modules/oper.c index 656ecb1e8..cb6b09b71 100644 --- a/src/modules/oper.c +++ b/src/modules/oper.c @@ -161,7 +161,7 @@ CMD_FUNC(cmd_oper) return 0; } - if (!Auth_Check(cptr, operblock->auth, password)) + if (!Auth_Check(sptr, operblock->auth, password)) { sendnumeric(sptr, ERR_PASSWDMISMATCH); if (FAILOPER_WARN) @@ -279,7 +279,7 @@ CMD_FUNC(cmd_oper) sptr->umodes |= UMODE_SERVNOTICE; } - send_umode_out(cptr, sptr, old_umodes); + send_umode_out(sptr, 1, old_umodes); sendnumeric(sptr, RPL_SNOMASK, get_sno_str(sptr)); list_add(&sptr->special_node, &oper_list); @@ -295,7 +295,7 @@ CMD_FUNC(cmd_oper) irccounts.operators++; if (SHOWOPERMOTD == 1) - (void)do_cmd(cptr, sptr, NULL, "OPERMOTD", parc, parv); + (void)do_cmd(sptr, NULL, "OPERMOTD", parc, parv); if (!BadPtr(OPER_AUTO_JOIN_CHANS) && strcmp(OPER_AUTO_JOIN_CHANS, "0")) { @@ -304,7 +304,7 @@ CMD_FUNC(cmd_oper) OPER_AUTO_JOIN_CHANS, NULL }; - if (do_cmd(cptr, sptr, NULL, "JOIN", 3, chans) == FLUSH_BUFFER) + if (do_cmd(sptr, NULL, "JOIN", 3, chans) == FLUSH_BUFFER) return FLUSH_BUFFER; } diff --git a/src/modules/part.c b/src/modules/part.c index 600c62a31..6b11e51c0 100644 --- a/src/modules/part.c +++ b/src/modules/part.c @@ -159,9 +159,9 @@ CMD_FUNC(cmd_part) new_message_special(sptr, recv_mtags, &mtags, ":%s PART %s", sptr->name, chptr->chname); /* Send to other servers... */ - sendto_server(cptr, PROTO_SID, 0, mtags, ":%s PART %s :%s", + sendto_server(sptr, PROTO_SID, 0, mtags, ":%s PART %s :%s", ID(sptr), chptr->chname, comment ? comment : ""); - sendto_server(cptr, 0, PROTO_SID, mtags, ":%s PART %s :%s", + sendto_server(sptr, 0, PROTO_SID, mtags, ":%s PART %s :%s", sptr->name, chptr->chname, comment ? comment : ""); if (invisible_user_in_channel(sptr, chptr)) @@ -212,9 +212,9 @@ CMD_FUNC(cmd_part) } if (MyUser(sptr)) - RunHook5(HOOKTYPE_LOCAL_PART, cptr, sptr, chptr, mtags, comment); + RunHook4(HOOKTYPE_LOCAL_PART, sptr, chptr, mtags, comment); else - RunHook5(HOOKTYPE_REMOTE_PART, cptr, sptr, chptr, mtags, comment); + RunHook4(HOOKTYPE_REMOTE_PART, sptr, chptr, mtags, comment); free_message_tags(mtags); diff --git a/src/modules/pass.c b/src/modules/pass.c index 012b793cb..285000327 100644 --- a/src/modules/pass.c +++ b/src/modules/pass.c @@ -115,19 +115,20 @@ CMD_FUNC(cmd_pass) { char *password = parc > 1 ? parv[1] : NULL; - if (BadPtr(password)) + if (!MyConnect(sptr) || (!IsUnknown(sptr) && !IsHandshake(sptr))) { - sendnumeric(cptr, ERR_NEEDMOREPARAMS, "PASS"); + sendnumeric(sptr, ERR_ALREADYREGISTRED); return 0; } - if (!MyConnect(sptr) || (!IsUnknown(cptr) && !IsHandshake(cptr))) + + if (BadPtr(password)) { - sendnumeric(cptr, ERR_ALREADYREGISTRED); + sendnumeric(sptr, ERR_NEEDMOREPARAMS, "PASS"); return 0; } /* Store the password */ - safe_strldup(cptr->local->passwd, password, PASSWDLEN+1); + safe_strldup(sptr->local->passwd, password, PASSWDLEN+1); /* note: the original non-truncated password is supplied as 2nd parameter. */ RunHookReturnInt2(HOOKTYPE_LOCAL_PASS, sptr, password, !=0); diff --git a/src/modules/pingpong.c b/src/modules/pingpong.c index 685947c70..772309bce 100644 --- a/src/modules/pingpong.c +++ b/src/modules/pingpong.c @@ -68,23 +68,17 @@ CMD_FUNC(cmd_ping) Client *acptr; char *origin, *destination; - if (parc < 2 || *parv[1] == '\0') + if (parc < 2 || BadPtr(parv[1])) { sendnumeric(sptr, ERR_NOORIGIN); return 0; } + origin = parv[1]; destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ if (!MyUser(sptr)) - { - /* I've no idea who invented this or what it is supposed to do.. */ - acptr = find_client(origin, NULL); - if (!acptr) - acptr = find_server_quick(origin); - if (acptr && acptr != sptr) - origin = cptr->name; - } + origin = sptr->name; if (!BadPtr(destination) && mycmp(destination, me.name) != 0 && mycmp(destination, me.id) != 0) { @@ -112,9 +106,9 @@ CMD_FUNC(cmd_nospoof) { unsigned long result; - if (IsNotSpoof(cptr)) + if (IsNotSpoof(sptr)) return 0; - if (IsRegistered(cptr)) + if (IsRegistered(sptr)) return 0; if (!*sptr->name) return 0; @@ -136,13 +130,12 @@ CMD_FUNC(cmd_nospoof) me.name, sptr->name); if (is_handshake_finished(sptr)) - return register_user(cptr, sptr, sptr->name, - sptr->user->username, NULL, NULL, NULL); + return register_user(sptr, sptr->name, sptr->user->username, NULL, NULL, NULL); return 0; temp: /* Homer compatibility */ - sendto_one(cptr, NULL, ":%X!nospoof@%s PRIVMSG %s :\1VERSION\1", - cptr->local->nospoof, me.name, cptr->name); + sendto_one(sptr, NULL, ":%X!nospoof@%s PRIVMSG %s :\1VERSION\1", + sptr->local->nospoof, me.name, sptr->name); return 0; } @@ -156,8 +149,8 @@ CMD_FUNC(cmd_pong) Client *acptr; char *origin, *destination; - if (!IsRegistered(cptr)) - return cmd_nospoof(cptr, sptr, recv_mtags, parc, parv); + if (!IsRegistered(sptr)) + return cmd_nospoof(sptr, recv_mtags, parc, parv); if (parc < 2 || *parv[1] == '\0') { @@ -168,26 +161,27 @@ CMD_FUNC(cmd_pong) origin = parv[1]; destination = parv[2]; ClearPingSent(sptr); - ClearPingSent(cptr); - ClearPingWarning(cptr); + ClearPingWarning(sptr); /* Remote pongs for clients? uhh... */ if (MyUser(sptr) || !IsRegistered(sptr)) - destination = NULL; + return 0; + /* PONG from a server - either for us, or needs relaying.. */ if (!BadPtr(destination) && mycmp(destination, me.name) != 0) { if ((acptr = find_client(destination, NULL)) || (acptr = find_server_quick(destination))) { - if (!IsServer(cptr) && !IsServer(acptr)) + if (IsUser(sptr) && !IsServer(acptr)) { sendnumeric(sptr, ERR_NOSUCHSERVER, destination); return 0; - } - else + } else + { sendto_one(acptr, NULL, ":%s PONG %s %s", sptr->name, origin, destination); + } } else { diff --git a/src/modules/protoctl.c b/src/modules/protoctl.c index 09ee68007..7916762af 100644 --- a/src/modules/protoctl.c +++ b/src/modules/protoctl.c @@ -70,7 +70,7 @@ CMD_FUNC(cmd_protoctl) if (!MyConnect(sptr)) return 0; /* Remote PROTOCTL's are not supported */ - SetProtoctlReceived(cptr); + SetProtoctlReceived(sptr); for (i = 1; i < parc; i++) { @@ -88,72 +88,72 @@ CMD_FUNC(cmd_protoctl) if (!strcmp(name, "NAMESX")) { - SetCapability(cptr, "multi-prefix"); + SetCapability(sptr, "multi-prefix"); } else if (!strcmp(name, "UHNAMES") && UHNAMES_ENABLED) { - SetCapability(cptr, "userhost-in-names"); + SetCapability(sptr, "userhost-in-names"); } else if (!strcmp(name, "NOQUIT")) { - SetNoQuit(cptr); + SetNoQuit(sptr); } else if (!strcmp(name, "SJOIN")) { - SetSJOIN(cptr); + SetSJOIN(sptr); } else if (!strcmp(name, "SJOIN2")) { - SetSJOIN2(cptr); + SetSJOIN2(sptr); } else if (!strcmp(name, "NICKv2")) { - SetNICKv2(cptr); + SetNICKv2(sptr); } else if (!strcmp(name, "UMODE2")) { - SetUMODE2(cptr); + SetUMODE2(sptr); } else if (!strcmp(name, "VL")) { - SetVL(cptr); + SetVL(sptr); } else if (!strcmp(name, "VHP")) { - SetVHP(cptr); + SetVHP(sptr); } else if (!strcmp(name, "CLK")) { - SetCLK(cptr); + SetCLK(sptr); } else if (!strcmp(name, "SJ3")) { - SetSJ3(cptr); + SetSJ3(sptr); } else if (!strcmp(name, "SJSBY") && iConf.ban_setter_sync) { - SetSJSBY(cptr); + SetSJSBY(sptr); } else if (!strcmp(name, "TKLEXT")) { - SetTKLEXT(cptr); + SetTKLEXT(sptr); } else if (!strcmp(name, "TKLEXT2")) { - SetTKLEXT2(cptr); - SetTKLEXT(cptr); /* TKLEXT is implied as well. always. */ + SetTKLEXT2(sptr); + SetTKLEXT(sptr); /* TKLEXT is implied as well. always. */ } else if (!strcmp(name, "NICKIP")) { - cptr->local->proto |= PROTO_NICKIP; + sptr->local->proto |= PROTO_NICKIP; } else if (!strcmp(name, "MTAGS")) { - SetMTAGS(cptr); + SetMTAGS(sptr); } else if (!strcmp(name, "NICKCHARS") && value) { - if (!IsServer(cptr) && !IsEAuth(cptr) && !IsHandshake(cptr)) + if (!IsServer(sptr) && !IsEAuth(sptr) && !IsHandshake(sptr)) continue; /* Ok, server is either authenticated, or is an outgoing connect... */ /* Some combinations are fatal because they would lead to mass-kills: @@ -165,50 +165,50 @@ CMD_FUNC(cmd_protoctl) snprintf(buf, sizeof(buf), "Server %s has utf8 in set::allowed-nickchars but %s does not. Link rejected.", me.name, *sptr->name ? sptr->name : "other side"); sendto_realops("\002ERROR\001 %s", buf); - return exit_client(cptr, sptr, &me, NULL, buf); + return exit_client(sptr, sptr, &me, NULL, buf); } /* We compare the character sets to see if we should warn opers about any mismatch... */ if (strcmp(value, charsys_get_current_languages())) { sendto_realops("\002WARNING!!!!\002 Link %s does not have the same set::allowed-nickchars settings (or is " "a different UnrealIRCd version), this MAY cause display issues. Our charset: '%s', theirs: '%s'", - get_client_name(cptr, FALSE), charsys_get_current_languages(), value); - /* return exit_client(cptr, cptr, &me, NULL, "Nick charset mismatch"); */ + get_client_name(sptr, FALSE), charsys_get_current_languages(), value); + /* return exit_client(sptr, sptr, &me, NULL, "Nick charset mismatch"); */ } - if (cptr->serv) - safe_strdup(cptr->serv->features.nickchars, value); + if (sptr->serv) + safe_strdup(sptr->serv->features.nickchars, value); /* If this is a runtime change (so post-handshake): */ if (IsServer(sptr)) - broadcast_sinfo(sptr, NULL, cptr); + broadcast_sinfo(sptr, NULL, sptr); } else if (!strcmp(name, "SID") && value) { - Client *acptr; + Client *asptr; char *sid = value; - if (!IsServer(cptr) && !IsEAuth(cptr) && !IsHandshake(cptr)) - return exit_client(cptr, cptr, &me, NULL, "Got PROTOCTL SID before EAUTH, that's the wrong order!"); + if (!IsServer(sptr) && !IsEAuth(sptr) && !IsHandshake(sptr)) + return exit_client(sptr, sptr, &me, NULL, "Got PROTOCTL SID before EAUTH, that's the wrong order!"); if (*sptr->id && (strlen(sptr->id)==3)) - return exit_client(cptr, cptr, &me, NULL, "Got PROTOCTL SID twice"); + return exit_client(sptr, sptr, &me, NULL, "Got PROTOCTL SID twice"); - if (IsServer(cptr)) - return exit_client(cptr, cptr, &me, NULL, "Got PROTOCTL SID after SERVER, that's the wrong order!"); + if (IsServer(sptr)) + return exit_client(sptr, sptr, &me, NULL, "Got PROTOCTL SID after SERVER, that's the wrong order!"); - if ((acptr = hash_find_id(sid, NULL)) != NULL) + if ((asptr = hash_find_id(sid, NULL)) != NULL) { - sendto_one(sptr, NULL, "ERROR :SID %s already exists from %s", acptr->id, acptr->name); + sendto_one(sptr, NULL, "ERROR :SID %s already exists from %s", asptr->id, asptr->name); sendto_snomask(SNO_SNOTICE, "Link %s rejected - SID %s already exists from %s", - get_client_name(cptr, FALSE), acptr->id, acptr->name); - return exit_client(cptr, cptr, &me, NULL, "SID collision"); + get_client_name(sptr, FALSE), asptr->id, asptr->name); + return exit_client(sptr, sptr, &me, NULL, "SID collision"); } if (*sptr->id) del_from_id_hash_table(sptr->id, sptr); /* delete old UID entry (created on connect) */ - strlcpy(cptr->id, sid, IDLEN); - add_to_id_hash_table(cptr->id, cptr); /* add SID */ - cptr->local->proto |= PROTO_SID; + strlcpy(sptr->id, sid, IDLEN); + add_to_id_hash_table(sptr->id, sptr); /* add SID */ + sptr->local->proto |= PROTO_SID; } else if (!strcmp(name, "EAUTH") && value && NEW_LINKING_PROTOCOL) { @@ -236,9 +236,9 @@ CMD_FUNC(cmd_protoctl) sendto_snomask (SNO_JUNK, "WARNING: Bogus server name (%s) from %s in EAUTH (maybe just a fishy client)", - servername ? servername : "", get_client_name(cptr, TRUE)); + servername ? servername : "", get_client_name(sptr, TRUE)); - return exit_client(cptr, sptr, &me, NULL, "Bogus server name"); + return exit_client(sptr, sptr, &me, NULL, "Bogus server name"); } @@ -252,7 +252,7 @@ CMD_FUNC(cmd_protoctl) } } - ret = verify_link(cptr, sptr, servername, &aconf); + ret = verify_link(sptr, servername, &aconf); if (ret < 0) return ret; /* FLUSH_BUFFER */ @@ -261,29 +261,29 @@ CMD_FUNC(cmd_protoctl) if (ret < 0) return ret; /* FLUSH_BUFFER */ - SetEAuth(cptr); - make_server(cptr); /* allocate and set cptr->serv */ - /* Set cptr->name but don't add to hash list. The real work on + SetEAuth(sptr); + make_server(sptr); /* allocate and set sptr->serv */ + /* Set sptr->name but don't add to hash list. The real work on * that is done in cmd_server. We just set it here for display * purposes of error messages (such as reject due to clock). */ - strlcpy(cptr->name, servername, sizeof(cptr->name)); + strlcpy(sptr->name, servername, sizeof(sptr->name)); if (protocol) - cptr->serv->features.protocol = atoi(protocol); + sptr->serv->features.protocol = atoi(protocol); if (software) - safe_strdup(cptr->serv->features.software, software); - if (!IsHandshake(cptr) && aconf) /* Send PASS early... */ + safe_strdup(sptr->serv->features.software, software); + if (!IsHandshake(sptr) && aconf) /* Send PASS early... */ sendto_one(sptr, NULL, "PASS :%s", (aconf->auth->type == AUTHTYPE_PLAINTEXT) ? aconf->auth->data : "*"); } else if (!strcmp(name, "SERVERS") && value && NEW_LINKING_PROTOCOL) { - Client *acptr, *srv; + Client *asptr, *srv; char *sid = NULL; - if (!IsEAuth(cptr)) + if (!IsEAuth(sptr)) continue; - if (cptr->serv->features.protocol < 2351) + if (sptr->serv->features.protocol < 2351) continue; /* old SERVERS= version */ /* Other side lets us know which servers are behind it. @@ -293,24 +293,24 @@ CMD_FUNC(cmd_protoctl) add_pending_net(sptr, value); - acptr = find_non_pending_net_duplicates(sptr); - if (acptr) + asptr = find_non_pending_net_duplicates(sptr); + if (asptr) { sendto_one(sptr, NULL, "ERROR :Server with SID %s (%s) already exists", - acptr->id, acptr->name); + asptr->id, asptr->name); sendto_realops("Link %s cancelled, server with SID %s (%s) already exists", - get_client_name(acptr, TRUE), acptr->id, acptr->name); + get_client_name(asptr, TRUE), asptr->id, asptr->name); return exit_client(sptr, sptr, sptr, NULL, "Server Exists (or non-unique me::sid)"); } - acptr = find_pending_net_duplicates(sptr, &srv, &sid); - if (acptr) + asptr = find_pending_net_duplicates(sptr, &srv, &sid); + if (asptr) { sendto_one(sptr, NULL, "ERROR :Server with SID %s is being introduced by another server as well. " "Just wait a moment for it to synchronize...", sid); sendto_realops("Link %s cancelled, server would introduce server with SID %s, which " "server %s is also about to introduce. Just wait a moment for it to synchronize...", - get_client_name(acptr, TRUE), sid, get_client_name(srv, TRUE)); + get_client_name(asptr, TRUE), sid, get_client_name(srv, TRUE)); return exit_client(sptr, sptr, sptr, NULL, "Server Exists (just wait a moment)"); } @@ -340,7 +340,7 @@ CMD_FUNC(cmd_protoctl) "Correct time is very important in IRC. Please " "verify the clock on both %s (them) and %s (us), " "fix it and then try linking again", - get_client_name(cptr, TRUE), + get_client_name(sptr, TRUE), (long long)(TStime() - t), sptr->name, me.name); } else @@ -356,7 +356,7 @@ CMD_FUNC(cmd_protoctl) "Correct time is very important in IRC. Please " "verify the clock on both %s (them) and %s (us), " "fix it and then try linking again", - get_client_name(cptr, TRUE), + get_client_name(sptr, TRUE), (long long)(t - TStime()), sptr->name, me.name); } @@ -370,21 +370,21 @@ CMD_FUNC(cmd_protoctl) } else if (!strcmp(name, "MLOCK")) { - cptr->local->proto |= PROTO_MLOCK; + sptr->local->proto |= PROTO_MLOCK; } else if (!strcmp(name, "CHANMODES") && value && sptr->serv) { parse_chanmodes_protoctl(sptr, value); /* If this is a runtime change (so post-handshake): */ if (IsServer(sptr)) - broadcast_sinfo(sptr, NULL, cptr); + broadcast_sinfo(sptr, NULL, sptr); } else if (!strcmp(name, "USERMODES") && value && sptr->serv) { safe_strdup(sptr->serv->features.usermodes, value); /* If this is a runtime change (so post-handshake): */ if (IsServer(sptr)) - broadcast_sinfo(sptr, NULL, cptr); + broadcast_sinfo(sptr, NULL, sptr); } else if (!strcmp(name, "BOOTED") && value && sptr->serv) { @@ -392,7 +392,7 @@ CMD_FUNC(cmd_protoctl) } else if (!strcmp(name, "EXTSWHOIS")) { - cptr->local->proto |= PROTO_EXTSWHOIS; + sptr->local->proto |= PROTO_EXTSWHOIS; } /* You can add protocol extensions here. * Use 'name' and 'value' (the latter may be NULL). @@ -402,14 +402,14 @@ CMD_FUNC(cmd_protoctl) */ } - if (first_protoctl && IsHandshake(cptr) && sptr->serv && !IsServerSent(sptr)) /* first & outgoing connection to server */ + if (first_protoctl && IsHandshake(sptr) && sptr->serv && !IsServerSent(sptr)) /* first & outgoing connection to server */ { /* SERVER message moved from completed_connection() to here due to EAUTH/SERVERS PROTOCTL stuff, * which needed to be delayed until after both sides have received SERVERS=xx (..or not.. in case * of older servers). * Actually, this is often not reached, as the PANGPANG stuff in do_numeric() is reached first. */ - send_server_message(cptr); + send_server_message(sptr); } return 0; diff --git a/src/modules/quit.c b/src/modules/quit.c index 00bc6e322..c854a4ba2 100644 --- a/src/modules/quit.c +++ b/src/modules/quit.c @@ -65,16 +65,16 @@ CMD_FUNC(cmd_quit) if (parv[1] && (strlen(comment) > iConf.quit_length)) comment[iConf.quit_length] = '\0'; - if (!IsServer(cptr) && IsUser(sptr)) + if (MyUser(sptr)) { int n; Hook *tmphook; if (STATIC_QUIT) - return exit_client(cptr, sptr, sptr, recv_mtags, STATIC_QUIT); + return exit_client(sptr->direction, sptr, sptr, recv_mtags, STATIC_QUIT); if (IsVirus(sptr)) - return exit_client(cptr, sptr, sptr, recv_mtags, "Client exited"); + return exit_client(sptr->direction, sptr, sptr, recv_mtags, "Client exited"); n = run_spamfilter(sptr, comment, SPAMF_QUIT, NULL, 0, NULL); if (n == FLUSH_BUFFER) @@ -121,7 +121,7 @@ CMD_FUNC(cmd_quit) parx[2] = newcomment; parx[3] = NULL; - ret = do_cmd(cptr, sptr, recv_mtags, "PART", newcomment ? 3 : 2, parx); + ret = do_cmd(sptr, recv_mtags, "PART", newcomment ? 3 : 2, parx); /* This would be unusual, but possible (somewhere in the future perhaps): */ if (ret == FLUSH_BUFFER) return ret; @@ -144,13 +144,13 @@ CMD_FUNC(cmd_quit) else strlcpy(commentbuf, comment, sizeof(commentbuf)); - return exit_client(cptr, sptr, sptr, recv_mtags, commentbuf); + return exit_client(sptr->direction, sptr, sptr, recv_mtags, commentbuf); } else { /* Remote quits and non-person quits always use their original comment. * Also pass recv_mtags so to keep the msgid and such. */ - return exit_client(cptr, sptr, sptr, recv_mtags, comment); + return exit_client(sptr->direction, sptr, sptr, recv_mtags, comment); } } diff --git a/src/modules/reputation.c b/src/modules/reputation.c index 4ee8daedf..830ffcb6f 100644 --- a/src/modules/reputation.c +++ b/src/modules/reputation.c @@ -788,15 +788,15 @@ CMD_FUNC(reputation_server_cmd) e = find_reputation_entry(ip); if (allow_reply && e && (e->score > score) && (e->score - score > UPDATE_SCORE_MARGIN)) { - /* We have a higher score, inform the cptr direction about it. + /* We have a higher score, inform the sptr direction about it. * This will prefix the score with a * so servers will never reply to it. */ - sendto_one(cptr, NULL, ":%s REPUTATION %s *%d", me.name, parv[1], e->score); + sendto_one(sptr, NULL, ":%s REPUTATION %s *%d", me.name, parv[1], e->score); #ifdef DEBUGMODE ircd_log(LOG_ERROR, "[reputation] Score for '%s' from %s is %d, but we have %d, sending back %d", ip, sptr->name, score, e->score, e->score); #endif - score = e->score; /* Update for propagation in the non-cptr direction */ + score = e->score; /* Update for propagation in the non-sptr direction */ } /* Update our score if sender has a higher score */ @@ -823,8 +823,8 @@ CMD_FUNC(reputation_server_cmd) add_reputation_entry(e); } - /* Propagate to the non-cptr direction (score may be updated) */ - sendto_server(cptr, 0, 0, NULL, + /* Propagate to the non-sptr direction (score may be updated) */ + sendto_server(sptr, 0, 0, NULL, ":%s REPUTATION %s %s%d", sptr->name, parv[1], @@ -837,10 +837,10 @@ CMD_FUNC(reputation_server_cmd) CMD_FUNC(reputation_cmd) { if (MyUser(sptr)) - return reputation_user_cmd(cptr, sptr, recv_mtags, parc, parv); + return reputation_user_cmd(sptr, recv_mtags, parc, parv); if (IsServer(sptr)) - return reputation_server_cmd(cptr, sptr, recv_mtags, parc, parv); + return reputation_server_cmd(sptr, recv_mtags, parc, parv); return 0; } diff --git a/src/modules/require-module.c b/src/modules/require-module.c index 45f8e712f..fdc3b66cf 100644 --- a/src/modules/require-module.c +++ b/src/modules/require-module.c @@ -476,7 +476,7 @@ CMD_FUNC(cmd_smod) if (abort) { sendto_umode_global(UMODE_OPER, "ABORTING LINK: %s <=> %s", me.name, sptr->name); - return exit_client(cptr, sptr, &me, NULL, "ABORTING LINK"); + return exit_client(sptr->direction, sptr, &me, NULL, "ABORTING LINK"); } return 0; diff --git a/src/modules/restrict-commands.c b/src/modules/restrict-commands.c index 445cc09cd..a2fa6d375 100644 --- a/src/modules/restrict-commands.c +++ b/src/modules/restrict-commands.c @@ -351,7 +351,7 @@ CMD_OVERRIDE_FUNC(rcmd_override) RestrictedCommand *rcmd; if (!MyUser(sptr) || !sptr->local || IsOper(sptr) || IsULine(sptr)) - return CallCommandOverride(ovr, cptr, sptr, recv_mtags, parc, parv); + return CallCommandOverride(ovr, sptr, recv_mtags, parc, parv); rcmd = find_restrictions_bycmd(ovr->command->cmd); if (rcmd) @@ -369,5 +369,5 @@ CMD_OVERRIDE_FUNC(rcmd_override) } // No restrictions apply, process command as normal =] - return CallCommandOverride(ovr, cptr, sptr, recv_mtags, parc, parv); + return CallCommandOverride(ovr, sptr, recv_mtags, parc, parv); } diff --git a/src/modules/rmtkl.c b/src/modules/rmtkl.c index a1ff3706c..73448f421 100644 --- a/src/modules/rmtkl.c +++ b/src/modules/rmtkl.c @@ -40,7 +40,7 @@ typedef struct { static int dump_str(Client *sptr, char **buf); static TKLType *find_TKLType_by_flag(char flag); void rmtkl_check_options(char *param, int *skipperm, int *silent); -int rmtkl_tryremove(Client *sptr, Client *cptr, TKLType *tkltype, TKL *tkl, char *uhmask, char *commentmask, int skipperm, int silent); +int rmtkl_tryremove(Client *sptr, TKLType *tkltype, TKL *tkl, char *uhmask, char *commentmask, int skipperm, int silent); CMD_FUNC(rmtkl); TKLType tkl_types[] = { @@ -134,7 +134,7 @@ void rmtkl_check_options(char *param, int *skipperm, int *silent) { *silent = 1; } -int rmtkl_tryremove(Client *sptr, Client *cptr, TKLType *tkltype, TKL *tkl, char *uhmask, char *commentmask, int skipperm, int silent) +int rmtkl_tryremove(Client *sptr, TKLType *tkltype, TKL *tkl, char *uhmask, char *commentmask, int skipperm, int silent) { if (tkl->type != tkltype->type) return 0; @@ -172,7 +172,7 @@ int rmtkl_tryremove(Client *sptr, Client *cptr, TKLType *tkltype, TKL *tkl, char if (!silent) sendnotice_tkl_del(sptr->name, tkl); - RunHook5(HOOKTYPE_TKL_DEL, cptr, sptr, tkl, NULL, NULL); + RunHook4(HOOKTYPE_TKL_DEL, sptr, tkl, NULL, NULL); if (tkl->type & TKL_SHUN) tkl_check_local_remove_shun(tkl); @@ -272,7 +272,7 @@ CMD_FUNC(rmtkl) { for (tkl = tklines_ip_hash[tklindex][tklindex2]; tkl; tkl = next) { next = tkl->next; - count += rmtkl_tryremove(sptr, cptr, tkltype, tkl, uhmask, commentmask, skipperm, silent); + count += rmtkl_tryremove(sptr, tkltype, tkl, uhmask, commentmask, skipperm, silent); } } } @@ -282,7 +282,7 @@ CMD_FUNC(rmtkl) { for (tkl = tklines[tklindex]; tkl; tkl = next) { next = tkl->next; - count += rmtkl_tryremove(sptr, cptr, tkltype, tkl, uhmask, commentmask, skipperm, silent); + count += rmtkl_tryremove(sptr, tkltype, tkl, uhmask, commentmask, skipperm, silent); } } diff --git a/src/modules/rules.c b/src/modules/rules.c index 931429afd..12de915f5 100644 --- a/src/modules/rules.c +++ b/src/modules/rules.c @@ -63,7 +63,7 @@ CMD_FUNC(cmd_rules) temp = NULL; - if (hunt_server(cptr, sptr, recv_mtags, ":%s RULES :%s", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s RULES :%s", 1, parc, parv) != HUNTED_ISME) return 0; ptr = Find_tld(sptr); diff --git a/src/modules/sajoin.c b/src/modules/sajoin.c index 46e998e98..829412004 100644 --- a/src/modules/sajoin.c +++ b/src/modules/sajoin.c @@ -220,9 +220,9 @@ CMD_FUNC(cmd_sajoin) sendto_channel(chptr, acptr, NULL, 0, 0, SEND_LOCAL, NULL, ":%s PART %s :%s", acptr->name, chptr->chname, "Left all channels"); - sendto_server(cptr, 0, 0, mtags, ":%s PART %s :Left all channels", acptr->name, chptr->chname); + sendto_server(sptr, 0, 0, mtags, ":%s PART %s :Left all channels", acptr->name, chptr->chname); if (MyConnect(acptr)) - RunHook5(HOOKTYPE_LOCAL_PART, acptr, acptr, chptr, mtags, "Left all channels"); + RunHook4(HOOKTYPE_LOCAL_PART, acptr, chptr, mtags, "Left all channels"); free_message_tags(mtags); remove_user_from_channel(acptr, chptr); } @@ -251,7 +251,7 @@ CMD_FUNC(cmd_sajoin) * Each with their own unique msgid. */ new_message(acptr, NULL, &mtags); - join_channel(chptr, acptr, acptr, mtags, flags); + join_channel(chptr, acptr, mtags, flags); if (sjmode) { opermode = 0; @@ -261,7 +261,7 @@ CMD_FUNC(cmd_sajoin) mode_args[0][1] = '\0'; mode_args[1] = acptr->name; mode_args[2] = 0; - (void)do_mode(chptr, &me, acptr, NULL, 3, mode_args, 0, 1); + (void)do_mode(chptr, acptr, NULL, 3, mode_args, 0, 1); sajoinmode = 0; safe_free(mode_args[0]); } diff --git a/src/modules/samode.c b/src/modules/samode.c index 696a7edb5..19b5541b0 100644 --- a/src/modules/samode.c +++ b/src/modules/samode.c @@ -82,7 +82,7 @@ CMD_FUNC(cmd_samode) } opermode = 0; - (void)do_mode(chptr, cptr, sptr, NULL, parc - 2, parv + 2, 0, 1); + (void)do_mode(chptr, sptr, NULL, parc - 2, parv + 2, 0, 1); return 0; } diff --git a/src/modules/sapart.c b/src/modules/sapart.c index df13f1482..b51504b74 100644 --- a/src/modules/sapart.c +++ b/src/modules/sapart.c @@ -171,7 +171,7 @@ CMD_FUNC(cmd_sapart) ircd_log(LOG_SACMDS,"SAPART: %s used SAPART to make %s part %s", sptr->name, acptr->name, parv[1]); } - (void)do_cmd(acptr, acptr, NULL, "PART", comment ? 3 : 2, parv); + (void)do_cmd(acptr, NULL, "PART", comment ? 3 : 2, parv); /* acptr may be killed now due to the part reason @ spamfilter */ } else diff --git a/src/modules/sasl.c b/src/modules/sasl.c index add311ea3..ec9b065b6 100644 --- a/src/modules/sasl.c +++ b/src/modules/sasl.c @@ -160,7 +160,7 @@ CMD_FUNC(cmd_svslogin) } /* not for us; propagate. */ - sendto_server(cptr, 0, 0, NULL, ":%s SVSLOGIN %s %s %s", + sendto_server(sptr, 0, 0, NULL, ":%s SVSLOGIN %s %s %s", sptr->name, parv[1], parv[2], parv[3]); return 0; @@ -229,7 +229,7 @@ CMD_FUNC(cmd_sasl) } /* not for us; propagate. */ - sendto_server(cptr, 0, 0, NULL, ":%s SASL %s %s %c %s %s", + sendto_server(sptr, 0, 0, NULL, ":%s SASL %s %s %c %s %s", sptr->name, parv[1], parv[2], *parv[3], parv[4], parc > 5 ? parv[5] : ""); return 0; diff --git a/src/modules/sdesc.c b/src/modules/sdesc.c index f09743d20..3103370c8 100644 --- a/src/modules/sdesc.c +++ b/src/modules/sdesc.c @@ -85,7 +85,7 @@ CMD_FUNC(cmd_sdesc) ircsnprintf(sptr->srvptr->info, sizeof(sptr->srvptr->info), "%s", parv[1]); - sendto_server(cptr, 0, 0, NULL, ":%s SDESC :%s", sptr->name, parv[1]); + sendto_server(sptr, 0, 0, NULL, ":%s SDESC :%s", sptr->name, parv[1]); if (MyConnect(sptr)) sendnotice(sptr, diff --git a/src/modules/sendsno.c b/src/modules/sendsno.c index c2986ec5b..37d2aa07d 100644 --- a/src/modules/sendsno.c +++ b/src/modules/sendsno.c @@ -79,7 +79,7 @@ CMD_FUNC(cmd_sendsno) new_message(sptr, recv_mtags, &mtags); /* Forward to others... */ - sendto_server(cptr, 0, 0, mtags, ":%s SENDSNO %s :%s", sptr->name, parv[1], parv[2]); + sendto_server(sptr, 0, 0, mtags, ":%s SENDSNO %s :%s", sptr->name, parv[1], parv[2]); for (p = sno; *p; p++) { diff --git a/src/modules/sendumode.c b/src/modules/sendumode.c index c66ec05b6..c06bbcff9 100644 --- a/src/modules/sendumode.c +++ b/src/modules/sendumode.c @@ -87,7 +87,7 @@ CMD_FUNC(cmd_sendumode) new_message(sptr, recv_mtags, &mtags); - sendto_server(IsServer(cptr) ? cptr : NULL, 0, 0, mtags, + sendto_server(sptr, 0, 0, mtags, ":%s SENDUMODE %s :%s", sptr->name, parv[1], message); for (p = parv[1]; *p; p++) diff --git a/src/modules/server.c b/src/modules/server.c index a82e418ae..78af0cd4a 100644 --- a/src/modules/server.c +++ b/src/modules/server.c @@ -28,7 +28,7 @@ void send_channel_modes_sjoin(Client *cptr, Channel *chptr); void send_channel_modes_sjoin3(Client *cptr, Channel *chptr); CMD_FUNC(cmd_server); CMD_FUNC(cmd_server_remote); -int _verify_link(Client *cptr, Client *sptr, char *servername, ConfigItem_link **link_out); +int _verify_link(Client *sptr, char *servername, ConfigItem_link **link_out); void _send_protoctl_servers(Client *sptr, int response); void _send_server_message(Client *sptr); void _introduce_user(Client *to, Client *acptr); @@ -228,29 +228,29 @@ void _send_server_message(Client *sptr) * @returns This function returns 0 on succesful auth, other values should be returned by * the calling function, as it will always be FLUSH_BUFFER due to exit_client(). */ -int _verify_link(Client *cptr, Client *sptr, char *servername, ConfigItem_link **link_out) +int _verify_link(Client *sptr, char *servername, ConfigItem_link **link_out) { char xerrmsg[256]; ConfigItem_link *link; - char *inpath = get_client_name(cptr, TRUE); + char *inpath = get_client_name(sptr, TRUE); Client *acptr = NULL, *ocptr = NULL; ConfigItem_ban *bconf; /* We set the sockhost here so you can have incoming masks based on hostnames. * Perhaps a bit late to do it here, but does anyone care? */ - if (cptr->local->hostp && cptr->local->hostp->h_name) - set_sockhost(cptr, cptr->local->hostp->h_name); + if (sptr->local->hostp && sptr->local->hostp->h_name) + set_sockhost(sptr, sptr->local->hostp->h_name); if (link_out) *link_out = NULL; strcpy(xerrmsg, "No matching link configuration"); - if (!cptr->local->passwd) + if (!sptr->local->passwd) { - sendto_one(cptr, NULL, "ERROR :Missing password"); - return exit_client(cptr, sptr, &me, NULL, "Missing password"); + sendto_one(sptr, NULL, "ERROR :Missing password"); + return exit_client(sptr, sptr, &me, NULL, "Missing password"); } /* First check if the server is in the list */ @@ -259,26 +259,26 @@ int _verify_link(Client *cptr, Client *sptr, char *servername, ConfigItem_link * goto errlink; } - if (cptr->serv && cptr->serv->conf) + if (sptr->serv && sptr->serv->conf) { /* This is an outgoing connect so we already know what link block we are - * dealing with. It's the one in: cptr->serv->conf + * dealing with. It's the one in: sptr->serv->conf */ /* Actually we still need to double check the servername to avoid confusion. */ - if (strcasecmp(servername, cptr->serv->conf->servername)) + if (strcasecmp(servername, sptr->serv->conf->servername)) { ircsnprintf(xerrmsg, sizeof(xerrmsg), "Outgoing connect from link block '%s' but server " "introduced himself as '%s'. Server name mismatch.", - cptr->serv->conf->servername, + sptr->serv->conf->servername, servername); - sendto_one(cptr, NULL, "ERROR :%s", xerrmsg); + sendto_one(sptr, NULL, "ERROR :%s", xerrmsg); sendto_ops_and_log("Outgoing link aborted to %s(%s@%s) (%s) %s", - cptr->serv->conf->servername, cptr->ident, cptr->local->sockhost, xerrmsg, inpath); - return exit_client(cptr, sptr, &me, NULL, xerrmsg); + sptr->serv->conf->servername, sptr->ident, sptr->local->sockhost, xerrmsg, inpath); + return exit_client(sptr, sptr, &me, NULL, xerrmsg); } - link = cptr->serv->conf; + link = sptr->serv->conf; goto skip_host_check; } else { /* Hunt the linkblock down ;) */ @@ -299,26 +299,26 @@ int _verify_link(Client *cptr, Client *sptr, char *servername, ConfigItem_link * goto errlink; } - link = Find_link(servername, cptr); + link = Find_link(servername, sptr); if (!link) { ircsnprintf(xerrmsg, sizeof(xerrmsg), "Server is in link block but link::incoming::mask didn't match"); errlink: /* Send the "simple" error msg to the server */ - sendto_one(cptr, NULL, + sendto_one(sptr, NULL, "ERROR :Link denied (No link block found named '%s' or link::incoming::mask did not match your IP %s) %s", - servername, GetIP(cptr), inpath); + servername, GetIP(sptr), inpath); /* And send the "verbose" error msg only to locally connected ircops */ sendto_ops_and_log("Link denied for %s(%s@%s) (%s) %s", - servername, cptr->ident, cptr->local->sockhost, xerrmsg, inpath); - return exit_client(cptr, sptr, &me, NULL, + servername, sptr->ident, sptr->local->sockhost, xerrmsg, inpath); + return exit_client(sptr, sptr, &me, NULL, "Link denied (No link block found with your server name or link::incoming::mask did not match)"); } skip_host_check: /* Now for checking passwords */ - if (!Auth_Check(cptr, link->auth, cptr->local->passwd)) + if (!Auth_Check(sptr, link->auth, sptr->local->passwd)) { /* Let's help admins a bit with a good error message in case * they mix different authentication systems (plaintext password @@ -327,8 +327,8 @@ skip_host_check: * 1. Check if our side expects a plaintext password but we did not receive one * 2. Check if our side expects a non-plaintext password but we did receive one */ - if (((link->auth->type == AUTHTYPE_PLAINTEXT) && cptr->local->passwd && !strcmp(cptr->local->passwd, "*")) || - ((link->auth->type != AUTHTYPE_PLAINTEXT) && cptr->local->passwd && strcmp(cptr->local->passwd, "*"))) + if (((link->auth->type == AUTHTYPE_PLAINTEXT) && sptr->local->passwd && !strcmp(sptr->local->passwd, "*")) || + ((link->auth->type != AUTHTYPE_PLAINTEXT) && sptr->local->passwd && strcmp(sptr->local->passwd, "*"))) { sendto_ops_and_log("Link denied for '%s' (Authentication failed due to different password types on both sides of the link) %s", servername, inpath); @@ -353,10 +353,10 @@ skip_host_check: sendto_ops_and_log("Link denied for '%s' (Authentication failed [Bad password?]) %s", servername, inpath); } - sendto_one(cptr, NULL, + sendto_one(sptr, NULL, "ERROR :Link '%s' denied (Authentication failed) %s", servername, inpath); - return exit_client(cptr, sptr, &me, NULL, + return exit_client(sptr, sptr, &me, NULL, "Link denied (Authentication failed)"); } @@ -365,25 +365,25 @@ skip_host_check: { char *errstr = NULL; - if (!IsTLS(cptr)) + if (!IsTLS(sptr)) { - sendto_one(cptr, NULL, + sendto_one(sptr, NULL, "ERROR :Link '%s' denied (Not using SSL/TLS) %s", servername, inpath); sendto_ops_and_log("Link denied for '%s' (Not using SSL/TLS and verify-certificate is on) %s", servername, inpath); - return exit_client(cptr, sptr, &me, NULL, + return exit_client(sptr, sptr, &me, NULL, "Link denied (Not using SSL/TLS)"); } - if (!verify_certificate(cptr->local->ssl, link->servername, &errstr)) + if (!verify_certificate(sptr->local->ssl, link->servername, &errstr)) { - sendto_one(cptr, NULL, + sendto_one(sptr, NULL, "ERROR :Link '%s' denied (Certificate verification failed) %s", servername, inpath); sendto_ops_and_log("Link denied for '%s' (Certificate verification failed) %s", servername, inpath); sendto_ops_and_log("Reason for certificate verification failure: %s", errstr); - return exit_client(cptr, sptr, &me, NULL, + return exit_client(sptr, sptr, &me, NULL, "Link denied (Certificate verification failed)"); } } @@ -405,10 +405,8 @@ skip_host_check: } acptr = acptr->direction; - ocptr = - (cptr->local->firsttime > acptr->local->firsttime) ? acptr : cptr; - acptr = - (cptr->local->firsttime > acptr->local->firsttime) ? cptr : acptr; + ocptr = (sptr->local->firsttime > acptr->local->firsttime) ? acptr : sptr; + acptr = (sptr->local->firsttime > acptr->local->firsttime) ? sptr : acptr; sendto_one(acptr, NULL, "ERROR :Server %s already exists from %s", servername, @@ -424,27 +422,27 @@ skip_host_check: { sendto_ops_and_log ("Cancelling link %s, banned server", - get_client_name(cptr, TRUE)); - sendto_one(cptr, NULL, "ERROR :Banned server (%s)", bconf->reason ? bconf->reason : "no reason"); - return exit_client(cptr, cptr, &me, NULL, "Banned server"); + get_client_name(sptr, TRUE)); + sendto_one(sptr, NULL, "ERROR :Banned server (%s)", bconf->reason ? bconf->reason : "no reason"); + return exit_client(sptr, sptr, &me, NULL, "Banned server"); } if (link->class->clients + 1 > link->class->maxclients) { sendto_ops_and_log("Cancelling link %s, full class", - get_client_name(cptr, TRUE)); - return exit_client(cptr, cptr, &me, NULL, "Full class"); + get_client_name(sptr, TRUE)); + return exit_client(sptr, sptr, &me, NULL, "Full class"); } - if (!IsLocalhost(cptr) && (iConf.plaintext_policy_server == POLICY_DENY) && !IsSecure(cptr)) + if (!IsLocalhost(sptr) && (iConf.plaintext_policy_server == POLICY_DENY) && !IsSecure(sptr)) { - sendto_one(cptr, NULL, "ERROR :Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')"); - sendto_ops_and_log("Rejected insecure server %s. See https://www.unrealircd.org/docs/FAQ#ERROR:_Servers_need_to_use_SSL.2FTLS", cptr->name); - return exit_client(cptr, sptr, &me, NULL, "Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')"); + sendto_one(sptr, NULL, "ERROR :Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')"); + sendto_ops_and_log("Rejected insecure server %s. See https://www.unrealircd.org/docs/FAQ#ERROR:_Servers_need_to_use_SSL.2FTLS", sptr->name); + return exit_client(sptr, sptr, &me, NULL, "Servers need to use SSL/TLS (set::plaintext-policy::server is 'deny')"); } - if (IsSecure(cptr) && (iConf.outdated_tls_policy_server == POLICY_DENY) && outdated_tls_client(cptr)) + if (IsSecure(sptr) && (iConf.outdated_tls_policy_server == POLICY_DENY) && outdated_tls_client(sptr)) { - sendto_one(cptr, NULL, "ERROR :Server is using an outdated SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')"); - sendto_ops_and_log("Rejected server %s using outdated %s. See https://www.unrealircd.org/docs/FAQ#server-outdated-tls", tls_get_cipher(cptr->local->ssl), cptr->name); - return exit_client(cptr, sptr, &me, NULL, "Server using outdates SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')"); + sendto_one(sptr, NULL, "ERROR :Server is using an outdated SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')"); + sendto_ops_and_log("Rejected server %s using outdated %s. See https://www.unrealircd.org/docs/FAQ#server-outdated-tls", tls_get_cipher(sptr->local->ssl), sptr->name); + return exit_client(sptr, sptr, &me, NULL, "Server using outdates SSL/TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')"); } if (link_out) *link_out = link; @@ -473,7 +471,6 @@ skip_host_check: CMD_FUNC(cmd_server) { char *servername = NULL; /* Pointer for servername */ - /* char *password = NULL; */ char *ch = NULL; /* */ char descbuf[BUFSIZE]; int hop = 0; @@ -482,14 +479,10 @@ CMD_FUNC(cmd_server) ConfigItem_deny_link *deny; char *flags = NULL, *protocol = NULL, *inf = NULL, *num = NULL; - - /* Ignore it */ if (IsUser(sptr)) { - sendnumeric(cptr, ERR_ALREADYREGISTRED); - sendnotice(cptr, - "*** Sorry, but your IRC program doesn't appear to support changing servers."); - sptr->local->since += 7; + sendnumeric(sptr, ERR_ALREADYREGISTRED); + sendnotice(sptr, "*** Sorry, but your IRC program doesn't appear to support changing servers."); return 0; } @@ -499,14 +492,11 @@ CMD_FUNC(cmd_server) if (parc < 4 || (!*parv[3])) { sendto_one(sptr, NULL, "ERROR :Not enough SERVER parameters"); - return exit_client(cptr, sptr, &me, NULL, "Not enough parameters"); + return exit_client(sptr->direction, sptr, &me, NULL, "Not enough parameters"); } - if (IsUnknown(cptr) && (cptr->local->listener->options & LISTENER_CLIENTSONLY)) - { - return exit_client(cptr, sptr, &me, NULL, - "This port is for clients only"); - } + if (MyConnect(sptr) && IsUnknown(sptr) && (sptr->local->listener->options & LISTENER_CLIENTSONLY)) + return exit_client(sptr, sptr, &me, NULL, "This port is for clients only"); /* Now, let us take a look at the parameters we got * Passes here: @@ -527,34 +517,34 @@ CMD_FUNC(cmd_server) sendto_snomask (SNO_JUNK, "WARNING: Bogus server name (%s) from %s (maybe just a fishy client)", - servername, get_client_name(cptr, TRUE)); + servername, get_client_name(sptr, TRUE)); - return exit_client(cptr, sptr, &me, NULL, "Bogus server name"); + return exit_client(sptr->direction, sptr, &me, NULL, "Bogus server name"); } - if ((IsUnknown(cptr) || IsHandshake(cptr)) && !cptr->local->passwd) + if ((IsUnknown(sptr) || IsHandshake(sptr)) && !sptr->local->passwd) { sendto_one(sptr, NULL, "ERROR :Missing password"); - return exit_client(cptr, sptr, &me, NULL, "Missing password"); + return exit_client(sptr, sptr, &me, NULL, "Missing password"); } /* * Now, we can take a look at it all */ - if (IsUnknown(cptr) || IsHandshake(cptr)) + if (IsUnknown(sptr) || IsHandshake(sptr)) { int ret; - ret = verify_link(cptr, sptr, servername, &aconf); + ret = verify_link(sptr, servername, &aconf); if (ret < 0) return ret; /* FLUSH_BUFFER / failure */ /* OK, let us check in the data now now */ hop = atol(parv[2]); strlcpy(info, parv[parc - 1], sizeof(info)); - strlcpy(cptr->name, servername, sizeof(cptr->name)); - cptr->hopcount = hop; + strlcpy(sptr->name, servername, sizeof(sptr->name)); + sptr->hopcount = hop; /* Add ban server stuff */ - if (SupportVL(cptr)) + if (SupportVL(sptr)) { char tmp[REALLEN + 61]; inf = protocol = flags = num = NULL; @@ -575,16 +565,16 @@ CMD_FUNC(cmd_server) { int ret; - strlcpy(cptr->info, inf[0] ? inf : "server", sizeof(cptr->info)); /* set real description */ + strlcpy(sptr->info, inf[0] ? inf : "server", sizeof(sptr->info)); /* set real description */ - ret = _check_deny_version(cptr, NULL, atoi(protocol), flags); + ret = _check_deny_version(sptr, NULL, atoi(protocol), flags); if (ret < 0) return ret; } else { - strlcpy(cptr->info, info[0] ? info : "server", sizeof(cptr->info)); + strlcpy(sptr->info, info[0] ? info : "server", sizeof(sptr->info)); } } else { - strlcpy(cptr->info, info[0] ? info : "server", sizeof(cptr->info)); + strlcpy(sptr->info, info[0] ? info : "server", sizeof(sptr->info)); } for (deny = conf_deny_link; deny; deny = deny->next) @@ -592,24 +582,23 @@ CMD_FUNC(cmd_server) if (deny->flag.type == CRULE_ALL && match_simple(deny->mask, servername) && crule_eval(deny->rule)) { sendto_ops_and_log("Refused connection from %s. Rejected by deny link { } block.", - get_client_host(cptr)); - return exit_client(cptr, cptr, cptr, NULL, - "Disallowed by connection rule"); + get_client_host(sptr)); + return exit_client(sptr, sptr, sptr, NULL, "Disallowed by connection rule"); } } if (aconf->options & CONNECT_QUARANTINE) - SetQuarantined(cptr); + SetQuarantined(sptr); ircsnprintf(descbuf, sizeof descbuf, "Server: %s", servername); - fd_desc(cptr->local->fd, descbuf); + fd_desc(sptr->local->fd, descbuf); /* Start synch now */ - if (cmd_server_synch(cptr, aconf) == FLUSH_BUFFER) + if (cmd_server_synch(sptr, aconf) == FLUSH_BUFFER) return FLUSH_BUFFER; } else { - return cmd_server_remote(cptr, sptr, recv_mtags, parc, parv); + return cmd_server_remote(sptr, recv_mtags, parc, parv); } return 0; } @@ -622,6 +611,7 @@ CMD_FUNC(cmd_server_remote) int hop; char info[REALLEN + 61]; char *servername = parv[1]; + Client *cptr = sptr->direction; /* lazy, since this function may be removed soon */ if (parc < 4 || (!*parv[3])) { @@ -629,6 +619,7 @@ CMD_FUNC(cmd_server_remote) return 0; } + /* Check if server already exists... */ if ((acptr = find_server(servername, NULL))) { /* Found. Bad. Quit. */ @@ -641,11 +632,10 @@ CMD_FUNC(cmd_server_remote) return exit_client(sptr, sptr, sptr, NULL, "Server Exists"); } + // FIXME: verify this code: acptr = acptr->direction; - ocptr = - (cptr->local->firsttime > acptr->local->firsttime) ? acptr : cptr; - acptr = - (cptr->local->firsttime > acptr->local->firsttime) ? cptr : acptr; + ocptr = (cptr->local->firsttime > acptr->local->firsttime) ? acptr : cptr; + acptr = (cptr->local->firsttime > acptr->local->firsttime) ? cptr : acptr; sendto_one(acptr, NULL, "ERROR :Server %s already exists from %s", servername, @@ -740,13 +730,13 @@ CMD_FUNC(cmd_server_remote) if (*acptr->id) { - sendto_server(cptr, PROTO_SID, 0, NULL, ":%s SID %s %d %s :%s", + sendto_server(sptr, PROTO_SID, 0, NULL, ":%s SID %s %d %s :%s", acptr->srvptr->id, acptr->name, hop + 1, acptr->id, acptr->info); - sendto_server(cptr, 0, PROTO_SID, NULL, ":%s SERVER %s %d :%s", + sendto_server(sptr, 0, PROTO_SID, NULL, ":%s SERVER %s %d :%s", acptr->srvptr->name, acptr->name, hop + 1, acptr->info); } else { - sendto_server(cptr, 0, 0, NULL, ":%s SERVER %s %d :%s", + sendto_server(sptr, 0, 0, NULL, ":%s SERVER %s %d :%s", acptr->srvptr->name, acptr->name, hop + 1, acptr->info); } @@ -757,7 +747,7 @@ CMD_FUNC(cmd_server_remote) void _introduce_user(Client *to, Client *acptr) { - send_umode(NULL, acptr, 0, SEND_UMODES, buf); + build_umode_string(acptr, 0, SEND_UMODES, buf); sendto_one_nickcmd(to, acptr, buf); diff --git a/src/modules/sethost.c b/src/modules/sethost.c index 24c5282e4..0cd586247 100644 --- a/src/modules/sethost.c +++ b/src/modules/sethost.c @@ -136,7 +136,7 @@ CMD_FUNC(cmd_sethost) /* get it in */ safe_strdup(sptr->user->virthost, vhost); /* spread it out */ - sendto_server(cptr, 0, 0, NULL, ":%s SETHOST %s", sptr->name, parv[1]); + sendto_server(sptr, 0, 0, NULL, ":%s SETHOST %s", sptr->name, parv[1]); userhost_changed(sptr); diff --git a/src/modules/setident.c b/src/modules/setident.c index 41d6d48ac..ad1260054 100644 --- a/src/modules/setident.c +++ b/src/modules/setident.c @@ -119,7 +119,7 @@ CMD_FUNC(cmd_setident) strlcpy(sptr->user->username, vident, sizeof(sptr->user->username)); - sendto_server(cptr, 0, 0, NULL, ":%s SETIDENT %s", sptr->name, parv[1]); + sendto_server(sptr, 0, 0, NULL, ":%s SETIDENT %s", sptr->name, parv[1]); userhost_changed(sptr); diff --git a/src/modules/setname.c b/src/modules/setname.c index 10d663fd3..f000c0241 100644 --- a/src/modules/setname.c +++ b/src/modules/setname.c @@ -108,7 +108,7 @@ CMD_FUNC(cmd_setname) strcpy(sptr->info, parv[1]); } - sendto_server(cptr, 0, 0, NULL, ":%s SETNAME :%s", sptr->name, parv[1]); + sendto_server(sptr, 0, 0, NULL, ":%s SETNAME :%s", sptr->name, parv[1]); if (MyConnect(sptr)) { diff --git a/src/modules/sinfo.c b/src/modules/sinfo.c index 704711418..c3f54d482 100644 --- a/src/modules/sinfo.c +++ b/src/modules/sinfo.c @@ -41,11 +41,11 @@ MOD_UNLOAD() * https://www.unrealircd.org/docs/Server_protocol:SINFO_command * ^ contains important remarks regarding when to send it and when not. */ -int sinfo_server(Client *cptr, Client *sptr, int parc, char *parv[]) +int sinfo_server(Client *sptr, int parc, char *parv[]) { char buf[512]; - if (cptr == sptr) + if (MyConnect(sptr)) { /* It is a protocol violation to send an SINFO for yourself, * eg if you are server 001, then you cannot send :001 SINFO .... @@ -57,7 +57,7 @@ int sinfo_server(Client *cptr, Client *sptr, int parc, char *parv[]) * failure to do so will lead to potential desyncs or other major * issues. */ - return exit_client(cptr, sptr, &me, NULL, "Protocol error: you cannot send SINFO about yourself"); + return exit_client(sptr, sptr, &me, NULL, "Protocol error: you cannot send SINFO about yourself"); } /* :SID SINFO up_since protocol umodes chanmodes nickchars :software name @@ -105,13 +105,13 @@ int sinfo_server(Client *cptr, Client *sptr, int parc, char *parv[]) /* Broadcast to 'the other side' of the net */ concat_params(buf, sizeof(buf), parc, parv); - sendto_server(cptr, 0, 0, NULL, ":%s SINFO %s", sptr->name, buf); + sendto_server(sptr, 0, 0, NULL, ":%s SINFO %s", sptr->name, buf); return 0; } #define SafeDisplayStr(x) ((x && *(x)) ? (x) : "-") -int sinfo_user(Client *cptr, Client *sptr, int parc, char *parv[]) +int sinfo_user(Client *sptr, int parc, char *parv[]) { Client *acptr; @@ -160,8 +160,8 @@ int sinfo_user(Client *cptr, Client *sptr, int parc, char *parv[]) CMD_FUNC(cmd_sinfo) { if (IsServer(sptr)) - return sinfo_server(cptr, sptr, parc, parv); + return sinfo_server(sptr, parc, parv); else if (MyUser(sptr)) - return sinfo_user(cptr, sptr, parc, parv); + return sinfo_user(sptr, parc, parv); return 0; } diff --git a/src/modules/sjoin.c b/src/modules/sjoin.c index 37f861a8c..206fd5a87 100644 --- a/src/modules/sjoin.c +++ b/src/modules/sjoin.c @@ -116,7 +116,7 @@ aParv *mp2parv(char *xmbuf, char *parmbuf) else {\ MessageTag *mtags = NULL; \ /* for old servers without sjoin: */ \ - sendto_server(cptr, 0, PROTO_SJOIN, NULL, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname,\ + sendto_server(sptr, 0, PROTO_SJOIN, NULL, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname,\ modebuf, parabuf, (long long)chptr->creationtime); \ new_message_special(sptr, recv_mtags, &mtags, ":%s MODE %s %s %s", sptr->name, chptr->chname, modebuf, parabuf); \ sendto_channel(chptr, sptr, NULL, 0, 0, SEND_LOCAL, mtags, \ @@ -158,7 +158,7 @@ CMD_FUNC(cmd_sjoin) long modeflags; char queue_s=0, queue_c=0; /* oh this is soooooo ugly :p */ - if (IsUser(sptr) || parc < 4 || !IsServer(sptr)) + if (!IsServer(sptr) || parc < 4) return 0; if (!IsChannelName(parv[2])) @@ -166,16 +166,16 @@ CMD_FUNC(cmd_sjoin) merge = nopara = nomode = removeours = removetheirs = 0; - if (SupportSJOIN(cptr) && !SupportSJ3(cptr) && !strncmp(parv[4], "", 6)) + if (SupportSJOIN(sptr->direction) && !SupportSJ3(sptr->direction) && !strncmp(parv[4], "", 6)) nopara = 1; - if (SupportSJOIN2(cptr) && !SupportSJ3(cptr) && !strncmp(parv[4], "<->", 6)) + if (SupportSJOIN2(sptr->direction) && !SupportSJ3(sptr->direction) && !strncmp(parv[4], "<->", 6)) nopara = 1; - if (SupportSJ3(cptr) && (parc < 6)) + if (SupportSJ3(sptr->direction) && (parc < 6)) nopara = 1; - if (SupportSJ3(cptr)) + if (SupportSJ3(sptr->direction)) { if (parc < 5) nomode = 1; @@ -186,7 +186,7 @@ CMD_FUNC(cmd_sjoin) nomode = 1; } - chptr = get_channel(cptr, parv[2], CREATE); + chptr = get_channel(sptr, parv[2], CREATE); ts = (time_t)atol(parv[1]); @@ -215,12 +215,13 @@ CMD_FUNC(cmd_sjoin) oldts = chptr->creationtime; } + // FIXME: make it so services cannot screw this up so easily --- if possible... if (ts < 750000) { if (ts != 0) sendto_ops ("Warning! Possible desynch: SJOIN for channel %s has a fishy timestamp (%lld) [%s/%s]", - chptr->chname, (long long)ts, sptr->name, cptr->name); + chptr->chname, (long long)ts, sptr->name, sptr->direction->name); } parabuf[0] = '\0'; @@ -228,7 +229,7 @@ CMD_FUNC(cmd_sjoin) modebuf[1] = '\0'; /* Grab current modes -> modebuf & parabuf */ - channel_modes(cptr, modebuf, parabuf, sizeof(modebuf), sizeof(parabuf), chptr); + channel_modes(sptr, modebuf, parabuf, sizeof(modebuf), sizeof(parabuf), chptr); /* Do we need to remove all our modes, bans/exempt/inves lists and -vhoaq our users? */ if (removeours) @@ -243,11 +244,10 @@ CMD_FUNC(cmd_sjoin) { MessageTag *mtags = NULL; ap = mp2parv(modebuf, parabuf); - set_mode(chptr, cptr, ap->parc, ap->parv, &pcount, - pvar, 0); + set_mode(chptr, sptr, ap->parc, ap->parv, &pcount, pvar, 0); /* for old servers without SJOIN: */ - sendto_server(cptr, 0, PROTO_SJOIN, mtags, + sendto_server(sptr, 0, PROTO_SJOIN, mtags, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname, modebuf, parabuf, (long long)chptr->creationtime); @@ -335,7 +335,7 @@ CMD_FUNC(cmd_sjoin) modebuf[b] = '\0'; /* for old servers without sjoin: */ - sendto_server(cptr, 0, PROTO_SJOIN, mtags, + sendto_server(sptr, 0, PROTO_SJOIN, mtags, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname, modebuf, parabuf, (long long)chptr->creationtime); @@ -349,7 +349,7 @@ CMD_FUNC(cmd_sjoin) } /* since we're dropping our modes, we want to clear the mlock as well. --nenolod */ - set_channel_mlock(cptr, sptr, chptr, NULL, FALSE); + set_channel_mlock(sptr, chptr, NULL, FALSE); } /* Mode setting done :), now for our beloved clients */ parabuf[0] = 0; @@ -379,7 +379,7 @@ CMD_FUNC(cmd_sjoin) for (s = strtoken(&saved, cbuf, " "); s; s = strtoken(&saved, NULL, " ")) { - char *setby = cptr->name; /**< Set by (nick, nick!user@host, or server name) */ + char *setby = sptr->name; /**< Set by (nick, nick!user@host, or server name) */ time_t setat = TStime(); /**< Set at timestamp */ int sjsby_info = 0; /**< Set to 1 if we receive SJSBY info to alter the above 2 vars */ @@ -390,7 +390,7 @@ CMD_FUNC(cmd_sjoin) /* UnrealIRCd 4.2.2 and later support "SJSBY" which allows communicating * setat/setby information for bans, ban exempts and invite exceptions. */ - if (SupportSJSBY(cptr) && (*tp == '<')) + if (SupportSJSBY(sptr->direction) && (*tp == '<')) { /* Special prefix to communicate timestamp and setter: * "<" + timestamp + "," + nick[!user@host] + ">" + normal SJOIN stuff @@ -542,14 +542,14 @@ getnick: MessageTag *mtags = NULL; add_user_to_channel(chptr, acptr, modeflags); - RunHook5(HOOKTYPE_REMOTE_JOIN, cptr, acptr, chptr, recv_mtags, NULL); + RunHook4(HOOKTYPE_REMOTE_JOIN, acptr, chptr, recv_mtags, NULL); new_message_special(acptr, recv_mtags, &mtags, ":%s JOIN %s", acptr->name, chptr->chname); send_join_to_local_users(acptr, chptr, mtags); free_message_tags(mtags); } /* old servers without SJOIN: */ - sendto_server(cptr, 0, PROTO_SJOIN, NULL, ":%s JOIN %s", acptr->name, chptr->chname); + sendto_server(sptr, 0, PROTO_SJOIN, NULL, ":%s JOIN %s", acptr->name, chptr->chname); CheckStatus('q', CHFL_CHANOWNER); CheckStatus('a', CHFL_CHANADMIN); @@ -560,7 +560,7 @@ getnick: if (strlen(nick_buf) + strlen(prefix) + strlen(acptr->name) > BUFSIZE - 10) { /* Send what we have and start a new buffer */ - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3, PROTO_SID, recv_mtags, "%s", nick_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3, PROTO_SID, recv_mtags, "%s", nick_buf); snprintf(nick_buf, sizeof(nick_buf), ":%s SJOIN %lld %s :", sptr->name, (long long)ts, sj3_parabuf); /* Double-check the new buffer is sufficient to concat the data */ if (strlen(nick_buf) + strlen(prefix) + strlen(acptr->name) > BUFSIZE - 5) @@ -576,7 +576,7 @@ getnick: if (strlen(uid_buf) + strlen(prefix) + IDLEN > BUFSIZE - 10) { /* Send what we have and start a new buffer */ - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID, PROTO_SJSBY, recv_mtags, "%s", uid_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID, PROTO_SJSBY, recv_mtags, "%s", uid_buf); snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lld %s :", ID(sptr), (long long)ts, sj3_parabuf); /* Double-check the new buffer is sufficient to concat the data */ if (strlen(uid_buf) + strlen(prefix) + strlen(ID(acptr)) > BUFSIZE - 5) @@ -592,7 +592,7 @@ getnick: if (strlen(uid_sjsby_buf) + strlen(prefix) + IDLEN > BUFSIZE - 10) { /* Send what we have and start a new buffer */ - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID, PROTO_SJSBY, recv_mtags, "%s", uid_sjsby_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID, PROTO_SJSBY, recv_mtags, "%s", uid_sjsby_buf); snprintf(uid_sjsby_buf, sizeof(uid_sjsby_buf), ":%s SJOIN %lld %s :", ID(sptr), (long long)ts, sj3_parabuf); /* Double-check the new buffer is sufficient to concat the data */ if (strlen(uid_sjsby_buf) + strlen(prefix) + strlen(ID(acptr)) > BUFSIZE - 5) @@ -651,7 +651,7 @@ getnick: if (strlen(nick_buf) + strlen(prefix) + strlen(nick) > BUFSIZE - 10) { /* Send what we have and start a new buffer */ - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3, PROTO_SID, recv_mtags, "%s", nick_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3, PROTO_SID, recv_mtags, "%s", nick_buf); snprintf(nick_buf, sizeof(nick_buf), ":%s SJOIN %lld %s :", sptr->name, (long long)ts, sj3_parabuf); /* Double-check the new buffer is sufficient to concat the data */ if (strlen(nick_buf) + strlen(prefix) + strlen(nick) > BUFSIZE - 5) @@ -667,7 +667,7 @@ getnick: if (strlen(uid_buf) + strlen(prefix) + strlen(nick) > BUFSIZE - 10) { /* Send what we have and start a new buffer */ - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID, PROTO_SJSBY, recv_mtags, "%s", uid_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID, PROTO_SJSBY, recv_mtags, "%s", uid_buf); snprintf(uid_buf, sizeof(uid_buf), ":%s SJOIN %lld %s :", ID(sptr), (long long)ts, sj3_parabuf); /* Double-check the new buffer is sufficient to concat the data */ if (strlen(uid_buf) + strlen(prefix) + strlen(nick) > BUFSIZE - 5) @@ -689,7 +689,7 @@ getnick: if (strlen(uid_sjsby_buf) + strlen(scratch_buf) > BUFSIZE - 10) { /* Send what we have and start a new buffer */ - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID | PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3 | PROTO_SID | PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf); snprintf(uid_sjsby_buf, sizeof(uid_sjsby_buf), ":%s SJOIN %lld %s :", ID(sptr), (long long)ts, sj3_parabuf); /* Double-check the new buffer is sufficient to concat the data */ if (strlen(uid_sjsby_buf) + strlen(scratch_buf) > BUFSIZE - 5) @@ -706,9 +706,9 @@ getnick: /* Send out any possible remainder.. */ Debug((DEBUG_DEBUG, "Sending '%li %s :%s' to sj3", ts, parabuf, parv[parc - 1])); - sendto_server(cptr, PROTO_SJOIN | PROTO_SJ3, PROTO_SID, recv_mtags, "%s", nick_buf); - sendto_server(cptr, PROTO_SID | PROTO_SJOIN | PROTO_SJ3, PROTO_SJSBY, recv_mtags, "%s", uid_buf); - sendto_server(cptr, PROTO_SID | PROTO_SJOIN | PROTO_SJ3 | PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf); + sendto_server(sptr, PROTO_SJOIN | PROTO_SJ3, PROTO_SID, recv_mtags, "%s", nick_buf); + sendto_server(sptr, PROTO_SID | PROTO_SJOIN | PROTO_SJ3, PROTO_SJSBY, recv_mtags, "%s", uid_buf); + sendto_server(sptr, PROTO_SID | PROTO_SJOIN | PROTO_SJ3 | PROTO_SJSBY, 0, recv_mtags, "%s", uid_sjsby_buf); if (modebuf[1]) { @@ -717,7 +717,7 @@ getnick: modebuf[b] = '\0'; /* for old servers without sjoin: */ - sendto_server(cptr, 0, PROTO_SJOIN, mtags, + sendto_server(sptr, 0, PROTO_SJOIN, mtags, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname, modebuf, parabuf, (long long)chptr->creationtime); @@ -746,10 +746,10 @@ getnick: strlcpy(paraback, parabuf, sizeof paraback); ap = mp2parv(modebuf, parabuf); - set_mode(chptr, cptr, ap->parc, ap->parv, &pcount, pvar, 0); + set_mode(chptr, sptr, ap->parc, ap->parv, &pcount, pvar, 0); /* for old servers without SJOIN: */ - sendto_server(cptr, 0, PROTO_SJOIN, NULL, + sendto_server(sptr, 0, PROTO_SJOIN, NULL, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname, modebuf, paraback, (long long)chptr->creationtime); @@ -782,7 +782,7 @@ getnick: } } ap = mp2parv(modebuf, parabuf); - set_mode(chptr, cptr, ap->parc, ap->parv, &pcount, pvar, 0); + set_mode(chptr, sptr, ap->parc, ap->parv, &pcount, pvar, 0); /* Good, now we got modes, now for the differencing and outputting of modes * We first see if any para modes are set. @@ -964,7 +964,7 @@ getnick: MessageTag *mtags = NULL; /* for old servers without SJOIN: */ - sendto_server(cptr, 0, PROTO_SJOIN, NULL, + sendto_server(sptr, 0, PROTO_SJOIN, NULL, ":%s MODE %s %s %s %lld", sptr->name, chptr->chname, modebuf, parabuf, (long long)chptr->creationtime); diff --git a/src/modules/sqline.c b/src/modules/sqline.c index deab7988f..f6a644ae7 100644 --- a/src/modules/sqline.c +++ b/src/modules/sqline.c @@ -83,5 +83,5 @@ CMD_FUNC(cmd_sqline) ircsnprintf(mo, sizeof(mo), "%lld", (long long)TStime()); tkllayer[7] = mo; tkllayer[8] = comment ? comment : "no reason"; - return cmd_tkl(&me, &me, NULL, 9, tkllayer); + return cmd_tkl(&me, NULL, 9, tkllayer); } diff --git a/src/modules/squit.c b/src/modules/squit.c index 362213b10..2a2ada092 100644 --- a/src/modules/squit.c +++ b/src/modules/squit.c @@ -61,7 +61,9 @@ CMD_FUNC(cmd_squit) { char *server; Client *acptr; - char *comment = (parc > 2 && parv[parc - 1]) ? parv[parc - 1] : cptr->name; + char *comment = (parc > 2 && parv[parc - 1]) ? parv[parc - 1] : sptr->name; + + // FIXME: this function is way too confusing, and full of old shit? if (!ValidatePermissionsForPath("route:local",sptr,NULL,NULL,NULL)) { @@ -69,25 +71,19 @@ CMD_FUNC(cmd_squit) return 0; } - if (parc > 1) + if ((parc < 2) || BadPtr(parv[1])) { - server = parv[1]; - - acptr = find_server_quick(server); - if (acptr && IsMe(acptr)) - { - acptr = cptr; - server = cptr->local->sockhost; - } + sendnumeric(sptr, ERR_NEEDMOREPARAMS, "SQUIT"); + return 0; } - else + + server = parv[1]; + + acptr = find_server_quick(server); + if (acptr && IsMe(acptr)) { - /* - ** This is actually protocol error. But, well, closing - ** the link is very proper answer to that... - */ - server = cptr->local->sockhost; - acptr = cptr; + acptr = sptr->direction; + server = sptr->direction->local->sockhost; } /* @@ -95,7 +91,7 @@ CMD_FUNC(cmd_squit) ** ** The old (irc2.2PL1 and earlier) code just cleans away the ** server client from the links (because it is never true - ** "cptr == acptr". + ** "sptr->direction == acptr". ** ** This logic here works the same way until "SQUIT host" hits ** the server having the target "host" as local link. Then it @@ -132,7 +128,7 @@ CMD_FUNC(cmd_squit) /* ** Notify all opers, if my local link is remotely squitted */ - if (MyConnect(acptr) && !MyUser(cptr)) + if (MyConnect(acptr) && !MyUser(sptr)) { sendto_umode_global(UMODE_OPER, "Received SQUIT %s from %s (%s)", acptr->name, get_client_name(sptr, FALSE), comment); @@ -164,5 +160,5 @@ CMD_FUNC(cmd_squit) SetSQuit(acptr); } - return exit_client(cptr, acptr, sptr, recv_mtags, comment); + return exit_client(sptr->direction, acptr, sptr, recv_mtags, comment); } diff --git a/src/modules/staff.c b/src/modules/staff.c index f66fc226d..ad4aef951 100644 --- a/src/modules/staff.c +++ b/src/modules/staff.c @@ -47,7 +47,7 @@ ModuleHeader MOD_HEADER /* Forward declarations */ static void unload_motd_file(MOTDFile *list); CMD_FUNC(cmd_staff); -static int cb_rehashflag(Client *cptr, Client *sptr, char *flag); +static int cb_rehashflag(Client *sptr, char *flag); static int cb_test(ConfigFile *, ConfigEntry *, int, int *); static int cb_conf(ConfigFile *, ConfigEntry *, int); static int cb_rehash(); @@ -335,7 +335,7 @@ static int cb_stats(Client *sptr, char *flag) return 0; } -static int cb_rehashflag(Client *cptr, Client *sptr, char *flag) +static int cb_rehashflag(Client *sptr, char *flag) { int myflag = 0; @@ -344,7 +344,7 @@ static int cb_rehashflag(Client *cptr, Client *sptr, char *flag) { if (myflag) sendto_ops("%sRehashing network staff file on the request of %s", - cptr != sptr ? "Remotely " : "", sptr->name); + MyUser(sptr) ? "Remotely " : "", sptr->name); #ifdef USE_LIBCURL if (Download.is_url) @@ -366,7 +366,7 @@ CMD_FUNC(cmd_staff) if (!IsUser(sptr)) return -1; - if (hunt_server(cptr, sptr, recv_mtags, ":%s STAFF", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s STAFF", 1, parc, parv) != HUNTED_ISME) return 0; if (!staff.lines) diff --git a/src/modules/stats.c b/src/modules/stats.c index 1265f1f56..5fe1bea2e 100644 --- a/src/modules/stats.c +++ b/src/modules/stats.c @@ -306,12 +306,12 @@ CMD_FUNC(cmd_stats) if (parc == 3 && parv[2][0] != '+' && parv[2][0] != '-') { - if (hunt_server(cptr, sptr, recv_mtags, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s STATS %s :%s", 2, parc, parv) != HUNTED_ISME) return 0; } else if (parc == 4 && parv[2][0] != '+' && parv[2][0] != '-') { - if (hunt_server(cptr, sptr, recv_mtags, ":%s STATS %s %s %s", 2, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s STATS %s %s %s", 2, parc, parv) != HUNTED_ISME) return 0; } if (parc < 2 || !*parv[1]) diff --git a/src/modules/svsfline.c b/src/modules/svsfline.c index f79682bd8..df64746ea 100644 --- a/src/modules/svsfline.c +++ b/src/modules/svsfline.c @@ -72,7 +72,7 @@ CMD_FUNC(cmd_svsfline) if (IsULine(sptr)) { - sendto_server(cptr, 0, 0, NULL, ":%s SVSFLINE + %s :%s", + sendto_server(sptr, 0, 0, NULL, ":%s SVSFLINE + %s :%s", sptr->name, parv[2], parv[3]); } @@ -94,7 +94,7 @@ CMD_FUNC(cmd_svsfline) DCCdeny_del(deny); - sendto_server(cptr, 0, 0, NULL, ":%s SVSFLINE %s", sptr->name, parv[2]); + sendto_server(sptr, 0, 0, NULL, ":%s SVSFLINE %s", sptr->name, parv[2]); break; } @@ -106,7 +106,7 @@ CMD_FUNC(cmd_svsfline) dcc_wipe_services(); - sendto_server(cptr, 0, 0, NULL, ":%s SVSFLINE *", sptr->name); + sendto_server(sptr, 0, 0, NULL, ":%s SVSFLINE *", sptr->name); break; } diff --git a/src/modules/svsjoin.c b/src/modules/svsjoin.c index ab9d6185c..62f83f6a1 100644 --- a/src/modules/svsjoin.c +++ b/src/modules/svsjoin.c @@ -76,12 +76,12 @@ CMD_FUNC(cmd_svsjoin) if (parc == 3) { parv[2] = NULL; - (void)do_cmd(acptr, acptr, NULL, "JOIN", 2, parv); + (void)do_cmd(acptr, NULL, "JOIN", 2, parv); /* NOTE: 'acptr' may be killed if we ever implement spamfilter join channel target */ } else { parv[2] = parv[3]; parv[3] = NULL; - (void)do_cmd(acptr, acptr, NULL, "JOIN", 3, parv); + (void)do_cmd(acptr, NULL, "JOIN", 3, parv); /* NOTE: 'acptr' may be killed if we ever implement spamfilter join channel target */ } } diff --git a/src/modules/svskill.c b/src/modules/svskill.c index d6223290f..215d56141 100644 --- a/src/modules/svskill.c +++ b/src/modules/svskill.c @@ -81,9 +81,9 @@ CMD_FUNC(cmd_svskill) /* for new_message() we use acptr here, makes sense for the exit_client, right? */ new_message(acptr, recv_mtags, &mtags); - sendto_server(cptr, 0, 0, mtags, ":%s SVSKILL %s :%s", sptr->name, parv[1], comment); + sendto_server(sptr, 0, 0, mtags, ":%s SVSKILL %s :%s", sptr->name, parv[1], comment); SetKilled(acptr); - n = exit_client(cptr, acptr, sptr, mtags, comment); + n = exit_client(sptr->direction, acptr, sptr, mtags, comment); free_message_tags(mtags); return n; } diff --git a/src/modules/svslusers.c b/src/modules/svslusers.c index c78d345f4..6b5c2b285 100644 --- a/src/modules/svslusers.c +++ b/src/modules/svslusers.c @@ -65,7 +65,7 @@ CMD_FUNC(cmd_svslusers) { if (!IsULine(sptr) || parc < 4) return -1; - if (hunt_server(cptr, sptr, NULL, ":%s SVSLUSERS %s %s :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, NULL, ":%s SVSLUSERS %s %s :%s", 1, parc, parv) == HUNTED_ISME) { int temp; temp = atoi(parv[2]); diff --git a/src/modules/svsmode.c b/src/modules/svsmode.c index 2f11ed163..4c9c2a4fc 100644 --- a/src/modules/svsmode.c +++ b/src/modules/svsmode.c @@ -195,7 +195,7 @@ void clear_bans(Client *sptr, Channel *chptr, char chmode) * * OLD syntax had a 'ts' parameter. No services are known to use this. */ -int channel_svsmode(Client *cptr, Client *sptr, int parc, char *parv[]) +int channel_svsmode(Client *sptr, int parc, char *parv[]) { Channel *chptr; Client *acptr; @@ -269,7 +269,7 @@ int channel_svsmode(Client *cptr, Client *sptr, int parc, char *parv[]) default: sendto_realops("Warning! Invalid mode `%c' used with 'SVSMODE %s %s %s' (from %s %s)", *m, chptr->chname, parv[2], parv[3] ? parv[3] : "", - cptr->name, sptr->name); + sptr->direction->name, sptr->name); break; } } @@ -287,7 +287,7 @@ int channel_svsmode(Client *cptr, Client *sptr, int parc, char *parv[]) sendto_server(NULL, 0, 0, mtags, ":%s MODE %s %s %s", sptr->name, chptr->chname, modebuf, parabuf); /* Activate this hook just like cmd_mode.c */ - RunHook8(HOOKTYPE_REMOTE_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, 0, 0); + RunHook7(HOOKTYPE_REMOTE_CHANMODE, sptr, chptr, mtags, modebuf, parabuf, 0, 0); free_message_tags(mtags); @@ -305,7 +305,7 @@ int channel_svsmode(Client *cptr, Client *sptr, int parc, char *parv[]) * * show_change can be 0 (for svsmode) or 1 (for svs2mode). */ -int do_svsmode(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], int show_change) +int do_svsmode(Client *sptr, MessageTag *recv_mtags, int parc, char *parv[], int show_change) { int i; char *m; @@ -322,7 +322,7 @@ int do_svsmode(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, cha return 0; if (parv[1][0] == '#') - return channel_svsmode(cptr, sptr, parc, parv); + return channel_svsmode(sptr, parc, parv); if (!(acptr = find_person(parv[1], NULL))) return 0; @@ -497,11 +497,11 @@ int do_svsmode(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, cha } /*switch*/ if (parc > 3) - sendto_server(cptr, 0, 0, NULL, ":%s %s %s %s %s", + sendto_server(sptr, 0, 0, NULL, ":%s %s %s %s %s", sptr->name, show_change ? "SVS2MODE" : "SVSMODE", parv[1], parv[2], parv[3]); else - sendto_server(cptr, 0, 0, NULL, ":%s %s %s %s", + sendto_server(sptr, 0, 0, NULL, ":%s %s %s %s", sptr->name, show_change ? "SVS2MODE" : "SVSMODE", parv[1], parv[2]); @@ -514,8 +514,8 @@ int do_svsmode(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, cha if (show_change) { char buf[BUFSIZE]; - send_umode(NULL, acptr, setflags, ALL_UMODES, buf); - if (MyUser(acptr) && buf[0] && buf[1]) + build_umode_string(acptr, setflags, ALL_UMODES, buf); + if (MyUser(acptr) && *buf) sendto_one(acptr, NULL, ":%s MODE %s :%s", sptr->name, acptr->name, buf); } @@ -533,7 +533,7 @@ int do_svsmode(Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, cha */ CMD_FUNC(cmd_svsmode) { - return do_svsmode(cptr, sptr, recv_mtags, parc, parv, 0); + return do_svsmode(sptr, recv_mtags, parc, parv, 0); } /* @@ -544,7 +544,7 @@ CMD_FUNC(cmd_svsmode) */ CMD_FUNC(cmd_svs2mode) { - return do_svsmode(cptr, sptr, recv_mtags, parc, parv, 1); + return do_svsmode(sptr, recv_mtags, parc, parv, 1); } void add_send_mode_param(Channel *chptr, Client *from, char what, char mode, char *param) diff --git a/src/modules/svsmotd.c b/src/modules/svsmotd.c index 54296331b..4f45aa89a 100644 --- a/src/modules/svsmotd.c +++ b/src/modules/svsmotd.c @@ -96,9 +96,9 @@ CMD_FUNC(cmd_svsmotd) return 0; } if (parv[2]) - sendto_server(cptr, 0, 0, NULL, ":%s SVSMOTD %s :%s", sptr->name, parv[1], parv[2]); + sendto_server(sptr, 0, 0, NULL, ":%s SVSMOTD %s :%s", sptr->name, parv[1], parv[2]); else - sendto_server(cptr, 0, 0, NULL, ":%s SVSMOTD %s", sptr->name, parv[1]); + sendto_server(sptr, 0, 0, NULL, ":%s SVSMOTD %s", sptr->name, parv[1]); if (conf == NULL) { diff --git a/src/modules/svsnick.c b/src/modules/svsnick.c index ee47c574f..e0581b3f0 100644 --- a/src/modules/svsnick.c +++ b/src/modules/svsnick.c @@ -68,7 +68,7 @@ CMD_FUNC(cmd_svsnick) if (!IsULine(sptr) || parc < 4 || (strlen(parv[2]) > NICKLEN)) return -1; /* This looks like an error anyway -Studded */ - if (hunt_server(cptr, sptr, NULL, ":%s SVSNICK %s %s :%s", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, NULL, ":%s SVSNICK %s %s :%s", 1, parc, parv) != HUNTED_ISME) return 0; /* Forwarded, done */ if (do_nick_name(parv[2]) == 0) diff --git a/src/modules/svsnline.c b/src/modules/svsnline.c index 181a107d2..0fb34116d 100644 --- a/src/modules/svsnline.c +++ b/src/modules/svsnline.c @@ -113,7 +113,7 @@ CMD_FUNC(cmd_svsnline) } if (IsULine(sptr)) - sendto_server(cptr, 0, 0, NULL, ":%s SVSNLINE + %s :%s", + sendto_server(sptr, 0, 0, NULL, ":%s SVSNLINE + %s :%s", sptr->name, parv[2], parv[3]); break; } @@ -141,7 +141,7 @@ CMD_FUNC(cmd_svsnline) safe_free(bconf); } - sendto_server(cptr, 0, 0, NULL, ":%s SVSNLINE - %s", sptr->name, parv[2]); + sendto_server(sptr, 0, 0, NULL, ":%s SVSNLINE - %s", sptr->name, parv[2]); break; } case '*': @@ -149,7 +149,7 @@ CMD_FUNC(cmd_svsnline) if (!IsULine(sptr)) return 0; wipe_svsnlines(); - sendto_server(cptr, 0, 0, NULL, ":%s SVSNLINE *", sptr->name); + sendto_server(sptr, 0, 0, NULL, ":%s SVSNLINE *", sptr->name); break; } diff --git a/src/modules/svsnolag.c b/src/modules/svsnolag.c index 80b0418dd..0b86c89ec 100644 --- a/src/modules/svsnolag.c +++ b/src/modules/svsnolag.c @@ -54,7 +54,7 @@ MOD_UNLOAD() return MOD_SUCCESS; } -int do_svsnolag(Client *cptr, Client *sptr, int parc, char *parv[], int show_change) +int do_svsnolag(Client *sptr, int parc, char *parv[], int show_change) { Client *acptr; char *cmd = show_change ? MSG_SVS2NOLAG : MSG_SVSNOLAG; @@ -98,10 +98,10 @@ int do_svsnolag(Client *cptr, Client *sptr, int parc, char *parv[], int show_cha CMD_FUNC(cmd_svsnolag) { - return do_svsnolag(cptr, sptr, parc, parv, 0); + return do_svsnolag(sptr, parc, parv, 0); } CMD_FUNC(cmd_svs2nolag) { - return do_svsnolag(cptr, sptr, parc, parv, 1); + return do_svsnolag(sptr, parc, parv, 1); } diff --git a/src/modules/svsnoop.c b/src/modules/svsnoop.c index ca98e2270..693f27f34 100644 --- a/src/modules/svsnoop.c +++ b/src/modules/svsnoop.c @@ -62,7 +62,7 @@ CMD_FUNC(cmd_svsnoop) if (!(IsULine(sptr) && parc > 2)) return 0; - if (hunt_server(cptr, sptr, NULL, ":%s SVSNOOP %s :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, NULL, ":%s SVSNOOP %s :%s", 1, parc, parv) == HUNTED_ISME) { if (parv[2][0] == '+') { diff --git a/src/modules/svspart.c b/src/modules/svspart.c index 160a2fb0d..0bf45fc9a 100644 --- a/src/modules/svspart.c +++ b/src/modules/svspart.c @@ -75,7 +75,7 @@ CMD_FUNC(cmd_svspart) parv[1] = parv[2]; parv[2] = comment; parv[3] = NULL; - (void)do_cmd(acptr, acptr, NULL, "PART", comment ? 3 : 2, parv); + (void)do_cmd(acptr, NULL, "PART", comment ? 3 : 2, parv); /* NOTE: acptr may be killed now by spamfilter due to the part reason */ } else diff --git a/src/modules/svssno.c b/src/modules/svssno.c index 790b62ca2..9fdf42ef3 100644 --- a/src/modules/svssno.c +++ b/src/modules/svssno.c @@ -61,7 +61,7 @@ MOD_UNLOAD() * parv[2] - snomasks to change * show_change determines whether to show the change to the user */ -int do_svssno(Client *cptr, Client *sptr, int parc, char *parv[], int show_change) +int do_svssno(Client *sptr, int parc, char *parv[], int show_change) { char *p; Client *acptr; @@ -79,7 +79,7 @@ int do_svssno(Client *cptr, Client *sptr, int parc, char *parv[], int show_chan if (!(acptr = find_person(parv[1], NULL))) return 0; - if (hunt_server(cptr, sptr, NULL, + if (hunt_server(sptr, NULL, show_change ? ":%s SVS2SNO %s %s" : ":%s SVSSNO %s %s", 1, parc, parv) != HUNTED_ISME) { @@ -126,10 +126,10 @@ int do_svssno(Client *cptr, Client *sptr, int parc, char *parv[], int show_chan CMD_FUNC(cmd_svssno) { - return do_svssno(cptr, sptr, parc, parv, 0); + return do_svssno(sptr, parc, parv, 0); } CMD_FUNC(cmd_svs2sno) { - return do_svssno(cptr, sptr, parc, parv, 1); + return do_svssno(sptr, parc, parv, 1); } diff --git a/src/modules/svswatch.c b/src/modules/svswatch.c index 85957fabe..7bcdeaa41 100644 --- a/src/modules/svswatch.c +++ b/src/modules/svswatch.c @@ -61,6 +61,7 @@ MOD_UNLOAD() CMD_FUNC(cmd_svswatch) { Client *acptr; + if (!IsULine(sptr)) return 0; @@ -72,7 +73,7 @@ CMD_FUNC(cmd_svswatch) parv[0] = acptr->name; parv[1] = parv[2]; parv[2] = NULL; - (void)do_cmd(acptr, acptr, NULL, "WATCH", 2, parv); + (void)do_cmd(acptr, NULL, "WATCH", 2, parv); } else sendto_one(acptr, NULL, ":%s SVSWATCH %s :%s", sptr->name, parv[1], parv[2]); diff --git a/src/modules/time.c b/src/modules/time.c index eab5da475..7c2dbfdb1 100644 --- a/src/modules/time.c +++ b/src/modules/time.c @@ -61,7 +61,7 @@ MOD_UNLOAD() */ CMD_FUNC(cmd_time) { - if (hunt_server(cptr, sptr, recv_mtags, ":%s TIME :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s TIME :%s", 1, parc, parv) == HUNTED_ISME) sendnumeric(sptr, RPL_TIME, me.name, long_date(0)); return 0; } diff --git a/src/modules/tkl.c b/src/modules/tkl.c index be8cae625..806165af7 100644 --- a/src/modules/tkl.c +++ b/src/modules/tkl.c @@ -47,7 +47,7 @@ CMD_FUNC(cmd_kline); CMD_FUNC(cmd_zline); CMD_FUNC(cmd_spamfilter); CMD_FUNC(cmd_eline); -int cmd_tkl_line(Client *cptr, Client *sptr, int parc, char *parv[], char* type); +int cmd_tkl_line(Client *sptr, int parc, char *parv[], char* type); int _tkl_hash(unsigned int c); char _tkl_typetochar(int type); int _tkl_chartotype(char c); @@ -873,10 +873,10 @@ CMD_FUNC(cmd_gline) parv[0] = NULL; parv[1] = "gline"; parv[2] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 2, parv); + return do_cmd(sptr, recv_mtags, "STATS", 2, parv); } - return cmd_tkl_line(cptr, sptr, parc, parv, "G"); + return cmd_tkl_line(sptr, parc, parv, "G"); } /** GZLINE - Global zline. @@ -898,10 +898,10 @@ CMD_FUNC(cmd_gzline) parv[0] = NULL; parv[1] = "gline"; /* (there's no /STATS gzline, it's included in /STATS gline output) */ parv[2] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 2, parv); + return do_cmd(sptr, recv_mtags, "STATS", 2, parv); } - return cmd_tkl_line(cptr, sptr, parc, parv, "Z"); + return cmd_tkl_line(sptr, parc, parv, "Z"); } @@ -924,10 +924,10 @@ CMD_FUNC(cmd_shun) parv[0] = NULL; parv[1] = "shun"; parv[2] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 2, parv); + return do_cmd(sptr, recv_mtags, "STATS", 2, parv); } - return cmd_tkl_line(cptr, sptr, parc, parv, "s"); + return cmd_tkl_line(sptr, parc, parv, "s"); } @@ -1023,7 +1023,7 @@ CMD_FUNC(cmd_kline) parv[0] = NULL; parv[1] = "kline"; parv[2] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 2, parv); + return do_cmd(sptr, recv_mtags, "STATS", 2, parv); } if (!ValidatePermissionsForPath("server-ban:kline:remove",sptr,NULL,NULL,NULL) && *parv[1] == '-') @@ -1032,7 +1032,7 @@ CMD_FUNC(cmd_kline) return 0; } - return cmd_tkl_line(cptr, sptr, parc, parv, "k"); + return cmd_tkl_line(sptr, parc, parv, "k"); } /** Generate stats for '/GLINE -stats' and such */ @@ -1091,7 +1091,7 @@ CMD_FUNC(cmd_zline) parv[0] = NULL; parv[1] = "kline"; /* (there's no /STATS zline, it's included in /STATS kline output) */ parv[2] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 2, parv); + return do_cmd(sptr, recv_mtags, "STATS", 2, parv); } if ((parc > 1) && !BadPtr(parv[1]) && !strcasecmp(parv[1], "-stats")) @@ -1101,7 +1101,7 @@ CMD_FUNC(cmd_zline) return 0; } - return cmd_tkl_line(cptr, sptr, parc, parv, "z"); + return cmd_tkl_line(sptr, parc, parv, "z"); } @@ -1153,7 +1153,7 @@ int ban_too_broad(char *usermask, char *hostmask) * This allows us doing some syntax checking and other helpful * things that are the same for many types of *LINES. */ -int cmd_tkl_line(Client *cptr, Client *sptr, int parc, char *parv[], char *type) +int cmd_tkl_line(Client *sptr, int parc, char *parv[], char *type) { time_t secs; int whattodo = 0; /* 0 = add 1 = del */ @@ -1339,12 +1339,12 @@ int cmd_tkl_line(Client *cptr, Client *sptr, int parc, char *parv[], char *type) } /* call the tkl layer .. */ - cmd_tkl(&me, &me, NULL, 9, tkllayer); + cmd_tkl(&me, NULL, 9, tkllayer); } else { /* call the tkl layer .. */ - cmd_tkl(&me, &me, NULL, 6, tkllayer); + cmd_tkl(&me, NULL, 6, tkllayer); } return 0; @@ -1550,13 +1550,13 @@ CMD_FUNC(cmd_eline) tkllayer[8] = bantypes; tkllayer[9] = reason; /* call the tkl layer .. */ - cmd_tkl(&me, &me, NULL, 10, tkllayer); + cmd_tkl(&me, NULL, 10, tkllayer); } else { /* Remove ELINE */ /* call the tkl layer .. */ - cmd_tkl(&me, &me, NULL, 10, tkllayer); + cmd_tkl(&me, NULL, 10, tkllayer); } return 0; @@ -1574,7 +1574,7 @@ int spamfilter_usage(Client *sptr) } /** Helper function for cmd_spamfilter, explaining usage has changed. */ -int spamfilter_new_usage(Client *cptr, Client *sptr, char *parv[]) +int spamfilter_new_usage(Client *sptr, char *parv[]) { sendnotice(sptr, "Unknown match-type '%s'. Must be one of: -regex (new fast PCRE regexes), " "-posix (old unreal 3.2.x posix regexes) or " @@ -1584,7 +1584,7 @@ int spamfilter_new_usage(Client *cptr, Client *sptr, char *parv[]) if (*parv[2] != '-') sendnotice(sptr, "Using the old 3.2.x /SPAMFILTER syntax? Note the new -regex/-posix/-simple field!!"); - return spamfilter_usage(cptr); + return spamfilter_usage(sptr); } /** Delete a spamfilter by ID (the ID can be obtained via '/SPAMFILTER del' */ @@ -1644,7 +1644,7 @@ int spamfilter_del_by_id(Client *sptr, char *id) ircsnprintf(mo2, sizeof(mo2), "%lld", (long long)TStime()); tkllayer[7] = mo2; /* deletion time */ - cmd_tkl(&me, &me, NULL, 12, tkllayer); + cmd_tkl(&me, NULL, 12, tkllayer); return 0; } @@ -1697,7 +1697,7 @@ CMD_FUNC(cmd_spamfilter) parv[0] = NULL; parv[1] = "spamfilter"; parv[2] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 2, parv); + return do_cmd(sptr, recv_mtags, "STATS", 2, parv); } if ((parc <= 3) && !strcmp(parv[1], "del")) @@ -1711,13 +1711,13 @@ CMD_FUNC(cmd_spamfilter) parv[2] = me.name; parv[3] = "del"; parv[4] = NULL; - return do_cmd(sptr, sptr, recv_mtags, "STATS", 4, parv); + return do_cmd(sptr, recv_mtags, "STATS", 4, parv); } return spamfilter_del_by_id(sptr, parv[2]); } if ((parc == 7) && (*parv[2] != '-')) - return spamfilter_new_usage(cptr,sptr,parv); + return spamfilter_new_usage(sptr,parv); if ((parc < 8) || BadPtr(parv[7])) return spamfilter_usage(sptr); @@ -1750,7 +1750,7 @@ CMD_FUNC(cmd_spamfilter) match_type = unreal_match_method_strtoval(parv[2]+1); if (!match_type) { - return spamfilter_new_usage(cptr,sptr,parv); + return spamfilter_new_usage(sptr,parv); } targets = spamfilter_gettargets(parv[3], sptr); @@ -1824,7 +1824,7 @@ CMD_FUNC(cmd_spamfilter) tkllayer[7] = mo2; } - cmd_tkl(&me, &me, NULL, 12, tkllayer); + cmd_tkl(&me, NULL, 12, tkllayer); return 0; } @@ -3833,14 +3833,14 @@ CMD_FUNC(cmd_tkl_add) safe_strdup(tkl->set_by, parv[5]); if (type & TKL_GLOBAL) - tkl_broadcast_entry(1, sptr, cptr, tkl); + tkl_broadcast_entry(1, sptr, sptr, tkl); } return 0; } /* Below this line we will only use 'tkl'. No parc/parv reading anymore. */ - RunHook3(HOOKTYPE_TKL_ADD, cptr, sptr, tkl); + RunHook2(HOOKTYPE_TKL_ADD, sptr, tkl); sendnotice_tkl_add(tkl); @@ -3852,7 +3852,7 @@ CMD_FUNC(cmd_tkl_add) loop.do_bancheck = 1; if (type & TKL_GLOBAL) - tkl_broadcast_entry(1, sptr, cptr, tkl); + tkl_broadcast_entry(1, sptr, sptr, tkl); return 0; } @@ -3967,10 +3967,10 @@ CMD_FUNC(cmd_tkl_del) if (type & TKL_SHUN) tkl_check_local_remove_shun(tkl); - RunHook3(HOOKTYPE_TKL_DEL, cptr, sptr, tkl); + RunHook2(HOOKTYPE_TKL_DEL, sptr, tkl); if (type & TKL_GLOBAL) - tkl_broadcast_entry(0, sptr, cptr, tkl); + tkl_broadcast_entry(0, sptr, sptr, tkl); if (TKLIsBanException(tkl)) @@ -4029,9 +4029,9 @@ CMD_FUNC(_cmd_tkl) switch (*parv[1]) { case '+': - return cmd_tkl_add(cptr, sptr, recv_mtags, parc, parv); + return cmd_tkl_add(sptr, recv_mtags, parc, parv); case '-': - return cmd_tkl_del(cptr, sptr, recv_mtags, parc, parv); + return cmd_tkl_del(sptr, recv_mtags, parc, parv); default: break; } @@ -4138,7 +4138,7 @@ int _place_host_ban(Client *sptr, BanAction action, char *reason, long duration) tkllayer[6] = mo; tkllayer[7] = mo2; tkllayer[8] = reason; - cmd_tkl(&me, &me, NULL, 9, tkllayer); + cmd_tkl(&me, NULL, 9, tkllayer); if ((action == BAN_ACT_SHUN) || (action == BAN_ACT_SOFT_SHUN)) { find_shun(sptr); @@ -4231,7 +4231,7 @@ int _join_viruschan(Client *sptr, TKL *tkl, int type) /* RECURSIVE CAUTION in case we ever add blacklisted chans */ spamf_ugly_vchanoverride = 1; - ret = do_cmd(sptr, sptr, NULL, "JOIN", 2, xparv); + ret = do_cmd(sptr, NULL, "JOIN", 2, xparv); spamf_ugly_vchanoverride = 0; if (ret == FLUSH_BUFFER) diff --git a/src/modules/topic.c b/src/modules/topic.c index 59caea90d..900be4263 100644 --- a/src/modules/topic.c +++ b/src/modules/topic.c @@ -173,11 +173,11 @@ CMD_FUNC(cmd_topic) chptr->topic_time = ttime; new_message(sptr, recv_mtags, &mtags); - RunHook5(HOOKTYPE_TOPIC, cptr, sptr, chptr, mtags, topic); - sendto_server(cptr, PROTO_SID, 0, mtags, ":%s TOPIC %s %s %lld :%s", + RunHook4(HOOKTYPE_TOPIC, sptr, chptr, mtags, topic); + sendto_server(sptr, PROTO_SID, 0, mtags, ":%s TOPIC %s %s %lld :%s", ID(sptr), chptr->chname, chptr->topic_nick, (long long)chptr->topic_time, chptr->topic); - sendto_server(cptr, 0, PROTO_SID, mtags, ":%s TOPIC %s %s %lld :%s", + sendto_server(sptr, 0, PROTO_SID, mtags, ":%s TOPIC %s %s %lld :%s", sptr->name, chptr->chname, chptr->topic_nick, (long long)chptr->topic_time, chptr->topic); sendto_channel(chptr, sptr, NULL, 0, 0, SEND_LOCAL, mtags, @@ -267,14 +267,14 @@ CMD_FUNC(cmd_topic) safe_strldup(chptr->topic, topic, iConf.topic_length+1); safe_strldup(chptr->topic_nick, tnick, NICKLEN+USERLEN+HOSTLEN+5); - if (ttime && IsServer(cptr)) + if (ttime && !MyUser(sptr)) chptr->topic_time = ttime; else chptr->topic_time = TStime(); new_message(sptr, recv_mtags, &mtags); - RunHook5(HOOKTYPE_TOPIC, cptr, sptr, chptr, mtags, topic); - sendto_server(cptr, 0, 0, mtags, ":%s TOPIC %s %s %lld :%s", + RunHook4(HOOKTYPE_TOPIC, sptr, chptr, mtags, topic); + sendto_server(sptr, 0, 0, mtags, ":%s TOPIC %s %s %lld :%s", sptr->name, chptr->chname, chptr->topic_nick, (long long)chptr->topic_time, chptr->topic); sendto_channel(chptr, sptr, NULL, 0, 0, SEND_LOCAL, mtags, diff --git a/src/modules/trace.c b/src/modules/trace.c index 40510a87b..43316dbee 100644 --- a/src/modules/trace.c +++ b/src/modules/trace.c @@ -71,7 +71,7 @@ CMD_FUNC(cmd_trace) // set some kind of flag? or? if (parc > 2) - if (hunt_server(cptr, sptr, NULL, ":%s TRACE %s :%s", 2, parc, parv)) + if (hunt_server(sptr, NULL, ":%s TRACE %s :%s", 2, parc, parv)) return 0; if (parc > 1) @@ -96,7 +96,7 @@ CMD_FUNC(cmd_trace) } } - switch (hunt_server(cptr, sptr, NULL, ":%s TRACE :%s", 1, parc, parv)) + switch (hunt_server(sptr, NULL, ":%s TRACE :%s", 1, parc, parv)) { case HUNTED_PASS: /* note: gets here only if parv[1] exists */ { diff --git a/src/modules/tsctl.c b/src/modules/tsctl.c index 8683dc6bd..1a0f3d9b3 100644 --- a/src/modules/tsctl.c +++ b/src/modules/tsctl.c @@ -66,7 +66,7 @@ CMD_FUNC(cmd_tsctl) { sendnotice(sptr, "*** Server=%s TStime=%lld", me.name, (long long)TStime()); - sendto_server(cptr, 0, 0, NULL, ":%s TSCTL alltime", sptr->name); + sendto_server(sptr, 0, 0, NULL, ":%s TSCTL alltime", sptr->name); return 0; } diff --git a/src/modules/umode2.c b/src/modules/umode2.c index 0366b3f6b..2ff5448ea 100644 --- a/src/modules/umode2.c +++ b/src/modules/umode2.c @@ -55,7 +55,7 @@ MOD_UNLOAD() /* cmd_umode2 added by Stskeeps parv[1] - modes to change - Small wrapper to bandwidth save + Small wrapper to save bandwidth */ CMD_FUNC(cmd_umode2) @@ -70,5 +70,5 @@ CMD_FUNC(cmd_umode2) if (!parv[1]) return 0; - return cmd_umode(cptr, sptr, recv_mtags, (parc > 3) ? 4 : 3, xparv); + return cmd_umode(sptr, recv_mtags, (parc > 3) ? 4 : 3, xparv); } diff --git a/src/modules/unsqline.c b/src/modules/unsqline.c index 8bcd4ca9c..6d5c3f982 100644 --- a/src/modules/unsqline.c +++ b/src/modules/unsqline.c @@ -70,7 +70,7 @@ CMD_FUNC(cmd_unsqline) if (parc < 2) return 0; - cmd_tkl(&me, &me, NULL, 6, tkllayer); + cmd_tkl(&me, NULL, 6, tkllayer); return 0; } diff --git a/src/modules/user.c b/src/modules/user.c index 19e883836..053cafa54 100644 --- a/src/modules/user.c +++ b/src/modules/user.c @@ -72,17 +72,19 @@ CMD_FUNC(cmd_user) char *virthost = NULL; char *ip = NULL; char *sstamp = NULL; + Client *cptr = sptr->direction; /* Lazyness, since this function should be rewritten anyway */ - if (IsServer(cptr) && !IsUnknown(sptr)) + // Eh, this is for old remote USER shit (which we currently still use indirectly via do_cmd). + // TODO: cleanup. Also, hope this is right: + if (!MyConnect(sptr) && !IsUnknown(sptr)) return 0; if (MyConnect(sptr) && (sptr->local->listener->options & LISTENER_SERVERSONLY)) - { - return exit_client(cptr, sptr, sptr, NULL, "This port is for servers only"); - } + return exit_client(sptr->direction, sptr, sptr, NULL, "This port is for servers only"); if (parc > 2 && (username = strchr(parv[1], '@'))) *username = '\0'; + if (parc < 5 || *parv[1] == '\0' || *parv[2] == '\0' || *parv[3] == '\0' || *parv[4] == '\0') { @@ -179,9 +181,7 @@ CMD_FUNC(cmd_user) me.name, sptr->name); if (strlen(username) > USERLEN) username[USERLEN] = '\0'; /* cut-off */ - return( - register_user(cptr, sptr, sptr->name, username, umodex, - virthost,ip)); + return register_user(sptr, sptr->name, username, umodex, virthost, ip); } return 0; diff --git a/src/modules/userhost.c b/src/modules/userhost.c index b79052ebd..963cc1629 100644 --- a/src/modules/userhost.c +++ b/src/modules/userhost.c @@ -62,7 +62,7 @@ CMD_FUNC(cmd_userhost) { char *p; /* scratch end pointer */ char *cn; /* current name */ - struct Client *acptr; + Client *acptr; char response[5][NICKLEN * 2 + CHANNELLEN + USERLEN + HOSTLEN + 30]; int i; /* loop counter */ diff --git a/src/modules/userip.c b/src/modules/userip.c index e32de8938..0f0fe9494 100644 --- a/src/modules/userip.c +++ b/src/modules/userip.c @@ -66,7 +66,7 @@ CMD_FUNC(cmd_userip) char *p; /* scratch end pointer */ char *cn; /* current name */ char *ip, ipbuf[HOSTLEN+1]; - struct Client *acptr; + Client *acptr; char response[5][NICKLEN * 2 + CHANNELLEN + USERLEN + HOSTLEN + 30]; int i; /* loop counter */ diff --git a/src/modules/usermodes/bot.c b/src/modules/usermodes/bot.c index 26b6d7f66..01c7b585e 100644 --- a/src/modules/usermodes/bot.c +++ b/src/modules/usermodes/bot.c @@ -90,7 +90,7 @@ int bot_umode_change(Client *sptr, long oldmode, long newmode) char *parv[2]; parv[0] = sptr->name; parv[1] = NULL; - (void)do_cmd(sptr, sptr, NULL, "BOTMOTD", 1, parv); + (void)do_cmd(sptr, NULL, "BOTMOTD", 1, parv); } return 0; diff --git a/src/modules/vhost.c b/src/modules/vhost.c index fd78454dd..614cd07ab 100644 --- a/src/modules/vhost.c +++ b/src/modules/vhost.c @@ -99,7 +99,7 @@ CMD_FUNC(cmd_vhost) return 0; } - if (!Auth_Check(cptr, vhost->auth, password)) + if (!Auth_Check(sptr, vhost->auth, password)) { sendto_snomask(SNO_VHOST, "[\2vhost\2] Failed login for vhost %s by %s!%s@%s - incorrect password", @@ -143,12 +143,12 @@ CMD_FUNC(cmd_vhost) { strcpy(olduser, sptr->user->username); strlcpy(sptr->user->username, vhost->virtuser, USERLEN); - sendto_server(cptr, 0, 0, NULL, ":%s SETIDENT %s", sptr->name, + sendto_server(sptr, 0, 0, NULL, ":%s SETIDENT %s", sptr->name, sptr->user->username); } sptr->umodes |= UMODE_HIDE; sptr->umodes |= UMODE_SETHOST; - sendto_server(cptr, 0, 0, NULL, ":%s SETHOST %s", sptr->name, sptr->user->virthost); + sendto_server(sptr, 0, 0, NULL, ":%s SETHOST %s", sptr->name, sptr->user->virthost); sendto_one(sptr, NULL, ":%s MODE %s :+tx", sptr->name, sptr->name); if (vhost->swhois) { diff --git a/src/modules/wallops.c b/src/modules/wallops.c index f88d30f61..0d6fa4327 100644 --- a/src/modules/wallops.c +++ b/src/modules/wallops.c @@ -73,8 +73,8 @@ CMD_FUNC(cmd_wallops) return 0; } - sendto_ops_butone(IsServer(cptr) ? cptr : NULL, sptr, - ":%s WALLOPS :%s", sptr->name, message); + // FIXME: verify: not sure about direction @ sptr, here or in send.c + sendto_ops_butone(sptr, sptr, ":%s WALLOPS :%s", sptr->name, message); return 0; } diff --git a/src/modules/webirc.c b/src/modules/webirc.c index f490be4b1..92dbfea4a 100644 --- a/src/modules/webirc.c +++ b/src/modules/webirc.c @@ -415,7 +415,7 @@ CMD_FUNC(cmd_webirc) if ((parc < 5) || BadPtr(parv[4])) { - sendnumeric(cptr, ERR_NEEDMOREPARAMS, "WEBIRC"); + sendnumeric(sptr, ERR_NEEDMOREPARAMS, "WEBIRC"); return -1; } @@ -427,10 +427,10 @@ CMD_FUNC(cmd_webirc) /* Check if allowed host */ e = Find_webirc(sptr, password, WEBIRC_WEBIRC, &error); if (!e) - return exit_client(cptr, sptr, &me, NULL, error); + return exit_client(sptr, sptr, &me, NULL, error); /* And do our job.. */ - return dowebirc(cptr, ip, host, options); + return dowebirc(sptr, ip, host, options); } diff --git a/src/modules/websocket.c b/src/modules/websocket.c index c872bf6ed..b8782fb5d 100644 --- a/src/modules/websocket.c +++ b/src/modules/websocket.c @@ -514,7 +514,7 @@ int websocket_handle_handshake(Client *sptr, char *readbuf, int *length) if (is_module_loaded("webredir")) { char *parx[2] = { NULL, NULL }; - do_cmd(sptr, sptr, NULL, "GET", 1, parx); + do_cmd(sptr, NULL, "GET", 1, parx); } dead_link(sptr, "Invalid WebSocket request"); return -1; diff --git a/src/modules/whois.c b/src/modules/whois.c index 1c7639d6a..f55c4f2bb 100644 --- a/src/modules/whois.c +++ b/src/modules/whois.c @@ -80,7 +80,7 @@ CMD_FUNC(cmd_whois) if (parc > 2) { - if (hunt_server(cptr, sptr, recv_mtags, ":%s WHOIS %s :%s", 1, parc, parv) != HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s WHOIS %s :%s", 1, parc, parv) != HUNTED_ISME) return 0; parv[1] = parv[2]; } diff --git a/src/modules/whowas.c b/src/modules/whowas.c index b3481ea3d..22674ec04 100644 --- a/src/modules/whowas.c +++ b/src/modules/whowas.c @@ -75,7 +75,7 @@ CMD_FUNC(cmd_whowas) if (parc > 2) max = atoi(parv[2]); if (parc > 3) - if (hunt_server(cptr, sptr, recv_mtags, ":%s WHOWAS %s %s :%s", 3, parc, parv)) + if (hunt_server(sptr, recv_mtags, ":%s WHOWAS %s %s :%s", 3, parc, parv)) return 0; if (!MyConnect(sptr) && (max > 20)) diff --git a/src/packet.c b/src/packet.c index a39b1f1da..b935b47b6 100644 --- a/src/packet.c +++ b/src/packet.c @@ -166,12 +166,12 @@ RealCommand *find_Command_simple(char *cmd) * of 1024 bytes, most of the ircd code depends on the max size of the * total command being less than 512 bytes. Same for parc < MAXPARA. */ -int do_cmd(Client *cptr, Client *sptr, MessageTag *mtags, char *cmd, int parc, char *parv[]) +int do_cmd(Client *sptr, MessageTag *mtags, char *cmd, int parc, char *parv[]) { RealCommand *cmptr; cmptr = find_Command_simple(cmd); if (!cmptr) return -99; - return (*cmptr->func) (cptr, sptr, mtags, parc, parv); + return (*cmptr->func) (sptr, mtags, parc, parv); } diff --git a/src/parse.c b/src/parse.c index 3e779064f..7ebc23262 100644 --- a/src/parse.c +++ b/src/parse.c @@ -28,6 +28,7 @@ char backupbuf[8192]; static char *para[MAXPARA + 2]; +static int do_numeric(int, Client *, MessageTag *, int, char **); static int cancel_clients(Client *, Client *, char *); static void remove_unknown(Client *, char *); @@ -399,7 +400,7 @@ int parse2(Client *cptr, Client **fromptr, MessageTag *mtags, char *ch) } para[++i] = NULL; if (cmptr == NULL) - return do_numeric(numeric, cptr, from, mtags, i, para); + return do_numeric(numeric, from, mtags, i, para); cmptr->count++; if (IsUser(cptr) && (cmptr->flags & CMD_RESETIDLE)) cptr->local->last = TStime(); @@ -407,22 +408,22 @@ int parse2(Client *cptr, Client **fromptr, MessageTag *mtags, char *ch) #ifndef DEBUGMODE if (cmptr->flags & CMD_ALIAS) { - return (*cmptr->aliasfunc) (cptr, from, mtags, i, para, cmptr->cmd); + return (*cmptr->aliasfunc) (from, mtags, i, para, cmptr->cmd); } else { if (!cmptr->overriders) - return (*cmptr->func) (cptr, from, mtags, i, para); - return (*cmptr->overridetail->func) (cmptr->overridetail, cptr, from, mtags, i, para); + return (*cmptr->func) (from, mtags, i, para); + return (*cmptr->overridetail->func) (cmptr->overridetail, from, mtags, i, para); } #else then = clock(); if (cmptr->flags & CMD_ALIAS) { - retval = (*cmptr->aliasfunc) (cptr, from, mtags, i, para, cmptr->cmd); + retval = (*cmptr->aliasfunc) (from, mtags, i, para, cmptr->cmd); } else { if (!cmptr->overriders) - retval = (*cmptr->func) (cptr, from, mtags, i, para); + retval = (*cmptr->func) (from, mtags, i, para); else - retval = (*cmptr->overridetail->func) (cmptr->overridetail, cptr, from, mtags, i, para); + retval = (*cmptr->overridetail->func) (cmptr->overridetail, from, mtags, i, para); } if (retval != FLUSH_BUFFER) { @@ -447,7 +448,7 @@ int parse2(Client *cptr, Client **fromptr, MessageTag *mtags, char *ch) * @notes In general you should NOT send anything back if you receive * a numeric, this to prevent creating loops. */ -int do_numeric(int numeric, Client *cptr, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]) +static int do_numeric(int numeric, Client *sptr, MessageTag *recv_mtags, int parc, char *parv[]) { Client *acptr; Channel *chptr; @@ -458,7 +459,7 @@ int do_numeric(int numeric, Client *cptr, Client *sptr, MessageTag *recv_mtags, if ((numeric < 0) || (numeric > 999)) return -1; - if (!IsServer(sptr) && !IsUser(sptr) && IsHandshake(cptr) && sptr->serv && !IsServerSent(sptr)) + if (MyConnect(sptr) && !IsServer(sptr) && !IsUser(sptr) && IsHandshake(sptr) && sptr->serv && !IsServerSent(sptr)) { /* This is an outgoing server connect that is currently not yet IsServer() but in 'unknown' state. * We need to handle a few responses here. @@ -477,29 +478,29 @@ int do_numeric(int numeric, Client *cptr, Client *sptr, MessageTag *recv_mtags, /* STARTTLS: unknown command */ if ((numeric == 451) && (parc > 2) && strstr(parv[1], "STARTTLS")) { - if (cptr->serv->conf && (cptr->serv->conf->outgoing.options & CONNECT_INSECURE)) - start_server_handshake(cptr); + if (sptr->serv->conf && (sptr->serv->conf->outgoing.options & CONNECT_INSECURE)) + start_server_handshake(sptr); else - reject_insecure_server(cptr); + reject_insecure_server(sptr); return 0; } /* STARTTLS failed */ if (numeric == 691) { - sendto_umode(UMODE_OPER, "STARTTLS failed for link %s. Please check the other side of the link.", cptr->name); - reject_insecure_server(cptr); + sendto_umode(UMODE_OPER, "STARTTLS failed for link %s. Please check the other side of the link.", sptr->name); + reject_insecure_server(sptr); return 0; } /* STARTTLS OK */ if (numeric == 670) { - int ret = client_starttls(cptr); + int ret = client_starttls(sptr); if (ret < 0) { - sendto_umode(UMODE_OPER, "STARTTLS handshake failed for link %s. Strange.", cptr->name); - reject_insecure_server(cptr); + sendto_umode(UMODE_OPER, "STARTTLS handshake failed for link %s. Strange.", sptr->name); + reject_insecure_server(sptr); return ret; } /* We don't call start_server_handshake() here. First the TLS handshake will @@ -535,13 +536,13 @@ int do_numeric(int numeric, Client *cptr, Client *sptr, MessageTag *recv_mtags, sendto_prefix_one(acptr, sptr, recv_mtags, ":%s %d %s%s", sptr->name, numeric, nick, buffer); } - else if (IsServer(acptr) && acptr->direction != cptr) + else if (IsServer(acptr) && acptr->direction != sptr->direction) sendto_prefix_one(acptr, sptr, recv_mtags, ":%s %d %s%s", sptr->name, numeric, nick, buffer); } else if ((acptr = find_server_quick(nick))) { - if (!IsMe(acptr) && acptr->direction != cptr) + if (!IsMe(acptr) && acptr->direction != sptr->direction) sendto_prefix_one(acptr, sptr, recv_mtags, ":%s %d %s%s", sptr->name, numeric, nick, buffer); } diff --git a/src/send.c b/src/send.c index e5cf36f08..4db1fe438 100644 --- a/src/send.c +++ b/src/send.c @@ -24,7 +24,7 @@ void vsendto_one(Client *to, MessageTag *mtags, const char *pattern, va_list vl); void sendbufto_one(Client *to, char *msg, unsigned int quick); -static int vmakebuf_local_withprefix(char *buf, size_t buflen, struct Client *from, const char *pattern, va_list vl); +static int vmakebuf_local_withprefix(char *buf, size_t buflen, Client *from, const char *pattern, va_list vl); #define ADD_CRLF(buf, len) { if (len > 510) len = 510; \ buf[len++] = '\r'; buf[len++] = '\n'; buf[len] = '\0'; } while(0) @@ -34,7 +34,7 @@ static int vmakebuf_local_withprefix(char *buf, size_t buflen, struct Client *fr static char sendbuf[2048]; static char sendbuf2[4096]; -void vsendto_prefix_one(struct Client *to, struct Client *from, MessageTag *mtags, +void vsendto_prefix_one(Client *to, Client *from, MessageTag *mtags, const char *pattern, va_list vl); MODVAR int current_serial; @@ -854,7 +854,7 @@ void sendto_ops_butone(Client *one, Client *from, FORMAT_STRING(const char *patt * they do not want or need the expanded prefix. In that case, simply * use ircvsnprintf() directly. */ -static int vmakebuf_local_withprefix(char *buf, size_t buflen, struct Client *from, const char *pattern, va_list vl) +static int vmakebuf_local_withprefix(char *buf, size_t buflen, Client *from, const char *pattern, va_list vl) { int len; @@ -899,8 +899,7 @@ static int vmakebuf_local_withprefix(char *buf, size_t buflen, struct Client *fr return len; } -void vsendto_prefix_one(struct Client *to, struct Client *from, MessageTag *mtags, - const char *pattern, va_list vl) +void vsendto_prefix_one(Client *to, Client *from, MessageTag *mtags, const char *pattern, va_list vl) { char *mtags_str = mtags ? mtags_to_string(mtags, to) : NULL; @@ -1066,51 +1065,51 @@ void sendto_serv_butone_nickcmd(Client *one, Client *sptr, char *umodes) * @param sptr Client to introduce * @param umodes User modes of client */ -void sendto_one_nickcmd(Client *cptr, Client *sptr, char *umodes) +void sendto_one_nickcmd(Client *server, Client *client, char *umodes) { char *vhost; if (!*umodes) umodes = "+"; - if (SupportVHP(cptr)) + if (SupportVHP(server)) { - if (IsHidden(sptr)) - vhost = sptr->user->virthost; + if (IsHidden(client)) + vhost = client->user->virthost; else - vhost = sptr->user->realhost; + vhost = client->user->realhost; } else { - if (IsHidden(sptr) && sptr->umodes & UMODE_SETHOST) - vhost = sptr->user->virthost; + if (IsHidden(client) && client->umodes & UMODE_SETHOST) + vhost = client->user->virthost; else vhost = "*"; } - if (CHECKPROTO(cptr, PROTO_SID) && *sptr->id) + if (CHECKPROTO(server, PROTO_SID) && *client->id) { - sendto_one(cptr, NULL, + sendto_one(server, NULL, ":%s UID %s %d %lld %s %s %s %s %s %s %s %s :%s", - sptr->srvptr->id, sptr->name, sptr->hopcount, - (long long)sptr->lastnick, - sptr->user->username, sptr->user->realhost, sptr->id, - sptr->user->svid, umodes, vhost, getcloak(sptr), - encode_ip(sptr->ip), sptr->info); + client->srvptr->id, client->name, client->hopcount, + (long long)client->lastnick, + client->user->username, client->user->realhost, client->id, + client->user->svid, umodes, vhost, getcloak(client), + encode_ip(client->ip), client->info); return; } - sendto_one(cptr, NULL, + sendto_one(server, NULL, "NICK %s %d %lld %s %s %s %s %s %s %s%s%s%s:%s", - sptr->name, sptr->hopcount+1, - (long long)sptr->lastnick, sptr->user->username, - sptr->user->realhost, sptr->srvptr->name, - sptr->user->svid, umodes, vhost, - CHECKPROTO(cptr, PROTO_CLK) ? getcloak(sptr) : "", - CHECKPROTO(cptr, PROTO_CLK) ? " " : "", - CHECKPROTO(cptr, PROTO_NICKIP) ? encode_ip(sptr->ip) : "", - CHECKPROTO(cptr, PROTO_NICKIP) ? " " : "", - sptr->info); + client->name, client->hopcount+1, + (long long)client->lastnick, client->user->username, + client->user->realhost, client->srvptr->name, + client->user->svid, umodes, vhost, + CHECKPROTO(server, PROTO_CLK) ? getcloak(client) : "", + CHECKPROTO(server, PROTO_CLK) ? " " : "", + CHECKPROTO(server, PROTO_NICKIP) ? encode_ip(client->ip) : "", + CHECKPROTO(server, PROTO_NICKIP) ? " " : "", + client->info); return; } diff --git a/src/serv.c b/src/serv.c index c000b3fc1..fccf42dc0 100644 --- a/src/serv.c +++ b/src/serv.c @@ -155,13 +155,13 @@ void send_version(Client* sptr, int reply) CMD_FUNC(cmd_version) { /* Only allow remote VERSIONs if registered -- Syzop */ - if (!IsUser(sptr) && !IsServer(cptr)) + if (!IsUser(sptr) && !IsServer(sptr)) { - send_version(sptr,RPL_ISUPPORT); + send_version(sptr, RPL_ISUPPORT); return 0; } - if (hunt_server(cptr, sptr, recv_mtags, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s VERSION :%s", 1, parc, parv) == HUNTED_ISME) { sendnumeric(sptr, RPL_VERSION, version, debugmode, me.name, (ValidatePermissionsForPath("server:info",sptr,NULL,NULL,NULL) ? serveropts : "0"), @@ -299,7 +299,7 @@ CMD_FUNC(cmd_info) if (remotecmdfilter(sptr, parc, parv)) return 0; - if (hunt_server(cptr, sptr, recv_mtags, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME) { cmd_info_send(sptr); } @@ -318,7 +318,7 @@ CMD_FUNC(cmd_dalinfo) if (remotecmdfilter(sptr, parc, parv)) return 0; - if (hunt_server(cptr, sptr, recv_mtags, ":%s DALINFO :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s DALINFO :%s", 1, parc, parv) == HUNTED_ISME) { while (*text) sendnumeric(sptr, RPL_INFO, *text++); @@ -344,7 +344,7 @@ CMD_FUNC(cmd_license) if (remotecmdfilter(sptr, parc, parv)) return 0; - if (hunt_server(cptr, sptr, recv_mtags, ":%s LICENSE :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s LICENSE :%s", 1, parc, parv) == HUNTED_ISME) { while (*text) sendnumeric(sptr, RPL_INFO, *text++); @@ -367,7 +367,7 @@ CMD_FUNC(cmd_credits) if (remotecmdfilter(sptr, parc, parv)) return 0; - if (hunt_server(cptr, sptr, recv_mtags, ":%s CREDITS :%s", 1, parc, parv) == HUNTED_ISME) + if (hunt_server(sptr, recv_mtags, ":%s CREDITS :%s", 1, parc, parv) == HUNTED_ISME) { while (*text) sendnumeric(sptr, RPL_INFO, *text++); @@ -464,6 +464,9 @@ CMD_FUNC(cmd_error) { char *para; + if (!MyConnect(sptr)) + return 0; + para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; Debug((DEBUG_ERROR, "Received ERROR message from %s: %s", @@ -474,15 +477,15 @@ CMD_FUNC(cmd_error) * This to prevent flooding and confusing IRCOps by * malicious users. */ - if (!IsServer(cptr) && !cptr->serv) + if (!IsServer(sptr) && !sptr->serv) { sendto_snomask(SNO_JUNK, "ERROR from %s -- %s", - get_client_name(cptr, FALSE), para); + get_client_name(sptr, FALSE), para); return 0; } sendto_umode_global(UMODE_OPER, "ERROR from %s -- %s", - get_client_name(cptr, FALSE), para); + get_client_name(sptr, FALSE), para); return 0; } @@ -582,13 +585,13 @@ CMD_FUNC(cmd_rehash) if (parv[1] && (parv[1][0] == '-')) x = HUNTED_ISME; else - x = hunt_server(cptr, sptr, recv_mtags, ":%s REHASH :%s", 1, parc, parv); + x = hunt_server(sptr, recv_mtags, ":%s REHASH :%s", 1, parc, parv); } else { if (match_simple("-glob*", parv[1])) /* This is really ugly... hack to make /rehash -global -something work */ { x = HUNTED_ISME; } else { - x = hunt_server(cptr, sptr, NULL, ":%s REHASH %s :%s", 1, parc, parv); + x = hunt_server(sptr, NULL, ":%s REHASH %s :%s", 1, parc, parv); // XXX: FIXME: labeled-response can't handle this, multiple servers. } } @@ -611,7 +614,7 @@ CMD_FUNC(cmd_rehash) return 0; } - if (cptr != sptr) + if (!MyConnect(sptr)) { #ifndef REMOTE_REHASH sendnumeric(sptr, ERR_NOPRIVILEGES); @@ -627,12 +630,12 @@ CMD_FUNC(cmd_rehash) sendto_umode_global(UMODE_OPER, "%s is remotely rehashing server %s config file", sptr->name, me.name); remote_rehash_client = sptr; reread_motdsandrules(); - return rehash(cptr, sptr, - (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0); + // TODO: clean this next line up, wtf man. + return rehash(sptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0); } parv[1] = parv[2]; } else { - /* Ok this is in an 'else' because it should be only executed for sptr == cptr, + /* Ok this is in an 'else' because it should be only executed for local clients, * but it's totally unrelated to the above ;). */ if (parv[1] && match_simple("-glob*", parv[1])) @@ -687,7 +690,7 @@ CMD_FUNC(cmd_rehash) if (!strncasecmp("-gar", parv[1], 4)) { loop.do_garbage_collect = 1; - RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]); + RunHook2(HOOKTYPE_REHASHFLAG, sptr, parv[1]); return 0; } if (!strncasecmp("-dns", parv[1], 4)) @@ -702,36 +705,35 @@ CMD_FUNC(cmd_rehash) } if (match_simple("-o*motd", parv[1])) { - if (cptr != sptr) - sendto_umode_global(UMODE_OPER, "Remotely rehashing OPERMOTD on request of %s", sptr->name); - else + if (MyUser(sptr)) sendto_ops("Rehashing OPERMOTD on request of %s", sptr->name); + else + sendto_umode_global(UMODE_OPER, "Remotely rehashing OPERMOTD on request of %s", sptr->name); read_motd(conf_files->opermotd_file, &opermotd); - RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]); + RunHook2(HOOKTYPE_REHASHFLAG, sptr, parv[1]); return 0; } if (match_simple("-b*motd", parv[1])) { - if (cptr != sptr) - sendto_umode_global(UMODE_OPER, "Remotely rehashing BOTMOTD on request of %s", sptr->name); - else + if (MyUser(sptr)) sendto_ops("Rehashing BOTMOTD on request of %s", sptr->name); - read_motd(conf_files->botmotd_file, &botmotd); - RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]); - return 0; - } - if (!strncasecmp("-motd", parv[1], 5) - || !strncasecmp("-rules", parv[1], 6)) - { - if (cptr != sptr) - sendto_umode_global(UMODE_OPER, "Remotely rehasing all MOTDs and RULES on request of %s", sptr->name); else - sendto_ops("Rehashing all MOTDs and RULES on request of %s", sptr->name); - rehash_motdrules(); - RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]); + sendto_umode_global(UMODE_OPER, "Remotely rehashing BOTMOTD on request of %s", sptr->name); + read_motd(conf_files->botmotd_file, &botmotd); + RunHook2(HOOKTYPE_REHASHFLAG, sptr, parv[1]); return 0; } - RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]); + if (!strncasecmp("-motd", parv[1], 5) || !strncasecmp("-rules", parv[1], 6)) + { + if (MyUser(sptr)) + sendto_ops("Rehashing all MOTDs and RULES on request of %s", sptr->name); + else + sendto_umode_global(UMODE_OPER, "Remotely rehasing all MOTDs and RULES on request of %s", sptr->name); + rehash_motdrules(); + RunHook2(HOOKTYPE_REHASHFLAG, sptr, parv[1]); + return 0; + } + RunHook2(HOOKTYPE_REHASHFLAG, sptr, parv[1]); return 0; } } @@ -746,9 +748,9 @@ CMD_FUNC(cmd_rehash) } /* Normal rehash, rehash motds&rules too, just like the on in the tld block will :p */ - if (cptr == sptr) - sendnumeric(sptr, RPL_REHASHING, configfile); - x = rehash(cptr, sptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0); + sendnumeric(sptr, RPL_REHASHING, configfile); + // TODO: fix next line - occurence #2 + x = rehash(sptr, (parc > 1) ? ((*parv[1] == 'q') ? 2 : 0) : 0); reread_motdsandrules(); return x; } @@ -761,9 +763,12 @@ CMD_FUNC(cmd_rehash) */ CMD_FUNC(cmd_restart) { -char *reason = parv[1]; + char *reason = parv[1]; Client *acptr; + if (!MyUser(sptr)) + return 0; + /* Check permissions */ if (!ValidatePermissionsForPath("server:restart",sptr,NULL,NULL,NULL)) { @@ -785,7 +790,7 @@ char *reason = parv[1]; /* Syntax: /restart [reason] */ if (conf_drpass) { - if (!Auth_Check(cptr, conf_drpass->restartauth, parv[1])) + if (!Auth_Check(sptr, conf_drpass->restartauth, parv[1])) { sendnumeric(sptr, ERR_PASSWDMISMATCH); return 0; @@ -1089,6 +1094,9 @@ CMD_FUNC(cmd_die) { Client *acptr; + if (!MyUser(sptr)) + return 0; + if (!ValidatePermissionsForPath("server:die",sptr,NULL,NULL,NULL)) { sendnumeric(sptr, ERR_NOPRIVILEGES); @@ -1102,7 +1110,7 @@ CMD_FUNC(cmd_die) sendnumeric(sptr, ERR_NEEDMOREPARAMS, "DIE"); return 0; } - if (!Auth_Check(cptr, conf_drpass->dieauth, parv[1])) + if (!Auth_Check(sptr, conf_drpass->dieauth, parv[1])) { sendnumeric(sptr, ERR_PASSWDMISMATCH); return 0; @@ -1132,7 +1140,7 @@ CMD_FUNC(cmd_die) * Added to let the local console shutdown the server without just * calling exit(-1), in Windows mode. -Cabal95 */ -int localdie(void) +int localdie(void) { Client *acptr; diff --git a/src/user.c b/src/user.c index ba2e40367..80f11d92d 100644 --- a/src/user.c +++ b/src/user.c @@ -25,15 +25,9 @@ #include "unrealircd.h" -void send_umode_out(Client *, Client *, long); -void send_umode(Client *, Client *, long, long, char *); -void set_snomask(Client *, char *); extern int short_motd(Client *sptr); -extern Channel *get_channel(Client *cptr, char *chname, int flag); -/* static Link *is_banned(Client *, Channel *); */ -int dontspread = 0; -extern char *me_hash; -extern char backupbuf[]; + +int dontspread = 0; static char buf[BUFSIZE]; MODVAR int labeled_response_inhibit = 0; @@ -179,7 +173,7 @@ long set_usermode(char *umode) ** complex and no longer understandable. It also was responsible ** for mysterious issues and crashes. Hence rewritten. */ -int hunt_server(Client *cptr, Client *sptr, MessageTag *mtags, char *command, int server, int parc, char *parv[]) +int hunt_server(Client *sptr, MessageTag *mtags, char *command, int server, int parc, char *parv[]) { Client *acptr; char *saved; @@ -444,16 +438,15 @@ void set_snomask(Client *sptr, char *snomask) { } } -/* - * send the MODE string for user (user) to connection cptr - * -avalon +/** Build the MODE line with (modified) user modes for this user. + * Originally by avalon. */ -void send_umode(Client *cptr, Client *sptr, long old, long sendmask, char *umode_buf) +void build_umode_string(Client *sptr, long old, long sendmask, char *umode_buf) { int i; long flag; char *m; - int what = MODE_NULL; + int what = MODE_NULL; /* * build a string in umode_buf to represent the change in the user's @@ -492,32 +485,29 @@ void send_umode(Client *cptr, Client *sptr, long old, long sendmask, char *umode } } *m = '\0'; - if (*umode_buf && cptr) - sendto_one(cptr, NULL, ":%s MODE %s :%s", sptr->name, - sptr->name, umode_buf); } -/* - * added Sat Jul 25 07:30:42 EST 1992 - */ -void send_umode_out(Client *cptr, Client *sptr, long old) +void send_umode_out(Client *sptr, int show_to_user, long old) { Client *acptr; - send_umode(NULL, sptr, old, SEND_UMODES, buf); + build_umode_string(sptr, old, SEND_UMODES, buf); list_for_each_entry(acptr, &server_list, special_node) { - if ((acptr != cptr) && (acptr != sptr) && *buf) + if ((acptr != sptr) && (acptr != sptr->direction) && *buf) { sendto_one(acptr, NULL, ":%s UMODE2 %s", - sptr->name, - buf); + sptr->name, buf); } } - if (cptr && MyUser(cptr)) - send_umode(cptr, sptr, old, ALL_UMODES, buf); + if (MyUser(sptr) && show_to_user) + { + build_umode_string(sptr, old, ALL_UMODES, buf); + if (*buf) + sendto_one(sptr, NULL, ":%s MODE %s :%s", sptr->name, sptr->name, buf); + } } static MaxTarget *maxtargets = NULL; /**< For set::max-targets-per-command configuration */