(fwd) Re: Openvpn-users RSA Key with password protection problem
On 03 Oct 2003 01:25:54 +0200, Stefano Bracalenti
<[email protected]...> wrote:
Quoted 10 lines · Arkadiusz Patyk
Thu Oct 02 22:00:10 2003 0: OpenVPN 1.5-beta9 Win32-MinGW [SSL] [LZO] [MTU-DYNAMIC] built on Oct 1 2003
Thu Oct 02 22:00:10 2003 1: Sorry but I can't read a password from the console because this operating system or C library doesn't support thegetpass()function
Thu Oct 02 22:00:10 2003 2: Exiting;-(
How can I protect using password ?
You need the getpass() function. I use one from a libc windows porting.
You can add something like this to win32.c:
---
char *
getpass (const char * prompt)
{
static char input[256];
HANDLE in;
HANDLE err;
DWORD count;
in = GetStdHandle (STD_INPUT_HANDLE);
err = GetStdHandle (STD_ERROR_HANDLE);
if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
return NULL;
if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
{
int istty = (GetFileType (in) == FILE_TYPE_CHAR);
DWORD old_flags;
int rc;
if (istty)
{
if (GetConsoleMode (in, &old_flags))
SetConsoleMode (in, ENABLE_LINE_INPUT
|
ENABLE_PROCESSED_INPUT);
else
istty = 0;
}
rc = ReadFile (in, input, sizeof (input), &count,
NULL);
if (count >= 2 && input[count - 2] == '\r')
input[count - 2] = '\0';
else
{
char buf[256];
while (ReadFile (in, buf, sizeof (buf),
&count,
NULL) > 0)
if (count >= 2 && buf[count - 2] ==
'\r')
break;
}
WriteFile (err, "\r\n", 2, &count, NULL);
if (istty)
SetConsoleMode (in, old_flags);
if (rc)
return input;
}
return NULL;
}---
Also remember to uncomment or insert if missing "#define HAVE_GETPASS 1"
in config-win32.h. Recompile and enjoy ;)
==============--
Is it possible to include this feature in next version?
Signature · 2 lines
Arkadiusz Patyk [areq(at)pld-linux.org] [http://rescuecd.pld-linux.org/] [IRC:areq ICQ:16231667 GG:1383] [AP3-6BONE] [AP14126-RIPE]
Quoted 76 lines · Arkadiusz Patyk
On 03 Oct 2003 01:25:54 +0200, Stefano Bracalenti
<[email protected]...> wrote:Quoted 10 lines · Arkadiusz Patyk
Thu Oct 02 22:00:10 2003 0: OpenVPN 1.5-beta9 Win32-MinGW [SSL] [LZO] [MTU-DYNAMIC] built on Oct 1 2003
Thu Oct 02 22:00:10 2003 1: Sorry but I can't read a password from the console because this operating system or C library doesn't support thegetpass()function
Thu Oct 02 22:00:10 2003 2: Exiting;-(
How can I protect using password ?
You need the
getpass()function. I use one from a libc windows porting.
You can add something like this towin32.c:---
char *
getpass (const char * prompt){ static char input[256]; HANDLE in; HANDLE err; DWORD count; in = GetStdHandle (STD_INPUT_HANDLE); err = GetStdHandle (STD_ERROR_HANDLE); if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE) return NULL; if (WriteFile (err, prompt, strlen (prompt), &count, NULL)) { int istty = (GetFileType (in) == FILE_TYPE_CHAR); DWORD old_flags; int rc; if (istty) { if (GetConsoleMode (in, &old_flags)) SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT); else istty = 0; } rc = ReadFile (in, input, sizeof (input), &count, NULL); if (count >= 2 && input[count - 2] == '\r') input[count - 2] = '\0'; else { char buf[256]; while (ReadFile (in, buf, sizeof (buf), &count, NULL) > 0) if (count >= 2 && buf[count - 2] == '\r') break; } WriteFile (err, "\r\n", 2, &count, NULL); if (istty) SetConsoleMode (in, old_flags); if (rc) return input; } return NULL; }---
Quoted 7 lines
Also remember to uncomment or insert if missing "#define
HAVE_GETPASS1"
inconfig-win32.h. Recompile and enjoy ;)==============--
Is it possible to include this feature in next version?
Yes, I will merge it for upcoming 1.5-beta10
James