Delete and add correct public keys and client entrys to pk_hash.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 3 Jan 2004 14:38:10 +0000 (14:38 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 3 Jan 2004 14:38:10 +0000 (14:38 +0000)
CHANGES
apps/silcd/command_reply.c
apps/silcd/packet_receive.c
apps/silcd/silcd.c

diff --git a/CHANGES b/CHANGES
index ad3606087f1675ffa56acb3ba3dd3e74d7fa29d3..a4c7badb89da802ba851d7c72e0946b746a9bf0b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Sat Jan  3 16:37:15 EET 2004  Pekka Riikonen <priikone@silcnet.org>
+
+       * Fixed whois public key hash table deleting and adding in
+         detached client case.  Affected file silcd/packet_receive.c.
+
 Sat Jan 03 12:15:38 CET 2004  Jochen Eisinger <jochen@penguin-breeder.org>
 
        * Changed filenames of silc/fe module not to collide with filenames
index 3f895f99d8bdf8e7c4a8b6022b8794edeedccd12..15e9c9307a8353995679bb1b746759f969a03db3 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
@@ -892,7 +892,7 @@ SILC_SERVER_CMD_REPLY_FUNC(motd)
         be bogus client or some router in the net is buggy. */
       if (server->server_type != SILC_SERVER)
        goto out;
+
       /* entry isn't known so we IDENTIFY it. otherwise the
          silc_server_command_motd won't know about it and tell
          the client that there is no such server */
@@ -905,7 +905,7 @@ SILC_SERVER_CMD_REPLY_FUNC(motd)
                              SILC_PACKET_COMMAND, 0, buffer->data,
                              buffer->len, TRUE);
       silc_server_command_pending(server, SILC_COMMAND_IDENTIFY,
-                                 server->cmd_ident, 
+                                 server->cmd_ident,
                                  silc_server_command_reply_motd,
                                  cmd);
       silc_buffer_free(buffer);
@@ -1369,12 +1369,14 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey)
        goto out;
     }
 
-    if (!silc_hash_table_find_by_context(server->pk_hash, public_key,
-                                        client, NULL))
-      silc_hash_table_add(server->pk_hash, public_key, client);
+    if (!client->data.public_key) {
+      if (!silc_hash_table_find_by_context(server->pk_hash, public_key,
+                                          client, NULL))
+       silc_hash_table_add(server->pk_hash, public_key, client);
 
-    client->data.public_key = public_key;
-    public_key = NULL;
+      client->data.public_key = public_key;
+      public_key = NULL;
+    }
   } else if (id_type == SILC_ID_SERVER) {
     server_id = silc_id_payload_get_id(idp);
 
index 9e574a593cefd5b668d109bdb4d109f744d0b411..8a2e2ca2877d9f602d7211302022c82813b3dcad 100644 (file)
@@ -3793,10 +3793,13 @@ void silc_server_resume_client(SilcServer server,
     sock->user_data = detached_client;
     detached_client->connection = sock;
 
-    if (client->data.public_key)
+    if (detached_client->data.public_key)
       silc_hash_table_del_by_context(server->pk_hash,
                                     detached_client->data.public_key,
-                                    client);
+                                    detached_client);
+    if (idata->public_key)
+      silc_hash_table_del_by_context(server->pk_hash,
+                                    idata->public_key, idata);
 
     /* Take new keys and stuff into use in the old entry */
     silc_idlist_del_data(detached_client);
@@ -3804,7 +3807,7 @@ void silc_server_resume_client(SilcServer server,
 
     if (detached_client->data.public_key)
       silc_hash_table_add(server->pk_hash,
-                          detached_client->data.public_key, client);
+                         detached_client->data.public_key, detached_client);
 
     detached_client->data.status |= SILC_IDLIST_STATUS_REGISTERED;
     detached_client->data.status |= SILC_IDLIST_STATUS_RESUMED;
@@ -3848,12 +3851,6 @@ void silc_server_resume_client(SilcServer server,
     silc_server_remove_from_channels(server, NULL, client, FALSE,
                                     NULL, FALSE, FALSE);
 
-    /* Remove from public key hash table. */
-    if (client->data.public_key)
-      silc_hash_table_del_by_context(server->pk_hash,
-                                    client->data.public_key,
-                                    client);
-
     silc_server_del_from_watcher_list(server, client);
     if (!silc_idlist_del_client(server->local_list, client))
       silc_idlist_del_client(server->global_list, client);
@@ -4051,8 +4048,6 @@ void silc_server_resume_client(SilcServer server,
     /* Client is detached, and now it is resumed.  Remove the detached
        mode and mark that it is resumed. */
 
-    /* we need to delete the public key from the has .. but do we need to
-     * get the key again? */
     if (detached_client->data.public_key)
       silc_hash_table_del_by_context(server->pk_hash,
                                     detached_client->data.public_key,
index 81f5cdf4296bee65f93a911f4304a5e3d2fdcf57..3635f169b84afa95888bc7dc37b08f6006e4a614 100644 (file)
@@ -591,7 +591,7 @@ int main(int argc, char **argv)
          printf("SILCd Secure Internet Live Conferencing daemon, "
                 "version %s (base: SILC Toolkit %s)\n",
                 silc_dist_version, silc_version);
-         printf("(c) 1997 - 2002 Pekka Riikonen "
+         printf("(c) 1997 - 2004 Pekka Riikonen "
                 "<priikone@silcnet.org>\n");
          exit(0);
          break;