X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-info.c;h=22284cb328c87b0e76a15cbd00c15cd8889bbec2;hp=3c8dcd51aee374527900d8422535c46ef4f46e09;hb=bf8e03c46652100547755322a797f0bf8e2da586;hpb=5dce3301bd3e9c26e1c1371379366a0aaba32e20 diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 3c8dcd51..22284cb3 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -298,7 +298,7 @@ IRC_WHO_Mask(CLIENT *Client, char *Mask, bool OnlyOps) static bool IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c) { - char str[LINE_LEN + 1]; + char str[COMMAND_LEN]; CL2CHAN *cl2chan; CHANNEL *chan; @@ -347,7 +347,7 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c) str, sizeof(str)); strlcat(str, Channel_Name(chan), sizeof(str)); - if (strlen(str) > (LINE_LEN - CHANNEL_NAME_LEN - 4)) { + if (strlen(str) > (COMMAND_LEN - CHANNEL_NAME_LEN - 4)) { /* Line becomes too long: send it! */ if (!IRC_WriteStrClient(Client, "%s", str)) return DISCONNECTED; @@ -361,8 +361,15 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c) return DISCONNECTED; } + /* IRC-Services? */ + if (Client_Type(c) == CLIENT_SERVICE && + !IRC_WriteStrClient(from, RPL_WHOISSERVICE_MSG, + Client_ID(from), Client_ID(c))) + return DISCONNECTED; + /* IRC-Operator? */ - if (Client_HasMode(c, 'o') && + if (Client_Type(c) != CLIENT_SERVICE && + Client_HasMode(c, 'o') && !IRC_WriteStrClient(from, RPL_WHOISOPERATOR_MSG, Client_ID(from), Client_ID(c))) return DISCONNECTED; @@ -374,10 +381,19 @@ IRC_WHOIS_SendReply(CLIENT *Client, CLIENT *from, CLIENT *c) return DISCONNECTED; /* Connected using SSL? */ - if (Conn_UsesSSL(Client_Conn(c)) && - !IRC_WriteStrClient(from, RPL_WHOISSSL_MSG, Client_ID(from), - Client_ID(c))) - return DISCONNECTED; + if (Conn_UsesSSL(Client_Conn(c))) { + if (!IRC_WriteStrClient(from, RPL_WHOISSSL_MSG, Client_ID(from), + Client_ID(c))) + return DISCONNECTED; + + /* Certificate fingerprint? */ + if (Conn_GetFingerprint(Client_Conn(c)) && + from == c && + !IRC_WriteStrClient(from, RPL_WHOISCERTFP_MSG, + Client_ID(from), Client_ID(c), + Conn_GetFingerprint(Client_Conn(c)))) + return DISCONNECTED; + } /* Registered nickname? */ if (Client_HasMode(c, 'R') && @@ -432,51 +448,37 @@ WHOWAS_EntryWrite(CLIENT *prefix, WHOWAS *entry) entry->id, entry->server, t_str); } -static bool -Show_MOTD_Start(CLIENT *Client) -{ - return IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG, - Client_ID( Client ), Client_ID( Client_ThisServer( ))); -} - -static bool -Show_MOTD_Sendline(CLIENT *Client, const char *msg) -{ - return IRC_WriteStrClient(Client, RPL_MOTD_MSG, Client_ID( Client ), msg); -} - -static bool -Show_MOTD_End(CLIENT *Client) -{ - if (!IRC_WriteStrClient(Client, RPL_ENDOFMOTD_MSG, Client_ID(Client))) - return DISCONNECTED; - - if (*Conf_CloakHost) - return IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG, - Client_ID(Client), - Client_Hostname(Client)); - - return CONNECTED; -} - #ifdef SSL_SUPPORT -static bool Show_MOTD_SSLInfo(CLIENT *Client) +static bool +Show_MOTD_SSLInfo(CLIENT *Client) { - bool ret = true; - char buf[COMMAND_LEN] = "Connected using Cipher "; - - if (!Conn_GetCipherInfo(Client_Conn(Client), buf + 23, sizeof buf - 23)) - return true; + char buf[COMMAND_LEN]; + char c_str[128]; + + if (Conn_GetCipherInfo(Client_Conn(Client), c_str, sizeof(c_str))) { + snprintf(buf, sizeof(buf), "Connected using Cipher %s", c_str); + if (!IRC_WriteStrClient(Client, RPL_MOTD_MSG, + Client_ID(Client), buf)) + return false; + } - if (!Show_MOTD_Sendline(Client, buf)) - ret = false; + if (Conn_GetFingerprint(Client_Conn(Client))) { + snprintf(buf, sizeof(buf), + "Your client certificate fingerprint is: %s", + Conn_GetFingerprint(Client_Conn(Client))); + if (!IRC_WriteStrClient(Client, RPL_MOTD_MSG, + Client_ID(Client), buf)) + return false; + } - return ret; + return true; } #else -static inline bool +static bool Show_MOTD_SSLInfo(UNUSED CLIENT *c) -{ return true; } +{ + return true; +} #endif /* Global functions */ @@ -838,7 +840,7 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) strlcat(rpl, " ", sizeof(rpl)); strlcat(rpl, Client_ID(c), sizeof(rpl)); - if (strlen(rpl) > LINE_LEN - CLIENT_NICK_LEN - 4) { + if (strlen(rpl) > COMMAND_LEN - CLIENT_NICK_LEN - 4) { /* Line is gwoing too long, send now */ if (!IRC_WriteStrClient(from, "%s", rpl)) return DISCONNECTED; @@ -1251,7 +1253,8 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req ) */ if (!has_wildcards || is_remote) { c = Client_Search(query); - if (c && Client_Type(c) == CLIENT_USER) { + if (c && (Client_Type(c) == CLIENT_USER + || Client_Type(c) == CLIENT_SERVICE)) { if (!IRC_WHOIS_SendReply(Client, from, c)) return DISCONNECTED; } else { @@ -1469,7 +1472,8 @@ IRC_Show_MOTD( CLIENT *Client ) if (len_tot == 0 && !Conn_UsesSSL(Client_Conn(Client))) return IRC_WriteStrClient(Client, ERR_NOMOTD_MSG, Client_ID(Client)); - if (!Show_MOTD_Start(Client)) + if (!IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG, Client_ID(Client), + Client_ID(Client_ThisServer()))) return DISCONNECTED; line = array_start(&Conf_Motd); @@ -1479,14 +1483,23 @@ IRC_Show_MOTD( CLIENT *Client ) assert(len_tot >= len_str); len_tot -= len_str; - if (!Show_MOTD_Sendline(Client, line)) + if (!IRC_WriteStrClient(Client, RPL_MOTD_MSG, Client_ID(Client), line)) return DISCONNECTED; line += len_str; } if (!Show_MOTD_SSLInfo(Client)) return DISCONNECTED; - return Show_MOTD_End(Client); + + if (!IRC_WriteStrClient(Client, RPL_ENDOFMOTD_MSG, Client_ID(Client))) + return DISCONNECTED; + + if (*Conf_CloakHost) + return IRC_WriteStrClient(Client, RPL_HOSTHIDDEN_MSG, + Client_ID(Client), + Client_Hostname(Client)); + + return CONNECTED; } /* IRC_Show_MOTD */ /** @@ -1500,7 +1513,7 @@ GLOBAL bool IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan) { bool is_visible, is_member; - char str[LINE_LEN + 1]; + char str[COMMAND_LEN]; CL2CHAN *cl2chan; CLIENT *cl; @@ -1539,7 +1552,7 @@ IRC_Send_NAMES(CLIENT * Client, CHANNEL * Chan) str, sizeof(str)); strlcat(str, Client_ID(cl), sizeof(str)); - if (strlen(str) > (LINE_LEN - CLIENT_NICK_LEN - 4)) { + if (strlen(str) > (COMMAND_LEN - CLIENT_NICK_LEN - 4)) { if (!IRC_WriteStrClient(Client, "%s", str)) return DISCONNECTED; snprintf(str, sizeof(str), RPL_NAMREPLY_MSG,