From 7b2c89711c8d7f20f9f1322c9af768727fc555a5 Mon Sep 17 00:00:00 2001 From: Jochen Eisinger Date: Sat, 17 Mar 2007 18:11:19 +0000 Subject: [PATCH] Sat Mar 17 19:07:15 CET 2007 Jochen Eisinger * Incorporate SILC Plugin patches. Affected files are apps/irssi/src/fe-common/silc/module-formats.{c,h}, apps/irssi/src/silc/core/clientutil.{c,h}, apps/irssi/src/silc/core/silc-core.c, apps/irssi/src/silc/core/silc-chatnets.{c,h}, apps/irssi/src/fe-common/silc/fe-silcnet.c, and apps/irssi/src/fe-common/silc/module.h --- CHANGES | 10 + apps/irssi/src/fe-common/silc/fe-silcnet.c | 8 + .../irssi/src/fe-common/silc/module-formats.c | 20 ++ .../irssi/src/fe-common/silc/module-formats.h | 21 +- apps/irssi/src/fe-common/silc/module.h | 1 + apps/irssi/src/silc/core/clientutil.c | 147 +++++++++++ apps/irssi/src/silc/core/clientutil.h | 10 + apps/irssi/src/silc/core/silc-chatnets.c | 8 - apps/irssi/src/silc/core/silc-chatnets.h | 2 - apps/irssi/src/silc/core/silc-core.c | 249 +++++++++++++++++- 10 files changed, 459 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index ec497b03..79aaa5c3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +Sat Mar 17 19:07:15 CET 2007 Jochen Eisinger + + * Incorporate SILC Plugin patches. Affected files are + apps/irssi/src/fe-common/silc/module-formats.{c,h}, + apps/irssi/src/silc/core/clientutil.{c,h}, + apps/irssi/src/silc/core/silc-core.c, + apps/irssi/src/silc/core/silc-chatnets.{c,h}, + apps/irssi/src/fe-common/silc/fe-silcnet.c, and + apps/irssi/src/fe-common/silc/module.h + Wed Mar 14 17:31:28 EET 2007 Pekka Riikonen * In notify handling resolve user entries many times if the diff --git a/apps/irssi/src/fe-common/silc/fe-silcnet.c b/apps/irssi/src/fe-common/silc/fe-silcnet.c index 2ab14d32..4efeca54 100644 --- a/apps/irssi/src/fe-common/silc/fe-silcnet.c +++ b/apps/irssi/src/fe-common/silc/fe-silcnet.c @@ -31,6 +31,14 @@ #include "silc-chatnets.h" #include "printtext.h" +void silcnet_create(SILC_CHATNET_REC *rec) +{ + g_return_if_fail(rec != NULL); + + rec->chat_type = SILC_PROTOCOL; + chatnet_create((CHATNET_REC *) rec); +} + static void cmd_silcnet_list(void) { GString *str; diff --git a/apps/irssi/src/fe-common/silc/module-formats.c b/apps/irssi/src/fe-common/silc/module-formats.c index 422e7c29..4bfe1d27 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.c +++ b/apps/irssi/src/fe-common/silc/module-formats.c @@ -272,5 +272,25 @@ FORMAT_REC fecommon_silc_formats[] = { { "silcnet_line", "%#$0: $1", 2, { 0, 0 } }, { "silcnet_footer", "", 0 }, +#ifdef SILC_PLUGIN + /* command line option handling */ + { NULL, "Command Line Option Handling", 0 }, + + { "config_debug", "Run-time debugging is {hilight $0}", 1, { 0 } }, + { "config_nodebug", "Run-time debugging is {hilight disabled}. To enable it recompile the client with {hilight --enable-debug} configuration option.", 0 }, + { "config_unknown", "Unknown option: $0", 1, { 0 } }, + { "config_list", " - $0", 1, { 0 } }, + { "config_algos", "Supported {hilight $0} algorithms:", 1, { 0 } }, + { "config_nexttime", "{hilight NOTE:} You need to reload the plugin for these changes to take effect!", 0 }, + { "config_pass_ask1", "Current Passphrase:", 0 }, + { "config_pass_ask2", "New Passphrase:", 0 }, + { "config_pass_ask3", "Retype new Passphrasse:", 0 }, + { "config_passmismatch", "The passphrases do not match!", 0 }, + { "config_passchange", "Changed the private key passphrase sucessfully", 0, { 0 } }, + { "config_passchange_fail", "Failed to change the passphrase!", 0, { 0 } }, + { "config_create", "Created a new key pair successfully", 0, { 0 } }, + { "config_create_fail", "Failed to create a new key pair", 0, { 0 } }, +#endif + { NULL, NULL, 0 } }; diff --git a/apps/irssi/src/fe-common/silc/module-formats.h b/apps/irssi/src/fe-common/silc/module-formats.h index b7a0fc93..8f174be1 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.h +++ b/apps/irssi/src/fe-common/silc/module-formats.h @@ -260,7 +260,26 @@ enum { SILCTXT_SILCNET_NOT_FOUND, SILCTXT_SILCNET_HEADER, SILCTXT_SILCNET_LINE, - SILCTXT_SILCNET_FOOTER + SILCTXT_SILCNET_FOOTER, + +#ifdef SILC_PLUGIN + SILCTXT_FILL_9, + + SILCTXT_CONFIG_DEBUG, + SILCTXT_CONFIG_NODEBUG, + SILCTXT_CONFIG_UNKNOWN, + SILCTXT_CONFIG_LIST, + SILCTXT_CONFIG_ALGOS, + SILCTXT_CONFIG_NEXTTIME, + SILCTXT_CONFIG_PASS_ASK1, + SILCTXT_CONFIG_PASS_ASK2, + SILCTXT_CONFIG_PASS_ASK3, + SILCTXT_CONFIG_PASSMISMATCH, + SILCTXT_CONFIG_PASSCHANGE, + SILCTXT_CONFIG_PASSCHANGE_FAIL, + SILCTXT_CONFIG_CREATE, + SILCTXT_CONFIG_CREATE_FAIL, +#endif }; diff --git a/apps/irssi/src/fe-common/silc/module.h b/apps/irssi/src/fe-common/silc/module.h index 0a06d9c5..b9293006 100644 --- a/apps/irssi/src/fe-common/silc/module.h +++ b/apps/irssi/src/fe-common/silc/module.h @@ -1,6 +1,7 @@ #include "common.h" #define MODULE_NAME "fe-common/silc" +#define SILC_PROTOCOL (chat_protocol_lookup("SILC")) #undef PACKAGE #undef VERSION diff --git a/apps/irssi/src/silc/core/clientutil.c b/apps/irssi/src/silc/core/clientutil.c index c3bcd328..9130779f 100644 --- a/apps/irssi/src/silc/core/clientutil.c +++ b/apps/irssi/src/silc/core/clientutil.c @@ -41,15 +41,40 @@ #include "fe-common/core/printtext.h" #include "fe-common/core/keyboard.h" +#include "fe-common/silc/module-formats.h" #include "core.h" +#ifdef SILC_PLUGIN +void silc_client_print_list(char *list) +{ + char **items; + int i=0; + + items = g_strsplit(list, ",", -1); + + while (items[i] != NULL) + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_LIST, + items[i++]); + + g_strfreev(items); +} +#endif + /* Lists supported ciphers */ void silc_client_list_ciphers() { char *ciphers = silc_cipher_get_supported(); +#ifdef SILC_PLUGIN + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_ALGOS, + "cipher"); + silc_client_print_list(ciphers); +#else fprintf(stdout, "%s\n", ciphers); +#endif silc_free(ciphers); } @@ -58,7 +83,14 @@ void silc_client_list_ciphers() void silc_client_list_hash_funcs() { char *hash = silc_hash_get_supported(); +#ifdef SILC_PLUGIN + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_ALGOS, + "hash"); + silc_client_print_list(hash); +#else fprintf(stdout, "%s\n", hash); +#endif silc_free(hash); } @@ -67,7 +99,14 @@ void silc_client_list_hash_funcs() void silc_client_list_hmacs() { char *hash = silc_hmac_get_supported(); +#ifdef SILC_PLUGIN + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_ALGOS, + "hmac"); + silc_client_print_list(hash); +#else fprintf(stdout, "%s\n", hash); +#endif silc_free(hash); } @@ -76,7 +115,14 @@ void silc_client_list_hmacs() void silc_client_list_pkcs() { char *pkcs = silc_pkcs_get_supported(); +#ifdef SILC_PLUGIN + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_ALGOS, + "pkcs"); + silc_client_print_list(pkcs); +#else fprintf(stdout, "%s\n", pkcs); +#endif silc_free(pkcs); } @@ -323,3 +369,104 @@ int silc_client_load_keys(SilcClient client) return ret; } + +#ifdef SILC_PLUGIN +void create_key_passphrase(const char *answer, CREATE_KEY_REC *rec) +{ + char priv_key_file[128], pub_key_file[128]; + + signal_stop(); + + if ((rec->passphrase == NULL) && (answer) && (*answer != '\0')) { + rec->passphrase = g_strdup(answer); + keyboard_entry_redirect((SIGNAL_FUNC) create_key_passphrase, + format_get_text("fe-common/silc", NULL, NULL, + NULL, SILCTXT_CONFIG_PASS_ASK2), + ENTRY_REDIRECT_FLAG_HIDDEN, rec); + return; + } + + if ((answer) && (*answer != '\0') && (rec->passphrase != NULL)) { + if (strcmp(answer, rec->passphrase)) { + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_PASSMISMATCH); + g_free(rec->pkcs); + g_free(rec->passphrase); + g_free(rec); + return; + } + } + + memset(priv_key_file, 0, sizeof(priv_key_file)); + memset(pub_key_file, 0, sizeof(pub_key_file)); + snprintf(priv_key_file, sizeof(priv_key_file) - 1, "%s/%s", + get_irssi_dir(), SILC_CLIENT_PRIVATE_KEY_NAME); + snprintf(pub_key_file, sizeof(pub_key_file) - 1, "%s/%s", + get_irssi_dir(), SILC_CLIENT_PUBLIC_KEY_NAME); + + if (silc_create_key_pair(rec->pkcs, rec->bits, pub_key_file, priv_key_file, + NULL, (rec->passphrase == NULL ? "" : rec->passphrase), + NULL, NULL, NULL, FALSE) == TRUE) + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_CREATE); + else + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_CREATE_FAIL); + + g_free(rec->passphrase); + g_free(rec->pkcs); + g_free(rec); + +} + +void change_private_key_passphrase(const char *answer, CREATE_KEY_REC *rec) +{ + signal_stop(); + + if (rec->old == NULL) { + rec->old = g_strdup((answer == NULL ? "" : answer)); + keyboard_entry_redirect((SIGNAL_FUNC) change_private_key_passphrase, + format_get_text("fe-common/silc", NULL, NULL, + NULL, SILCTXT_CONFIG_PASS_ASK2), + ENTRY_REDIRECT_FLAG_HIDDEN, rec); + return; + } + + if ((rec->passphrase == NULL) && (answer) && (*answer != '\0')) { + rec->passphrase = g_strdup(answer); + keyboard_entry_redirect((SIGNAL_FUNC) change_private_key_passphrase, + format_get_text("fe-common/silc", NULL, NULL, + NULL, SILCTXT_CONFIG_PASS_ASK3), + ENTRY_REDIRECT_FLAG_HIDDEN, rec); + return; + } + + if ((answer) && (*answer != '\0') && (rec->passphrase != NULL)) { + if (strcmp(answer, rec->passphrase)) { + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_PASSMISMATCH); + g_free(rec->old); + g_free(rec->file); + g_free(rec->pkcs); + g_free(rec->passphrase); + g_free(rec); + return; + } + } + + if (silc_change_private_key_passphrase(rec->file, rec->old, + (rec->passphrase == NULL ? + "" : rec->passphrase)) == TRUE) + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_PASSCHANGE); + else + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_PASSCHANGE_FAIL); + g_free(rec->old); + g_free(rec->file); + g_free(rec->passphrase); + g_free(rec->pkcs); + g_free(rec); + +} +#endif diff --git a/apps/irssi/src/silc/core/clientutil.h b/apps/irssi/src/silc/core/clientutil.h index 6b703f5d..240100a6 100644 --- a/apps/irssi/src/silc/core/clientutil.h +++ b/apps/irssi/src/silc/core/clientutil.h @@ -31,4 +31,14 @@ void silc_client_list_pkcs(); int silc_client_check_silc_dir(); int silc_client_load_keys(SilcClient client); +#ifdef SILC_PLUGIN +typedef struct { + char *old, *passphrase, *file, *pkcs; + int bits; +} CREATE_KEY_REC; + +void create_key_passphrase(const char *answer, CREATE_KEY_REC *rec); +void change_private_key_passphrase(const char *answer, CREATE_KEY_REC *rec); +#endif + #endif diff --git a/apps/irssi/src/silc/core/silc-chatnets.c b/apps/irssi/src/silc/core/silc-chatnets.c index 8fbaf2df..9e179d6f 100644 --- a/apps/irssi/src/silc/core/silc-chatnets.c +++ b/apps/irssi/src/silc/core/silc-chatnets.c @@ -26,14 +26,6 @@ #include "silc-chatnets.h" -void silcnet_create(SILC_CHATNET_REC *rec) -{ - g_return_if_fail(rec != NULL); - - rec->chat_type = SILC_PROTOCOL; - chatnet_create((CHATNET_REC *) rec); -} - static void sig_chatnet_read(SILC_CHATNET_REC *rec, CONFIG_NODE *node) { if (!IS_SILC_CHATNET(rec)) diff --git a/apps/irssi/src/silc/core/silc-chatnets.h b/apps/irssi/src/silc/core/silc-chatnets.h index e9a1f673..f786c300 100644 --- a/apps/irssi/src/silc/core/silc-chatnets.h +++ b/apps/irssi/src/silc/core/silc-chatnets.h @@ -20,8 +20,6 @@ struct _SILC_CHATNET_REC { typedef struct _SILC_CHATNET_REC SILC_CHATNET_REC; -void silcnet_create(SILC_CHATNET_REC *rec); - #define silc_chatnet_find(name) \ SILC_CHATNET(chatnet_find(name)) #define silcnet_find(name) silc_chatnet_find(name) diff --git a/apps/irssi/src/silc/core/silc-core.c b/apps/irssi/src/silc/core/silc-core.c index 259d7a6f..9510a975 100644 --- a/apps/irssi/src/silc/core/silc-core.c +++ b/apps/irssi/src/silc/core/silc-core.c @@ -31,18 +31,24 @@ #include "silc-nicklist.h" #include "silc-chatnets.h" #include "silc-cmdqueue.h" +#include "silc-commands.h" #include "signals.h" #include "levels.h" #include "settings.h" +#include "commands.h" #include "fe-common/core/printtext.h" #include "fe-common/core/fe-channels.h" #include "fe-common/core/keyboard.h" #include "fe-common/silc/module-formats.h" +#ifndef SILC_PLUGIN /* Command line option variables */ static char *opt_pkcs = NULL; static int opt_bits = 0; +#else +static int init_failed = 0; +#endif static int idletag = -1; @@ -66,6 +72,10 @@ void silc_expandos_deinit(void); void silc_lag_init(void); void silc_lag_deinit(void); +#ifdef SILC_PLUGIN +void silc_core_deinit(void); +#endif + static int my_silc_scheduler(void) { silc_client_run_one(silc_client); @@ -169,8 +179,11 @@ static void silc_init_userinfo(void) } } -#ifdef SILC_DEBUG +#if defined(SILC_DEBUG) || defined(SILC_PLUGIN) static bool i_debug; +#endif + +#ifdef SILC_DEBUG static bool silc_irssi_debug_print(char *file, char *function, int line, char *message, void *context) { @@ -229,7 +242,12 @@ static void silc_register_cipher(SilcClient client, const char *cipher) if (!silc_cipher_is_supported(cipher)) { SILC_LOG_ERROR(("Unknown cipher `%s'", cipher)); +#ifdef SILC_PLUGIN + init_failed = -1; + returnn; +#else exit(1); +#endif } } @@ -250,7 +268,12 @@ static void silc_register_hash(SilcClient client, const char *hash) if (!silc_hash_is_supported(hash)) { SILC_LOG_ERROR(("Unknown hash function `%s'", hash)); +#ifdef SILC_PLUGIN + init_failed = -1; + returnn; +#else exit(1); +#endif } } @@ -271,7 +294,12 @@ static void silc_register_hmac(SilcClient client, const char *hmac) if (!silc_hmac_is_supported(hmac)) { SILC_LOG_ERROR(("Unknown HMAC `%s'", hmac)); +#ifdef SILC_PLUGIN + init_failed = -1; + returnn; +#else exit(1); +#endif } } @@ -281,11 +309,38 @@ static void silc_register_hmac(SilcClient client, const char *hmac) /* Finalize init. Init finish signal calls this. */ +#ifdef SILC_PLUGIN +#define FUNCTION_EXIT goto out +void silc_opt_callback(const char *data, SERVER_REC *server, + WI_ITEM_REC *item) +#else +#define FUNCTION_EXIT exit(0) void silc_opt_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, void *data) +#endif { +#ifdef SILC_PLUGIN + unsigned char **argv=NULL, *tmp; + SilcUInt32 *argv_lens=NULL, *argv_types=NULL, argc=0; + int i; + unsigned char privkey[128], pubkey[128]; + + memset(privkey, 0, sizeof(privkey)); + memset(pubkey, 0, sizeof(pubkey)); + snprintf(pubkey, sizeof(pubkey) - 1, "%s/%s", get_irssi_dir(), + SILC_CLIENT_PUBLIC_KEY_NAME); + snprintf(privkey, sizeof(privkey) - 1, "%s/%s", get_irssi_dir(), + SILC_CLIENT_PRIVATE_KEY_NAME); + + tmp = g_strconcat("SILC", " ", data, NULL); + silc_parse_command_line(tmp, &argv, &argv_lens, &argv_types, &argc, 6); + g_free(tmp); + + if (argc < 2) + goto err; +#else if (strcmp(opt->longName, "nick") == 0) { g_free(opt_nickname); opt_nickname = g_strdup(arg); @@ -295,45 +350,138 @@ void silc_opt_callback(poptContext con, silc_free(opt_hostname); opt_hostname = strdup(arg); } +#endif +#ifdef SILC_PLUGIN + if ((argc == 2) && (strcasecmp(argv[1], "list-ciphers") == 0)) { +#else if (strcmp(opt->longName, "list-ciphers") == 0) { silc_cipher_register_default(); +#endif silc_client_list_ciphers(); - exit(0); + FUNCTION_EXIT; } +#ifdef SILC_PLUGIN + if ((argc == 2) && (strcasecmp(argv[1], "list-hash-funcs") == 0)) { +#else if (strcmp(opt->longName, "list-hash-funcs") == 0) { silc_hash_register_default(); +#endif silc_client_list_hash_funcs(); - exit(0); + FUNCTION_EXIT; } +#ifdef SILC_PLUGIN + if ((argc == 2) && (strcasecmp(argv[1], "list-hmacs") == 0)) { +#else if (strcmp(opt->longName, "list-hmacs") == 0) { silc_hmac_register_default(); +#endif silc_client_list_hmacs(); - exit(0); + FUNCTION_EXIT; } +#ifdef SILC_PLUGIN + if ((argc == 2) && (strcasecmp(argv[1], "list-pkcs") == 0)) { +#else if (strcmp(opt->longName, "list-pkcs") == 0) { silc_pkcs_register_default(); +#endif silc_client_list_pkcs(); - exit(0); + FUNCTION_EXIT; } +#ifdef SILC_PLUGIN + if ((argc < 5) && (strcasecmp(argv[1], "debug") == 0)) { +#else if (strcmp(opt->longName, "debug") == 0) { silc_log_debug(TRUE); silc_log_debug_hexdump(TRUE); silc_log_set_debug_string(arg); +#endif +#ifdef SILC_PLUGIN + if (argc == 2) { + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_DEBUG, + (i_debug == TRUE ? "enabled" : "disabled")); + goto out; + } +#endif #ifndef SILC_DEBUG +#ifdef SILC_PLUGIN + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_NODEBUG); +#else fprintf(stdout, "Run-time debugging is not enabled. To enable it recompile\n" "the client with --enable-debug configuration option.\n"); sleep(1); +#endif +#else +#ifdef SILC_PLUGIN + if (strcasecmp(argv[2], "on") == 0) { + settings_set_bool("debug", TRUE); + if (argc == 4) + settings_set_str("debug_string", argv[3]); + } else if ((argc == 3) && (strcasecmp(argv[2], "off") == 0)) { + settings_set_bool("debug", FALSE); + } else + goto err; + sig_setup_changed(); + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_DEBUG, + (settings_get_bool("debug") == TRUE ? + "enabled" : "disabled")); + goto out; +#endif #endif } +#ifdef SILC_PLUGIN + if (strcasecmp(argv[1], "create-key-pair") == 0) { +#else if (strcmp(opt->longName, "create-key-pair") == 0) { +#endif /* Create new key pair and exit */ +#ifdef SILC_PLUGIN + char *endptr, *pkcs=NULL; + long int val; + int bits=0; + CREATE_KEY_REC *rec; + + if ((argc == 3) || (argc == 5)) + goto err; + + for (i=2; i= INT_MAX)) + goto err; + bits = val; + } else + goto err; + } else + goto err; + + rec = g_new0(CREATE_KEY_REC, 1); + rec->pkcs = (pkcs == NULL ? NULL : g_strdup(pkcs)); + rec->bits = bits; + + keyboard_entry_redirect((SIGNAL_FUNC) create_key_passphrase, + format_get_text("fe-common/silc", NULL, NULL, + NULL, SILCTXT_CONFIG_PASS_ASK2), + ENTRY_REDIRECT_FLAG_HIDDEN, rec); + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_NEXTTIME); + goto out; +#else silc_cipher_register_default(); silc_pkcs_register_default(); silc_hash_register_default(); @@ -341,18 +489,37 @@ void silc_opt_callback(poptContext con, silc_create_key_pair(opt_pkcs, opt_bits, NULL, NULL, NULL, NULL, NULL, NULL, TRUE); exit(0); +#endif } +#ifdef SILC_PLUGIN + if ((argc < 4) && (strcasecmp(argv[1], "passphrase-change") == 0)) { +#else if (strcmp(opt->longName, "passphrase-change") == 0) { +#endif /* Change the passphrase of the private key file */ +#ifdef SILC_PLUGIN + CREATE_KEY_REC *rec; + + rec = g_new0(CREATE_KEY_REC, 1); + rec->file = g_strdup((argc == 3 ? argv[2] : privkey)); + + keyboard_entry_redirect((SIGNAL_FUNC) change_private_key_passphrase, + format_get_text("fe-common/silc", NULL, NULL, + NULL, SILCTXT_CONFIG_PASS_ASK1), + ENTRY_REDIRECT_FLAG_HIDDEN, rec); + goto out; +#else silc_cipher_register_default(); silc_pkcs_register_default(); silc_hash_register_default(); silc_hmac_register_default(); silc_change_private_key_passphrase(arg, NULL, NULL); exit(0); +#endif } +#ifndef SILC_PLUGIN if (strcmp(opt->longName, "show-key") == 0) { /* Dump the key */ silc_cipher_register_default(); @@ -362,7 +529,24 @@ void silc_opt_callback(poptContext con, silc_show_public_key_file((char *)arg); exit(0); } +#endif + +#ifdef SILC_PLUGIN +err: + printformat_module("fe-common/silc", NULL, NULL, + MSGLEVEL_CRAP, SILCTXT_CONFIG_UNKNOWN, + data); + +out: + for (i=0; iname = "SILC"; @@ -557,6 +782,14 @@ void silc_core_init(void) silc_lag_init(); silc_chatnets_init(); +#ifdef SILC_PLUGIN + sig_init_finished(); + if (init_failed) { + silc_core_deinit(); + return; + } +#endif + module_register("silc", "core"); } @@ -573,8 +806,12 @@ void silc_core_deinit(void) g_free(opt_nickname); signal_remove("setup changed", (SIGNAL_FUNC) sig_setup_changed); - signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished); signal_remove("gui exit", (SIGNAL_FUNC) sig_gui_quit); +#ifdef SILC_PLUGIN + command_unbind("silc", (SIGNAL_FUNC) silc_opt_callback); +#else + signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished); +#endif silc_hash_free(sha1hash); -- 2.24.0