From 8a338943d22f887cc96c432055b12be3ba14ebff Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 18 Jul 2001 19:19:27 +0000 Subject: [PATCH] updates. --- CHANGES | 18 +++++++++++ CREDITS | 4 +-- TODO | 3 ++ apps/irssi/docs/help/in/silcoper.in | 5 ++- apps/silcd/command.c | 7 ++-- apps/silcd/server.c | 45 +++++++++++++++++--------- lib/silcclient/client_keyagr.c | 14 ++++---- lib/silccore/silcprotocol.c | 2 +- lib/silcutil/silcnet.h | 11 +++++++ lib/silcutil/silcschedule.c | 3 +- lib/silcutil/silcschedule.h | 3 ++ lib/silcutil/win32/silcwin32schedule.c | 3 ++ 12 files changed, 87 insertions(+), 31 deletions(-) diff --git a/CHANGES b/CHANGES index b47f5c58..e5a11169 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,21 @@ +Wed Jul 18 18:34:01 EEST 2001 Pekka Riikonen + + * Call silc_schedule_task_del_by_context in the + silc_protocol_cancel instead of silc_schedule_task_del_by_callback. + Affected file lib/silccore/silcprotocol.c. + + * Call silc_protocol_cancel for active protocols in the + silc_server_close_connection if the funtion + silc_server_free_sock_user_data has not been called. + Affected file silcd/server.c. + + * Generic tasks cannot be deleted using the del_by_fd + task deleting function since generic tasks does not match + any specific fd. Affected file lib/silcutil/silcschedule.[ch]. + + * Added a notion to SILCOPER help file that the SILCOPER works + only on router server, not on normal server. + Wed Jul 18 09:40:04 EEST 2001 Pekka Riikonen * Added for WIN32 support for the new scheduler as well. diff --git a/CREDITS b/CREDITS index 67aca48b..b626e568 100644 --- a/CREDITS +++ b/CREDITS @@ -24,8 +24,8 @@ E: priikone@ssh.com P: 1024/A924ED4F AD 82 53 2D 84 FF C7 D1 FF 63 19 0E 1A 78 9F 8A A9 24 ED 4F D: Protocol architet D: Main developer -S: Kasarmikatu 11 A4 -S: 70110 Kuopio +S: Snellmanninkatu 34 A 15 +S: 70100 Kuopio S: Finland N: Juha Räsänen diff --git a/TODO b/TODO index 1bb758dc..02d3d74a 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,9 @@ TODO/bugs in Irssi SILC client cipher, hash, hmac and pkcs configuration to the Irssi SILC's config file. + o The QUIT command should wait for servers disconnection (at least for + a while) before exiting the application. + o Add local command to switch the channel's private key when channel has several private keys. Currently sending channel messages with many keys is not possible because changing the key is not possible by the diff --git a/apps/irssi/docs/help/in/silcoper.in b/apps/irssi/docs/help/in/silcoper.in index b75ef81c..8f0c5056 100644 --- a/apps/irssi/docs/help/in/silcoper.in +++ b/apps/irssi/docs/help/in/silcoper.in @@ -1,9 +1,12 @@ @SYNTAX:silcoper@ -Gives you router operator priviledges if thecorrect +Gives you router operator priviledges if the correct username and passphrase are given. User will be prompted for the passphrase if the is not provided. +NOTE: This command works only on router server. It has +no effect on normal SILC server. + See also: KILL, SCONNECT, CLOSE, OPER diff --git a/apps/silcd/command.c b/apps/silcd/command.c index b0207cfa..bab8ee25 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -4299,11 +4299,14 @@ SILC_SERVER_CMD_FUNC(silcoper) SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_SILCOPER, cmd, 1, 2); - if (server->server_type == SILC_SERVER) + if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT) goto out; - if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT) + if (server->server_type == SILC_SERVER) { + silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER, + SILC_STATUS_ERR_AUTH_FAILED); goto out; + } /* Get the username */ username = silc_argument_get_arg_type(cmd->args, 1, &tmp_len); diff --git a/apps/silcd/server.c b/apps/silcd/server.c index f9aa6c9b..492e6f25 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -830,10 +830,10 @@ SILC_TASK_CALLBACK(silc_server_connect_to_router_final) server. This task remains on the queue until the end of the program. */ if (!server->listenning) { silc_schedule_task_add(server->schedule, server->sock, - silc_server_accept_new_connection, - (void *)server, 0, 0, - SILC_TASK_FD, - SILC_TASK_PRI_NORMAL); + silc_server_accept_new_connection, + (void *)server, 0, 0, + SILC_TASK_FD, + SILC_TASK_PRI_NORMAL); server->listenning = TRUE; } @@ -1036,10 +1036,10 @@ silc_server_accept_new_connection_lookup(SilcSocketConnection sock, be closed if the key exchange protocol has not been started. */ proto_ctx->timeout_task = silc_schedule_task_add(server->schedule, sock->sock, - silc_server_timeout_remote, - context, 60, 0, - SILC_TASK_TIMEOUT, - SILC_TASK_PRI_LOW); + silc_server_timeout_remote, + context, 60, 0, + SILC_TASK_TIMEOUT, + SILC_TASK_PRI_LOW); } /* Accepts new connections to the server. Accepting new connections are @@ -1186,10 +1186,10 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_second) this is 60 seconds and is hard coded limit (XXX). */ proto_ctx->timeout_task = silc_schedule_task_add(server->schedule, sock->sock, - silc_server_timeout_remote, - (void *)server, 60, 0, - SILC_TASK_TIMEOUT, - SILC_TASK_PRI_LOW); + silc_server_timeout_remote, + (void *)server, 60, 0, + SILC_TASK_TIMEOUT, + SILC_TASK_PRI_LOW); } /* Final part of accepting new connection. The connection has now @@ -1459,10 +1459,10 @@ SILC_TASK_CALLBACK(silc_server_packet_process) if (!server->standalone && sock->type == SILC_SOCKET_TYPE_ROUTER && sock == server->router->connection) silc_schedule_task_add(server->schedule, 0, - silc_server_connect_to_router, - context, 1, 0, - SILC_TASK_TIMEOUT, - SILC_TASK_PRI_NORMAL); + silc_server_connect_to_router, + context, 1, 0, + SILC_TASK_TIMEOUT, + SILC_TASK_PRI_NORMAL); if (sock->user_data) silc_server_free_sock_user_data(server, sock); @@ -2105,6 +2105,19 @@ void silc_server_close_connection(SilcServer server, sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" : "Router"), sock->sock)); + /* If sock->user_data is NULL then we'll check for active protocols + here since the silc_server_free_sock_user_data has not been called + for this connection. */ + if (!sock->user_data) { + /* If any protocol is active cancel its execution */ + if (sock->protocol) { + silc_protocol_cancel(sock->protocol, server->schedule); + sock->protocol->state = SILC_PROTOCOL_STATE_ERROR; + silc_protocol_execute_final(sock->protocol, server->schedule); + sock->protocol = NULL; + } + } + /* We won't listen for this connection anymore */ silc_schedule_unset_listen_fd(server->schedule, sock->sock); diff --git a/lib/silcclient/client_keyagr.c b/lib/silcclient/client_keyagr.c index c68a432f..78337cfe 100644 --- a/lib/silcclient/client_keyagr.c +++ b/lib/silcclient/client_keyagr.c @@ -343,9 +343,9 @@ void silc_client_send_key_agreement(SilcClient client, will not start the key exchange protocol within the specified timeout. */ ke->timeout = silc_schedule_task_add(client->schedule, 0, - silc_client_key_agreement_timeout, - (void *)ke, timeout_secs, 0, - SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW); + silc_client_key_agreement_timeout, + (void *)ke, timeout_secs, 0, + SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW); } /* Encode the key agreement payload */ @@ -373,10 +373,10 @@ silc_client_connect_to_client_internal(SilcClientInternalConnectContext *ctx) /* Register task that will receive the async connect and will read the result. */ ctx->task = silc_schedule_task_add(ctx->client->schedule, sock, - silc_client_perform_key_agreement_start, - (void *)ctx, 0, 0, - SILC_TASK_FD, - SILC_TASK_PRI_NORMAL); + silc_client_perform_key_agreement_start, + (void *)ctx, 0, 0, + SILC_TASK_FD, + SILC_TASK_PRI_NORMAL); silc_schedule_set_listen_fd(ctx->client->schedule, sock, SILC_TASK_WRITE); ctx->sock = sock; diff --git a/lib/silccore/silcprotocol.c b/lib/silccore/silcprotocol.c index 9c91d845..3703c30e 100644 --- a/lib/silccore/silcprotocol.c +++ b/lib/silccore/silcprotocol.c @@ -138,5 +138,5 @@ void silc_protocol_execute_final(SilcProtocol protocol, SilcSchedule schedule) void silc_protocol_cancel(SilcProtocol protocol, SilcSchedule schedule) { - silc_schedule_task_del_by_callback(schedule, protocol->protocol->callback); + silc_schedule_task_del_by_context(schedule, protocol); } diff --git a/lib/silcutil/silcnet.h b/lib/silcutil/silcnet.h index d5b8a6ba..949a4a60 100644 --- a/lib/silcutil/silcnet.h +++ b/lib/silcutil/silcnet.h @@ -20,6 +20,17 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * + * DESCRIPTION + * + * SILC Net API provides various network routines for applications. It + * can be used to create TCP/IP connections and servers. Various utility + * functions for resolving various information is also provided. + * + * On WIN32 systems the SILC Net API must initialized by calling the + * silc_net_win32_init and uninitialized when the application ends by + * calling the silc_net_win32_uninit function. The initializing must be + * done in order to assure that the SILC Net API works correctly. + * */ #ifndef SILCNET_H diff --git a/lib/silcutil/silcschedule.c b/lib/silcutil/silcschedule.c index 6bef700d..fd53ffe2 100644 --- a/lib/silcutil/silcschedule.c +++ b/lib/silcutil/silcschedule.c @@ -745,7 +745,6 @@ void silc_schedule_task_del_by_fd(SilcSchedule schedule, uint32 fd) { silc_task_del_by_fd(schedule->timeout_queue, fd); silc_task_del_by_fd(schedule->fd_queue, fd); - silc_task_del_by_fd(schedule->generic_queue, fd); } /* Remove task by task callback. */ @@ -1056,7 +1055,7 @@ static int silc_schedule_task_remove(SilcTaskQueue queue, SilcTask task) { SilcTask first, old, next; - if (!queue) + if (!queue || !task) return FALSE; if (!queue->task) { diff --git a/lib/silcutil/silcschedule.h b/lib/silcutil/silcschedule.h index b2597f74..2272f8e1 100644 --- a/lib/silcutil/silcschedule.h +++ b/lib/silcutil/silcschedule.h @@ -463,6 +463,9 @@ void silc_schedule_task_del(SilcSchedule schedule, SilcTask task); * in task callbacks (including in the task's own task callback) and * in multi-threaded environment in other threads as well. * + * Note that generic tasks cannot be deleted using this function + * since generic tasks does not match any specific fd. + * ***/ void silc_schedule_task_del_by_fd(SilcSchedule schedule, uint32 fd); diff --git a/lib/silcutil/win32/silcwin32schedule.c b/lib/silcutil/win32/silcwin32schedule.c index 433b5ec2..9321fecb 100644 --- a/lib/silcutil/win32/silcwin32schedule.c +++ b/lib/silcutil/win32/silcwin32schedule.c @@ -57,6 +57,9 @@ int silc_select(SilcScheduleFd fds, uint32 fds_count, struct timeval *timeout) int nhandles = 0, i; MSG msg; + if (fds_count > MAXIMUM_WAIT_OBJECTS) + fds_count = MAXIMUM_WAIT_OBJECTS; + for (i = 0; i < fds_count; i++) { if (!fds[i].events) continue; -- 2.24.0