* [Openvpn-devel] MSVC fixes
@ 2012-02-16 17:30 Heiko Hund
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32 Heiko Hund
` (4 more replies)
0 siblings, 5 replies; 37+ messages in thread
From: Heiko Hund @ 2012-02-16 17:30 UTC (permalink / raw)
To: openvpn-devel
Hi,
this patch series fixes several issues when building for Windows
with the MSVC buildsystem discovered today:
[PATCH 1/4] replace check for TARGET_WIN32 with WIN32
[PATCH 2/4] do not use mode_t on Windows
[PATCH 3/4] use the underscore version of stat on Windows
[PATCH 4/4] make MSVC link against shell32 as well
For details check the commit messages of the individual patches.
Regards
Heiko
--
Heiko Hund | Software Engineer | Phone +49-721-25516-237 | Fax -200
Astaro a Sophos Company | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRA 702710 | Headquarter Location: Karlsruhe
Represented by the General Partner Astaro Verwaltungs GmbH
Amalienbadstraße 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRB 708248 | Executive Board: Gert Hansen,
Markus Hennig, Jan Hichert, Günter Junk, Dr. Frank Nellissen
^ permalink raw reply [flat|nested] 37+ messages in thread
* [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32
2012-02-16 17:30 [Openvpn-devel] MSVC fixes Heiko Hund
@ 2012-02-16 17:30 ` Heiko Hund
2012-02-16 18:23 ` Gert Doering
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows Heiko Hund
` (3 subsequent siblings)
4 siblings, 1 reply; 37+ messages in thread
From: Heiko Hund @ 2012-02-16 17:30 UTC (permalink / raw)
To: openvpn-devel
Use of TARGET_WIN32 breaks MSVC builds as it is only defined
for mingw builds done with the autotools buildsystem.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
---
misc.c | 6 +++---
misc.h | 6 +++---
openvpn.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/misc.c b/misc.c
index 58096fa..a07780f 100644
--- a/misc.c
+++ b/misc.c
@@ -356,7 +356,7 @@ int
openvpn_chdir (const char* dir)
{
#ifdef HAVE_CHDIR
-#ifdef TARGET_WIN32
+#ifdef WIN32
int res;
struct gc_arena gc = gc_new ();
res = _wchdir (wide_string (dir, &gc));
@@ -598,7 +598,7 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
/*
* execute the command
*/
-#ifdef TARGET_WIN32
+#ifdef WIN32
gc = gc_new ();
ret = _wsystem (wide_string (command, &gc));
gc_free (&gc);
@@ -627,7 +627,7 @@ openvpn_system (const char *command, const struct env_set *es, unsigned int flag
int
openvpn_access (const char *path, int mode)
{
-#ifdef TARGET_WIN32
+#ifdef WIN32
struct gc_arena gc = gc_new ();
int ret = _waccess (wide_string (path, &gc), mode);
gc_free (&gc);
diff --git a/misc.h b/misc.h
index 2413f53..8c0bae1 100644
--- a/misc.h
+++ b/misc.h
@@ -147,7 +147,7 @@ openvpn_run_script (const struct argv *a, const struct env_set *es, const unsign
return openvpn_execve_check(a, es, flags | S_SCRIPT, msg);
};
-#ifdef TARGET_WIN32
+#ifdef WIN32
FILE * openvpn_fopen (const char *path, const char *mode);
#else
static inline FILE *
@@ -157,7 +157,7 @@ openvpn_fopen (const char *path, const char *mode)
}
#endif
-#ifdef TARGET_WIN32
+#ifdef WIN32
int openvpn_open (const char *path, int flags, mode_t mode);
#else
static inline int
@@ -167,7 +167,7 @@ openvpn_open (const char *path, int flags, mode_t mode)
}
#endif
-#ifdef TARGET_WIN32
+#ifdef WIN32
int openvpn_stat (const char *path, struct stat *buf);
#else
static inline int
diff --git a/openvpn.c b/openvpn.c
index 84289d2..b2175a1 100644
--- a/openvpn.c
+++ b/openvpn.c
@@ -131,7 +131,7 @@ main (int argc, char *argv[])
return 1;
#endif
-#ifdef TARGET_WIN32
+#ifdef WIN32
SetConsoleOutputCP (CP_UTF8);
#endif
--
1.7.5.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows
2012-02-16 17:30 [Openvpn-devel] MSVC fixes Heiko Hund
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32 Heiko Hund
@ 2012-02-16 17:30 ` Heiko Hund
2012-02-16 18:26 ` Gert Doering
2012-02-16 18:34 ` Alon Bar-Lev
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 3/4] use the underscore version of stat " Heiko Hund
` (2 subsequent siblings)
4 siblings, 2 replies; 37+ messages in thread
From: Heiko Hund @ 2012-02-16 17:30 UTC (permalink / raw)
To: openvpn-devel
The MSVC headers do not define mode_t. open() uses an int for
the permissions instead. Fixes building with the MSVC based
buildsystem.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
---
misc.h | 2 +-
win32.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc.h b/misc.h
index 8c0bae1..e7a0b55 100644
--- a/misc.h
+++ b/misc.h
@@ -158,7 +158,7 @@ openvpn_fopen (const char *path, const char *mode)
#endif
#ifdef WIN32
-int openvpn_open (const char *path, int flags, mode_t mode);
+int openvpn_open (const char *path, int flags, int mode);
#else
static inline int
openvpn_open (const char *path, int flags, mode_t mode)
diff --git a/win32.c b/win32.c
index 5b38918..a8f4ed9 100644
--- a/win32.c
+++ b/win32.c
@@ -1064,7 +1064,7 @@ openvpn_fopen (const char *path, const char *mode)
}
int
-openvpn_open (const char *path, int flags, mode_t mode)
+openvpn_open (const char *path, int flags, int mode)
{
struct gc_arena gc = gc_new ();
int fd = _wopen (wide_string (path, &gc), flags, mode);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Openvpn-devel] [PATCH 3/4] use the underscore version of stat on Windows
2012-02-16 17:30 [Openvpn-devel] MSVC fixes Heiko Hund
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32 Heiko Hund
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows Heiko Hund
@ 2012-02-16 17:30 ` Heiko Hund
2012-02-16 18:29 ` Gert Doering
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well Heiko Hund
2012-02-17 10:14 ` [Openvpn-devel] MSVC fixes David Sommerseth
4 siblings, 1 reply; 37+ messages in thread
From: Heiko Hund @ 2012-02-16 17:30 UTC (permalink / raw)
To: openvpn-devel
MSVC does not know wstat(). Instead _wstat() must be used here.
Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
introduced to handle this situation in a portable way.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
---
misc.h | 6 ++++--
pf.c | 2 +-
win32.c | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/misc.h b/misc.h
index e7a0b55..55d494f 100644
--- a/misc.h
+++ b/misc.h
@@ -168,10 +168,12 @@ openvpn_open (const char *path, int flags, mode_t mode)
#endif
#ifdef WIN32
-int openvpn_stat (const char *path, struct stat *buf);
+typedef struct _stat stat_t;
+int openvpn_stat (const char *path, stat_t *buf);
#else
+typedef struct stat stat_t;
static inline int
-openvpn_stat (const char *path, struct stat *buf)
+openvpn_stat (const char *path, stat_t *buf)
{
return stat (path, buf);
}
diff --git a/pf.c b/pf.c
index a0e9fc8..67cd28f 100644
--- a/pf.c
+++ b/pf.c
@@ -498,7 +498,7 @@ pf_check_reload (struct context *c)
&& c->c2.pf.filename
&& event_timeout_trigger (&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT))
{
- struct stat s;
+ stat_t s;
if (!openvpn_stat (c->c2.pf.filename, &s))
{
if (s.st_mtime > c->c2.pf.file_last_mod)
diff --git a/win32.c b/win32.c
index a8f4ed9..4efc8df 100644
--- a/win32.c
+++ b/win32.c
@@ -1073,10 +1073,10 @@ openvpn_open (const char *path, int flags, int mode)
}
int
-openvpn_stat (const char *path, struct stat *buf)
+openvpn_stat (const char *path, stat_t *buf)
{
struct gc_arena gc = gc_new ();
- int res = wstat (wide_string (path, &gc), buf);
+ int res = _wstat (wide_string (path, &gc), buf);
gc_free (&gc);
return res;
}
--
1.7.5.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well
2012-02-16 17:30 [Openvpn-devel] MSVC fixes Heiko Hund
` (2 preceding siblings ...)
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 3/4] use the underscore version of stat " Heiko Hund
@ 2012-02-16 17:30 ` Heiko Hund
2012-02-16 17:47 ` Gert Doering
2012-02-16 18:37 ` Alon Bar-Lev
2012-02-17 10:14 ` [Openvpn-devel] MSVC fixes David Sommerseth
4 siblings, 2 replies; 37+ messages in thread
From: Heiko Hund @ 2012-02-16 17:30 UTC (permalink / raw)
To: openvpn-devel
Windows API CommandLineToArgvW(), introduced in Windows unicode path
commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
---
win/msvc.mak.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/win/msvc.mak.in b/win/msvc.mak.in
index 115e395..191f370 100644
--- a/win/msvc.mak.in
+++ b/win/msvc.mak.in
@@ -31,7 +31,7 @@ LZO_DYNAMIC = lzo2.lib
INCLUDE_DIRS = -I$(OPENSSL)/include -I$(POLARSSL)/include -I$(LZO)/include -I$(PKCS11_HELPER)/include
-LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib
+LIBS = $(OPENSSL_DYNAMIC) $(POLARSSL_DYNAMIC) $(PKCS11_HELPER_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib shell32.lib
LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(POLARSSL)\build\library -LIBPATH:$(PKCS11_HELPER)\lib -LIBPATH:$(LZO)\lib
--
1.7.5.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well Heiko Hund
@ 2012-02-16 17:47 ` Gert Doering
2012-02-16 18:37 ` Alon Bar-Lev
1 sibling, 0 replies; 37+ messages in thread
From: Gert Doering @ 2012-02-16 17:47 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 610 bytes --]
Hi,
On Thu, Feb 16, 2012 at 06:30:41PM +0100, Heiko Hund wrote:
> Windows API CommandLineToArgvW(), introduced in Windows unicode path
> commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.
>
> Signed-off-by: Heiko Hund <heiko.hund@...1489...>
Since you've tested it and it makes Samuli happy -> ACK :-)
gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany gert@...1296...
fax: +49-89-35655025 gert@...1297...
[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32 Heiko Hund
@ 2012-02-16 18:23 ` Gert Doering
0 siblings, 0 replies; 37+ messages in thread
From: Gert Doering @ 2012-02-16 18:23 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 851 bytes --]
Hi,
On Thu, Feb 16, 2012 at 06:30:38PM +0100, Heiko Hund wrote:
> Use of TARGET_WIN32 breaks MSVC builds as it is only defined
> for mingw builds done with the autotools buildsystem.
ACK. I think it's reasonable to have exactly one CPP symbol to
identify "building in the windows 32bit environment".
I have no particular preference, and there are less TARGET_WIN32s in
the code - so get rid of that one :-)
(Yes, we should get rid of all the windows build cruft, but the focus
for now is "have something that *builds* and can be tagged as 2.3-alpha1").
gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany gert@...1296...
fax: +49-89-35655025 gert@...1297...
[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows Heiko Hund
@ 2012-02-16 18:26 ` Gert Doering
2012-02-16 18:34 ` Alon Bar-Lev
1 sibling, 0 replies; 37+ messages in thread
From: Gert Doering @ 2012-02-16 18:26 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
Hi,
On Thu, Feb 16, 2012 at 06:30:39PM +0100, Heiko Hund wrote:
> The MSVC headers do not define mode_t. open() uses an int for
> the permissions instead. Fixes building with the MSVC based
> buildsystem.
ACK.
(I was slightly worried that this might break mingw building, but
David assures me that you've tested this :-) ).
gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany gert@...1296...
fax: +49-89-35655025 gert@...1297...
[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 3/4] use the underscore version of stat on Windows
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 3/4] use the underscore version of stat " Heiko Hund
@ 2012-02-16 18:29 ` Gert Doering
2012-02-16 18:47 ` [Openvpn-devel] [PATCH v2] " David Sommerseth
0 siblings, 1 reply; 37+ messages in thread
From: Gert Doering @ 2012-02-16 18:29 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 857 bytes --]
Hi,
On Thu, Feb 16, 2012 at 06:30:40PM +0100, Heiko Hund wrote:
> MSVC does not know wstat(). Instead _wstat() must be used here.
> Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
> introduced to handle this situation in a portable way.
Semi-ACK.
In general, ACK, though it might be a bit easier to understand the code
if there were an explantory comment at the typedef, and the type would be
called "openvpn_stat_t" or such - so that when referenced in pf.c, it's
clear that this is not something "from the build environment" but "local".
gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany gert@...1296...
fax: +49-89-35655025 gert@...1297...
[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows Heiko Hund
2012-02-16 18:26 ` Gert Doering
@ 2012-02-16 18:34 ` Alon Bar-Lev
2012-02-17 9:39 ` Heiko Hund
1 sibling, 1 reply; 37+ messages in thread
From: Alon Bar-Lev @ 2012-02-16 18:34 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel
I stopped following all OpenVPN changes.
It seems like more changes are entered than should without proper review.
Anyway, this is not the correct solution.
Correct solution is to have config-msvc.h and have:
---
#define mode_t int
---
And in autoconf (if mingw does not have this as well):
AC_CHECK_DECLS(
[mode_t],
,
[AC_DEFINE([mode_t],[int], [Emulate mode_t])],
[[
#include <fcntl.h>
]]
)
On Thu, Feb 16, 2012 at 7:30 PM, Heiko Hund <heiko.hund@...1489...> wrote:
>
> The MSVC headers do not define mode_t. open() uses an int for
> the permissions instead. Fixes building with the MSVC based
> buildsystem.
>
> Signed-off-by: Heiko Hund <heiko.hund@...1489...>
> ---
> misc.h | 2 +-
> win32.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/misc.h b/misc.h
> index 8c0bae1..e7a0b55 100644
> --- a/misc.h
> +++ b/misc.h
> @@ -158,7 +158,7 @@ openvpn_fopen (const char *path, const char *mode)
> #endif
>
> #ifdef WIN32
> -int openvpn_open (const char *path, int flags, mode_t mode);
> +int openvpn_open (const char *path, int flags, int mode);
> #else
> static inline int
> openvpn_open (const char *path, int flags, mode_t mode)
> diff --git a/win32.c b/win32.c
> index 5b38918..a8f4ed9 100644
> --- a/win32.c
> +++ b/win32.c
> @@ -1064,7 +1064,7 @@ openvpn_fopen (const char *path, const char *mode)
> }
>
> int
> -openvpn_open (const char *path, int flags, mode_t mode)
> +openvpn_open (const char *path, int flags, int mode)
> {
> struct gc_arena gc = gc_new ();
> int fd = _wopen (wide_string (path, &gc), flags, mode);
> --
> 1.7.5.4
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well Heiko Hund
2012-02-16 17:47 ` Gert Doering
@ 2012-02-16 18:37 ` Alon Bar-Lev
2012-02-17 9:51 ` Heiko Hund
1 sibling, 1 reply; 37+ messages in thread
From: Alon Bar-Lev @ 2012-02-16 18:37 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel
On Thu, Feb 16, 2012 at 7:30 PM, Heiko Hund <heiko.hund@...1489...> wrote:
> Windows API CommandLineToArgvW(), introduced in Windows unicode path
> commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.
Usually this should be avoided and get command-line from wmain().
^ permalink raw reply [flat|nested] 37+ messages in thread
* [Openvpn-devel] [PATCH v2] use the underscore version of stat on Windows
2012-02-16 18:29 ` Gert Doering
@ 2012-02-16 18:47 ` David Sommerseth
2012-02-16 18:51 ` Gert Doering
2012-02-16 18:53 ` Alon Bar-Lev
0 siblings, 2 replies; 37+ messages in thread
From: David Sommerseth @ 2012-02-16 18:47 UTC (permalink / raw)
To: openvpn-devel
From: Heiko Hund <heiko.hund@...1489...>
MSVC does not know wstat(). Instead _wstat() must be used here.
Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
introduced to handle this situation in a portable way.
[v2: Use openvpn_stat_t instead of stat_t (David Sommerseth)]
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
Signed-off-by: David Sommerseth <davids@...1347...>
---
misc.h | 6 ++++--
pf.c | 2 +-
win32.c | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/misc.h b/misc.h
index e7a0b55..bdada42 100644
--- a/misc.h
+++ b/misc.h
@@ -168,10 +168,12 @@ openvpn_open (const char *path, int flags, mode_t mode)
#endif
#ifdef WIN32
-int openvpn_stat (const char *path, struct stat *buf);
+typedef struct _stat openvpn_stat_t;
+int openvpn_stat (const char *path, openvpn_stat_t *buf);
#else
+typedef struct stat openvpn_stat_t;
static inline int
-openvpn_stat (const char *path, struct stat *buf)
+openvpn_stat (const char *path, openvpn_stat_t *buf)
{
return stat (path, buf);
}
diff --git a/pf.c b/pf.c
index a0e9fc8..0ef839e 100644
--- a/pf.c
+++ b/pf.c
@@ -498,7 +498,7 @@ pf_check_reload (struct context *c)
&& c->c2.pf.filename
&& event_timeout_trigger (&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT))
{
- struct stat s;
+ openvpn_stat_t s;
if (!openvpn_stat (c->c2.pf.filename, &s))
{
if (s.st_mtime > c->c2.pf.file_last_mod)
diff --git a/win32.c b/win32.c
index a8f4ed9..2ba97fc 100644
--- a/win32.c
+++ b/win32.c
@@ -1073,10 +1073,10 @@ openvpn_open (const char *path, int flags, int mode)
}
int
-openvpn_stat (const char *path, struct stat *buf)
+openvpn_stat (const char *path, openvpn_stat_t *buf)
{
struct gc_arena gc = gc_new ();
- int res = wstat (wide_string (path, &gc), buf);
+ int res = _wstat (wide_string (path, &gc), buf);
gc_free (&gc);
return res;
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH v2] use the underscore version of stat on Windows
2012-02-16 18:47 ` [Openvpn-devel] [PATCH v2] " David Sommerseth
@ 2012-02-16 18:51 ` Gert Doering
2012-02-16 18:53 ` Alon Bar-Lev
1 sibling, 0 replies; 37+ messages in thread
From: Gert Doering @ 2012-02-16 18:51 UTC (permalink / raw)
To: David Sommerseth <davids@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 783 bytes --]
Hi,
On Thu, Feb 16, 2012 at 07:47:25PM +0100, David Sommerseth wrote:
> From: Heiko Hund <heiko.hund@...1489...>
>
> MSVC does not know wstat(). Instead _wstat() must be used here.
> Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
> introduced to handle this situation in a portable way.
>
> [v2: Use openvpn_stat_t instead of stat_t (David Sommerseth)]
>
> Signed-off-by: Heiko Hund <heiko.hund@...1489...>
> Signed-off-by: David Sommerseth <davids@...1347...>
ACK!
gert
--
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany gert@...1296...
fax: +49-89-35655025 gert@...1297...
[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH v2] use the underscore version of stat on Windows
2012-02-16 18:47 ` [Openvpn-devel] [PATCH v2] " David Sommerseth
2012-02-16 18:51 ` Gert Doering
@ 2012-02-16 18:53 ` Alon Bar-Lev
1 sibling, 0 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-02-16 18:53 UTC (permalink / raw)
To: David Sommerseth <davids@; +Cc: openvpn-devel
Again,
All conditional statements should be within single config.h or
config-msvc.h or sysheader.h or anything.
Doing conditional inline makes code complex and unmaintainable.
But as you adds loooooooong patches without proper review I guess it
is not that important.
Alon.
On Thu, Feb 16, 2012 at 8:47 PM, David Sommerseth <davids@...1347...> wrote:
> From: Heiko Hund <heiko.hund@...1489...>
>
> MSVC does not know wstat(). Instead _wstat() must be used here.
> Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
> introduced to handle this situation in a portable way.
>
> [v2: Use openvpn_stat_t instead of stat_t (David Sommerseth)]
>
> Signed-off-by: Heiko Hund <heiko.hund@...1489...>
> Signed-off-by: David Sommerseth <davids@...1347...>
> ---
> misc.h | 6 ++++--
> pf.c | 2 +-
> win32.c | 4 ++--
> 3 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/misc.h b/misc.h
> index e7a0b55..bdada42 100644
> --- a/misc.h
> +++ b/misc.h
> @@ -168,10 +168,12 @@ openvpn_open (const char *path, int flags, mode_t mode)
> #endif
>
> #ifdef WIN32
> -int openvpn_stat (const char *path, struct stat *buf);
> +typedef struct _stat openvpn_stat_t;
> +int openvpn_stat (const char *path, openvpn_stat_t *buf);
> #else
> +typedef struct stat openvpn_stat_t;
> static inline int
> -openvpn_stat (const char *path, struct stat *buf)
> +openvpn_stat (const char *path, openvpn_stat_t *buf)
> {
> return stat (path, buf);
> }
> diff --git a/pf.c b/pf.c
> index a0e9fc8..0ef839e 100644
> --- a/pf.c
> +++ b/pf.c
> @@ -498,7 +498,7 @@ pf_check_reload (struct context *c)
> && c->c2.pf.filename
> && event_timeout_trigger (&c->c2.pf.reload, &c->c2.timeval, ETT_DEFAULT))
> {
> - struct stat s;
> + openvpn_stat_t s;
> if (!openvpn_stat (c->c2.pf.filename, &s))
> {
> if (s.st_mtime > c->c2.pf.file_last_mod)
> diff --git a/win32.c b/win32.c
> index a8f4ed9..2ba97fc 100644
> --- a/win32.c
> +++ b/win32.c
> @@ -1073,10 +1073,10 @@ openvpn_open (const char *path, int flags, int mode)
> }
>
> int
> -openvpn_stat (const char *path, struct stat *buf)
> +openvpn_stat (const char *path, openvpn_stat_t *buf)
> {
> struct gc_arena gc = gc_new ();
> - int res = wstat (wide_string (path, &gc), buf);
> + int res = _wstat (wide_string (path, &gc), buf);
> gc_free (&gc);
> return res;
> }
> --
> 1.7.4.4
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows
2012-02-16 18:34 ` Alon Bar-Lev
@ 2012-02-17 9:39 ` Heiko Hund
2012-02-17 9:56 ` Alon Bar-Lev
0 siblings, 1 reply; 37+ messages in thread
From: Heiko Hund @ 2012-02-17 9:39 UTC (permalink / raw)
To: Alon Bar-Lev <alon.barlev@; +Cc: openvpn-devel@lists.sourceforge.net
Alon,
On Thursday 16 February 2012 18:34:34 Alon Bar-Lev wrote:
> Anyway, this is not the correct solution.
> Correct solution is to have config-msvc.h and have:
> ---
> #define mode_t int
I don't think that a MSVC specific header will do good. mode_t shouldn't
actually be used in mingw either, even if they define it. I stumbled over such
glue code a couple of times and the only reason I can come up with why they
have it is backwards compatibility with old code. So it's rather a general
WIN32 thing. And I absolutely agree that putting all the WIN32 stuff into
win32.[ch] would make the code prettier. I just don't feel enough itch to
approach this scratching myself.
Heiko
--
Heiko Hund | Software Engineer | Phone +49-721-25516-237 | Fax -200
Astaro a Sophos Company | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRA 702710 | Headquarter Location: Karlsruhe
Represented by the General Partner Astaro Verwaltungs GmbH
Amalienbadstraße 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRB 708248 | Executive Board: Gert Hansen,
Markus Hennig, Jan Hichert, Günter Junk, Dr. Frank Nellissen
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well
2012-02-16 18:37 ` Alon Bar-Lev
@ 2012-02-17 9:51 ` Heiko Hund
2012-02-17 9:55 ` Alon Bar-Lev
0 siblings, 1 reply; 37+ messages in thread
From: Heiko Hund @ 2012-02-17 9:51 UTC (permalink / raw)
To: Alon Bar-Lev <alon.barlev@; +Cc: openvpn-devel@lists.sourceforge.net
Alon,
On Thursday 16 February 2012 18:37:21 Alon Bar-Lev wrote:
> On Thu, Feb 16, 2012 at 7:30 PM, Heiko Hund <heiko.hund@...1489...> wrote:
> > Windows API CommandLineToArgvW(), introduced in Windows unicode path
> > commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.
>
> Usually this should be avoided and get command-line from wmain().
the general idea is to make Unicode things happen without changing the openvpn
code too much in a very Windows specific way. Converting UCS-2 to UTF-8
directly where input and output is happening and passing it through the rest
of openvpn as char* does that. I don't see any benefit in converting openvpn
into a native unicode binary.
Regards
Heiko
--
Heiko Hund | Software Engineer | Phone +49-721-25516-237 | Fax -200
Astaro a Sophos Company | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRA 702710 | Headquarter Location: Karlsruhe
Represented by the General Partner Astaro Verwaltungs GmbH
Amalienbadstraße 41 Bau 52 | 76227 Karlsruhe | Germany
Commercial Register: Mannheim HRB 708248 | Executive Board: Gert Hansen,
Markus Hennig, Jan Hichert, Günter Junk, Dr. Frank Nellissen
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well
2012-02-17 9:51 ` Heiko Hund
@ 2012-02-17 9:55 ` Alon Bar-Lev
2012-03-24 20:31 ` [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest Alon Bar-Lev
0 siblings, 1 reply; 37+ messages in thread
From: Alon Bar-Lev @ 2012-02-17 9:55 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel@lists.sourceforge.net
On Fri, Feb 17, 2012 at 11:51 AM, Heiko Hund <heiko.hund@...1489...> wrote:
> Alon,
>
> On Thursday 16 February 2012 18:37:21 Alon Bar-Lev wrote:
>> On Thu, Feb 16, 2012 at 7:30 PM, Heiko Hund <heiko.hund@...1489...> wrote:
>> > Windows API CommandLineToArgvW(), introduced in Windows unicode path
>> > commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.
>>
>> Usually this should be avoided and get command-line from wmain().
>
> the general idea is to make Unicode things happen without changing the openvpn
> code too much in a very Windows specific way. Converting UCS-2 to UTF-8
> directly where input and output is happening and passing it through the rest
> of openvpn as char* does that. I don't see any benefit in converting openvpn
> into a native unicode binary.
I agree.
Compiling entry point as wmain and not main is not bigger change than
any other change in the unicode patch.
Anyway as it seem we have an opportunity window to cleanup the mess,
so apply whatever needed in orderer to make it work and then we revise
it.
Personally, I don't think this unicode patch was ready to be merged...
Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows
2012-02-17 9:39 ` Heiko Hund
@ 2012-02-17 9:56 ` Alon Bar-Lev
0 siblings, 0 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-02-17 9:56 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel@lists.sourceforge.net
On Fri, Feb 17, 2012 at 11:39 AM, Heiko Hund <heiko.hund@...1489...> wrote:
> Alon,
>
> On Thursday 16 February 2012 18:34:34 Alon Bar-Lev wrote:
>> Anyway, this is not the correct solution.
>> Correct solution is to have config-msvc.h and have:
>> ---
>> #define mode_t int
>
> I don't think that a MSVC specific header will do good. mode_t shouldn't
> actually be used in mingw either, even if they define it. I stumbled over such
> glue code a couple of times and the only reason I can come up with why they
> have it is backwards compatibility with old code. So it's rather a general
> WIN32 thing. And I absolutely agree that putting all the WIN32 stuff into
> win32.[ch] would make the code prettier. I just don't feel enough itch to
> approach this scratching myself.
>
You will be surprised how mingw is better in this sense.
Anyway, as I wrote commit whatever you need for now, we will clean up
the build system soon.
Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] MSVC fixes
2012-02-16 17:30 [Openvpn-devel] MSVC fixes Heiko Hund
` (3 preceding siblings ...)
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well Heiko Hund
@ 2012-02-17 10:14 ` David Sommerseth
4 siblings, 0 replies; 37+ messages in thread
From: David Sommerseth @ 2012-02-17 10:14 UTC (permalink / raw)
To: openvpn-devel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 16/02/12 18:30, Heiko Hund wrote:
> Hi,
>
> this patch series fixes several issues when building for Windows with
> the MSVC buildsystem discovered today:
>
> [PATCH 1/4] replace check for TARGET_WIN32 with WIN32 [PATCH 2/4] do
> not use mode_t on Windows [PATCH 3/4] use the underscore version of
> stat on Windows [PATCH 4/4] make MSVC link against shell32 as well
>
> For details check the commit messages of the individual patches.
All patches applied to master on -testing and -stable trees.
For patch 3/4, a v2 patch was applied.
commit 76a3c405549bf02902846a9bd0e7d0f3a25a5b4d
Author: Heiko Hund <heiko.hund@...1489...>
Date: Thu Feb 16 18:30:38 2012 +0100
replace check for TARGET_WIN32 with WIN32
Use of TARGET_WIN32 breaks MSVC builds as it is only defined
for mingw builds done with the autotools buildsystem.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
Acked-by: Gert Doering <gert@...1296...>
Signed-off-by: David Sommerseth <davids@...1347...>
commit d0109cbf459409a84963668c78f444c97ec2b349
Author: Heiko Hund <heiko.hund@...1489...>
Date: Thu Feb 16 18:30:39 2012 +0100
do not use mode_t on Windows
The MSVC headers do not define mode_t. open() uses an int for
the permissions instead. Fixes building with the MSVC based
buildsystem.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
Acked-by: Gert Doering <gert@...1296...>
Signed-off-by: David Sommerseth <davids@...1347...>
commit a13cd253ca1ce987e4feca7d80bd19ff749f7787
Author: Heiko Hund <heiko.hund@...1489...>
Date: Thu Feb 16 18:30:40 2012 +0100
use the underscore version of stat on Windows
MSVC does not know wstat(). Instead _wstat() must be used here.
Unfortunately _wstat() takes a 'struct _stat'. A type 'stat_t' is
introduced to handle this situation in a portable way.
[v2: Use openvpn_stat_t instead of stat_t (David Sommerseth)]
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
Signed-off-by: David Sommerseth <davids@...1347...>
Acked-by: Gert Doering <gert@...1296...>
commit 67fe36f888d72d2c9c2b8dac849159a229400367
Author: Heiko Hund <heiko.hund@...1489...>
Date: Thu Feb 16 18:30:41 2012 +0100
make MSVC link against shell32 as well
Windows API CommandLineToArgvW(), introduced in Windows unicode path
commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein.
Signed-off-by: Heiko Hund <heiko.hund@...1489...>
Acked-by: Gert Doering <gert@...1296...>
Signed-off-by: David Sommerseth <davids@...1347...>
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk8+KHgACgkQDC186MBRfrrEQwCfSZXxIf3+E+iR3+0h+HI6R5KV
utwAn36V2rzrGZvdeStrp6rjG/mOtZME
=XnhK
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 37+ messages in thread
* [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-02-17 9:55 ` Alon Bar-Lev
@ 2012-03-24 20:31 ` Alon Bar-Lev
2012-04-02 11:39 ` Alon Bar-Lev
` (2 more replies)
0 siblings, 3 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-03-24 20:31 UTC (permalink / raw)
To: openvpn-devel; +Cc: Alon Bar-Lev <alon.barlev@
Discussed at [1].
Use wmain under windows, drop the custom parsing and shell32 linkage.
There is no need for gc magic as this allocation is static.
[1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
---
src/openvpn/Makefile.am | 6 +++++-
src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
src/openvpn/openvpn.vcxproj | 10 ++++++----
src/openvpn/options.c | 27 ---------------------------
4 files changed, 47 insertions(+), 33 deletions(-)
mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
index 4e485e7..0506b11 100644
--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Makefile.am
@@ -27,6 +27,10 @@ AM_CFLAGS = \
$(OPTIONAL_CRYPTO_CFLAGS) \
$(OPTIONAL_LZO_CFLAGS) \
$(OPTIONAL_PKCS11_HELPER_CFLAGS)
+if WIN32
+# we want unicode entry point but not the macro
+AM_CFLAGS += -municode -UUNICODE
+endif
sbin_PROGRAMS = openvpn
@@ -118,5 +122,5 @@ openvpn_LDADD = \
$(OPTIONAL_DL_LIBS)
if WIN32
openvpn_SOURCES += openvpn_win32_resources.rc
-openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32
+openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
endif
diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
index 3db1b86..6e70a58 100644
--- a/src/openvpn/openvpn.c
+++ b/src/openvpn/openvpn.c
@@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
* @param argc - Commandline argument count.
* @param argv - Commandline argument values.
*/
+static
int
-main (int argc, char *argv[])
+openvpn_main (int argc, char *argv[])
{
struct context c;
@@ -289,3 +290,37 @@ main (int argc, char *argv[])
openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
return 0; /* NOTREACHED */
}
+
+#ifdef WIN32
+int
+wmain (int argc, wchar_t *wargv[]) {
+ char **argv;
+ int ret;
+ int i;
+
+ if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
+ return 1;
+
+ for (i = 0; i < argc; i++)
+ {
+ int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
+ argv[i] = malloc (n);
+ WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
+ }
+
+ ret = openvpn_main(argc, argv);
+
+ for (i=0; i < argc; i++ )
+ {
+ free (argv[i]);
+ }
+ free(argv);
+
+ return ret;
+}
+#else
+int
+main (int argc, char *argv[]) {
+ return openvpn_main(argc, argv);
+}
+#endif
diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
old mode 100644
new mode 100755
index 51e19af..452876f
--- a/src/openvpn/openvpn.vcxproj
+++ b/src/openvpn/openvpn.vcxproj
@@ -18,12 +18,12 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
+ <CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -56,12 +56,13 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
@@ -80,12 +81,13 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
- <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 25786f6..66241b4 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
{
int i, j;
-#ifdef WIN32
- /*
- * Windows replaces Unicode characters in argv[] that are not present
- * in the current codepage with '?'. Get the wide char command line and
- * convert it to UTF-8 ourselves.
- */
- int wargc;
- WCHAR **wargv;
- char **uargv;
-
- wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
- if (wargv == NULL || wargc != argc)
- usage ();
-
- uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
-
- for (i = 0; i < wargc; i++)
- {
- int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
- uargv[i] = gc_malloc (n, false, &options->gc);
- WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, NULL);
- }
-
- LocalFree (wargv);
- argv = uargv;
-#endif
-
/* usage message */
if (argc <= 1)
usage ();
--
1.7.3.4
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-03-24 20:31 ` [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest Alon Bar-Lev
@ 2012-04-02 11:39 ` Alon Bar-Lev
2012-04-27 8:54 `
2012-06-29 8:11 ` David Sommerseth
2 siblings, 0 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-04-02 11:39 UTC (permalink / raw)
To: openvpn-devel
Please review/test.
On Sat, Mar 24, 2012 at 10:31 PM, Alon Bar-Lev <alon.barlev@...277...> wrote:
> Discussed at [1].
>
> Use wmain under windows, drop the custom parsing and shell32 linkage.
>
> There is no need for gc magic as this allocation is static.
>
> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>
> Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
> ---
> src/openvpn/Makefile.am | 6 +++++-
> src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
> src/openvpn/openvpn.vcxproj | 10 ++++++----
> src/openvpn/options.c | 27 ---------------------------
> 4 files changed, 47 insertions(+), 33 deletions(-)
> mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
>
> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
> index 4e485e7..0506b11 100644
> --- a/src/openvpn/Makefile.am
> +++ b/src/openvpn/Makefile.am
> @@ -27,6 +27,10 @@ AM_CFLAGS = \
> $(OPTIONAL_CRYPTO_CFLAGS) \
> $(OPTIONAL_LZO_CFLAGS) \
> $(OPTIONAL_PKCS11_HELPER_CFLAGS)
> +if WIN32
> +# we want unicode entry point but not the macro
> +AM_CFLAGS += -municode -UUNICODE
> +endif
>
> sbin_PROGRAMS = openvpn
>
> @@ -118,5 +122,5 @@ openvpn_LDADD = \
> $(OPTIONAL_DL_LIBS)
> if WIN32
> openvpn_SOURCES += openvpn_win32_resources.rc
> -openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32
> +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
> endif
> diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
> index 3db1b86..6e70a58 100644
> --- a/src/openvpn/openvpn.c
> +++ b/src/openvpn/openvpn.c
> @@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
> * @param argc - Commandline argument count.
> * @param argv - Commandline argument values.
> */
> +static
> int
> -main (int argc, char *argv[])
> +openvpn_main (int argc, char *argv[])
> {
> struct context c;
>
> @@ -289,3 +290,37 @@ main (int argc, char *argv[])
> openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
> return 0; /* NOTREACHED */
> }
> +
> +#ifdef WIN32
> +int
> +wmain (int argc, wchar_t *wargv[]) {
> + char **argv;
> + int ret;
> + int i;
> +
> + if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
> + return 1;
> +
> + for (i = 0; i < argc; i++)
> + {
> + int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
> + argv[i] = malloc (n);
> + WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
> + }
> +
> + ret = openvpn_main(argc, argv);
> +
> + for (i=0; i < argc; i++ )
> + {
> + free (argv[i]);
> + }
> + free(argv);
> +
> + return ret;
> +}
> +#else
> +int
> +main (int argc, char *argv[]) {
> + return openvpn_main(argc, argv);
> +}
> +#endif
> diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
> old mode 100644
> new mode 100755
> index 51e19af..452876f
> --- a/src/openvpn/openvpn.vcxproj
> +++ b/src/openvpn/openvpn.vcxproj
> @@ -18,12 +18,12 @@
> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
> <ConfigurationType>Application</ConfigurationType>
> - <CharacterSet>MultiByte</CharacterSet>
> <WholeProgramOptimization>true</WholeProgramOptimization>
> + <CharacterSet>Unicode</CharacterSet>
> </PropertyGroup>
> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
> <ConfigurationType>Application</ConfigurationType>
> - <CharacterSet>MultiByte</CharacterSet>
> + <CharacterSet>Unicode</CharacterSet>
> </PropertyGroup>
> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
> <ImportGroup Label="ExtensionSettings">
> @@ -56,12 +56,13 @@
> </PrecompiledHeader>
> <WarningLevel>Level3</WarningLevel>
> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
> </ClCompile>
> <ResourceCompile>
> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
> </ResourceCompile>
> <Link>
> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
> <GenerateDebugInformation>true</GenerateDebugInformation>
> <SubSystem>Console</SubSystem>
> @@ -80,12 +81,13 @@
> </PrecompiledHeader>
> <WarningLevel>Level3</WarningLevel>
> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
> </ClCompile>
> <ResourceCompile>
> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
> </ResourceCompile>
> <Link>
> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
> <GenerateDebugInformation>true</GenerateDebugInformation>
> <SubSystem>Console</SubSystem>
> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
> index 25786f6..66241b4 100644
> --- a/src/openvpn/options.c
> +++ b/src/openvpn/options.c
> @@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
> {
> int i, j;
>
> -#ifdef WIN32
> - /*
> - * Windows replaces Unicode characters in argv[] that are not present
> - * in the current codepage with '?'. Get the wide char command line and
> - * convert it to UTF-8 ourselves.
> - */
> - int wargc;
> - WCHAR **wargv;
> - char **uargv;
> -
> - wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
> - if (wargv == NULL || wargc != argc)
> - usage ();
> -
> - uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
> -
> - for (i = 0; i < wargc; i++)
> - {
> - int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
> - uargv[i] = gc_malloc (n, false, &options->gc);
> - WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, NULL);
> - }
> -
> - LocalFree (wargv);
> - argv = uargv;
> -#endif
> -
> /* usage message */
> if (argc <= 1)
> usage ();
> --
> 1.7.3.4
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-03-24 20:31 ` [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest Alon Bar-Lev
2012-04-02 11:39 ` Alon Bar-Lev
@ 2012-04-27 8:54 `
2012-04-27 8:59 ` Alon Bar-Lev
2012-04-27 9:18 ` Heiko Hund
2012-06-29 8:11 ` David Sommerseth
2 siblings, 2 replies; 37+ messages in thread
From: @ 2012-04-27 8:54 UTC (permalink / raw)
To: Alon Bar-Lev <alon.barlev@; +Cc: openvpn-devel@lists.sourceforge.net
Hi,
As promised in yesterday's IRC meeting (summary coming today), I tested
this patch on Windows 7 (64-bit). So far I've had no luck, but don't
think the problems have anything to do with this patch.
Anyways, I cross-compiled latest "master" with this patch applied and
"bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
install. The old "bin" directory was renamed to make sure none of it was
used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
"ääliö.key" using Windows Explorer. Then I updated the configuration
file to point to these files using Notepad (and later Wordpad).
OpenVPN-GUI (Heiko's new version) detected the configuration file
properly, showing "ääliö" as one available connection option. However,
it output the following when trying to connect:
Options error: --tls-auth fails with 'ääliö.key': No such file or
directory
Git Bash showed the file as ??li?.key, which could mean Windows Explorer
is using a single-byte character set.
Windows command prompt shows the characters properly, but issuing
"openvpn --config ääliö.ovpn" gives the same error as OpenVPN-GUI above,
except that 'ääliö.key' shows faulty glyphs[1]. This also triggers an
interesting bug in the command prompt[2]
Anyways, as the Windows 7 install is English-language, I suspect it's
using a single-byte character set instead of UCS-2. I'll continue
debugging, but any pointers are obviously much appreciated!
Samuli
[1] <http://users.utu.fi/sjsepp/cmd.png>
[2] Typing an "ä" or "ö" moves the (invisible) cursor forward one
character, but each backspace will delete two characters instead of one.
This does not happen until openvpn has been (unsuccessfully) started.
> Discussed at [1].
>
> Use wmain under windows, drop the custom parsing and shell32 linkage.
>
> There is no need for gc magic as this allocation is static.
>
> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>
> Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
> ---
> src/openvpn/Makefile.am | 6 +++++-
> src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
> src/openvpn/openvpn.vcxproj | 10 ++++++----
> src/openvpn/options.c | 27 ---------------------------
> 4 files changed, 47 insertions(+), 33 deletions(-)
> mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
>
> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
> index 4e485e7..0506b11 100644
> --- a/src/openvpn/Makefile.am
> +++ b/src/openvpn/Makefile.am
> @@ -27,6 +27,10 @@ AM_CFLAGS = \
> $(OPTIONAL_CRYPTO_CFLAGS) \
> $(OPTIONAL_LZO_CFLAGS) \
> $(OPTIONAL_PKCS11_HELPER_CFLAGS)
> +if WIN32
> +# we want unicode entry point but not the macro
> +AM_CFLAGS += -municode -UUNICODE
> +endif
>
> sbin_PROGRAMS = openvpn
>
> @@ -118,5 +122,5 @@ openvpn_LDADD = \
> $(OPTIONAL_DL_LIBS)
> if WIN32
> openvpn_SOURCES += openvpn_win32_resources.rc
> -openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32
> +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
> endif
> diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
> index 3db1b86..6e70a58 100644
> --- a/src/openvpn/openvpn.c
> +++ b/src/openvpn/openvpn.c
> @@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
> * @param argc - Commandline argument count.
> * @param argv - Commandline argument values.
> */
> +static
> int
> -main (int argc, char *argv[])
> +openvpn_main (int argc, char *argv[])
> {
> struct context c;
>
> @@ -289,3 +290,37 @@ main (int argc, char *argv[])
> openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
> return 0; /* NOTREACHED */
> }
> +
> +#ifdef WIN32
> +int
> +wmain (int argc, wchar_t *wargv[]) {
> + char **argv;
> + int ret;
> + int i;
> +
> + if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
> + return 1;
> +
> + for (i = 0; i < argc; i++)
> + {
> + int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
> + argv[i] = malloc (n);
> + WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
> + }
> +
> + ret = openvpn_main(argc, argv);
> +
> + for (i=0; i < argc; i++ )
> + {
> + free (argv[i]);
> + }
> + free(argv);
> +
> + return ret;
> +}
> +#else
> +int
> +main (int argc, char *argv[]) {
> + return openvpn_main(argc, argv);
> +}
> +#endif
> diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
> old mode 100644
> new mode 100755
> index 51e19af..452876f
> --- a/src/openvpn/openvpn.vcxproj
> +++ b/src/openvpn/openvpn.vcxproj
> @@ -18,12 +18,12 @@
> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
> <ConfigurationType>Application</ConfigurationType>
> - <CharacterSet>MultiByte</CharacterSet>
> <WholeProgramOptimization>true</WholeProgramOptimization>
> + <CharacterSet>Unicode</CharacterSet>
> </PropertyGroup>
> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
> <ConfigurationType>Application</ConfigurationType>
> - <CharacterSet>MultiByte</CharacterSet>
> + <CharacterSet>Unicode</CharacterSet>
> </PropertyGroup>
> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
> <ImportGroup Label="ExtensionSettings">
> @@ -56,12 +56,13 @@
> </PrecompiledHeader>
> <WarningLevel>Level3</WarningLevel>
> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
> </ClCompile>
> <ResourceCompile>
> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
> </ResourceCompile>
> <Link>
> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
> <GenerateDebugInformation>true</GenerateDebugInformation>
> <SubSystem>Console</SubSystem>
> @@ -80,12 +81,13 @@
> </PrecompiledHeader>
> <WarningLevel>Level3</WarningLevel>
> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
> </ClCompile>
> <ResourceCompile>
> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
> </ResourceCompile>
> <Link>
> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
> <GenerateDebugInformation>true</GenerateDebugInformation>
> <SubSystem>Console</SubSystem>
> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
> index 25786f6..66241b4 100644
> --- a/src/openvpn/options.c
> +++ b/src/openvpn/options.c
> @@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
> {
> int i, j;
>
> -#ifdef WIN32
> - /*
> - * Windows replaces Unicode characters in argv[] that are not present
> - * in the current codepage with '?'. Get the wide char command line and
> - * convert it to UTF-8 ourselves.
> - */
> - int wargc;
> - WCHAR **wargv;
> - char **uargv;
> -
> - wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
> - if (wargv == NULL || wargc != argc)
> - usage ();
> -
> - uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
> -
> - for (i = 0; i < wargc; i++)
> - {
> - int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
> - uargv[i] = gc_malloc (n, false, &options->gc);
> - WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, NULL);
> - }
> -
> - LocalFree (wargv);
> - argv = uargv;
> -#endif
> -
> /* usage message */
> if (argc <= 1)
> usage ();
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 8:54 `
@ 2012-04-27 8:59 ` Alon Bar-Lev
2012-04-27 11:13 `
2012-04-27 9:18 ` Heiko Hund
1 sibling, 1 reply; 37+ messages in thread
From: Alon Bar-Lev @ 2012-04-27 8:59 UTC (permalink / raw)
Cc: openvpn-devel@lists.sourceforge.net
Hello Samuli,
Curios: Did you manage to get it work using master without my patch?
If not, to make it easy...
Use Windows Explorer and rename the key file to something non-ascii.
Then open openvpn configuration using UTF-8 editor and modify key file there.
This should work, as we do not use unicode/conversion command-line.
Next step would be to remove the key from configuration and use it in
command-line.
Alon.
2012/4/27 Samuli Seppänen <samuli@...515...>:
> Hi,
>
> As promised in yesterday's IRC meeting (summary coming today), I tested
> this patch on Windows 7 (64-bit). So far I've had no luck, but don't
> think the problems have anything to do with this patch.
>
> Anyways, I cross-compiled latest "master" with this patch applied and
> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
> install. The old "bin" directory was renamed to make sure none of it was
> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
> "ääliö.key" using Windows Explorer. Then I updated the configuration
> file to point to these files using Notepad (and later Wordpad).
>
> OpenVPN-GUI (Heiko's new version) detected the configuration file
> properly, showing "ääliö" as one available connection option. However,
> it output the following when trying to connect:
>
> Options error: --tls-auth fails with 'ääliö.key': No such file or
> directory
>
> Git Bash showed the file as ??li?.key, which could mean Windows Explorer
> is using a single-byte character set.
>
> Windows command prompt shows the characters properly, but issuing
> "openvpn --config ääliö.ovpn" gives the same error as OpenVPN-GUI above,
> except that 'ääliö.key' shows faulty glyphs[1]. This also triggers an
> interesting bug in the command prompt[2]
>
> Anyways, as the Windows 7 install is English-language, I suspect it's
> using a single-byte character set instead of UCS-2. I'll continue
> debugging, but any pointers are obviously much appreciated!
>
> Samuli
>
> [1] <http://users.utu.fi/sjsepp/cmd.png>
> [2] Typing an "ä" or "ö" moves the (invisible) cursor forward one
> character, but each backspace will delete two characters instead of one.
> This does not happen until openvpn has been (unsuccessfully) started.
>
>
>> Discussed at [1].
>>
>> Use wmain under windows, drop the custom parsing and shell32 linkage.
>>
>> There is no need for gc magic as this allocation is static.
>>
>> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>>
>> Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
>> ---
>> src/openvpn/Makefile.am | 6 +++++-
>> src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
>> src/openvpn/openvpn.vcxproj | 10 ++++++----
>> src/openvpn/options.c | 27 ---------------------------
>> 4 files changed, 47 insertions(+), 33 deletions(-)
>> mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
>>
>> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
>> index 4e485e7..0506b11 100644
>> --- a/src/openvpn/Makefile.am
>> +++ b/src/openvpn/Makefile.am
>> @@ -27,6 +27,10 @@ AM_CFLAGS = \
>> $(OPTIONAL_CRYPTO_CFLAGS) \
>> $(OPTIONAL_LZO_CFLAGS) \
>> $(OPTIONAL_PKCS11_HELPER_CFLAGS)
>> +if WIN32
>> +# we want unicode entry point but not the macro
>> +AM_CFLAGS += -municode -UUNICODE
>> +endif
>>
>> sbin_PROGRAMS = openvpn
>>
>> @@ -118,5 +122,5 @@ openvpn_LDADD = \
>> $(OPTIONAL_DL_LIBS)
>> if WIN32
>> openvpn_SOURCES += openvpn_win32_resources.rc
>> -openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32
>> +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
>> endif
>> diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
>> index 3db1b86..6e70a58 100644
>> --- a/src/openvpn/openvpn.c
>> +++ b/src/openvpn/openvpn.c
>> @@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
>> * @param argc - Commandline argument count.
>> * @param argv - Commandline argument values.
>> */
>> +static
>> int
>> -main (int argc, char *argv[])
>> +openvpn_main (int argc, char *argv[])
>> {
>> struct context c;
>>
>> @@ -289,3 +290,37 @@ main (int argc, char *argv[])
>> openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
>> return 0; /* NOTREACHED */
>> }
>> +
>> +#ifdef WIN32
>> +int
>> +wmain (int argc, wchar_t *wargv[]) {
>> + char **argv;
>> + int ret;
>> + int i;
>> +
>> + if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
>> + return 1;
>> +
>> + for (i = 0; i < argc; i++)
>> + {
>> + int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
>> + argv[i] = malloc (n);
>> + WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
>> + }
>> +
>> + ret = openvpn_main(argc, argv);
>> +
>> + for (i=0; i < argc; i++ )
>> + {
>> + free (argv[i]);
>> + }
>> + free(argv);
>> +
>> + return ret;
>> +}
>> +#else
>> +int
>> +main (int argc, char *argv[]) {
>> + return openvpn_main(argc, argv);
>> +}
>> +#endif
>> diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
>> old mode 100644
>> new mode 100755
>> index 51e19af..452876f
>> --- a/src/openvpn/openvpn.vcxproj
>> +++ b/src/openvpn/openvpn.vcxproj
>> @@ -18,12 +18,12 @@
>> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
>> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
>> <ConfigurationType>Application</ConfigurationType>
>> - <CharacterSet>MultiByte</CharacterSet>
>> <WholeProgramOptimization>true</WholeProgramOptimization>
>> + <CharacterSet>Unicode</CharacterSet>
>> </PropertyGroup>
>> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
>> <ConfigurationType>Application</ConfigurationType>
>> - <CharacterSet>MultiByte</CharacterSet>
>> + <CharacterSet>Unicode</CharacterSet>
>> </PropertyGroup>
>> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
>> <ImportGroup Label="ExtensionSettings">
>> @@ -56,12 +56,13 @@
>> </PrecompiledHeader>
>> <WarningLevel>Level3</WarningLevel>
>> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
>> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>> </ClCompile>
>> <ResourceCompile>
>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>> </ResourceCompile>
>> <Link>
>> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>> <GenerateDebugInformation>true</GenerateDebugInformation>
>> <SubSystem>Console</SubSystem>
>> @@ -80,12 +81,13 @@
>> </PrecompiledHeader>
>> <WarningLevel>Level3</WarningLevel>
>> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
>> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>> </ClCompile>
>> <ResourceCompile>
>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>> </ResourceCompile>
>> <Link>
>> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>> <GenerateDebugInformation>true</GenerateDebugInformation>
>> <SubSystem>Console</SubSystem>
>> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
>> index 25786f6..66241b4 100644
>> --- a/src/openvpn/options.c
>> +++ b/src/openvpn/options.c
>> @@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
>> {
>> int i, j;
>>
>> -#ifdef WIN32
>> - /*
>> - * Windows replaces Unicode characters in argv[] that are not present
>> - * in the current codepage with '?'. Get the wide char command line and
>> - * convert it to UTF-8 ourselves.
>> - */
>> - int wargc;
>> - WCHAR **wargv;
>> - char **uargv;
>> -
>> - wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
>> - if (wargv == NULL || wargc != argc)
>> - usage ();
>> -
>> - uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
>> -
>> - for (i = 0; i < wargc; i++)
>> - {
>> - int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
>> - uargv[i] = gc_malloc (n, false, &options->gc);
>> - WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, NULL);
>> - }
>> -
>> - LocalFree (wargv);
>> - argv = uargv;
>> -#endif
>> -
>> /* usage message */
>> if (argc <= 1)
>> usage ();
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 8:54 `
2012-04-27 8:59 ` Alon Bar-Lev
@ 2012-04-27 9:18 ` Heiko Hund
2012-04-27 11:15 `
2012-04-27 11:55 `
1 sibling, 2 replies; 37+ messages in thread
From: Heiko Hund @ 2012-04-27 9:18 UTC (permalink / raw)
To: openvpn-devel
On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
> Anyways, I cross-compiled latest "master" with this patch applied and
> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
> install. The old "bin" directory was renamed to make sure none of it was
> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
> "ääliö.key" using Windows Explorer. Then I updated the configuration
> file to point to these files using Notepad (and later Wordpad).
Notepad saves UTF-8 files with BOM, which is very uncommon. Maybe that was the
problem. I ran into that when I was testing my patch. You might want to try
using Notepad++ and save it as UTF-8 without BOM.
HTH
Heiko
--
Heiko Hund | Software Engineer | Tel +49-721-25516-237 | Fax -200
SOPHOS NSG | Amalienbadstr. 41 Bau 52 | 76227 Karlsruhe | Germany
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 8:59 ` Alon Bar-Lev
@ 2012-04-27 11:13 `
2012-04-27 11:24 ` Alon Bar-Lev
0 siblings, 1 reply; 37+ messages in thread
From: @ 2012-04-27 11:13 UTC (permalink / raw)
To: Alon Bar-Lev <alon.barlev@; +Cc: openvpn-devel@lists.sourceforge.net
> Hello Samuli,
>
> Curios: Did you manage to get it work using master without my patch?
Nope, although I only tested it briefly. I'll try that again just in case.
> If not, to make it easy...
>
> Use Windows Explorer and rename the key file to something non-ascii.
> Then open openvpn configuration using UTF-8 editor and modify key file there.
> This should work, as we do not use unicode/conversion command-line.
>
> Next step would be to remove the key from configuration and use it in
> command-line.
>
> Alon.
Thanks, I'll try that.
Samuli
>
> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>> Hi,
>>
>> As promised in yesterday's IRC meeting (summary coming today), I tested
>> this patch on Windows 7 (64-bit). So far I've had no luck, but don't
>> think the problems have anything to do with this patch.
>>
>> Anyways, I cross-compiled latest "master" with this patch applied and
>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>> install. The old "bin" directory was renamed to make sure none of it was
>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>> file to point to these files using Notepad (and later Wordpad).
>>
>> OpenVPN-GUI (Heiko's new version) detected the configuration file
>> properly, showing "ääliö" as one available connection option. However,
>> it output the following when trying to connect:
>>
>> Options error: --tls-auth fails with 'ääliö.key': No such file or
>> directory
>>
>> Git Bash showed the file as ??li?.key, which could mean Windows Explorer
>> is using a single-byte character set.
>>
>> Windows command prompt shows the characters properly, but issuing
>> "openvpn --config ääliö.ovpn" gives the same error as OpenVPN-GUI above,
>> except that 'ääliö.key' shows faulty glyphs[1]. This also triggers an
>> interesting bug in the command prompt[2]
>>
>> Anyways, as the Windows 7 install is English-language, I suspect it's
>> using a single-byte character set instead of UCS-2. I'll continue
>> debugging, but any pointers are obviously much appreciated!
>>
>> Samuli
>>
>> [1] <http://users.utu.fi/sjsepp/cmd.png>
>> [2] Typing an "ä" or "ö" moves the (invisible) cursor forward one
>> character, but each backspace will delete two characters instead of one.
>> This does not happen until openvpn has been (unsuccessfully) started.
>>
>>
>>> Discussed at [1].
>>>
>>> Use wmain under windows, drop the custom parsing and shell32 linkage.
>>>
>>> There is no need for gc magic as this allocation is static.
>>>
>>> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>>>
>>> Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
>>> ---
>>> src/openvpn/Makefile.am | 6 +++++-
>>> src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
>>> src/openvpn/openvpn.vcxproj | 10 ++++++----
>>> src/openvpn/options.c | 27 ---------------------------
>>> 4 files changed, 47 insertions(+), 33 deletions(-)
>>> mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
>>>
>>> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
>>> index 4e485e7..0506b11 100644
>>> --- a/src/openvpn/Makefile.am
>>> +++ b/src/openvpn/Makefile.am
>>> @@ -27,6 +27,10 @@ AM_CFLAGS = \
>>> $(OPTIONAL_CRYPTO_CFLAGS) \
>>> $(OPTIONAL_LZO_CFLAGS) \
>>> $(OPTIONAL_PKCS11_HELPER_CFLAGS)
>>> +if WIN32
>>> +# we want unicode entry point but not the macro
>>> +AM_CFLAGS += -municode -UUNICODE
>>> +endif
>>>
>>> sbin_PROGRAMS = openvpn
>>>
>>> @@ -118,5 +122,5 @@ openvpn_LDADD = \
>>> $(OPTIONAL_DL_LIBS)
>>> if WIN32
>>> openvpn_SOURCES += openvpn_win32_resources.rc
>>> -openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32
>>> +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
>>> endif
>>> diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
>>> index 3db1b86..6e70a58 100644
>>> --- a/src/openvpn/openvpn.c
>>> +++ b/src/openvpn/openvpn.c
>>> @@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
>>> * @param argc - Commandline argument count.
>>> * @param argv - Commandline argument values.
>>> */
>>> +static
>>> int
>>> -main (int argc, char *argv[])
>>> +openvpn_main (int argc, char *argv[])
>>> {
>>> struct context c;
>>>
>>> @@ -289,3 +290,37 @@ main (int argc, char *argv[])
>>> openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
>>> return 0; /* NOTREACHED */
>>> }
>>> +
>>> +#ifdef WIN32
>>> +int
>>> +wmain (int argc, wchar_t *wargv[]) {
>>> + char **argv;
>>> + int ret;
>>> + int i;
>>> +
>>> + if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
>>> + return 1;
>>> +
>>> + for (i = 0; i < argc; i++)
>>> + {
>>> + int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
>>> + argv[i] = malloc (n);
>>> + WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
>>> + }
>>> +
>>> + ret = openvpn_main(argc, argv);
>>> +
>>> + for (i=0; i < argc; i++ )
>>> + {
>>> + free (argv[i]);
>>> + }
>>> + free(argv);
>>> +
>>> + return ret;
>>> +}
>>> +#else
>>> +int
>>> +main (int argc, char *argv[]) {
>>> + return openvpn_main(argc, argv);
>>> +}
>>> +#endif
>>> diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
>>> old mode 100644
>>> new mode 100755
>>> index 51e19af..452876f
>>> --- a/src/openvpn/openvpn.vcxproj
>>> +++ b/src/openvpn/openvpn.vcxproj
>>> @@ -18,12 +18,12 @@
>>> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
>>> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
>>> <ConfigurationType>Application</ConfigurationType>
>>> - <CharacterSet>MultiByte</CharacterSet>
>>> <WholeProgramOptimization>true</WholeProgramOptimization>
>>> + <CharacterSet>Unicode</CharacterSet>
>>> </PropertyGroup>
>>> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
>>> <ConfigurationType>Application</ConfigurationType>
>>> - <CharacterSet>MultiByte</CharacterSet>
>>> + <CharacterSet>Unicode</CharacterSet>
>>> </PropertyGroup>
>>> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
>>> <ImportGroup Label="ExtensionSettings">
>>> @@ -56,12 +56,13 @@
>>> </PrecompiledHeader>
>>> <WarningLevel>Level3</WarningLevel>
>>> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
>>> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>>> </ClCompile>
>>> <ResourceCompile>
>>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>> </ResourceCompile>
>>> <Link>
>>> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>>> <GenerateDebugInformation>true</GenerateDebugInformation>
>>> <SubSystem>Console</SubSystem>
>>> @@ -80,12 +81,13 @@
>>> </PrecompiledHeader>
>>> <WarningLevel>Level3</WarningLevel>
>>> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
>>> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>>> </ClCompile>
>>> <ResourceCompile>
>>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>> </ResourceCompile>
>>> <Link>
>>> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>>> <GenerateDebugInformation>true</GenerateDebugInformation>
>>> <SubSystem>Console</SubSystem>
>>> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
>>> index 25786f6..66241b4 100644
>>> --- a/src/openvpn/options.c
>>> +++ b/src/openvpn/options.c
>>> @@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
>>> {
>>> int i, j;
>>>
>>> -#ifdef WIN32
>>> - /*
>>> - * Windows replaces Unicode characters in argv[] that are not present
>>> - * in the current codepage with '?'. Get the wide char command line and
>>> - * convert it to UTF-8 ourselves.
>>> - */
>>> - int wargc;
>>> - WCHAR **wargv;
>>> - char **uargv;
>>> -
>>> - wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
>>> - if (wargv == NULL || wargc != argc)
>>> - usage ();
>>> -
>>> - uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
>>> -
>>> - for (i = 0; i < wargc; i++)
>>> - {
>>> - int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
>>> - uargv[i] = gc_malloc (n, false, &options->gc);
>>> - WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, NULL);
>>> - }
>>> -
>>> - LocalFree (wargv);
>>> - argv = uargv;
>>> -#endif
>>> -
>>> /* usage message */
>>> if (argc <= 1)
>>> usage ();
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 9:18 ` Heiko Hund
@ 2012-04-27 11:15 `
2012-04-27 11:55 `
1 sibling, 0 replies; 37+ messages in thread
From: @ 2012-04-27 11:15 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel@lists.sourceforge.net
> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>> Anyways, I cross-compiled latest "master" with this patch applied and
>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>> install. The old "bin" directory was renamed to make sure none of it was
>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>> file to point to these files using Notepad (and later Wordpad).
> Notepad saves UTF-8 files with BOM, which is very uncommon. Maybe that was the
> problem. I ran into that when I was testing my patch. You might want to try
> using Notepad++ and save it as UTF-8 without BOM.
>
> HTH
> Heiko
I'll give Notepad++ a try, thanks!
Samuli
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 11:13 `
@ 2012-04-27 11:24 ` Alon Bar-Lev
0 siblings, 0 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-04-27 11:24 UTC (permalink / raw)
Cc: openvpn-devel@lists.sourceforge.net
Hello,
Here is a simple program that will make it easier for you....
The file in ca and pkcs12 parameters is found when using Hebrew.
Alon.
---
#include <Windows.h>
int main(void) {
WCHAR cmdline[] =
L"s:\\Temp\\openvpn\\build-win32\\src\\openvpn\\.libs\\openvpn.exe
--dev tap --tls-client --ca c:\\temp\\עברית\\ניסוי.txt --pkcs12
c:\\temp\\עברית\\ניסוי.txt";
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
CreateProcessW(
NULL,
cmdline,
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi
);
return 0;
}
---
2012/4/27 Samuli Seppänen <samuli@...515...>:
>
>> Hello Samuli,
>>
>> Curios: Did you manage to get it work using master without my patch?
>
> Nope, although I only tested it briefly. I'll try that again just in case.
>
>> If not, to make it easy...
>>
>> Use Windows Explorer and rename the key file to something non-ascii.
>> Then open openvpn configuration using UTF-8 editor and modify key file there.
>> This should work, as we do not use unicode/conversion command-line.
>>
>> Next step would be to remove the key from configuration and use it in
>> command-line.
>>
>> Alon.
>
> Thanks, I'll try that.
>
> Samuli
>
>>
>> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>>> Hi,
>>>
>>> As promised in yesterday's IRC meeting (summary coming today), I tested
>>> this patch on Windows 7 (64-bit). So far I've had no luck, but don't
>>> think the problems have anything to do with this patch.
>>>
>>> Anyways, I cross-compiled latest "master" with this patch applied and
>>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>>> install. The old "bin" directory was renamed to make sure none of it was
>>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>>> file to point to these files using Notepad (and later Wordpad).
>>>
>>> OpenVPN-GUI (Heiko's new version) detected the configuration file
>>> properly, showing "ääliö" as one available connection option. However,
>>> it output the following when trying to connect:
>>>
>>> Options error: --tls-auth fails with 'ääliö.key': No such file or
>>> directory
>>>
>>> Git Bash showed the file as ??li?.key, which could mean Windows Explorer
>>> is using a single-byte character set.
>>>
>>> Windows command prompt shows the characters properly, but issuing
>>> "openvpn --config ääliö.ovpn" gives the same error as OpenVPN-GUI above,
>>> except that 'ääliö.key' shows faulty glyphs[1]. This also triggers an
>>> interesting bug in the command prompt[2]
>>>
>>> Anyways, as the Windows 7 install is English-language, I suspect it's
>>> using a single-byte character set instead of UCS-2. I'll continue
>>> debugging, but any pointers are obviously much appreciated!
>>>
>>> Samuli
>>>
>>> [1] <http://users.utu.fi/sjsepp/cmd.png>
>>> [2] Typing an "ä" or "ö" moves the (invisible) cursor forward one
>>> character, but each backspace will delete two characters instead of one.
>>> This does not happen until openvpn has been (unsuccessfully) started.
>>>
>>>
>>>> Discussed at [1].
>>>>
>>>> Use wmain under windows, drop the custom parsing and shell32 linkage.
>>>>
>>>> There is no need for gc magic as this allocation is static.
>>>>
>>>> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>>>>
>>>> Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
>>>> ---
>>>> src/openvpn/Makefile.am | 6 +++++-
>>>> src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
>>>> src/openvpn/openvpn.vcxproj | 10 ++++++----
>>>> src/openvpn/options.c | 27 ---------------------------
>>>> 4 files changed, 47 insertions(+), 33 deletions(-)
>>>> mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
>>>>
>>>> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am
>>>> index 4e485e7..0506b11 100644
>>>> --- a/src/openvpn/Makefile.am
>>>> +++ b/src/openvpn/Makefile.am
>>>> @@ -27,6 +27,10 @@ AM_CFLAGS = \
>>>> $(OPTIONAL_CRYPTO_CFLAGS) \
>>>> $(OPTIONAL_LZO_CFLAGS) \
>>>> $(OPTIONAL_PKCS11_HELPER_CFLAGS)
>>>> +if WIN32
>>>> +# we want unicode entry point but not the macro
>>>> +AM_CFLAGS += -municode -UUNICODE
>>>> +endif
>>>>
>>>> sbin_PROGRAMS = openvpn
>>>>
>>>> @@ -118,5 +122,5 @@ openvpn_LDADD = \
>>>> $(OPTIONAL_DL_LIBS)
>>>> if WIN32
>>>> openvpn_SOURCES += openvpn_win32_resources.rc
>>>> -openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lshell32
>>>> +openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm
>>>> endif
>>>> diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
>>>> index 3db1b86..6e70a58 100644
>>>> --- a/src/openvpn/openvpn.c
>>>> +++ b/src/openvpn/openvpn.c
>>>> @@ -127,8 +127,9 @@ tunnel_point_to_point (struct context *c)
>>>> * @param argc - Commandline argument count.
>>>> * @param argv - Commandline argument values.
>>>> */
>>>> +static
>>>> int
>>>> -main (int argc, char *argv[])
>>>> +openvpn_main (int argc, char *argv[])
>>>> {
>>>> struct context c;
>>>>
>>>> @@ -289,3 +290,37 @@ main (int argc, char *argv[])
>>>> openvpn_exit (OPENVPN_EXIT_STATUS_GOOD); /* exit point */
>>>> return 0; /* NOTREACHED */
>>>> }
>>>> +
>>>> +#ifdef WIN32
>>>> +int
>>>> +wmain (int argc, wchar_t *wargv[]) {
>>>> + char **argv;
>>>> + int ret;
>>>> + int i;
>>>> +
>>>> + if ((argv = calloc(argc+1, sizeof(char*))) == NULL)
>>>> + return 1;
>>>> +
>>>> + for (i = 0; i < argc; i++)
>>>> + {
>>>> + int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
>>>> + argv[i] = malloc (n);
>>>> + WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, argv[i], n, NULL, NULL);
>>>> + }
>>>> +
>>>> + ret = openvpn_main(argc, argv);
>>>> +
>>>> + for (i=0; i < argc; i++ )
>>>> + {
>>>> + free (argv[i]);
>>>> + }
>>>> + free(argv);
>>>> +
>>>> + return ret;
>>>> +}
>>>> +#else
>>>> +int
>>>> +main (int argc, char *argv[]) {
>>>> + return openvpn_main(argc, argv);
>>>> +}
>>>> +#endif
>>>> diff --git a/src/openvpn/openvpn.vcxproj b/src/openvpn/openvpn.vcxproj
>>>> old mode 100644
>>>> new mode 100755
>>>> index 51e19af..452876f
>>>> --- a/src/openvpn/openvpn.vcxproj
>>>> +++ b/src/openvpn/openvpn.vcxproj
>>>> @@ -18,12 +18,12 @@
>>>> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
>>>> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
>>>> <ConfigurationType>Application</ConfigurationType>
>>>> - <CharacterSet>MultiByte</CharacterSet>
>>>> <WholeProgramOptimization>true</WholeProgramOptimization>
>>>> + <CharacterSet>Unicode</CharacterSet>
>>>> </PropertyGroup>
>>>> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
>>>> <ConfigurationType>Application</ConfigurationType>
>>>> - <CharacterSet>MultiByte</CharacterSet>
>>>> + <CharacterSet>Unicode</CharacterSet>
>>>> </PropertyGroup>
>>>> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
>>>> <ImportGroup Label="ExtensionSettings">
>>>> @@ -56,12 +56,13 @@
>>>> </PrecompiledHeader>
>>>> <WarningLevel>Level3</WarningLevel>
>>>> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
>>>> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>>>> </ClCompile>
>>>> <ResourceCompile>
>>>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>>> </ResourceCompile>
>>>> <Link>
>>>> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>>>> <GenerateDebugInformation>true</GenerateDebugInformation>
>>>> <SubSystem>Console</SubSystem>
>>>> @@ -80,12 +81,13 @@
>>>> </PrecompiledHeader>
>>>> <WarningLevel>Level3</WarningLevel>
>>>> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
>>>> + <UndefinePreprocessorDefinitions>UNICODE</UndefinePreprocessorDefinitions>
>>>> </ClCompile>
>>>> <ResourceCompile>
>>>> <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
>>>> </ResourceCompile>
>>>> <Link>
>>>> - <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>> + <AdditionalDependencies>libeay32.lib;ssleay32.lib;lzo2.lib;pkcs11-helper.dll.lib;gdi32.lib;ws2_32.lib;wininet.lib;crypt32.lib;iphlpapi.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
>>>> <AdditionalLibraryDirectories>$(OPENSSL_HOME)/lib;$(LZO_HOME)/lib;$(PKCS11H_HOME)/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
>>>> <GenerateDebugInformation>true</GenerateDebugInformation>
>>>> <SubSystem>Console</SubSystem>
>>>> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
>>>> index 25786f6..66241b4 100644
>>>> --- a/src/openvpn/options.c
>>>> +++ b/src/openvpn/options.c
>>>> @@ -3832,33 +3832,6 @@ parse_argv (struct options *options,
>>>> {
>>>> int i, j;
>>>>
>>>> -#ifdef WIN32
>>>> - /*
>>>> - * Windows replaces Unicode characters in argv[] that are not present
>>>> - * in the current codepage with '?'. Get the wide char command line and
>>>> - * convert it to UTF-8 ourselves.
>>>> - */
>>>> - int wargc;
>>>> - WCHAR **wargv;
>>>> - char **uargv;
>>>> -
>>>> - wargv = CommandLineToArgvW (GetCommandLineW (), &wargc);
>>>> - if (wargv == NULL || wargc != argc)
>>>> - usage ();
>>>> -
>>>> - uargv = gc_malloc (wargc * sizeof (*uargv), false, &options->gc);
>>>> -
>>>> - for (i = 0; i < wargc; i++)
>>>> - {
>>>> - int n = WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL);
>>>> - uargv[i] = gc_malloc (n, false, &options->gc);
>>>> - WideCharToMultiByte (CP_UTF8, 0, wargv[i], -1, uargv[i], n, NULL, NULL);
>>>> - }
>>>> -
>>>> - LocalFree (wargv);
>>>> - argv = uargv;
>>>> -#endif
>>>> -
>>>> /* usage message */
>>>> if (argc <= 1)
>>>> usage ();
>
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 9:18 ` Heiko Hund
2012-04-27 11:15 `
@ 2012-04-27 11:55 `
2012-04-27 11:59 `
2012-04-27 12:15 ` Alon Bar-Lev
1 sibling, 2 replies; 37+ messages in thread
From: @ 2012-04-27 11:55 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel@lists.sourceforge.net
Il 27.04.2012 12:18, Heiko Hund ha scritto:
> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>> Anyways, I cross-compiled latest "master" with this patch applied and
>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>> install. The old "bin" directory was renamed to make sure none of it was
>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>> file to point to these files using Notepad (and later Wordpad).
> Notepad saves UTF-8 files with BOM, which is very uncommon. Maybe that was the
> problem. I ran into that when I was testing my patch. You might want to try
> using Notepad++ and save it as UTF-8 without BOM.
>
> HTH
> Heiko
Saved the configuration file to UTF-8 without BOM - after this I got no
complaints from OpenVPN-GUI. Launching OpenVPN from the command prompt
also worked... tls-auth was undefined in the config, and openvpn called
like this:
> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
Only minor issue was that the command prompt displayed funky characters
instead of the proper ones:
<http://users.utu.fi/sjsepp/cmd2.png>
Thanks for the tip, Heiko!
--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc
irc freenode net: mattock
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 11:55 `
@ 2012-04-27 11:59 `
2012-04-27 12:15 ` Alon Bar-Lev
1 sibling, 0 replies; 37+ messages in thread
From: @ 2012-04-27 11:59 UTC (permalink / raw)
To: Heiko Hund <heiko.hund@; +Cc: openvpn-devel@lists.sourceforge.net
> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>> Anyways, I cross-compiled latest "master" with this patch applied and
>>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>>> install. The old "bin" directory was renamed to make sure none of it was
>>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>>> file to point to these files using Notepad (and later Wordpad).
>> Notepad saves UTF-8 files with BOM, which is very uncommon. Maybe that was the
>> problem. I ran into that when I was testing my patch. You might want to try
>> using Notepad++ and save it as UTF-8 without BOM.
>>
>> HTH
>> Heiko
> Saved the configuration file to UTF-8 without BOM - after this I got no
> complaints from OpenVPN-GUI. Launching OpenVPN from the command prompt
> also worked... tls-auth was undefined in the config, and openvpn called
> like this:
>
>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
> Only minor issue was that the command prompt displayed funky characters
> instead of the proper ones:
>
> <http://users.utu.fi/sjsepp/cmd2.png>
>
> Thanks for the tip, Heiko!
>
OpenVPN 2.3-alpha1 also behaves in the exactly same way. Is that to be
expected?
--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc
irc freenode net: mattock
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 11:55 `
2012-04-27 11:59 `
@ 2012-04-27 12:15 ` Alon Bar-Lev
2012-05-02 9:18 ` Alon Bar-Lev
2012-05-03 7:26 ` David Sommerseth
1 sibling, 2 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-04-27 12:15 UTC (permalink / raw)
Cc: openvpn-devel@lists.sourceforge.net
2012/4/27 Samuli Seppänen <samuli@...515...>:
> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>> Anyways, I cross-compiled latest "master" with this patch applied and
>>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>>> install. The old "bin" directory was renamed to make sure none of it was
>>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>>> file to point to these files using Notepad (and later Wordpad).
>> Notepad saves UTF-8 files with BOM, which is very uncommon. Maybe that was the
>> problem. I ran into that when I was testing my patch. You might want to try
>> using Notepad++ and save it as UTF-8 without BOM.
>>
>> HTH
>> Heiko
> Saved the configuration file to UTF-8 without BOM - after this I got no
> complaints from OpenVPN-GUI. Launching OpenVPN from the command prompt
> also worked... tls-auth was undefined in the config, and openvpn called
> like this:
if bom is a problem we should handle it properly in options.c, as we
cannot expect users to understand bom issues.
>
>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
>
> Only minor issue was that the command prompt displayed funky characters
> instead of the proper ones:
>
> <http://users.utu.fi/sjsepp/cmd2.png>
Yes. this is OK.
Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 12:15 ` Alon Bar-Lev
@ 2012-05-02 9:18 ` Alon Bar-Lev
2012-05-03 7:26 ` David Sommerseth
1 sibling, 0 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-05-02 9:18 UTC (permalink / raw)
Cc: openvpn-devel@lists.sourceforge.net
News?
On Fri, Apr 27, 2012 at 3:15 PM, Alon Bar-Lev <alon.barlev@...277...> wrote:
> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>>> Anyways, I cross-compiled latest "master" with this patch applied and
>>>> "bin" and "lib" directories on top of an existing openvpn-2.3-alpha1
>>>> install. The old "bin" directory was renamed to make sure none of it was
>>>> used. I then renamed "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to
>>>> "ääliö.key" using Windows Explorer. Then I updated the configuration
>>>> file to point to these files using Notepad (and later Wordpad).
>>> Notepad saves UTF-8 files with BOM, which is very uncommon. Maybe that was the
>>> problem. I ran into that when I was testing my patch. You might want to try
>>> using Notepad++ and save it as UTF-8 without BOM.
>>>
>>> HTH
>>> Heiko
>> Saved the configuration file to UTF-8 without BOM - after this I got no
>> complaints from OpenVPN-GUI. Launching OpenVPN from the command prompt
>> also worked... tls-auth was undefined in the config, and openvpn called
>> like this:
>
> if bom is a problem we should handle it properly in options.c, as we
> cannot expect users to understand bom issues.
>
>>
>>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
>>
>> Only minor issue was that the command prompt displayed funky characters
>> instead of the proper ones:
>>
>> <http://users.utu.fi/sjsepp/cmd2.png>
>
> Yes. this is OK.
>
> Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-04-27 12:15 ` Alon Bar-Lev
2012-05-02 9:18 ` Alon Bar-Lev
@ 2012-05-03 7:26 ` David Sommerseth
2012-05-03 7:41 ` Alon Bar-Lev
1 sibling, 1 reply; 37+ messages in thread
From: David Sommerseth @ 2012-05-03 7:26 UTC (permalink / raw)
To: Alon Bar-Lev <alon.barlev@; +Cc: openvpn-devel@lists.sourceforge.net
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 27/04/12 14:15, Alon Bar-Lev wrote:
> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>>> Anyways, I cross-compiled latest "master" with this patch
>>>> applied and "bin" and "lib" directories on top of an existing
>>>> openvpn-2.3-alpha1 install. The old "bin" directory was
>>>> renamed to make sure none of it was used. I then renamed
>>>> "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to "ääliö.key"
>>>> using Windows Explorer. Then I updated the configuration file
>>>> to point to these files using Notepad (and later Wordpad).
>>> Notepad saves UTF-8 files with BOM, which is very uncommon.
>>> Maybe that was the problem. I ran into that when I was testing
>>> my patch. You might want to try using Notepad++ and save it as
>>> UTF-8 without BOM.
>>>
>>> HTH Heiko
>> Saved the configuration file to UTF-8 without BOM - after this I
>> got no complaints from OpenVPN-GUI. Launching OpenVPN from the
>> command prompt also worked... tls-auth was undefined in the
>> config, and openvpn called like this:
>
> if bom is a problem we should handle it properly in options.c, as
> we cannot expect users to understand bom issues.
>
>>
>>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
>>
>> Only minor issue was that the command prompt displayed funky
>> characters instead of the proper ones:
>>
>> <http://users.utu.fi/sjsepp/cmd2.png>
>
> Yes. this is OK.
Just so that I understand this more properly. The reason this is
okay, is that because cmd.exe is not UTF-8 capable when displaying the
log data?
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEUEARECAAYFAk+iMy8ACgkQDC186MBRfrp8LACeNRzTrcdd8JWyzTEJ3B5Kv1ye
iFsAmNM0T3LgxrlJeg3I+7F1aoMSqpw=
=PhBy
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-05-03 7:26 ` David Sommerseth
@ 2012-05-03 7:41 ` Alon Bar-Lev
2012-05-03 10:53 `
0 siblings, 1 reply; 37+ messages in thread
From: Alon Bar-Lev @ 2012-05-03 7:41 UTC (permalink / raw)
To: David Sommerseth <openvpn.list@; +Cc: openvpn-devel@lists.sourceforge.net
On Thu, May 3, 2012 at 10:26 AM, David Sommerseth
<openvpn.list@...1114...> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 27/04/12 14:15, Alon Bar-Lev wrote:
> > 2012/4/27 Samuli Seppänen <samuli@...515...>:
> >> Il 27.04.2012 12:18, Heiko Hund ha scritto:
> >>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
> >>>> Anyways, I cross-compiled latest "master" with this patch
> >>>> applied and "bin" and "lib" directories on top of an existing
> >>>> openvpn-2.3-alpha1 install. The old "bin" directory was
> >>>> renamed to make sure none of it was used. I then renamed
> >>>> "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to "ääliö.key"
> >>>> using Windows Explorer. Then I updated the configuration file
> >>>> to point to these files using Notepad (and later Wordpad).
> >>> Notepad saves UTF-8 files with BOM, which is very uncommon.
> >>> Maybe that was the problem. I ran into that when I was testing
> >>> my patch. You might want to try using Notepad++ and save it as
> >>> UTF-8 without BOM.
> >>>
> >>> HTH Heiko
> >> Saved the configuration file to UTF-8 without BOM - after this I
> >> got no complaints from OpenVPN-GUI. Launching OpenVPN from the
> >> command prompt also worked... tls-auth was undefined in the
> >> config, and openvpn called like this:
> >
> > if bom is a problem we should handle it properly in options.c, as
> > we cannot expect users to understand bom issues.
> >
> >>
> >>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
> >>
> >> Only minor issue was that the command prompt displayed funky
> >> characters instead of the proper ones:
> >>
> >> <http://users.utu.fi/sjsepp/cmd2.png>
> >
> > Yes. this is OK.
>
> Just so that I understand this more properly. The reason this is
> okay, is that because cmd.exe is not UTF-8 capable when displaying the
> log data?
Yes.
The cmd uses the plain old DOS code page, and needs special fonts.
If you add --log parameter you will see this correctly.
Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-05-03 7:41 ` Alon Bar-Lev
@ 2012-05-03 10:53 `
2012-05-03 17:47 ` Alon Bar-Lev
0 siblings, 1 reply; 37+ messages in thread
From: @ 2012-05-03 10:53 UTC (permalink / raw)
To: Alon Bar-Lev <alon.barlev@; +Cc: James Yonan <james@
> On Thu, May 3, 2012 at 10:26 AM, David Sommerseth
> <openvpn.list@...1114...> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 27/04/12 14:15, Alon Bar-Lev wrote:
>>> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>>>> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>>>>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>>>>> Anyways, I cross-compiled latest "master" with this patch
>>>>>> applied and "bin" and "lib" directories on top of an existing
>>>>>> openvpn-2.3-alpha1 install. The old "bin" directory was
>>>>>> renamed to make sure none of it was used. I then renamed
>>>>>> "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to "ääliö.key"
>>>>>> using Windows Explorer. Then I updated the configuration file
>>>>>> to point to these files using Notepad (and later Wordpad).
>>>>> Notepad saves UTF-8 files with BOM, which is very uncommon.
>>>>> Maybe that was the problem. I ran into that when I was testing
>>>>> my patch. You might want to try using Notepad++ and save it as
>>>>> UTF-8 without BOM.
>>>>>
>>>>> HTH Heiko
>>>> Saved the configuration file to UTF-8 without BOM - after this I
>>>> got no complaints from OpenVPN-GUI. Launching OpenVPN from the
>>>> command prompt also worked... tls-auth was undefined in the
>>>> config, and openvpn called like this:
>>> if bom is a problem we should handle it properly in options.c, as
>>> we cannot expect users to understand bom issues.
>>>
>>>>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
>>>> Only minor issue was that the command prompt displayed funky
>>>> characters instead of the proper ones:
>>>>
>>>> <http://users.utu.fi/sjsepp/cmd2.png>
>>> Yes. this is OK.
>> Just so that I understand this more properly. The reason this is
>> okay, is that because cmd.exe is not UTF-8 capable when displaying the
>> log data?
> Yes.
> The cmd uses the plain old DOS code page, and needs special fonts.
> If you add --log parameter you will see this correctly.
>
> Alon.
>
Tested with --log parameter. The logfile[1] seems to use the UTF-8
encoding, and with proper viewers/editors the Scandinavian characters
(a/o umlauts, ä/ö) look just fine. On Windows most editors/viewers[3]
display funky two-byte characters, but that's probably expected.
[1] An example log file is available here, search for "tls_auth_file":
<http://users.utu.fi/sjsepp/openvpn-log.txt>
[2] E.g. less and vi (in Git Bash), Wordpad, etc.
--
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc
irc freenode net: mattock
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-05-03 10:53 `
@ 2012-05-03 17:47 ` Alon Bar-Lev
2012-06-26 10:20 ` Alon Bar-Lev
0 siblings, 1 reply; 37+ messages in thread
From: Alon Bar-Lev @ 2012-05-03 17:47 UTC (permalink / raw)
Cc: James Yonan <james@
On Thu, May 3, 2012 at 1:53 PM, Samuli Seppänen <samuli@...515...> wrote:
>
>> On Thu, May 3, 2012 at 10:26 AM, David Sommerseth
>> <openvpn.list@...1114...> wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> On 27/04/12 14:15, Alon Bar-Lev wrote:
>>>> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>>>>> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>>>>>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>>>>>> Anyways, I cross-compiled latest "master" with this patch
>>>>>>> applied and "bin" and "lib" directories on top of an existing
>>>>>>> openvpn-2.3-alpha1 install. The old "bin" directory was
>>>>>>> renamed to make sure none of it was used. I then renamed
>>>>>>> "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to "ääliö.key"
>>>>>>> using Windows Explorer. Then I updated the configuration file
>>>>>>> to point to these files using Notepad (and later Wordpad).
>>>>>> Notepad saves UTF-8 files with BOM, which is very uncommon.
>>>>>> Maybe that was the problem. I ran into that when I was testing
>>>>>> my patch. You might want to try using Notepad++ and save it as
>>>>>> UTF-8 without BOM.
>>>>>>
>>>>>> HTH Heiko
>>>>> Saved the configuration file to UTF-8 without BOM - after this I
>>>>> got no complaints from OpenVPN-GUI. Launching OpenVPN from the
>>>>> command prompt also worked... tls-auth was undefined in the
>>>>> config, and openvpn called like this:
>>>> if bom is a problem we should handle it properly in options.c, as
>>>> we cannot expect users to understand bom issues.
>>>>
>>>>>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
>>>>> Only minor issue was that the command prompt displayed funky
>>>>> characters instead of the proper ones:
>>>>>
>>>>> <http://users.utu.fi/sjsepp/cmd2.png>
>>>> Yes. this is OK.
>>> Just so that I understand this more properly. The reason this is
>>> okay, is that because cmd.exe is not UTF-8 capable when displaying the
>>> log data?
>> Yes.
>> The cmd uses the plain old DOS code page, and needs special fonts.
>> If you add --log parameter you will see this correctly.
>>
>> Alon.
>>
> Tested with --log parameter. The logfile[1] seems to use the UTF-8
> encoding, and with proper viewers/editors the Scandinavian characters
> (a/o umlauts, ä/ö) look just fine. On Windows most editors/viewers[3]
> display funky two-byte characters, but that's probably expected.
>
> [1] An example log file is available here, search for "tls_auth_file":
> <http://users.utu.fi/sjsepp/openvpn-log.txt>
> [2] E.g. less and vi (in Git Bash), Wordpad, etc.
>
So I guess now we are good.
Is anything else missing?
Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-05-03 17:47 ` Alon Bar-Lev
@ 2012-06-26 10:20 ` Alon Bar-Lev
0 siblings, 0 replies; 37+ messages in thread
From: Alon Bar-Lev @ 2012-06-26 10:20 UTC (permalink / raw)
Cc: openvpn-devel@lists.sourceforge.net
Please apply.
https://github.com/alonbl/openvpn/compare/master...unicode
On Thu, May 3, 2012 at 8:47 PM, Alon Bar-Lev <alon.barlev@...277...> wrote:
> On Thu, May 3, 2012 at 1:53 PM, Samuli Seppänen <samuli@...515...> wrote:
>>
>>> On Thu, May 3, 2012 at 10:26 AM, David Sommerseth
>>> <openvpn.list@...1114...> wrote:
>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>> Hash: SHA1
>>>>
>>>> On 27/04/12 14:15, Alon Bar-Lev wrote:
>>>>> 2012/4/27 Samuli Seppänen <samuli@...515...>:
>>>>>> Il 27.04.2012 12:18, Heiko Hund ha scritto:
>>>>>>> On Friday 27 April 2012 09:54:15 Samuli Seppänen wrote:
>>>>>>>> Anyways, I cross-compiled latest "master" with this patch
>>>>>>>> applied and "bin" and "lib" directories on top of an existing
>>>>>>>> openvpn-2.3-alpha1 install. The old "bin" directory was
>>>>>>>> renamed to make sure none of it was used. I then renamed
>>>>>>>> "openvpn.ovpn" to "ääliö.ovpn" and "ta.key" to "ääliö.key"
>>>>>>>> using Windows Explorer. Then I updated the configuration file
>>>>>>>> to point to these files using Notepad (and later Wordpad).
>>>>>>> Notepad saves UTF-8 files with BOM, which is very uncommon.
>>>>>>> Maybe that was the problem. I ran into that when I was testing
>>>>>>> my patch. You might want to try using Notepad++ and save it as
>>>>>>> UTF-8 without BOM.
>>>>>>>
>>>>>>> HTH Heiko
>>>>>> Saved the configuration file to UTF-8 without BOM - after this I
>>>>>> got no complaints from OpenVPN-GUI. Launching OpenVPN from the
>>>>>> command prompt also worked... tls-auth was undefined in the
>>>>>> config, and openvpn called like this:
>>>>> if bom is a problem we should handle it properly in options.c, as
>>>>> we cannot expect users to understand bom issues.
>>>>>
>>>>>>> openvpn --config ääliö.ovpn --tls-auth ääliö.key 1
>>>>>> Only minor issue was that the command prompt displayed funky
>>>>>> characters instead of the proper ones:
>>>>>>
>>>>>> <http://users.utu.fi/sjsepp/cmd2.png>
>>>>> Yes. this is OK.
>>>> Just so that I understand this more properly. The reason this is
>>>> okay, is that because cmd.exe is not UTF-8 capable when displaying the
>>>> log data?
>>> Yes.
>>> The cmd uses the plain old DOS code page, and needs special fonts.
>>> If you add --log parameter you will see this correctly.
>>>
>>> Alon.
>>>
>> Tested with --log parameter. The logfile[1] seems to use the UTF-8
>> encoding, and with proper viewers/editors the Scandinavian characters
>> (a/o umlauts, ä/ö) look just fine. On Windows most editors/viewers[3]
>> display funky two-byte characters, but that's probably expected.
>>
>> [1] An example log file is available here, search for "tls_auth_file":
>> <http://users.utu.fi/sjsepp/openvpn-log.txt>
>> [2] E.g. less and vi (in Git Bash), Wordpad, etc.
>>
>
> So I guess now we are good.
> Is anything else missing?
>
> Alon.
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
2012-03-24 20:31 ` [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest Alon Bar-Lev
2012-04-02 11:39 ` Alon Bar-Lev
2012-04-27 8:54 `
@ 2012-06-29 8:11 ` David Sommerseth
2 siblings, 0 replies; 37+ messages in thread
From: David Sommerseth @ 2012-06-29 8:11 UTC (permalink / raw)
To: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]
On 24/03/12 21:31, Alon Bar-Lev wrote:
> Discussed at [1].
>
> Use wmain under windows, drop the custom parsing and shell32 linkage.
>
> There is no need for gc magic as this allocation is static.
>
> [1] http://permalink.gmane.org/gmane.network.openvpn.devel/5433
>
> Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
> ---
> src/openvpn/Makefile.am | 6 +++++-
> src/openvpn/openvpn.c | 37 ++++++++++++++++++++++++++++++++++++-
> src/openvpn/openvpn.vcxproj | 10 ++++++----
> src/openvpn/options.c | 27 ---------------------------
> 4 files changed, 47 insertions(+), 33 deletions(-)
> mode change 100644 => 100755 src/openvpn/openvpn.vcxproj
This patch has been applied to master through lazy consensus.
The patch has been tested and seems to work perfectly fine, and it have
been discussed in a developers meeting as a reasonable patch to include.
Thus no reason to delay inclusion any longer.
commit 74370aa89df9285a95084616e9c2d3c8464760b9
Author: Alon Bar-Lev <alon.barlev@...277...>
Date: Sat Mar 24 22:31:10 2012 +0200
cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest
Signed-off-by: Alon Bar-Lev <alon.barlev@...277...>
Message-Id: 1332621070-28464-1-git-send-email-alon.barlev@...277...
URL: http://article.gmane.org/gmane.network.openvpn.devel/6063
Tested-by: Samuli Seppänen <samuli@...515...>
Signed-off-by: David Sommerseth <davids@...1347...>
kind regards,
David Sommerseth
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2012-06-29 8:11 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-16 17:30 [Openvpn-devel] MSVC fixes Heiko Hund
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 1/4] replace check for TARGET_WIN32 with WIN32 Heiko Hund
2012-02-16 18:23 ` Gert Doering
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 2/4] do not use mode_t on Windows Heiko Hund
2012-02-16 18:26 ` Gert Doering
2012-02-16 18:34 ` Alon Bar-Lev
2012-02-17 9:39 ` Heiko Hund
2012-02-17 9:56 ` Alon Bar-Lev
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 3/4] use the underscore version of stat " Heiko Hund
2012-02-16 18:29 ` Gert Doering
2012-02-16 18:47 ` [Openvpn-devel] [PATCH v2] " David Sommerseth
2012-02-16 18:51 ` Gert Doering
2012-02-16 18:53 ` Alon Bar-Lev
2012-02-16 17:30 ` [Openvpn-devel] [PATCH 4/4] make MSVC link against shell32 as well Heiko Hund
2012-02-16 17:47 ` Gert Doering
2012-02-16 18:37 ` Alon Bar-Lev
2012-02-17 9:51 ` Heiko Hund
2012-02-17 9:55 ` Alon Bar-Lev
2012-03-24 20:31 ` [Openvpn-devel] [PATCH] cleanup: windows: convert argv (UCS-2 to UTF-8) at earliest Alon Bar-Lev
2012-04-02 11:39 ` Alon Bar-Lev
2012-04-27 8:54 `
2012-04-27 8:59 ` Alon Bar-Lev
2012-04-27 11:13 `
2012-04-27 11:24 ` Alon Bar-Lev
2012-04-27 9:18 ` Heiko Hund
2012-04-27 11:15 `
2012-04-27 11:55 `
2012-04-27 11:59 `
2012-04-27 12:15 ` Alon Bar-Lev
2012-05-02 9:18 ` Alon Bar-Lev
2012-05-03 7:26 ` David Sommerseth
2012-05-03 7:41 ` Alon Bar-Lev
2012-05-03 10:53 `
2012-05-03 17:47 ` Alon Bar-Lev
2012-06-26 10:20 ` Alon Bar-Lev
2012-06-29 8:11 ` David Sommerseth
2012-02-17 10:14 ` [Openvpn-devel] MSVC fixes David Sommerseth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.