updates.
authorPekka Riikonen <priikone@silcnet.org>
Thu, 18 Oct 2001 19:37:18 +0000 (19:37 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Thu, 18 Oct 2001 19:37:18 +0000 (19:37 +0000)
15 files changed:
CHANGES
TODO
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/silc-channels.c
apps/silcd/command.c
apps/silcd/server.c
lib/silcclient/client_channel.c
lib/silcclient/client_notify.c
lib/silcclient/client_prvmsg.c
lib/silcclient/command.c
lib/silcclient/command_reply.c
lib/silcclient/idlist.c
lib/silcclient/idlist.h
lib/silccore/silcpacket.c
lib/silccore/silcpacket.h

diff --git a/CHANGES b/CHANGES
index ee08994b805d797e635e664a30b5bcb123d5af2a..0e8d4c6aca0aefbd037a726869cfafbd7a659fd6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,36 @@
+Thu Oct 18 20:58:13 EDT 2001  Pekka Riikonen <priikone@silcnet.org>
+
+       * Resolve the client info when received private message or
+         channel message for a client which nickname we don't know.
+         Affected files lib/silcclient/client_prvmsg.c and
+         lib/silcclient/client_channel.c.
+
+       * Do not crash in /KEY if client is not connected.  Affected
+         file irssi/src/silc/core/silc-channels.c.
+
+       * Added SilcClientStatus field to the SilcClientEntry in the
+         lib/silcclient/idlist.h.
+
+         Added SILC_CLIENT_STATUS_RESOLVING to mark that the entry
+         is incomplete and is being resolved, it won't be resolved
+         twice.
+
+         Make sure also that USERS command reply does not resolve
+         twice information.  Affected file is
+         lib/silcclient/command_reply.c.
+
+         Make sure that silc_client_get_clients_by_list does not
+         resolve twice same information.
+
+       * Check for valid client->id in the silc_server_free_client_data.
+         Affected file silcd/server.c.
+
+       * Fixed /GETKEY nick@server not to crash if the server entry
+         is not found.  Affected file lib/silcclient/command.c.
+
+       * Fixed the silc_server_check_cmode_rights to check the
+         requested modes correctly.  Affected file silcd/command.c.
+
 Thu Oct 18 12:10:22 CEST 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * Better checks for non-printable chars in nick added.
diff --git a/TODO b/TODO
index 2c984a4be6e179fdab23792a406e3cceff1d422e..d542fb24a02ad006f2cfa34f1495e5872daf4108 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
 TODO/bugs in Irssi SILC client
 ==============================
 
- o /key msg * list crashes the client
+ o Add the SFTP support.
 
  o Add local command to switch the channel's private key when channel has
    several private keys.  Currently sending channel messages with many
@@ -15,9 +15,6 @@ TODO/bugs in Irssi SILC client
    that the user has.  And a local command to dump the contents of the
    public key to the screen.  Something like LISTKEYS, SHOWKEY...
 
- o The QUIT command should wait for server's disconnection (at least for
-   a while) before exiting the application.
-
  o The JOIN command's HELP is generated from Irssi IRCs JOIN help and
    the syntax is not same in SILC.  This must be fixed.  Most likely
    we must forget the Irssi's JOIN command and mimic it to get our
@@ -40,6 +37,8 @@ TODO/bugs in Irssi SILC client
 TODO/bugs In SILC Client Library
 ================================
 
+ o Add the SFTP support.
+
  o JOIN command's argument handling is buggy.  See the XXX in the code.
 
 
@@ -54,7 +53,7 @@ TODO/bugs In SILC Server
  o Channel user mode changes are notified unnecessarely when switching
    to backup router on router crash.
 
- o Change the sever to connect to another server from low ports (706)
+ o Change the server to connect to another server from low ports (706)
    and not from high ports.  Currently we cannot do incoming connection
    checking by remote port because the port is not fixed.
 
@@ -120,6 +119,9 @@ TODO/bugs In SILC Server
 TODO/bugs In SILC Libraries
 ===========================
 
