query socks credentials by management interface
PATCH 1/1 query socks credentials by management interface
Support --management-query-passwords for SOCKS 5 proxies as well.
Signed-off-by Heiko Hund <[email protected]...>
--- src/openvpn/socks.c | 38 +++++++++++++++----------------------- src/openvpn/socks.h | 4 ++-- 2 files changed, 17 insertions(+), 25 deletions(-)
src/openvpn/socks.c +15 -23
@@ -72,14 +72,9 @@ socks_proxy_new (const char *server,ASSERT (server);ASSERT (legal_ipv4_port (port)); -strncpynt (p->server, server,sizeof (p->server)); + p->server = server; p->port = port; - -if (authfile) -strncpynt (p->authfile, authfile,sizeof (p->authfile)); -else - p->authfile[0 ] =0 ; - + p->authfile = authfile; p->retry = retry; p->defined = true;
@@ -107,13 +102,18 @@ socks_username_password_auth (struct socks_proxy_info *p, creds.defined =0 ;get_user_pass (&creds, p->authfile,UP_TYPE_SOCKS ,GET_USER_PASS_MANAGEMENT ); -if ( !creds.username || (strlen (creds.username) >255 ) - || !creds.password || (strlen (creds.password) >255 ) ) { -msg (M_NONFATAL , -"SOCKS username and/or password exceeds 255 characters. " -"Authentication not possible." ); -return false; - } +if (creds.username ==NULL || creds.password ==NULL ) + { +msg (D_LINK_ERRORS ,"socks_username_password_auth: " +"server asked for auth but no credentials were provided" ); +return false; + } +else if (strlen (creds.username) >255 ||strlen (creds.password) >255 ) + { +msg (M_NONFATAL ,"SOCKS username and/or password exceed 255 characters. " +"Authentication not possible." ); +return false; + }openvpn_snprintf (to_send,sizeof (to_send),"\x01%c%s%c%s" , (int )strlen (creds.username), creds.username, (int )strlen (creds.password), creds.password); size =send (sd, to_send,strlen (to_send),MSG_NOSIGNAL );
@@ -259,16 +259,8 @@ socks_handshake (struct socks_proxy_info *p,break ;case 2 :/* login/password */ -if (!p->authfile[0 ]) - { -msg (D_LINK_ERRORS ,"socks_handshake: server asked for username/login auth but we were " -"not provided any credentials" ); +if (!socks_username_password_auth (p, sd, signal_received))return false; - } - -if (!socks_username_password_auth (p, sd, signal_received)) -return false; -break ;default :/* unknown auth method */
src/openvpn/socks.h +2 -2
@@ -41,9 +41,9 @@ struct socks_proxy_info {bool defined;bool retry; -char server[128 ]; +const char *server;int port; -char authfile[256 ]; +const char *authfile; };void socks_adjust_frame_parameters (struct frame *frame,int proto);
Signature · 1 line
1.7.9.5