From 482d3275621c40888ffcc942e905aff6ea78b92e Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 17 Oct 2004 11:28:03 +0000 Subject: nickserv passwords hidden (new config option: log_hide_nickserv_pwd on/off) --- src/common/history.c | 30 ++++++++++++++++++++++++++++++ src/common/weeconfig.c | 5 +++++ src/common/weeconfig.h | 1 + src/irc/irc-send.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) (limited to 'src') diff --git a/src/common/history.c b/src/common/history.c index 6724662c1..33f13e963 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -39,6 +39,32 @@ t_history *history_general_ptr = NULL; int num_history_general = 0; +/* + * history_hide_password: hide a nickserv password + */ + +void +history_hide_password (char *string) +{ + char *pos_pwd; + + if (strstr (string, "nickserv ")) + { + pos_pwd = strstr (string, "identify "); + if (!pos_pwd) + pos_pwd = strstr (string, "register "); + if (pos_pwd) + { + pos_pwd += 9; + while (pos_pwd[0]) + { + pos_pwd[0] = '*'; + pos_pwd++; + } + } + } +} + /* * history_add: add a text/command to history */ @@ -53,6 +79,8 @@ history_add (void *buffer, char *string) if (new_history) { new_history->text = strdup (string); + if (cfg_log_hide_nickserv_pwd) + history_hide_password (new_history->text); if (history_general) history_general->prev_history = new_history; @@ -82,6 +110,8 @@ history_add (void *buffer, char *string) if (new_history) { new_history->text = strdup (string); + if (cfg_log_hide_nickserv_pwd) + history_hide_password (new_history->text); if (((t_gui_buffer *)(buffer))->history) ((t_gui_buffer *)(buffer))->history->prev_history = new_history; diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index d78d581ee..38bf40427 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -417,6 +417,7 @@ int cfg_log_auto_channel; int cfg_log_auto_private; char *cfg_log_path; char *cfg_log_timestamp; +int cfg_log_hide_nickserv_pwd; t_config_option weechat_options_log[] = { { "log_auto_server", N_("automatically log server messages"), @@ -439,6 +440,10 @@ t_config_option weechat_options_log[] = N_("timestamp for log (see man strftime for date/time specifiers)"), OPTION_TYPE_STRING, 0, 0, 0, "%Y %b %d %H:%M:%S", NULL, NULL, &cfg_log_timestamp, NULL }, + { "log_hide_nickserv_pwd", N_("hide password displayed by nickserv"), + N_("hide password displayed by nickserv"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_log_hide_nickserv_pwd, NULL, NULL }, { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } }; diff --git a/src/common/weeconfig.h b/src/common/weeconfig.h index c90d287b7..d5e217720 100644 --- a/src/common/weeconfig.h +++ b/src/common/weeconfig.h @@ -144,6 +144,7 @@ extern int cfg_log_auto_channel; extern int cfg_log_auto_private; extern char *cfg_log_path; extern char *cfg_log_timestamp; +extern int cfg_log_hide_nickserv_pwd; extern int cfg_dcc_auto_accept_files; extern int cfg_dcc_auto_accept_chats; diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index c55aacb36..1db8219c7 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -513,6 +513,7 @@ int irc_cmd_send_msg (t_irc_server *server, char *arguments) { char *pos, *pos_comma; + char *msg_pwd_hidden, *pos_pwd; t_irc_channel *ptr_channel; t_irc_nick *ptr_nick; @@ -582,6 +583,41 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } else { + /* message to nickserv with identify ? */ + if (strcmp (arguments, "nickserv") == 0) + { + msg_pwd_hidden = strdup (pos); + if (cfg_log_hide_nickserv_pwd) + { + pos_pwd = strstr (msg_pwd_hidden, "identify "); + if (!pos_pwd) + pos_pwd = strstr (msg_pwd_hidden, "register "); + if (pos_pwd) + { + pos_pwd += 9; + while (pos_pwd[0]) + { + pos_pwd[0] = '*'; + pos_pwd++; + } + } + } + gui_printf_color_type (server->buffer, + MSG_TYPE_NICK, + COLOR_WIN_CHAT_DARK, "-"); + gui_printf_color_type (server->buffer, + MSG_TYPE_NICK, + COLOR_WIN_CHAT_NICK, "%s", arguments); + gui_printf_color_type (server->buffer, + MSG_TYPE_NICK, + COLOR_WIN_CHAT_DARK, "-"); + gui_printf_color (server->buffer, + COLOR_WIN_CHAT, " %s\n", msg_pwd_hidden); + server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); + free (msg_pwd_hidden); + return 0; + } + ptr_channel = channel_search (server, arguments); if (!ptr_channel) { -- cgit v1.2.3