Patch for Password authentication
Hello!
Attached are 2 usability patches for password authentication on Windows, one for OpenVPN 2.0.0 and OpenVPN-GUI 1.0.
The patches provide the following functionality:
You can provide predefined usernames for password authentication, backward compatibility is guaranteed.
It looks like the following:
Client Config looks like:
=========================
# Ask for username and password
auth-user-pass user.up
# Optionally the win32-gui switch can be set (see for combinations below) win32-gui
user.up contains:
=================
username
password or stdin or gui (stdin and gui are reserverd keywords)
When password is set, the password is taken.
When stdin or gui is set as the password the user is asked to provide the password only (The username is not queried or is already predefined in the GUI dialog and the focus is set to the password text field).
# Usefull combinations are:
# disabled win32-gui with auth-user-pass username/gui (Best) ============================================================ OpenVPN Userauthentication Dialog (only one dialog appears) with the following information:
Username: gerhard (predefined as from user.up!!!)
Password: Enter the password here
When a private key password is set, it is also queried.
Username is taken from user.up
# win32-gui with auth-user-pass username/stdin (Best) ====================================================== The following dialog pops up: Enter Auth Password for user gerhard: Enter the username here
When a private key password is set, it is also queried.
Username is taken from user.up
# win32-gui with auth-user-pass username/gui ============================================ Enter Auth Username [gerhard]: Enter the username here Enter Auth Password: Enter the password here
When a private key password is set, it is also queried.
# Useless combinations are:
# disabled win32-gui with auth-user-pass username/stdin ======================================================= OpenVPN is blocked, since the GUI waits for input from stdin, but nothing usefull is sent.
Server side looks like:
=======================
plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so login
It has been tested with MinGW compiler, Windows 2000 and Linux as a server unpatched (2.0.0).
Please let me know whether you integrate the patches in the upcoming OpenVPN 2.0.1 release.
Comments are welcome.
Ciao,
Gerhard
openvpn-2.0\chartable.h renamed from orig\openvpn-2.0\chartable.h +286 -0
@@ -0,0 +1,286 @@ +/* +* OpenVPN -- An application to securely tunnel IP networks +* over a single UDP port, with support for SSL/TLS-based +* session authentication and key exchange, +* packet encryption, packet authentication, and +* packet compression. +* +* Copyright (C) 2002-2005 OpenVPN Solutions LLC <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program (see the file COPYING included with this +* distribution); if not, write to the Free Software Foundation, Inc., +* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifdef WIN32 + +WCHAR unicode_to_ascii[256 ] = { +0x0000 , +0x0001 , +0x0002 , +0x0003 , +0x0004 , +0x0005 , +0x0006 , +0x0007 , +0x0008 , +0x0009 , +0x000a , +0x000b , +0x000c , +0x000d , +0x000e , +0x000f , +0x0010 , +0x0011 , +0x0012 , +0x0013 , +0x0014 , +0x0015 , +0x0016 , +0x0017 , +0x0018 , +0x0019 , +0x001a , +0x001b , +0x001c , +0x001d , +0x001e , +0x001f , +0x0020 , +0x0021 , +0x0022 , +0x0023 , +0x0024 , +0x0025 , +0x0026 , +0x0027 , +0x0028 , +0x0029 , +0x002a , +0x002b , +0x002c , +0x002d , +0x002e , +0x002f , +0x0030 , +0x0031 , +0x0032 , +0x0033 , +0x0034 , +0x0035 , +0x0036 , +0x0037 , +0x0038 , +0x0039 , +0x003a , +0x003b , +0x003c , +0x003d , +0x003e , +0x003f , +0x0040 , +0x0041 , +0x0042 , +0x0043 , +0x0044 , +0x0045 , +0x0046 , +0x0047 , +0x0048 , +0x0049 , +0x004a , +0x004b , +0x004c , +0x004d , +0x004e , +0x004f , +0x0050 , +0x0051 , +0x0052 , +0x0053 , +0x0054 , +0x0055 , +0x0056 , +0x0057 , +0x0058 , +0x0059 , +0x005a , +0x005b , +0x005c , +0x005d , +0x005e , +0x005f , +0x0060 , +0x0061 , +0x0062 , +0x0063 , +0x0064 , +0x0065 , +0x0066 , +0x0067 , +0x0068 , +0x0069 , +0x006a , +0x006b , +0x006c , +0x006d , +0x006e , +0x006f , +0x0070 , +0x0071 , +0x0072 , +0x0073 , +0x0074 , +0x0075 , +0x0076 , +0x0077 , +0x0078 , +0x0079 , +0x007a , +0x007b , +0x007c , +0x007d , +0x007e , +0x007f , +0x00c7 , +0x00fc , +0x00e9 , +0x00e2 , +0x00e4 , +0x00e0 , +0x00e5 , +0x00e7 , +0x00ea , +0x00eb , +0x00e8 , +0x00ef , +0x00ee , +0x00ec , +0x00c4 , +0x00c5 , +0x00c9 , +0x00e6 , +0x00c6 , +0x00f4 , +0x00f6 , +0x00f2 , +0x00fb , +0x00f9 , +0x00ff , +0x00d6 , +0x00dc , +0x00f8 , +0x00a3 , +0x00d8 , +0x00d7 , +0x0192 , +0x00e1 , +0x00ed , +0x00f3 , +0x00fa , +0x00f1 , +0x00d1 , +0x00aa , +0x00ba , +0x00bf , +0x00ae , +0x00ac , +0x00bd , +0x00bc , +0x00a1 , +0x00ab , +0x00bb , +0x2591 , +0x2592 , +0x2593 , +0x2502 , +0x2524 , +0x00c1 , +0x00c2 , +0x00c0 , +0x00a9 , +0x2563 , +0x2551 , +0x2557 , +0x255d , +0x00a2 , +0x00a5 , +0x2510 , +0x2514 , +0x2534 , +0x252c , +0x251c , +0x2500 , +0x253c , +0x00e3 , +0x00c3 , +0x255a , +0x2554 , +0x2569 , +0x2566 , +0x2560 , +0x2550 , +0x256c , +0x00a4 , +0x00f0 , +0x00d0 , +0x00ca , +0x00cb , +0x00c8 , +0x0131 , +0x00cd , +0x00ce , +0x00cf , +0x2518 , +0x250c , +0x2588 , +0x2584 , +0x00a6 , +0x00cc , +0x2580 , +0x00d3 , +0x00df , +0x00d4 , +0x00d2 , +0x00f5 , +0x00d5 , +0x00b5 , +0x00fe , +0x00de , +0x00da , +0x00db , +0x00d9 , +0x00fd , +0x00dd , +0x00af , +0x00b4 , +0x00ad , +0x00b1 , +0x2017 , +0x00be , +0x00b6 , +0x00a7 , +0x00f7 , +0x00b8 , +0x00b0 , +0x00a8 , +0x00b7 , +0x00b9 , +0x00b3 , +0x00b2 , +0x25a0 , +0x00a0 +}; + +#endif
openvpn-2.0\config-win32.h renamed from orig\openvpn-2.0\config-win32.h +2 -1
@@ -64,6 +64,7 @@/* Allow --askpass and --auth-user-pass passwords to be read from a file */ /* #undef ENABLE_PASSWORD_SAVE */ +#define ENABLE_PASSWORD_SAVE 1/* Enable client/server capability */ #define ENABLE_CLIENT_SERVER 1
@@ -221,7 +222,7 @@#define PACKAGE_TARNAME "openvpn"/* Define to the version of this package. */ -#define PACKAGE_VERSION "2.0"/* AUTO_VERSION */ +#define PACKAGE_VERSION "2.0-GUI"/* AUTO_VERSION */ /* Define to the full name and version of this package. */ #ifdef DEBUG_LABEL
openvpn-2.0\makefile-GUI.w32 renamed from orig\openvpn-2.0\makefile-GUI.w32 +212 -0
212 lines not on this page · raw message
openvpn-2.0\misc.c renamed from orig\openvpn-2.0\misc.c +29 -1
@@ -1245,8 +1245,36 @@if (!password_only &&strlen (up->username) ==0 )msg (M_FATAL ,"ERROR: username from %s authfile '%s' is empty" , prefix, auth_file); - } +if (streq (up->password,"stdin" )) + { +struct buffer user_pass_prompt =alloc_buf_gc (256 , &gc); + +buf_printf (&user_pass_prompt,"Enter %s Password for user %s:" + , prefix, up->username); + +if (!get_console_input (BSTR (&user_pass_prompt), false, up->password,USER_PASS_LEN )) +msg (M_FATAL ,"ERROR: could not not read %s password from stdin" , prefix); + } +else if (streq (up->password,"gui" )) + { +struct buffer user_prompt =alloc_buf_gc (128 , &gc); +struct buffer pass_prompt =alloc_buf_gc (128 , &gc); + +buf_printf (&user_prompt,"Enter %s Username [%s]:" , prefix, up->username); +buf_printf (&pass_prompt,"Enter %s Password:" , prefix); + +if (!get_console_input (BSTR (&user_prompt), true, up->username,USER_PASS_LEN )) +msg (M_FATAL ,"ERROR: could not read %s username from stdin" , prefix); + +if (strlen (up->username) ==0 ) +msg (M_FATAL ,"ERROR: %s username is empty" , prefix); + +if (!get_console_input (BSTR (&pass_prompt), false, up->password,USER_PASS_LEN )) +msg (M_FATAL ,"ERROR: could not not read %s password from stdin" , prefix); + + } + }string_mod (up->username,CC_PRINT ,CC_CRLF ,0 );string_mod (up->password,CC_PRINT ,CC_CRLF ,0 );
openvpn-2.0\options.c renamed from orig\openvpn-2.0\options.c +7 -0
@@ -29,6 +29,7 @@#ifdef WIN32 #include "config-win32.h" +#include "win32gui.h" #else #include "config.h" #endif
@@ -484,6 +485,7 @@" signaled, will cause " PACKAGE_NAME " to exit. A second\n" " optional parameter controls the initial state of ex.\n" "--show-net-up : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n" +"--win32-gui : Get user input via a GUI dialog instead of console window.\n" " after TAP adapter is up and routes have been added.\n" "Windows Standalone Options:\n" "\n"
@@ -4030,6 +4032,11 @@ ++i; options->exit_event_initial_state = (atoi (p[2 ]) !=0 ); } + } +else if (streq (p[0 ],"win32-gui" )) + { +VERIFY_PERMISSION (OPT_P_GENERAL ); +enable_userinput_via_dialog_win32 (); }else if (streq (p[0 ],"user" ) && p[1 ]) {
openvpn-2.0\win32.c renamed from orig\openvpn-2.0\win32.c +5 -1
@@ -37,6 +37,7 @@#include "mtu.h" #include "sig.h" #include "win32.h" +#include "win32gui.h" #include "memdbg.h"
@@ -683,7 +684,7 @@ }/* -* Get input from console. +* Get input from console or a dialog(--win32-gui). * * Return false on input error, or if service * exit event is signaled.
@@ -704,6 +705,9 @@ in =GetStdHandle (STD_INPUT_HANDLE ); err =get_orig_stderr (); + +if (use_userinput_dialog_win32 ()) +return get_userinput_dialog_win32 (prompt, input, capacity);if (in !=INVALID_HANDLE_VALUE && err != INVALID_HANDLE_VALUE
openvpn-2.0\win32gui-res.h renamed from orig\openvpn-2.0\win32gui-res.h +29 -0
@@ -0,0 +1,29 @@ +/* +* OpenVPN -- An application to securely tunnel IP networks +* over a single TCP/UDP port, with support for SSL/TLS-based +* session authentication and key exchange, +* packet encryption, packet authentication, and +* packet compression. +* +* Copyright (C) 2002-2005 OpenVPN Solutions LLC <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program (see the file COPYING included with this +* distribution); if not, write to the Free Software Foundation, Inc., +* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* Ask for User Input Dialog */ +#define IDD_USERINPUT 100 +#define EDIT_TEXTBOX 101 +#define TEXT_LABEL 102
openvpn-2.0\win32gui.c renamed from orig\openvpn-2.0\win32gui.c +153 -0
153 lines not on this page · raw message
openvpn-2.0\win32gui.h renamed from orig\openvpn-2.0\win32gui.h +32 -0
@@ -0,0 +1,32 @@ +/* +* OpenVPN -- An application to securely tunnel IP networks +* over a single UDP port, with support for SSL/TLS-based +* session authentication and key exchange, +* packet encryption, packet authentication, and +* packet compression. +* +* Copyright (C) 2002-2005 OpenVPN Solutions LLC <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program (see the file COPYING included with this +* distribution); if not, write to the Free Software Foundation, Inc., +* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef WIN32 + +int get_userinput_dialog_win32 (const char *prompt,char *input,const int capacity); +int use_userinput_dialog_win32 (); +void enable_userinput_via_dialog_win32 (); + +#endif
openvpn-2.0\win32gui.rc renamed from orig\openvpn-2.0\win32gui.rc +39 -0
@@ -0,0 +1,39 @@ +/* + * OpenVPN -- An application to securely tunnel IP networks + * over a single TCP/UDP port, with support for SSL/TLS-based + * session authentication and key exchange, + * packet encryption, packet authentication, and + * packet compression. + * + * Copyright (C) 2002-2005 OpenVPN Solutions LLC <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (see the file COPYING included with this + * distribution); if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "win32gui-res.h" +#include <windows.h> + +IDD_USERINPUT DIALOGEX 6, 18, 160, 51 +STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | DS_CENTER | DS_SETFOREGROUND +EXSTYLE WS_EX_TOPMOST +CAPTION "OpenVPN" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "", TEXT_LABEL, 6, 6, 147, 10 + EDITTEXT EDIT_TEXTBOX, 6, 17, 147, 12, ES_PASSWORD | ES_AUTOHSCROLL + PUSHBUTTON "OK", IDOK, 26, 33, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 84, 33, 50, 14 +END
openvpn-gui-1.0\Makefile renamed from orig\openvpn-gui-1.0\Makefile +2 -2
@@ -1,6 +1,6 @@ # This makefile builds OpenVPN-GUI using the mingw environment. -OPENSSL = /c/OpenSSL +OPENSSL = /c/work/C/OpenVPN/openssl-0.9.7g RES_LANG = en GUI_VERSION = 1.0
@@ -16,7 +16,7 @@ openvpn_config.o scripts.o openvpn-gui-$(RES_LANG).res INCLUDE_DIRS = -I. -I${OPENSSL}/include -LIB_DIRS = -L${OPENSSL}/lib/MinGW +LIB_DIRS = -L${OPENSSL} WARNS = -W -Wall -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast \ -Wcast-align -Wwrite-strings -Wconversion -Wsign-compare \
openvpn-gui-1.0\passphrase.c renamed from orig\openvpn-gui-1.0\passphrase.c +30 -1
@@ -151,10 +151,31 @@DWORD nCharsWritten;struct user_auth user_auth; +unsigned int auth_len =21 ; + +int old_auth = (strncmp (line,"Enter Auth Username:" ,20 ) ==0 ); +int new_auth = (strncmp (line,"Enter Auth Username [" , auth_len) ==0 ); +/* Check for Passphrase prompt */ -if (strncmp (line,"Enter Auth Username:" ,20 ) ==0 ) +if (old_auth || new_auth) {CLEAR (user_auth); + +if (new_auth) + { +char * usernamebegin = line + auth_len; +char * usernameend =strchr (line,']' ); + +if (usernameend) + { +unsigned int len = usernameend - usernamebegin; + +if (len >sizeof (user_auth.username)) len =sizeof (user_auth.username); + +strncpy (user_auth.username, usernamebegin, len); + } + } + if (DialogBoxParam(o.hInstance, (LPCTSTR)IDD_AUTH_PASSWORD, NULL,
@@ -266,6 +287,14 @@case WM_INITDIALOG : user_auth = (struct user_auth *) lParam; + +SetDlgItemText (hwndDlg,EDIT_AUTH_USERNAME , user_auth->username); + +if (strlen (user_auth->username) >0 ) + { +SetFocus (GetDlgItem (hwndDlg,EDIT_AUTH_PASSWORD )); + } +SetForegroundWindow (hwndDlg);break ;
Quoted 68 lines · Gerhard Wiesinger
Hello!
Attached are 2 usability patches for password authentication on Windows, one for OpenVPN 2.0.0 and OpenVPN-GUI 1.0.
The patches provide the following functionality:
You can provide predefined usernames for password authentication, backward compatibility is guaranteed.It looks like the following:
Client Config looks like:
=========================
# Ask for username and password
auth-user-pass user.up# Optionally the win32-gui switch can be set (see for combinations below) win32-gui
user.up contains:
=================
username
password or stdin or gui (stdin and gui are reserverd keywords)When password is set, the password is taken.
When stdin or gui is set as the password the user is asked to provide the password only (The username is not queried or is already predefined in the GUI dialog and the focus is set to the password text field).# Usefull combinations are:
# disabled win32-gui with auth-user-pass username/gui (Best) ============================================================ OpenVPN Userauthentication Dialog (only one dialog appears) with the following information:Username: gerhard (predefined as from user.up!!!)
Password: Enter the password hereWhen a private key password is set, it is also queried.
Username is taken from user.up
# win32-gui with auth-user-pass username/stdin (Best) ====================================================== The following dialog pops up: Enter Auth Password for user gerhard: Enter the username hereWhen a private key password is set, it is also queried.
Username is taken from user.up
# win32-gui with auth-user-pass username/gui ============================================ Enter Auth Username [gerhard]: Enter the username here Enter Auth Password: Enter the password hereWhen a private key password is set, it is also queried.
# Useless combinations are:
# disabled win32-gui with auth-user-pass username/stdin ======================================================= OpenVPN is blocked, since the GUI waits for input from stdin, but nothing usefull is sent.Server side looks like:
=======================
plugin/usr/share/openvpn/plugin/lib/openvpn-auth-pam.sologin
Quoted 5 lines
It has been tested with MinGW compiler, Windows 2000 and Linux as a server unpatched (2.0.0).
Please let me know whether you integrate the patches in the upcoming OpenVPN 2.0.1 release.
Why would you want to add platform-specific GUI code to the OpenVPN core (as the non-GUI patch does), rather than coding the GUI functionality as a separate applet and communicating with the OpenVPN core via the management interface? It's a bit more work this way, but it has the advantage of decoupling the OpenVPN core from the platform-specific GUI elements.
James
Quoted 76 lines · James Yonan
Quoted 68 lines · Gerhard Wiesinger
Hello!
Attached are 2 usability patches for password authentication on Windows, one for OpenVPN 2.0.0 and OpenVPN-GUI 1.0.
The patches provide the following functionality:
You can provide predefined usernames for password authentication, backward compatibility is guaranteed.It looks like the following:
Client Config looks like:
=========================
# Ask for username and password
auth-user-pass user.up# Optionally the win32-gui switch can be set (see for combinations below) win32-gui
user.up contains:
=================
username
password or stdin or gui (stdin and gui are reserverd keywords)When password is set, the password is taken.
When stdin or gui is set as the password the user is asked to provide the password only (The username is not queried or is already predefined in the GUI dialog and the focus is set to the password text field).# Usefull combinations are:
# disabled win32-gui with auth-user-pass username/gui (Best) ============================================================ OpenVPN Userauthentication Dialog (only one dialog appears) with the following information:Username: gerhard (predefined as from user.up!!!)
Password: Enter the password hereWhen a private key password is set, it is also queried.
Username is taken from user.up
# win32-gui with auth-user-pass username/stdin (Best) ====================================================== The following dialog pops up: Enter Auth Password for user gerhard: Enter the username hereWhen a private key password is set, it is also queried.
Username is taken from user.up
# win32-gui with auth-user-pass username/gui ============================================ Enter Auth Username [gerhard]: Enter the username here Enter Auth Password: Enter the password hereWhen a private key password is set, it is also queried.
# Useless combinations are:
# disabled win32-gui with auth-user-pass username/stdin ======================================================= OpenVPN is blocked, since the GUI waits for input from stdin, but nothing usefull is sent.Server side looks like:
=======================
plugin/usr/share/openvpn/plugin/lib/openvpn-auth-pam.sologinQuoted 5 lines
It has been tested with MinGW compiler, Windows 2000 and Linux as a server unpatched (2.0.0).
Please let me know whether you integrate the patches in the upcoming OpenVPN 2.0.1 release.
Quoted 7 lines
Why would you want to add platform-specific GUI code to the OpenVPN core (as the non-GUI patch does), rather than coding the GUI functionality as a separate applet and communicating with the OpenVPN core via the management interface? It's a bit more work this way, but it has the advantage of decoupling the OpenVPN core from the platform-specific GUI elements.
I only "enhanced" the already existing patch for openvpn.
See
http://openvpn.se/development.html
http://openvpn.se/files/patches/openvpn-2.0_rc16-gui.patch
for details.
Of course a management interface is a better design, but my patch (not the original one) also works with stdin redirection without the win32-gui option, so there is no platform specific code in there any more and could be removed. A GUI interface with platform specific DLLs, shared objects or something might be a better solution (e.g. plugin concept).
But from a practical point of view I don't see any problems with GUI code in it, do you?
Ciao,
Gerhard