From 444b93742ddb1f0759ed9315190060a2f45db73a Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Fri, 2 Jan 2004 22:00:26 +0000 Subject: [PATCH] Fixed the CUMODE channel founder authentication on normal server to not remove the founder rights on existing founder before checking that router accepts the mode change. --- CHANGES | 22 ++++++++++++++++----- TODO | 3 --- apps/silcd/command.c | 39 ++++++++++++++++++++++--------------- apps/silcd/packet_receive.c | 11 ++++++++--- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/CHANGES b/CHANGES index 014fc930..3e3d03ac 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,20 @@ +Fri Jan 2 23:34:17 EET 2004 Pekka Riikonen + + * Fixed the CUMODE channel founder authentication on normal + server to not remove the founder rights on existing founder + before checking that router accepts the mode change. Affected + files are silcd/command.c and silcd/packet_receive.c. + + * Remove the server entry correctly when rekey timeouts and + remote router connection on normal server is closed. Fixes + a crash where server uses the freed server entry. Affected + file silcd/server.c. + Fri Jan 02 10:28:15 CET 2004 Jochen Eisinger * Add /SILCNET [ADD|REMOVE|LIST] command to manage different SILC networks. This is the first step in solving the bug about - /SERVER ADD -silcnet . Affected files + /SERVER ADD -silcnet . Affected files irssi/docs/in/silcnet.in; irssi/src/fe-common/silc/Makefile.am, fe-silcnet.c, fe-common-silc.c, module-formats.[ch]; irssi/src/silc/core/silc-chatnets.[ch], silc-core.c, Makefile.am @@ -25,7 +37,7 @@ Wed Dec 31 17:06:55 CET 2003 Jochen Eisinger * Make the session data filename configurable. This makes it possible to have different session files for different SILC networks. Affected files irssi/src/silc/core/silc-core.c, - client_ops.[ch], silc-servers.c, + client_ops.[ch], silc-servers.c, irssi/src/silc/fe-common/silc/module-formats.[ch] * Use the same set of libtool files for the MPI lib as for the @@ -43,7 +55,7 @@ Sat Dec 20 14:42:36 EET 2003 Pekka Riikonen search error. Added support in send_reply to send errors without specific argument. Affected file silcd/server_query.c. - * Fixed the WHOIS, IDENTIFY and WHOWAS error handling in SILC + * Fixed the WHOIS, IDENTIFY and WHOWAS error handling in SILC Client for NO_SUCH_NICK. It was against the protocol specs. Affected file irssi/src/silc/core/client_ops.c. @@ -54,7 +66,7 @@ Sat Dec 20 14:42:36 EET 2003 Pekka Riikonen Sat Dec 20 00:44:47 CET 2003 Patrik Weiskircher - * fixed a bug in the whois using attributes function where no + * fixed a bug in the whois using attributes function where no error was sent if no nickname and client id but the attributes were given to whois. Affected file silcd/server_query.c @@ -76,7 +88,7 @@ Sat Dec 06 21:35:14 CET 2003 Patrik Weiskircher Thu Dec 04 11:33:46 CET 2003 Jochen Eisinger - * Initialize the variable idletag, since it is tested in + * Initialize the variable idletag, since it is tested in silc_core_deinit for its default value. Affected file irssi/src/silc/core/silc-core.c diff --git a/TODO b/TODO index 436222d4..acf5e00f 100644 --- a/TODO +++ b/TODO @@ -13,9 +13,6 @@ TODO for SILC Client 1.0 branch TODO for SILC Server 1.0 ======================== - o Check that +of works correctly when same client is +of already on - some other server on same channel. - o Check that founder key is distributed ok during backup resuming. o invite (with @server!*@host) not working from normal server/backup diff --git a/apps/silcd/command.c b/apps/silcd/command.c index d3f89b9a..99111649 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2003 Pekka Riikonen + Copyright (C) 1997 - 2004 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2611,7 +2611,7 @@ SILC_SERVER_CMD_FUNC(motd) /* Send to primary router only if we don't know the server * the client requested or if the server is not locally connected */ - if ((!entry || !(entry->data.status & SILC_IDLIST_STATUS_LOCAL)) + if ((!entry || !(entry->data.status & SILC_IDLIST_STATUS_LOCAL)) && !cmd->pending && !server->standalone) { /* Send to the primary router */ SilcBuffer tmpbuf; @@ -3323,16 +3323,15 @@ SILC_SERVER_CMD_FUNC(cumode) /* Get target client's entry */ target_client = silc_idlist_find_client_by_id(server->local_list, client_id, TRUE, NULL); - if (!target_client) { + if (!target_client) target_client = silc_idlist_find_client_by_id(server->global_list, client_id, TRUE, NULL); - } if (target_client != client && !(sender_mask & SILC_CHANNEL_UMODE_CHANFO) && !(sender_mask & SILC_CHANNEL_UMODE_CHANOP)) { silc_server_command_send_status_data(cmd, SILC_COMMAND_CUMODE, - SILC_STATUS_ERR_NO_CHANNEL_PRIV, 0, + SILC_STATUS_ERR_NOT_YOU, 0, 2, tmp_ch_id, tmp_ch_len); goto out; } @@ -3365,7 +3364,8 @@ SILC_SERVER_CMD_FUNC(cumode) if (target_mask & SILC_CHANNEL_UMODE_CHANFO) { if (target_client != client) { silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE, - SILC_STATUS_ERR_NOT_YOU, 0); + SILC_STATUS_ERR_NO_CHANNEL_FOPRIV, + 0); goto out; } @@ -3409,16 +3409,23 @@ SILC_SERVER_CMD_FUNC(cumode) } /* There cannot be anyone else as founder on the channel now. This - client is definitely the founder due to this authentication */ - silc_hash_table_list(channel->user_list, &htl); - while (silc_hash_table_get(&htl, NULL, (void *)&chl2)) - if (chl2->mode & SILC_CHANNEL_UMODE_CHANFO) { - chl2->mode &= ~SILC_CHANNEL_UMODE_CHANFO; - silc_server_force_cumode_change(server, NULL, channel, chl2, - chl2->mode); - break; - } - silc_hash_table_list_reset(&htl); + client is definitely the founder due to this authentication. This + is done only on router, not on server, since server cannot know + whether router will accept this mode change or not. XXX This + probably shouldn't be done anymore at all, may cause problems in + router-router connections too (maybe just AUTH_FAILED error should + be returned). -Pekka */ + if (server->server_type == SILC_ROUTER) { + silc_hash_table_list(channel->user_list, &htl); + while (silc_hash_table_get(&htl, NULL, (void *)&chl2)) + if (chl2->mode & SILC_CHANNEL_UMODE_CHANFO) { + chl2->mode &= ~SILC_CHANNEL_UMODE_CHANFO; + silc_server_force_cumode_change(server, NULL, channel, chl2, + chl2->mode); + break; + } + silc_hash_table_list_reset(&htl); + } sender_mask = chl->mode |= SILC_CHANNEL_UMODE_CHANFO; } diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 05928b51..9e574a59 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2003 Pekka Riikonen + Copyright (C) 1997 - 2004 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -982,6 +982,7 @@ void silc_server_notify(SilcServer server, silc_hash_table_list(channel->user_list, &htl); while (silc_hash_table_get(&htl, NULL, (void *)&chl2)) if (chl2->mode & SILC_CHANNEL_UMODE_CHANFO) { + SILC_LOG_DEBUG(("Founder already on channel")); chl->mode = mode &= ~SILC_CHANNEL_UMODE_CHANFO; silc_server_force_cumode_change(server, sock, channel, chl, mode); @@ -992,7 +993,7 @@ void silc_server_notify(SilcServer server, if (!(mode & SILC_CHANNEL_UMODE_CHANFO)) break; - /* Founder not found of the channel. Since the founder auth mode + /* Founder not found on the channel. Since the founder auth mode is set on the channel now check whether this is the client that originally set the mode. */ @@ -1002,6 +1003,7 @@ void silc_server_notify(SilcServer server, if (!tmp || !silc_pkcs_public_key_payload_decode(tmp, tmp_len, &founder_key)) { chl->mode = mode &= ~SILC_CHANNEL_UMODE_CHANFO; + SILC_LOG_DEBUG(("Founder public key not present")); silc_server_force_cumode_change(server, sock, channel, chl, mode); notify_sent = TRUE; break; @@ -1012,6 +1014,7 @@ void silc_server_notify(SilcServer server, if (!silc_pkcs_public_key_compare(channel->founder_key, founder_key)) { chl->mode = mode &= ~SILC_CHANNEL_UMODE_CHANFO; + SILC_LOG_DEBUG(("Founder public key mismatch")); silc_server_force_cumode_change(server, sock, channel, chl, mode); notify_sent = TRUE; break; @@ -1020,11 +1023,13 @@ void silc_server_notify(SilcServer server, /* There cannot be anyone else as founder on the channel now. This client is definitely the founder due to this 'authentication'. - We trust the server did the actual authentication earlier. */ + We trust the server did the actual signature verification + earlier (bad, yes). */ silc_hash_table_list(channel->user_list, &htl); while (silc_hash_table_get(&htl, NULL, (void *)&chl2)) if (chl2->mode & SILC_CHANNEL_UMODE_CHANFO) { chl2->mode &= ~SILC_CHANNEL_UMODE_CHANFO; + SILC_LOG_DEBUG(("Removing old founder rights, new authenticated")); silc_server_force_cumode_change(server, NULL, channel, chl2, chl2->mode); break; -- 2.24.0