From 2110c6d92e1785d55ab7117a3aaa8113e0870d99 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 19 Sep 2013 15:07:55 +0200 Subject: [PATCH] core: add support of secured data in proxy options username/password (evaluate content) --- po/cs.po | 15 +++++------ po/de.po | 15 +++++------ po/es.po | 15 +++++------ po/fr.po | 19 +++++++------- po/hu.po | 16 +++++------- po/it.po | 15 +++++------ po/ja.po | 15 +++++------ po/pl.po | 15 +++++------ po/pt_BR.po | 11 +++----- po/ru.po | 16 +++++------- po/tr.po | 15 +++++------ po/weechat.pot | 6 ++--- src/core/wee-network.c | 57 ++++++++++++++++++++++++++++++++---------- src/core/wee-proxy.c | 6 +++-- 14 files changed, 119 insertions(+), 117 deletions(-) diff --git a/po/cs.po b/po/cs.po index 6deb4f380..2b4d53087 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,8 +20,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:20+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:45+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" "Language: cs\n" @@ -3521,11 +3521,11 @@ msgstr "adresa proxy serveru (IP nebo jméno hosta)" msgid "port for connecting to proxy server" msgstr "port pro připojení na proxy server" -msgid "username for proxy server" -msgstr "uživatelské jméno pro proxy server" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "heslo pro proxy server" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -9824,6 +9824,3 @@ msgstr "" msgid "Constants" msgstr "" - -#~ msgid "password for server" -#~ msgstr "heslo pro server" diff --git a/po/de.po b/po/de.po index 7ee5f6531..fe5931e5a 100644 --- a/po/de.po +++ b/po/de.po @@ -22,8 +22,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-16 22:50+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:43+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" "Language: de_DE\n" @@ -4021,11 +4021,11 @@ msgstr "Adresse des Proxy-Servers (IP oder Hostname)" msgid "port for connecting to proxy server" msgstr "Port, auf dem der Proxy-Server läuft" -msgid "username for proxy server" -msgstr "Benutzername für die Proxy-Verbindung" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "Passwort für die Proxy-Verbindung" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -10839,6 +10839,3 @@ msgstr "Type" msgid "Constants" msgstr "Konstanten" - -#~ msgid "password for server" -#~ msgstr "Passwort für den Server" diff --git a/po/es.po b/po/es.po index 48f33aa23..7ae4654d7 100644 --- a/po/es.po +++ b/po/es.po @@ -22,8 +22,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:20+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:46+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" "Language: es\n" @@ -3721,11 +3721,11 @@ msgstr "dirección del servidor proxy (IP o nombre de máquina)" msgid "port for connecting to proxy server" msgstr "puerto para conectarse al servidor proxy" -msgid "username for proxy server" -msgstr "nombre de usuario para el servidor proxy" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "contraseña para el servidor proxy" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -10081,6 +10081,3 @@ msgstr "Tipo" msgid "Constants" msgstr "Constantes" - -#~ msgid "password for server" -#~ msgstr "contraseña del servidor" diff --git a/po/fr.po b/po/fr.po index 0a453d161..f90c41708 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-19 13:57+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:44+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -3912,11 +3912,15 @@ msgstr "adresse du serveur proxy (IP ou nom de machine)" msgid "port for connecting to proxy server" msgstr "port pour se connecter au serveur proxy" -msgid "username for proxy server" -msgstr "nom d'utilisateur pour le serveur proxy" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" +"nom d'utilisateur pour le serveur proxy (note: le contenu est évalué, voir /" +"help eval)" -msgid "password for proxy server" -msgstr "mot de passe pour le serveur proxy" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" +"mot de passe pour le serveur proxy (note: le contenu est évalué, voir /help " +"eval)" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -10572,6 +10576,3 @@ msgstr "Type" msgid "Constants" msgstr "Constantes" - -#~ msgid "password for server" -#~ msgstr "mot de passe pour le serveur" diff --git a/po/hu.po b/po/hu.po index 66946bb0d..ad1bccf17 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,8 +20,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:20+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:35+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" "Language: hu\n" @@ -3147,11 +3147,11 @@ msgstr "proxy szerver címe (IP-cím vagy gépnév)" msgid "port for connecting to proxy server" msgstr "proxy szerverhez való csatlakozáskor használt port" -msgid "username for proxy server" -msgstr "felhasználónév a proxy szerverhez" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "jelszó a proxy szerverhez" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -9255,7 +9255,3 @@ msgstr "" msgid "Constants" msgstr "" - -#, fuzzy -#~ msgid "password for server" -#~ msgstr "jelszó az IRC szerveren" diff --git a/po/it.po b/po/it.po index 10143e52b..40f71f61f 100644 --- a/po/it.po +++ b/po/it.po @@ -20,8 +20,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:20+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:46+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" "Language: it\n" @@ -3786,11 +3786,11 @@ msgstr "indirizzo del server proxy (IP o nome host)" msgid "port for connecting to proxy server" msgstr "porta per la connessione al server proxy" -msgid "username for proxy server" -msgstr "nome utente per il server proxy" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "password per il server proxy" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -10180,6 +10180,3 @@ msgstr "Tipo" msgid "Constants" msgstr "Costanti" - -#~ msgid "password for server" -#~ msgstr "password per il server" diff --git a/po/ja.po b/po/ja.po index 5cd31b286..3f8f84276 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,8 +20,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:20+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:44+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" "Language: ja\n" @@ -3759,11 +3759,11 @@ msgstr "プロキシサーバアドレス (IP アドレスかホスト名)" msgid "port for connecting to proxy server" msgstr "プロキシサーバの接続ポート" -msgid "username for proxy server" -msgstr "プロキシサーバのユーザ名" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "プロキシサーバのパスワード" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -10193,6 +10193,3 @@ msgstr "タイプ" msgid "Constants" msgstr "定数" - -#~ msgid "password for server" -#~ msgstr "サーバのパスワード" diff --git a/po/pl.po b/po/pl.po index 578771d08..db8224396 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:21+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:46+0200\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" "Language: pl\n" @@ -3847,11 +3847,11 @@ msgstr "adres serwera proxy (adres IP lub nazwa hosta)" msgid "port for connecting to proxy server" msgstr "port do połączeń z serwerem proxy" -msgid "username for proxy server" -msgstr "nazwa użytkownika dla serwera proxy" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "hasło do serwera proxy" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -10376,6 +10376,3 @@ msgstr "Typ" msgid "Constants" msgstr "Stałe" - -#~ msgid "password for server" -#~ msgstr "hasło dla serwera" diff --git a/po/pt_BR.po b/po/pt_BR.po index 62936386a..84489a1d3 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-16 11:21+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:46+0200\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" "Language: pt_BR\n" @@ -3609,10 +3609,10 @@ msgstr "" msgid "port for connecting to proxy server" msgstr "" -msgid "username for proxy server" +msgid "username for proxy server (note: content is evaluated, see /help eval)" msgstr "" -msgid "password for proxy server" +msgid "password for proxy server (note: content is evaluated, see /help eval)" msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" @@ -9455,6 +9455,3 @@ msgstr "" msgid "Constants" msgstr "" - -#~ msgid "password for server" -#~ msgstr "senha para o servidor" diff --git a/po/ru.po b/po/ru.po index c22f801e5..32497f743 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:21+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:35+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" "Language: ru\n" @@ -3175,11 +3175,11 @@ msgstr "адрес proxy-сервера (IP или хост)" msgid "port for connecting to proxy server" msgstr "порт, используемый при подключении к proxy-серверу" -msgid "username for proxy server" -msgstr "имя пользователя, используемое при подключения к proxy-серверу" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "пароль к proxy серверу" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -9275,7 +9275,3 @@ msgstr "" msgid "Constants" msgstr "" - -#, fuzzy -#~ msgid "password for server" -#~ msgstr "пароль, используемый при подключении к IRC серверу" diff --git a/po/tr.po b/po/tr.po index a088b6e21..db690cfc5 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,8 +20,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-rc1\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" -"PO-Revision-Date: 2013-09-02 21:21+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" +"PO-Revision-Date: 2013-09-19 14:35+0200\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" "Language: tr\n" @@ -2798,11 +2798,11 @@ msgstr "" msgid "port for connecting to proxy server" msgstr "" -msgid "username for proxy server" -msgstr "vekil sunucu için kullanıcı adı" +msgid "username for proxy server (note: content is evaluated, see /help eval)" +msgstr "" -msgid "password for proxy server" -msgstr "vekil sunucu için parola" +msgid "password for proxy server (note: content is evaluated, see /help eval)" +msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" msgstr "" @@ -8277,6 +8277,3 @@ msgstr "Tür" msgid "Constants" msgstr "" - -#~ msgid "password for server" -#~ msgstr "sunucu için parola" diff --git a/po/weechat.pot b/po/weechat.pot index 2d504eb14..c011c789d 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.1-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-09-19 13:56+0200\n" +"POT-Creation-Date: 2013-09-19 14:26+0200\n" "PO-Revision-Date: 2013-02-14 18:20+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: weechat-dev \n" @@ -2802,10 +2802,10 @@ msgstr "" msgid "port for connecting to proxy server" msgstr "" -msgid "username for proxy server" +msgid "username for proxy server (note: content is evaluated, see /help eval)" msgstr "" -msgid "password for proxy server" +msgid "password for proxy server (note: content is evaluated, see /help eval)" msgstr "" msgid "Please enter your passphrase to decrypt the data secured by WeeChat:" diff --git a/src/core/wee-network.c b/src/core/wee-network.c index aa5ea105e..79ee04f69 100644 --- a/src/core/wee-network.c +++ b/src/core/wee-network.c @@ -48,6 +48,7 @@ #include "weechat.h" #include "wee-network.h" +#include "wee-eval.h" #include "wee-hook.h" #include "wee-config.h" #include "wee-proxy.h" @@ -238,17 +239,27 @@ int network_pass_httpproxy (struct t_proxy *proxy, int sock, const char *address, int port) { - char buffer[256], authbuf[128], authbuf_base64[512]; + char buffer[256], authbuf[128], authbuf_base64[512], *username, *password; int length; if (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]) && CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])[0]) { /* authentication */ - snprintf (authbuf, sizeof (authbuf), "%s:%s", - CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]), - (CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD])) ? - CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]) : ""); + username = eval_expression (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]), + NULL, NULL, NULL); + if (!username) + return 0; + password = eval_expression (CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]), + NULL, NULL, NULL); + if (!password) + { + free (username); + return 0; + } + snprintf (authbuf, sizeof (authbuf), "%s:%s", username, password); + free (username); + free (password); string_encode_base64 (authbuf, strlen (authbuf), authbuf_base64); length = snprintf (buffer, sizeof (buffer), "CONNECT %s:%d HTTP/1.0\r\nProxy-Authorization: " @@ -340,16 +351,22 @@ network_pass_socks4proxy (struct t_proxy *proxy, int sock, const char *address, { struct t_network_socks4 socks4; unsigned char buffer[24]; - char ip_addr[NI_MAXHOST]; + char ip_addr[NI_MAXHOST], *username; int length; + username = eval_expression (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]), + NULL, NULL, NULL); + if (!username) + return 0; + socks4.version = 4; socks4.method = 1; socks4.port = htons (port); network_resolve (address, ip_addr, NULL); socks4.address = inet_addr (ip_addr); - strncpy (socks4.user, CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]), - sizeof (socks4.user) - 1); + strncpy (socks4.user, username, sizeof (socks4.user) - 1); + + free (username); length = 8 + strlen (socks4.user) + 1; if (network_send_with_retry (sock, (char *) &socks4, length, 0) != length) @@ -388,6 +405,7 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address, unsigned char buffer[288]; int username_len, password_len, addr_len, addr_buffer_len; unsigned char *addr_buffer; + char *username, *password; socks5.version = 5; socks5.nmethods = 1; @@ -419,16 +437,29 @@ network_pass_socks5proxy (struct t_proxy *proxy, int sock, const char *address, return 0; /* authentication as in RFC 1929 */ - username_len = strlen (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME])); - password_len = strlen (CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD])); + username = eval_expression (CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]), + NULL, NULL, NULL); + if (!username) + return 0; + password = eval_expression (CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]), + NULL, NULL, NULL); + if (!password) + { + free (username); + return 0; + } + username_len = strlen (username); + password_len = strlen (password); /* make username/password buffer */ buffer[0] = 1; buffer[1] = (unsigned char) username_len; - memcpy(buffer + 2, CONFIG_STRING(proxy->options[PROXY_OPTION_USERNAME]), username_len); + memcpy (buffer + 2, username, username_len); buffer[2 + username_len] = (unsigned char) password_len; - memcpy (buffer + 3 + username_len, - CONFIG_STRING(proxy->options[PROXY_OPTION_PASSWORD]), password_len); + memcpy (buffer + 3 + username_len, password, password_len); + + free (username); + free (password); if (network_send_with_retry (sock, buffer, 3 + username_len + password_len, 0) < 3 + username_len + password_len) return 0; diff --git a/src/core/wee-proxy.c b/src/core/wee-proxy.c index 1548bf4cf..f4af06dff 100644 --- a/src/core/wee-proxy.c +++ b/src/core/wee-proxy.c @@ -337,7 +337,8 @@ proxy_create_option (const char *proxy_name, int index_option, ptr_option = config_file_new_option ( weechat_config_file, weechat_config_section_proxy, option_name, "string", - N_("username for proxy server"), + N_("username for proxy server " + "(note: content is evaluated, see /help eval)"), NULL, 0, 0, value, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); break; @@ -345,7 +346,8 @@ proxy_create_option (const char *proxy_name, int index_option, ptr_option = config_file_new_option ( weechat_config_file, weechat_config_section_proxy, option_name, "string", - N_("password for proxy server"), + N_("password for proxy server " + "(note: content is evaluated, see /help eval)"), NULL, 0, 0, value, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); break;