+Sat Jun 29 17:40:12 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Return NO_SUCH_CHANNEL error in USERS for channel that is
+ secret or private, otherwise it's possible to find out
+ whether a secret channel exists or not. Affected file
+ silcd/command.c.
+
+ * If CMODE change fails during the mode setting, assure that
+ the old mode mask is set for the channel back. Affected
+ file silcd/command.c.
+
+ * Fixed passphrase saving on +a channel on normal server
+ after successful JOIN command. Affected file silcd/command.c.
+
Fri Jun 28 11:53:25 CEST 2002 Pekka Riikonen <priikone@silcnet.org>
* Remove server/router operator privileges in DETACH command,
/* Save channel passphrase, if user provided it successfully */
unsigned char *pa;
SilcUInt32 pa_len;
- pa = silc_argument_get_arg_type(reply->args, 3, &pa_len);
+ pa = silc_argument_get_arg_type(cmd->args, 3, &pa_len);
if (pa) {
silc_free(channel->passphrase);
channel->passphrase = silc_memdup(pa, pa_len);
SilcBuffer packet, cidp;
unsigned char *tmp, *tmp_id, *tmp_mask;
char *cipher = NULL, *hmac = NULL, *passphrase = NULL;
- SilcUInt32 mode_mask = 0, tmp_len, tmp_len2;
+ SilcUInt32 mode_mask = 0, old_mask = 0, tmp_len, tmp_len2;
SilcUInt16 ident = silc_command_get_ident(cmd->payload);
bool set_mask = FALSE;
SilcPublicKey founder_key = NULL;
if (!tmp_id) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_CMODE,
SILC_STATUS_ERR_NO_CHANNEL_ID, 0);
- goto out;
+ silc_server_command_free(cmd);
+ return;
}
channel_id = silc_id_payload_parse_id(tmp_id, tmp_len2, NULL);
if (!channel_id) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_CMODE,
SILC_STATUS_ERR_NO_CHANNEL_ID, 0);
- goto out;
- }
-
- /* Get the channel mode mask */
- tmp_mask = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
- if (tmp_mask) {
- SILC_GET32_MSB(mode_mask, tmp_mask);
- set_mask = TRUE;
+ silc_server_command_free(cmd);
+ return;
}
/* Get channel entry */
silc_server_command_send_status_reply(cmd, SILC_COMMAND_CMODE,
SILC_STATUS_ERR_NO_SUCH_CHANNEL,
0);
- goto out;
+ silc_free(channel_id);
+ silc_server_command_free(cmd);
+ return;
}
}
+ old_mask = channel->mode;
+
+ /* Get the channel mode mask */
+ tmp_mask = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+ if (tmp_mask) {
+ SILC_GET32_MSB(mode_mask, tmp_mask);
+ set_mask = TRUE;
+ }
/* Check whether this client is on the channel */
if (!silc_server_client_on_channel(client, channel, &chl)) {
}
/* Finally, set the mode */
- channel->mode = mode_mask;
+ old_mask = channel->mode = mode_mask;
/* Send CMODE_CHANGE notify. */
cidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
silc_buffer_free(cidp);
out:
+ channel->mode = old_mask;
silc_free(fkey);
silc_free(channel_id);
silc_server_command_free(cmd);
&& !silc_server_client_on_channel(cmd->sock->user_data, channel,
NULL)) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_USERS,
- SILC_STATUS_ERR_NOT_ON_CHANNEL, 0);
+ SILC_STATUS_ERR_NO_SUCH_CHANNEL,
+ 0);
goto out;
}
}
0, channel_id, sock->user_data, NULL, NULL, 0);
if (!channel)
return;
- channel->disabled = TRUE;
+ channel->disabled = TRUE; /* Disabled until someone JOINs */
server->stat.channels++;
if (server->server_type == SILC_ROUTER)
silc_free(channel_id);
return;
}
- channel->disabled = TRUE;
+ channel->disabled = TRUE; /* Disabled until someone JOINs */
+
+#if 0 /* We assume that CMODE_CHANGE notify is sent to us after this. */
+
+ /* XXX Dunno if this is supposed to be set in any server type. If set
+ here the CMODE_CHANGE that may follow sets mode that we already
+ have, and we may loose data from the CMODE_CHANGE notify. */
if (server_entry->server_type != SILC_BACKUP_ROUTER)
channel->mode = silc_channel_get_mode(payload);
+#endif
/* Send the new channel key to the server */
id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
void silc_server_close_connection(SilcServer server,
SilcSocketConnection sock)
{
+ char tmp[128];
+
if (!server->sockets[sock->sock] && SILC_IS_DISCONNECTED(sock)) {
silc_schedule_task_add(server->schedule, 0,
silc_server_close_connection_final,
return;
}
- SILC_LOG_INFO(("Closing connection %s:%d [%s]", sock->hostname,
+ memset(tmp, 0, sizeof(tmp));
+ silc_socket_get_error(sock, tmp, sizeof(tmp));
+ SILC_LOG_INFO(("Closing connection %s:%d [%s] %s", sock->hostname,
sock->port,
(sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
- "Router")));
+ "Router"), tmp[0] ? tmp : ""));
/* We won't listen for this connection anymore */
silc_schedule_unset_listen_fd(server->schedule, sock->sock);
{
SilcServerHBContext hb = (SilcServerHBContext)hb_context;
- SILC_LOG_DEBUG(("Sending heartbeat to %s (%s)", sock->hostname, sock->ip));
+ SILC_LOG_DEBUG(("Sending heartbeat to %s:%d (%s)", sock->hostname,
+ sock->port, sock->ip));
/* Send the heartbeat */
silc_server_send_heartbeat(hb->server, sock);