]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-mode.c
Change Lists_MakeMask() to receive a buffer for the mask
[ngircd-alex.git] / src / ngircd / irc-mode.c
index 907c929766f9355b8d201a7fee3eaac218fd574e..765de394483b8880b0bdc149e6ef28e46d963991 100644 (file)
@@ -36,8 +36,6 @@
 #include "irc-mode.h"
 
 
-static void Announce_Client_Hostname PARAMS((CLIENT *Origin, CLIENT *Client));
-
 static bool Client_Mode PARAMS((CLIENT *Client, REQUEST *Req, CLIENT *Origin,
                                CLIENT *Target));
 static bool Channel_Mode PARAMS((CLIENT *Client, REQUEST *Req, CLIENT *Origin,
@@ -156,7 +154,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
        /* Mode request: let's answer it :-) */
        if (Req->argc == 1)
                return IRC_WriteStrClient(Origin, RPL_UMODEIS_MSG,
-                                         Client_ID(Origin),
+                                         Client_ID(Target),
                                          Client_Modes(Target));
 
        mode_arg = 1;
@@ -368,9 +366,17 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
                                                  "MODE %s :%s",
                                                  Client_ID(Target),
                                                  the_modes);
-                       if (send_RPL_HOSTHIDDEN_MSG)
-                               Announce_Client_Hostname(Origin, Client);
                }
+
+               if (send_RPL_HOSTHIDDEN_MSG && Client_Conn(Target) > NONE) {
+                       /* A new (cloaked) hostname must be annoucned */
+                       IRC_WriteStrClientPrefix(Target, Origin,
+                                                RPL_HOSTHIDDEN_MSG,
+                                                Client_ID(Target),
+                                                Client_HostnameDisplayed(Target));
+
+               }
+
                LogDebug("%s \"%s\": Mode change, now \"%s\".",
                         Client_TypeText(Target), Client_Mask(Target),
                         Client_Modes(Target));
@@ -381,27 +387,6 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 } /* Client_Mode */
 
 
-/**
- * Announce changed client hostname in the network.
- *
- * @param Client The client of which the hostname changed.
- */
-static void
-Announce_Client_Hostname(CLIENT *Origin, CLIENT *Client)
-{
-       assert(Client != NULL);
-
-       /* Inform the client itself */
-       IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG, Client_ID(Client),
-                          Client_HostnameDisplayed(Client));
-
-       /* Inform other servers in the network */
-       IRC_WriteStrServersPrefixFlag(Origin, Client_ThisServer(), 'M',
-                                     "METADATA %s host :%s", Client_ID(Client),
-                                     Client_HostnameDisplayed(Client));
-}
-
-
 static bool
 Channel_Mode_Answer_Request(CLIENT *Origin, CHANNEL *Channel)
 {
@@ -565,7 +550,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                if (arg_arg >= Req->argc)
                        arg_arg = -1;
 
-               if(!is_machine) {
+               if(!is_machine && !is_oper) {
                        o_mode_ptr = Channel_UserModes(Channel, Client);
                        while( *o_mode_ptr ) {
                                if ( *o_mode_ptr == 'q')
@@ -643,9 +628,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                                Req->argv[arg_arg][0] = '\0';
                                arg_arg++;
                        } else {
+#ifdef STRICT_RFC
+                               /* Only send error message in "strict" mode,
+                                * this is how ircd2.11 and others behave ... */
                                connected = IRC_WriteStrClient(Origin,
                                        ERR_NEEDMOREPARAMS_MSG,
                                        Client_ID(Origin), Req->command);
+#endif
                                goto chan_exit;
                        }
                        break;
@@ -683,9 +672,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                                Req->argv[arg_arg][0] = '\0';
                                arg_arg++;
                        } else {
+#ifdef STRICT_RFC
+                               /* Only send error message in "strict" mode,
+                                * this is how ircd2.11 and others behave ... */
                                connected = IRC_WriteStrClient(Origin,
                                        ERR_NEEDMOREPARAMS_MSG,
                                        Client_ID(Origin), Req->command);
+#endif
                                goto chan_exit;
                        }
                        break;
@@ -776,9 +769,17 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
                                Req->argv[arg_arg][0] = '\0';
                                arg_arg++;
                        } else {
+#ifdef STRICT_RFC
+                               /* Report an error to the client, when a user
+                                * mode should be changed but no nickname is
+                                * given. But don't do it when not in "strict"
+                                * mode, because most other servers don't do
+                                * it as well and some clients send "wired"
+                                * MODE commands like "MODE #chan -ooo nick". */
                                connected = IRC_WriteStrClient(Origin,
                                        ERR_NEEDMOREPARAMS_MSG,
                                        Client_ID(Origin), Req->command);
+#endif
                                goto chan_exit;
                        }
                        break;
@@ -979,7 +980,7 @@ static bool
 Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
            const char *Pattern)
 {
-       const char *mask;
+       char mask[MASK_LEN];
        struct list_head *list = NULL;
        long int current_count;
 
@@ -988,7 +989,7 @@ Add_To_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
        assert(Pattern != NULL);
        assert(what == 'I' || what == 'b' || what == 'e');
 
-       mask = Lists_MakeMask(Pattern);
+       Lists_MakeMask(Pattern, mask, sizeof(mask));
        current_count = Lists_Count(Channel_GetListInvites(Channel))
                        + Lists_Count(Channel_GetListExcepts(Channel))
                        + Lists_Count(Channel_GetListBans(Channel));
@@ -1046,7 +1047,7 @@ static bool
 Del_From_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
              const char *Pattern)
 {
-       const char *mask;
+       char mask[MASK_LEN];
        struct list_head *list = NULL;
 
        assert(Client != NULL);
@@ -1054,7 +1055,7 @@ Del_From_List(char what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel,
        assert(Pattern != NULL);
        assert(what == 'I' || what == 'b' || what == 'e');
 
-       mask = Lists_MakeMask(Pattern);
+       Lists_MakeMask(Pattern, mask, sizeof(mask));
 
        switch (what) {
                case 'I':