/* If we are normal server, send the command to router, since we
want to know all channels in the network. */
- if (!cmd->pending && server->server_type == SILC_SERVER &&
+ if (!cmd->pending && server->server_type != SILC_ROUTER &&
!server->standalone) {
SilcBuffer tmpbuf;
SilcUInt16 old_ident;
}
memset(invite, 0, sizeof(invite));
- strncat(invite, dest->nickname, strlen(dest->nickname));
- strncat(invite, "!", 1);
- strncat(invite, dest->username, strlen(dest->username));
+ silc_strncat(invite, sizeof(invite),
+ dest->nickname, strlen(dest->nickname));
+ silc_strncat(invite, sizeof(invite), "!", 1);
+ silc_strncat(invite, sizeof(invite),
+ dest->username, strlen(dest->username));
if (!strchr(dest->username, '@')) {
- strncat(invite, "@", 1);
- strncat(invite, cmd->sock->hostname, strlen(cmd->sock->hostname));
+ silc_strncat(invite, sizeof(invite), "@", 1);
+ silc_strncat(invite, sizeof(invite), cmd->sock->hostname,
+ strlen(cmd->sock->hostname));
}
len = strlen(invite);
/* Send command reply */
tmp = silc_argument_get_arg_type(cmd->args, 1, &len);
- if (add || del)
- packet =
- silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
- SILC_STATUS_OK, 0, ident, 2,
- 2, tmp, len,
- 3, channel->invite_list,
- channel->invite_list ?
- strlen(channel->invite_list) : 0);
- else
- packet =
- silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
- SILC_STATUS_OK, 0, ident, 1,
- 2, tmp, len);
+ packet =
+ silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
+ SILC_STATUS_OK, 0, ident, 2,
+ 2, tmp, len,
+ 3, channel->invite_list,
+ channel->invite_list ?
+ strlen(channel->invite_list) : 0);
silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0,
packet->data, packet->len, FALSE);
silc_buffer_free(packet);
{
SilcServerCommandContext cmd = (SilcServerCommandContext)context;
SilcServer server = cmd->server;
- SilcServerID *id;
SilcUInt32 len;
unsigned char *tmp;
- SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_INFO, cmd, 1, 2);
+ SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_PING, cmd, 1, 2);
/* Get Server ID */
tmp = silc_argument_get_arg_type(cmd->args, 1, &len);
SILC_STATUS_ERR_NO_SERVER_ID, 0);
goto out;
}
- id = silc_id_str2id(tmp, len, SILC_ID_SERVER);
- if (!id)
- goto out;
- if (SILC_ID_SERVER_COMPARE(id, server->id)) {
+ if (!memcmp(tmp, server->id_string, server->id_string_len)) {
/* Send our reply */
silc_server_command_send_status_reply(cmd, SILC_COMMAND_PING,
SILC_STATUS_OK, 0);
goto out;
}
- silc_free(id);
-
out:
silc_server_command_free(cmd);
}
bool resolve;
unsigned char *fkey = NULL;
SilcUInt32 fkey_len = 0;
+ const char *cipher;
SILC_LOG_DEBUG(("Joining client to channel"));
goto out;
}
+ if (auth && auth_len && !client->data.public_key) {
+ if (cmd->pending == 2)
+ goto out;
+
+ /* We must retrieve the detached client's public key by sending
+ GETKEY command. Reprocess this packet after receiving the key */
+ clidp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
+ silc_server_send_command(server, cmd->sock,
+ SILC_COMMAND_GETKEY, ++server->cmd_ident,
+ 1, 1, clidp->data, clidp->len);
+ silc_buffer_free(clidp);
+ silc_server_command_pending(server, SILC_COMMAND_GETKEY,
+ server->cmd_ident,
+ silc_server_command_join,
+ silc_server_command_dup(cmd));
+ cmd->pending = 2;
+ goto out;
+ }
+
cmd->pending = FALSE;
}
if (!umode) {
memset(check, 0, sizeof(check));
memset(check2, 0, sizeof(check2));
- strncat(check, client->nickname, strlen(client->nickname));
- strncat(check, "!", 1);
- strncat(check, client->username, strlen(client->username));
+ silc_strncat(check, sizeof(check),
+ client->nickname, strlen(client->nickname));
+ silc_strncat(check, sizeof(check), "!", 1);
+ silc_strncat(check, sizeof(check),
+ client->username, strlen(client->username));
if (!strchr(client->username, '@')) {
- strncat(check, "@", 1);
- strncat(check, cmd->sock->hostname, strlen(cmd->sock->hostname));
+ silc_strncat(check, sizeof(check), "@", 1);
+ silc_strncat(check, sizeof(check),
+ cmd->sock->hostname, strlen(cmd->sock->hostname));
}
- strncat(check2, client->nickname, strlen(client->nickname));
+ silc_strncat(check2, sizeof(check2),
+ client->nickname, strlen(client->nickname));
if (!strchr(client->nickname, '@')) {
- strncat(check2, "@", 1);
- strncat(check2, server->server_name, strlen(server->server_name));
+ silc_strncat(check2, sizeof(check2), "@", 1);
+ silc_strncat(check2, sizeof(check2),
+ server->server_name, strlen(server->server_name));
}
- strncat(check2, "!", 1);
- strncat(check2, client->username, strlen(client->username));
+ silc_strncat(check2, sizeof(check2), "!", 1);
+ silc_strncat(check2, sizeof(check2),
+ client->username, strlen(client->username));
if (!strchr(client->username, '@')) {
- strncat(check2, "@", 1);
- strncat(check2, cmd->sock->hostname, strlen(cmd->sock->hostname));
+ silc_strncat(check2, sizeof(check2), "@", 1);
+ silc_strncat(check2, sizeof(check2),
+ cmd->sock->hostname, strlen(cmd->sock->hostname));
}
/* Check invite list if channel is invite-only channel */
if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
tmp = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
+ cipher = silc_cipher_get_name(channel->channel_key);
keyp = silc_channel_key_payload_encode(silc_id_get_len(channel->id,
SILC_ID_CHANNEL),
tmp,
- strlen(channel->channel_key->
- cipher->name),
- channel->channel_key->cipher->name,
+ strlen(cipher), cipher,
channel->key_len / 8, channel->key);
silc_free(tmp);
}
}
if (!entry) {
- silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
+ silc_server_command_send_status_reply(cmd, SILC_COMMAND_MOTD,
SILC_STATUS_ERR_NO_SUCH_SERVER, 0);
goto out;
}
silc_server_send_channel_key(server, NULL, channel,
server->server_type == SILC_ROUTER ?
FALSE : !server->standalone);
-
- cipher = channel->channel_key->cipher->name;
+
+ cipher = (char *)silc_cipher_get_name(channel->channel_key);
hmac = (char *)silc_hmac_get_name(channel->hmac);
}
}
SilcServer server = cmd->server;
SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
SilcIDListData idata = (SilcIDListData)client;
- SilcChannelID *channel_id;
- SilcClientID *client_id;
+ SilcChannelID *channel_id = NULL;
+ SilcClientID *client_id = NULL;
SilcChannelEntry channel;
SilcClientEntry target_client;
SilcChannelClientEntry chl;
packet->data, packet->len, FALSE);
silc_buffer_free(packet);
- silc_free(channel_id);
- silc_free(client_id);
silc_buffer_free(idp);
out:
+ silc_free(channel_id);
+ silc_free(client_id);
silc_free(fkey);
silc_server_command_free(cmd);
}
silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
SILC_STATUS_ERR_AUTH_FAILED,
0);
+ SILC_LOG_INFO(("OPER authentication failed for username '%s' by "
+ "nickname '%s' from %s", username,
+ client->nickname, cmd->sock->hostname));
goto out;
}
}
SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_WATCH, cmd, 1, 3);
- if (server->server_type == SILC_SERVER && !server->standalone) {
+ if (server->server_type != SILC_ROUTER && !server->standalone) {
if (!cmd->pending) {
/* Send the command to router */
SilcBuffer tmpbuf;
SilcUInt16 old_ident;
+ SILC_LOG_DEBUG(("Forwarding WATCH to router"));
+
old_ident = silc_command_get_ident(cmd->payload);
silc_command_set_ident(cmd->payload, ++server->cmd_ident);
tmpbuf = silc_command_payload_encode_payload(cmd->payload);
/* Received reply from router, just send same data to the client. */
SilcServerCommandReplyContext reply = context2;
SilcStatus status;
+
+ SILC_LOG_DEBUG(("Received reply to WATCH from router"));
silc_command_get_status(reply->payload, &status, NULL);
silc_server_command_send_status_reply(cmd, SILC_COMMAND_WATCH, status,
0);
if (!admin) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
SILC_STATUS_ERR_AUTH_FAILED, 0);
+ SILC_LOG_INFO(("SILCOPER authentication failed for username '%s' by "
+ "nickname '%s' from %s", username,
+ client->nickname, cmd->sock->hostname));
goto out;
}
}
goto out;
}
- if (server->server_type == SILC_ROUTER &&
+ if (server->server_type == SILC_ROUTER && !server->backup_router &&
client->mode & SILC_UMODE_SERVER_OPERATOR) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CONNECT,
SILC_STATUS_ERR_NO_ROUTER_PRIV, 0);