+ o Add some silc_rng_get_byte_fast that read directly from /dev/urandom.
+   That can be used for padding generation.  The current is too slow.
+
  o Compression routines are missing.  The protocol supports packet
    compression thus it must be implemented.  SILC Comp API must be
    defined.  zlib package is already included into the lib dir (in CVS,
index b140aa8ed106cdd84f4283c12cdf941ba569ec0a..6324f3dff1e9842bfd4fb910cfcaca61eeb67eaf 100644 (file)
@@ -90,6 +90,18 @@ void silc_channel_message(SilcClient client, SilcClientConnection conn,
     return;
   
   nick = silc_nicklist_find(chanrec, sender);
+  if (!nick) {
+    /* We didn't find client but it clearly exists, add it. */
+    SilcChannelUser chu;
+
+    silc_list_start(channel->clients);
+    while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
+      if (chu->client == sender) {
+       nick = silc_nicklist_insert(chanrec, chu, FALSE);
+       break;
+      }
+    }
+  }
 
   if (flags & SILC_MESSAGE_FLAG_ACTION)
     printformat_module("fe-common/silc", server, channel->channel_name,
@@ -285,6 +297,8 @@ static void silc_client_join_get_users(SilcClient client,
 
   silc_list_start(channel->clients);
   while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
+    if (!chu->client->nickname)
+      continue;
     if (chu->mode & SILC_CHANNEL_UMODE_CHANFO)
       founder = chu->client;
     silc_nicklist_insert(chanrec, chu, FALSE);
@@ -671,6 +685,9 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
        SilcClientEntry e = chu->client;
        char stat[5], *mode;
+
+       if (!e->nickname)
+         continue;
        
        memset(stat, 0, sizeof(stat));
        mode = silc_client_chumode_char(chu->mode);
@@ -683,8 +700,10 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
 
        printformat_module("fe-common/silc", server, channel->channel_name,
                           MSGLEVEL_CRAP, SILCTXT_USERS,
-                          e->nickname, stat, e->username, 
-                          e->hostname, e->realname ? e->realname : "");
+                          e->nickname, stat, 
+                          e->username ? e->username : "",
+                          e->hostname ? e->hostname : "",
+                          e->realname ? e->realname : "");
        if (mode)
          silc_free(mode);
       }
index 81696eeecbd0b160cd02b0358c29d669c0208e89..a44f88cd6bdf6da1aad165e059a71b36133b6cb1 100644 (file)
@@ -829,7 +829,7 @@ SILC_CLIENT_CMD_FUNC(key_get_clients)
 static void command_key(const char *data, SILC_SERVER_REC *server,
                        WI_ITEM_REC *item)
 {
-  SilcClientConnection conn = server->conn;
+  SilcClientConnection conn;
   SilcClientEntry client_entry = NULL;
   SilcChannelEntry channel_entry = NULL;
   char *nickname = NULL, *tmp;
@@ -840,9 +840,11 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
   unsigned char **argv;
   uint32 *argv_lens, *argv_types;
  
-  if (!IS_SILC_SERVER(server) || !server->connected)
+  if (!server || !IS_SILC_SERVER(server) || !server->connected)
     cmd_return_error(CMDERR_NOT_CONNECTED);
 
+  conn = server->conn;
+
   /* Now parse all arguments */
   tmp = g_strconcat("KEY", " ", data, NULL);
   silc_parse_command_line(tmp, &argv, &argv_lens, &argv_types, &argc, 7);
@@ -870,7 +872,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
 
   if (type == 1) {
     if (argv[2][0] == '*') {
-      nickname = "*";
+      nickname = strdup("*");
     } else {
       /* Parse the typed nickname. */
       if (!silc_parse_userfqdn(argv[2], &nickname, NULL)) {
@@ -1099,6 +1101,7 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
       }
 
       silc_client_free_private_message_keys(keys, keys_count);
+
     } else if (type == 2) {
       SilcChannelPrivateKey *keys;
       uint32 keys_count;
@@ -1108,12 +1111,14 @@ static void command_key(const char *data, SILC_SERVER_REC *server,
       keys = silc_client_list_channel_private_keys(silc_client, conn, 
                                                   channel_entry,
                                                   &keys_count);
-      if (!keys)
-       goto out;
-      
+
       printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
                         SILCTXT_CH_PRIVATE_KEY_LIST,
                         channel_entry->channel_name);
+
+      if (!keys)
+       goto out;
+      
       for (k = 0; k < keys_count; k++) {
        memset(buf, 0, sizeof(buf));
        strncat(buf, "  ", 2);
index 18eb9691dde569074611b530fd9927a0a7fc47c1..fafd56b1253d3d2f0f8619d416876f2a8cbc43d5 100644 (file)
@@ -3642,8 +3642,9 @@ int silc_server_check_cmode_rights(SilcChannelEntry channel,
      modes are available automatically for channel operator. */
 
   if (mode & SILC_CHANNEL_MODE_PRIVKEY) {
-    if (is_op && !is_fo)
-      return FALSE;
+    if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY))
+      if (is_op && !is_fo)
+       return FALSE;
   } else {
     if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY) {
       if (is_op && !is_fo)
@@ -3652,8 +3653,9 @@ int silc_server_check_cmode_rights(SilcChannelEntry channel,
   }
   
   if (mode & SILC_CHANNEL_MODE_PASSPHRASE) {
-    if (is_op && !is_fo)
-      return FALSE;
+    if (!(channel->mode & SILC_CHANNEL_MODE_PASSPHRASE))
+      if (is_op && !is_fo)
+       return FALSE;
   } else {
     if (channel->mode & SILC_CHANNEL_MODE_PASSPHRASE) {
       if (is_op && !is_fo)
@@ -3662,8 +3664,9 @@ int silc_server_check_cmode_rights(SilcChannelEntry channel,
   }
 
   if (mode & SILC_CHANNEL_MODE_CIPHER) {
-    if (is_op && !is_fo)
-      return FALSE;
+    if (!(channel->mode & SILC_CHANNEL_MODE_CIPHER))
+      if (is_op && !is_fo)
+       return FALSE;
   } else {
     if (channel->mode & SILC_CHANNEL_MODE_CIPHER) {
       if (is_op && !is_fo)
@@ -3672,8 +3675,9 @@ int silc_server_check_cmode_rights(SilcChannelEntry channel,
   }
   
   if (mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) {
-    if (is_op && !is_fo)
-      return FALSE;
+    if (!(channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH))
+      if (is_op && !is_fo)
+       return FALSE;
   } else {
     if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) {
       if (is_op && !is_fo)
index 5192004d89ed1f3c8d6a08d5e56b4a08dc0c13e4..869d6450b12cd80874a585ee10320051b5a8b92b 100644 (file)
@@ -2240,12 +2240,15 @@ void silc_server_free_client_data(SilcServer server,
      to the network before removing the client entry. */
   silc_server_packet_queue_purge(server, sock);
 
+  if (!client->id)
+    return;
+
   /* Send SIGNOFF notify to routers. */
   if (notify && !server->standalone && server->router)
     silc_server_send_notify_signoff(server, server->router->connection,
                                    server->server_type == SILC_SERVER ?
                                    FALSE : TRUE, client->id, signoff);
-
+    
   /* Remove client from all channels */
   if (notify)
     silc_server_remove_from_channels(server, NULL, client, 
@@ -2253,7 +2256,7 @@ void silc_server_free_client_data(SilcServer server,
   else
     silc_server_remove_from_channels(server, NULL, client, 
                                     FALSE, NULL, FALSE);
-
+    
   /* We will not delete the client entry right away. We will take it
      into history (for WHOWAS command) for 5 minutes */
   i->server = server;
index 8bc011e1155d5626cdb833e5ecabd2ac6dc58116..440c6999db9dc455bf59e0a35d00f57dd03d7c7f 100644 (file)
@@ -248,7 +248,8 @@ void silc_client_channel_message(SilcClient client,
   /* Find client entry */
   silc_list_start(channel->clients);
   while ((chu = silc_list_get(channel->clients)) != SILC_LIST_END) {
-    if (SILC_ID_CLIENT_COMPARE(chu->client->id, client_id)) {
+    if (SILC_ID_CLIENT_COMPARE(chu->client->id, client_id) && 
+       chu->client->nickname) {
       found = TRUE;
       break;
     }
index 94e487f173dd92c76e24909c38bc9eaeddd266a8..403d7623af0b0eea538042d641a0e2015ecaa943 100644 (file)
@@ -184,8 +184,10 @@ void silc_client_notify_by_server(SilcClient client,
 
     /* If nickname or username hasn't been resolved, do so */
     if (!client_entry->nickname || !client_entry->username) {
-      if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING)
+      if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) {
+       client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
        goto out;
+      }
       client_entry->status |= SILC_CLIENT_STATUS_RESOLVING;
       silc_client_notify_by_server_resolve(client, conn, packet, client_id);
       goto out;
index d9f2e65d4d02e8bc5ad09b91e92833e382ce00a8..a5c6d7d171c1bf442bf737636d2faa8e247d0bb2 100644 (file)
@@ -164,7 +164,8 @@ void silc_client_private_message(SilcClient client,
   if (!silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)remote_id, 
                                       NULL, NULL, 
                                       silc_hash_client_id_compare, NULL,
-                                      &id_cache)) {
+                                      &id_cache) || 
+      ((SilcClientEntry)id_cache->context)->nickname == NULL) {
     /* Resolve the client info */
     silc_client_get_client_by_id_resolve(client, conn, remote_id,
                                         silc_client_private_message_cb,
index 781607e3ae676af4807153be70907c11804b9638..90ca482a5f25a2c5874ad9c8f26f856a5c5f5071 100644 (file)
@@ -2149,7 +2149,12 @@ SILC_CLIENT_CMD_FUNC(getkey)
     /* Check whether user requested server actually */
     server_entry = silc_client_get_server(client, conn, cmd->argv[1]);
 
-    if (!server_entry && !cmd->pending) {
+    if (!server_entry) {
+      if (cmd->pending) {
+       COMMAND_ERROR;
+       goto out;
+      }
+
       /* No. what ever user wants we don't have it, so resolve it. We
         will try to resolve both client and server, one of them is
         bound to be wrong. */
index 4cc302cbaae525fe1fe717ecc75131142b0d007f..01fe350cfd1a0a386b1ff6d12f676a96ed1171c2 100644 (file)
@@ -1706,6 +1706,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(users)
       if (id_cache && id_cache->context) {
        SilcClientEntry client_entry = (SilcClientEntry)id_cache->context;
        if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) {
+         client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
          silc_buffer_pull(client_id_list, idp_len);
          silc_buffer_pull(client_mode_list, 4);
          continue;
index 83efa2057fd70d09a6c4624689346696c31edaa4..8e870e137cfa453d515f9a2156c10168bedd72e2 100644 (file)
@@ -311,6 +311,7 @@ void silc_client_get_clients_by_list(SilcClient client,
 
       if (entry) {
        if (entry->status & SILC_CLIENT_STATUS_RESOLVING) {
+         client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
          silc_free(client_id);
          silc_buffer_pull(client_id_list, idp_len);
          continue;
index 08b9cc6fd883c8960a415f6a90d67d41a51401b1..cd4de48926b603611613715a82f3627a8fac912e 100644 (file)
 #ifndef IDLIST_H
 #define IDLIST_H
 
+typedef enum {
+  SILC_CLIENT_STATUS_NONE       = 0x0000,
+  SILC_CLIENT_STATUS_RESOLVING  = 0x0001,
+} SilcClientStatus;
+
 /* Client entry context. When client receives information about new client
    (it receives its ID, for example, by IDENTIFY request) we create new
    client entry. This entry also includes the private message keys if
@@ -43,6 +48,7 @@ typedef struct {
   uint32 key_len;
   bool generated;              /* TRUE if library generated the key */
   SilcClientKeyAgreement ke;   /* Current key agreement context or NULL */
+  SilcClientStatus status;     /* Status mask */
 } *SilcClientEntry;
 
 /* Client and its mode on a channel */
index 2e7b9cbf006b1929687356a2d6a001e1ee591f60..cdf844d48cfe6178fe9820e4bf186a5fb4bb3030 100644 (file)
@@ -378,7 +378,7 @@ void silc_packet_receive_process(SilcSocketConnection sock,
     silc_buffer_put(parse_ctx->packet->buffer, sock->inbuf->data, 
                    paddedlen + mac_len);
 
-    SILC_LOG_HEXDUMP(("Incoming packet (%d) (%d bytes decrypted), len %d", 
+    SILC_LOG_HEXDUMP(("Incoming packet (%d) (%dB decrypted), len %d", 
                      sequence - 1, block_len, paddedlen + mac_len),
                     sock->inbuf->data, paddedlen + mac_len);
 
index 535d3f0f29f78ecab01d90948e4a00991e7e2bf0..f0df279e8b32f6b17f1c0c6b270d705c7b7c790b 100644 (file)
@@ -223,10 +223,6 @@ typedef struct {
   uint8 dst_id_len;
   uint8 dst_id_type;
 
-  /* Back pointers */
-  void *context;
-  SilcSocketConnection sock;
-
   int users;
   bool long_pad;               /* Set to TRUE to use maximum padding
                                   in packet (up to 256 bytes). */