X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=4728c7a4672ac802d944dc599d23031f75e50d60;hp=2466c7175a3bd11eb52000a62e03baf355d56196;hb=33fae67579eeab31d7f96f9e53f0529f584b0b1f;hpb=9d8974d5098e9426f9185f31b2b3853e55513f3e diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 2466c717..4728c7a4 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -440,18 +440,6 @@ Client_SetFlags( CLIENT *Client, const char *Flags ) } /* Client_SetFlags */ -GLOBAL void -Client_SetPassword( CLIENT *Client, const char *Pwd ) -{ - /* set password sent by client */ - - assert( Client != NULL ); - assert( Pwd != NULL ); - - strlcpy(Client->pwd, Pwd, sizeof(Client->pwd)); -} /* Client_SetPassword */ - - GLOBAL void Client_SetAway( CLIENT *Client, const char *Txt ) { @@ -699,27 +687,36 @@ Client_Hostname(CLIENT *Client) /** * Get potentially cloaked hostname of a client. + * * If the client has not enabled cloaking, the real hostname is used. + * Please note that this function uses a global static buffer, so you can't + * nest invocations without overwriting earlier results! + * * @param Client Pointer to client structure * @return Pointer to client hostname */ GLOBAL char * Client_HostnameCloaked(CLIENT *Client) { + static char Cloak_Buffer[CLIENT_HOST_LEN]; + assert(Client != NULL); - if (Client_HasMode(Client, 'x')) - return Client_ID(Client->introducer); - else + + if (!Client_HasMode(Client, 'x')) return Client_Hostname(Client); -} /* Client_HostnameCloaked */ + /* Do simple mapping to the server ID? */ + if (!*Conf_CloakHostModeX) + return Client_ID(Client->introducer); -GLOBAL char * -Client_Password( CLIENT *Client ) -{ - assert( Client != NULL ); - return Client->pwd; -} /* Client_Password */ + strlcpy(Cloak_Buffer, Client->host, CLIENT_HOST_LEN); + strlcat(Cloak_Buffer, Conf_CloakHostSalt, CLIENT_HOST_LEN); + + snprintf(Cloak_Buffer, CLIENT_HOST_LEN, Conf_CloakHostModeX, + Hash(Cloak_Buffer)); + + return Cloak_Buffer; +} /* Client_HostnameCloaked */ GLOBAL char * @@ -812,10 +809,12 @@ Client_Mask( CLIENT *Client ) /** * Return ID of a client with cloaked hostname: "client!user@server-name" + * * This client ID is used for IRC prefixes, for example. * Please note that this function uses a global static buffer, so you can't * nest invocations without overwriting earlier results! * If the client has not enabled cloaking, the real hostname is used. + * * @param Client Pointer to client structure * @return Pointer to global buffer containing the client ID */ @@ -823,7 +822,6 @@ GLOBAL char * Client_MaskCloaked(CLIENT *Client) { static char Mask_Buffer[GETID_LEN]; - char Cloak_Buffer[GETID_LEN]; assert (Client != NULL); @@ -831,16 +829,8 @@ Client_MaskCloaked(CLIENT *Client) if (!Client_HasMode(Client, 'x')) return Client_Mask(Client); - if(*Conf_CloakHostModeX) { - strlcpy(Cloak_Buffer, Client->host, GETID_LEN); - strlcat(Cloak_Buffer, Conf_CloakHostSalt, GETID_LEN); - snprintf(Cloak_Buffer, GETID_LEN, Conf_CloakHostModeX, Hash(Cloak_Buffer)); - } else { - strncpy(Cloak_Buffer, Client_ID(Client->introducer), GETID_LEN); - } - - snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s", - Client->id, Client->user, Cloak_Buffer); + snprintf(Mask_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, + Client_HostnameCloaked(Client)); return Mask_Buffer; } /* Client_MaskCloaked */ @@ -905,6 +895,16 @@ Client_CheckNick(CLIENT *Client, char *Nick) return false; } + if (Client_Type(Client) != CLIENT_SERVER + && Client_Type(Client) != CLIENT_SERVICE) { + /* Make sure that this isn't a restricted/forbidden nick name */ + if (Conf_NickIsBlocked(Nick)) { + IRC_WriteStrClient(Client, ERR_FORBIDDENNICKNAME_MSG, + Client_ID(Client), Nick); + return false; + } + } + /* Nickname already registered? */ if (Client_Search(Nick)) { IRC_WriteStrClient(Client, ERR_NICKNAMEINUSE_MSG,