Fixed the CUMODE channel founder authentication on normal
authorPekka Riikonen <priikone@silcnet.org>
Fri, 2 Jan 2004 22:00:26 +0000 (22:00 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 2 Jan 2004 22:00:26 +0000 (22:00 +0000)
server to not remove the founder rights on existing founder
before checking that router accepts the mode change.

CHANGES
TODO
apps/silcd/command.c
apps/silcd/packet_receive.c

diff --git a/CHANGES b/CHANGES
index 014fc9300a66b92e9a62a8bca2360f3563f54208..3e3d03ac8d6d7ac9348ce69ff41a4af167c71ba6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,20 @@
+Fri Jan  2 23:34:17 EET 2004  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <jochen@penguin-breeder.org>
 
        * Add /SILCNET [ADD|REMOVE|LIST] command to manage different SILC
          networks.  This is the first step in solving the bug about
-         /SERVER ADD -silcnet <silcnet>.  Affected files 
+         /SERVER ADD -silcnet <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 <jochen@penguin-breeder.org>
        * 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 <priikone@silcnet.org>
          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 <priikone@silcnet.org>
 
 Sat Dec 20 00:44:47 CET 2003  Patrik Weiskircher <pat@icore.at>
 
-       * 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 <pat@icore.at>
 
 Thu Dec 04 11:33:46 CET 2003  Jochen Eisinger <jochen@penguin-breeder.org>
 
-       * 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 436222d494e27269c38a9bad19cbc992aedc3404..acf5e00f05c6a706fdac7c5cbb86bdc94134c8f7 100644 (file)
--- 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
index d3f89b9a85fecd0aa30be6787fb805dd0bcb650e..991116495bfd590fea991e3203fd98ee75ca188c 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  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;
     }
index 05928b5116be393ea4a9c80d62e9c329e66c3c76..9e574a593cefd5b668d109bdb4d109f744d0b411 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  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;