From a67bfbe8a773eac3852d82a7dafb53a421a3769d Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Wed, 14 Mar 2001 14:45:11 +0000 Subject: [PATCH] updates. --- CHANGES | 10 ++++ apps/silcd/serverconfig.c | 66 +++++++++++++++++++++------ apps/silcd/serverconfig.h | 7 ++- doc/draft-riikonen-silc-spec-01.nroff | 3 +- doc/example_silcd.conf | 16 ++++++- 5 files changed, 83 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index 454faa11..03d80a67 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +Wed Mar 14 16:10:30 EET 2001 Pekka Riikonen + + * Changed the format of AdminConnection configuration section + in the server. Added username of the admin to the format. + Affected files silcd/serverconfig.[ch]. + + Added silc_server_config_find_admin into silcd/serverconfig.[ch] + to return admin configuration data by host, username and/or + nickname. + Wed Mar 14 13:18:16 EET 2001 Pekka Riikonen * Implemented WHOWAS command to the server. Added the functions: diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index 485c261a..cc51b89b 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -864,6 +864,22 @@ int silc_server_config_parse_lines(SilcServerConfig config, /* Any host */ config->admins->host = strdup("*"); + /* Get username */ + ret = silc_config_get_token(line, &config->admins->username); + if (ret < 0) + break; + if (ret == 0) + /* Any username */ + config->admins->username = strdup("*"); + + /* Get nickname */ + ret = silc_config_get_token(line, &config->admins->nickname); + if (ret < 0) + break; + if (ret == 0) + /* Any nickname */ + config->admins->nickname = strdup("*"); + /* Get authentication method */ ret = silc_config_get_token(line, &tmp); if (ret < 0) @@ -890,20 +906,6 @@ int silc_server_config_parse_lines(SilcServerConfig config, if (ret < 0) break; - /* Get nickname */ - ret = silc_config_get_token(line, &config->admins->nickname); - if (ret < 0) - break; - - /* Get class number */ - ret = silc_config_get_token(line, &tmp); - if (ret < 0) - break; - if (ret) { - config->admins->class = atoi(tmp); - silc_free(tmp); - } - check = TRUE; checkmask |= (1L << pc->section->type); break; @@ -1384,6 +1386,42 @@ silc_server_config_find_router_conn(SilcServerConfig config, return serv; } +/* Returns Admin connection configuration by host, username and/or + nickname. */ + +SilcServerConfigSectionAdminConnection * +silc_server_config_find_admin(SilcServerConfig config, + char *host, char *username, char *nickname) +{ + SilcServerConfigSectionAdminConnection *admin = NULL; + int i; + + if (!config->admins) + return NULL; + + if (!host) + host = "*"; + if (!username) + username = "*"; + if (nickname) + nickname = "*"; + + admin = config->admins; + for (i = 0; admin; i++) { + if (silc_string_compare(admin->host, host) && + silc_string_compare(admin->username, username) && + silc_string_compare(admin->nickname, nickname)) + break; + + admin = admin->next; + } + + if (!admin) + return NULL; + + return admin; +} + /* Prints out example configuration file with default built in configuration values. */ diff --git a/apps/silcd/serverconfig.h b/apps/silcd/serverconfig.h index 1d33597d..3e911eac 100644 --- a/apps/silcd/serverconfig.h +++ b/apps/silcd/serverconfig.h @@ -106,10 +106,10 @@ typedef struct SilcServerConfigSectionClientConnectionStruct { /* Hols all server's administrators authentication data from config file */ typedef struct SilcServerConfigSectionAdminConnectionStruct { char *host; + char *username; + char *nickname; int auth_meth; char *auth_data; - char *nickname; - unsigned int class; struct SilcServerConfigSectionAdminConnectionStruct *next; struct SilcServerConfigSectionAdminConnectionStruct *prev; } SilcServerConfigSectionAdminConnection; @@ -266,6 +266,9 @@ silc_server_config_find_server_conn(SilcServerConfig config, SilcServerConfigSectionServerConnection * silc_server_config_find_router_conn(SilcServerConfig config, char *host, int port); +SilcServerConfigSectionAdminConnection * +silc_server_config_find_admin(SilcServerConfig config, + char *host, char *username, char *nickname); void silc_server_config_print(); #endif diff --git a/doc/draft-riikonen-silc-spec-01.nroff b/doc/draft-riikonen-silc-spec-01.nroff index 1cb7cb4e..f36990e4 100644 --- a/doc/draft-riikonen-silc-spec-01.nroff +++ b/doc/draft-riikonen-silc-spec-01.nroff @@ -1115,7 +1115,8 @@ o Authentication Data (variable length) - Authentication If the authentication method is password based, the Authentication Data field includes the plaintext password. It is safe to send -plaintext password since the entire payload is encrypted. +plaintext password since the entire payload is encrypted. In this +case the Public Data Lenght is set to zero (0). If the authentication method is public key based (or certificate) the Authentication Data is computed as follows: diff --git a/doc/example_silcd.conf b/doc/example_silcd.conf index 8d4bcf59..ece466f2 100644 --- a/doc/example_silcd.conf +++ b/doc/example_silcd.conf @@ -120,16 +120,22 @@ infologfile:silcd.log:10000 # # Format: :::: # +# The is either passphrase or file path to the public key +# file. +# [ClientConnection] :::1333:1 # # Configured server administrator connections # -# Format: :::: +# Format: :::: +# +# The is either passphrase or file path to the public key +# file. # [AdminConnection] -10.2.1.199:passwd:veryscret:XXX:1 +10.2.1.199:priikone:pekka:passwd:veryscret # # Configured server connections. @@ -141,6 +147,9 @@ infologfile:silcd.log:10000 # # Format: ::::: # +# The is either passphrase or file path to the public key +# file. +# [ServerConnection] 10.2.1.7:passwd:veryscret:706:1:1 @@ -154,6 +163,9 @@ infologfile:silcd.log:10000 # # Format: :::::: # +# The is either passphrase or file path to the public key +# file. +# [RouterConnection] #10.2.1.100:passwd:veryverysecret:706:1:1:1 -- 2.24.0