X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fcommand_reply.c;h=dee4e0bef9bcd7a1838c08a96a06445caec96082;hb=386c883d8774999c6e74d7c6c37e52e4163a4cb1;hp=56c222263714c293046d1259d11bfbb21059cd5f;hpb=2f93ad66ac16ad7c8bde97d1298bb78aad5b4f35;p=silc.git diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index 56c22226..dee4e0be 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -284,15 +284,17 @@ SILC_SERVER_CMD_REPLY_FUNC(whois) "the entry from cache")); client = silc_idlist_find_client_by_id(server->global_list, client_id, FALSE, NULL); - if (client) + if (client) { + silc_server_remove_from_channels(server, NULL, client, TRUE, + NULL, TRUE); silc_idlist_del_client(server->global_list, client); + } silc_free(client_id); } } } SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_WHOIS); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOIS); silc_server_command_reply_free(cmd); } @@ -405,7 +407,6 @@ SILC_SERVER_CMD_REPLY_FUNC(whowas) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_WHOWAS); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOWAS); silc_server_command_reply_free(cmd); } @@ -644,15 +645,17 @@ SILC_SERVER_CMD_REPLY_FUNC(identify) "the entry from cache")); client = silc_idlist_find_client_by_id(server->global_list, client_id, FALSE, NULL); - if (client) + if (client) { + silc_server_remove_from_channels(server, NULL, client, TRUE, + NULL, TRUE); silc_idlist_del_client(server->global_list, client); + } silc_free(client_id); } } } SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_IDENTIFY); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_IDENTIFY); silc_server_command_reply_free(cmd); } @@ -710,7 +713,6 @@ SILC_SERVER_CMD_REPLY_FUNC(info) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_INFO); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_INFO); silc_server_command_reply_free(cmd); } @@ -754,7 +756,6 @@ SILC_SERVER_CMD_REPLY_FUNC(motd) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_MOTD); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_MOTD); silc_server_command_reply_free(cmd); if (entry) @@ -823,6 +824,7 @@ SILC_SERVER_CMD_REPLY_FUNC(join) silc_buffer_put(keyp, tmp, len); } + /* Parse the Channel ID */ id = silc_id_payload_parse_id(id_string, id_len); if (!id) goto out; @@ -872,8 +874,13 @@ SILC_SERVER_CMD_REPLY_FUNC(join) local list. */ entry = silc_idlist_find_channel_by_name(server->global_list, channel_name, &cache); - if (entry) + if (entry) { + if (entry->rekey) { + silc_schedule_task_del_by_context(server->schedule, entry->rekey); + SILC_LOG_ERROR(("global_list->channels: entry->rekey != NULL, inform Pekka now!!!")); + } silc_idlist_del_channel(server->global_list, entry); + } /* Add the channel to our local list. */ entry = silc_idlist_add_channel(server->local_list, strdup(channel_name), @@ -886,19 +893,19 @@ SILC_SERVER_CMD_REPLY_FUNC(join) server->stat.my_channels++; } else { /* The entry exists. */ - silc_free(cache->id); - entry->id = id; - cache->id = entry->id; + + /* If ID has changed, then update it to the cache too. */ + if (!SILC_ID_CHANNEL_COMPARE(entry->id, id)) + silc_idlist_replace_channel_id(server->local_list, entry->id, id); + entry->disabled = FALSE; /* Remove the founder auth data if the mode is not set but we have them in the entry */ if (!(mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) && entry->founder_key) { silc_pkcs_public_key_free(entry->founder_key); - if (entry->founder_passwd) { - silc_free(entry->founder_passwd); - entry->founder_passwd = NULL; - } + silc_free(entry->founder_passwd); + entry->founder_passwd = NULL; } } @@ -910,26 +917,21 @@ SILC_SERVER_CMD_REPLY_FUNC(join) /* Get the ban list */ tmp = silc_argument_get_arg_type(cmd->args, 8, &len); if (tmp) { - if (entry->ban_list) - silc_free(entry->ban_list); - entry->ban_list = silc_calloc(len, sizeof(*entry->ban_list)); - memcpy(entry->ban_list, tmp, len); + silc_free(entry->ban_list); + entry->ban_list = silc_memdup(tmp, len); } /* Get the invite list */ tmp = silc_argument_get_arg_type(cmd->args, 9, &len); if (tmp) { - if (entry->invite_list) - silc_free(entry->invite_list); - entry->invite_list = silc_calloc(len, sizeof(*entry->invite_list)); - memcpy(entry->invite_list, tmp, len); + silc_free(entry->invite_list); + entry->invite_list = silc_memdup(tmp, len); } /* Get the topic */ tmp = silc_argument_get_arg_type(cmd->args, 10, &len); if (tmp) { - if (entry->topic) - silc_free(entry->topic); + silc_free(entry->topic); entry->topic = strdup(tmp); } @@ -948,10 +950,11 @@ SILC_SERVER_CMD_REPLY_FUNC(join) entry->mode = mode; /* Save channel key */ - if (!(entry->mode & SILC_CHANNEL_MODE_PRIVKEY)) - silc_server_save_channel_key(server, keyp, entry); - if (keyp) + if (keyp) { + if (!(entry->mode & SILC_CHANNEL_MODE_PRIVKEY)) + silc_server_save_channel_key(server, keyp, entry); silc_buffer_free(keyp); + } /* Save the users to the channel */ silc_server_save_users_on_channel(server, cmd->sock, entry, @@ -960,7 +963,6 @@ SILC_SERVER_CMD_REPLY_FUNC(join) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_JOIN); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_JOIN); silc_free(client_id); silc_server_command_reply_free(cmd); @@ -1016,7 +1018,7 @@ SILC_SERVER_CMD_REPLY_FUNC(users) USERS command reply callback. */ silc_server_command_pending(server, SILC_COMMAND_IDENTIFY, server->cmd_ident, - NULL, silc_server_command_reply_users, cmd); + silc_server_command_reply_users, cmd); return; } } @@ -1055,7 +1057,6 @@ SILC_SERVER_CMD_REPLY_FUNC(users) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_USERS); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_USERS); silc_free(channel_id); silc_server_command_reply_free(cmd); } @@ -1136,7 +1137,6 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_GETKEY); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_GETKEY); if (idp) silc_id_payload_free(idp); silc_free(client_id); @@ -1199,6 +1199,8 @@ SILC_SERVER_CMD_REPLY_FUNC(list) cache->expire = time(NULL) + 60; } + channel->user_count = usercount; + if (topic) { silc_free(channel->topic); channel->topic = strdup(topic); @@ -1217,7 +1219,6 @@ SILC_SERVER_CMD_REPLY_FUNC(list) out: SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_LIST); - SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_LIST); silc_free(channel_id); silc_server_command_reply_free(cmd); }