From: Heiko H. <hei...@so...> - 2012-02-16 17:31:08
|
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 |
From: Heiko H. <hei...@so...> - 2012-02-16 17:31:08
|
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 <hei...@so...> --- 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 |
From: Gert D. <ge...@gr...> - 2012-02-16 18:24:04
|
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 ge...@gr... fax: +49-89-35655025 ge...@ne... |
From: Heiko H. <hei...@so...> - 2012-02-16 17:31:30
|
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 <hei...@so...> --- 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 |
From: Gert D. <ge...@gr...> - 2012-02-16 18:26:32
|
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 ge...@gr... fax: +49-89-35655025 ge...@ne... |
From: Heiko H. <hei...@so...> - 2012-02-16 17:31:31
|
Windows API CommandLineToArgvW(), introduced in Windows unicode path commit 71bbbd76c62630c88441237d72fe5b61f0b45b2a, is defined therein. Signed-off-by: Heiko Hund <hei...@so...> --- 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 |
From: Gert D. <ge...@gr...> - 2012-02-16 17:48:09
|
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 <hei...@so...> 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 ge...@gr... fax: +49-89-35655025 ge...@ne... |
From: Heiko H. <hei...@so...> - 2012-02-16 17:31:29
|
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 <hei...@so...> --- 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 |
From: Gert D. <ge...@gr...> - 2012-02-16 18:29:23
|
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 ge...@gr... fax: +49-89-35655025 ge...@ne... |
From: David S. <da...@re...> - 2012-02-16 18:47:51
|
From: Heiko Hund <hei...@so...> 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 <hei...@so...> Signed-off-by: David Sommerseth <da...@re...> --- 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 |
From: Gert D. <ge...@gr...> - 2012-02-16 18:51:39
|
Hi, On Thu, Feb 16, 2012 at 07:47:25PM +0100, David Sommerseth wrote: > From: Heiko Hund <hei...@so...> > > 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 <hei...@so...> > Signed-off-by: David Sommerseth <da...@re...> ACK! gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany ge...@gr... fax: +49-89-35655025 ge...@ne... |
From: Alon Bar-L. <alo...@gm...> - 2012-02-16 18:53:55
|
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 <da...@re...> wrote: > From: Heiko Hund <hei...@so...> > > 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 <hei...@so...> > Signed-off-by: David Sommerseth <da...@re...> > --- > 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 > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openvpn-devel |
From: Alon Bar-L. <alo...@gm...> - 2012-02-16 18:34:46
|
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 <hei...@so...> 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 <hei...@so...> > --- > 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 > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openvpn-devel |
From: Alon Bar-L. <alo...@gm...> - 2012-02-16 18:37:33
|
On Thu, Feb 16, 2012 at 7:30 PM, Heiko Hund <hei...@so...> 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(). |
From: Heiko H. <hei...@so...> - 2012-02-17 09:39:31
|
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 |
From: Alon Bar-L. <alo...@gm...> - 2012-02-17 09:57:01
|
On Fri, Feb 17, 2012 at 11:39 AM, Heiko Hund <hei...@so...> 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. |
From: Heiko H. <hei...@so...> - 2012-02-17 09:51:24
|
Alon, On Thursday 16 February 2012 18:37:21 Alon Bar-Lev wrote: > On Thu, Feb 16, 2012 at 7:30 PM, Heiko Hund <hei...@so...> 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 |
From: Alon Bar-L. <alo...@gm...> - 2012-02-17 09:55:31
|
On Fri, Feb 17, 2012 at 11:51 AM, Heiko Hund <hei...@so...> 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 <hei...@so...> 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. |
From: Alon Bar-L. <alo...@gm...> - 2012-03-24 20:31:45
|
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 <alo...@gm...> --- 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 |
From: Alon Bar-L. <alo...@gm...> - 2012-04-02 11:39:16
|
Please review/test. On Sat, Mar 24, 2012 at 10:31 PM, Alon Bar-Lev <alo...@gm...> 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 <alo...@gm...> > --- > 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 > |
From: David S. <ope...@to...> - 2012-06-29 08:11:25
Attachments:
signature.asc
|
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 <alo...@gm...> > --- > 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 <alo...@gm...> 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 <alo...@gm...> Message-Id: 133...@gm... URL: http://article.gmane.org/gmane.network.openvpn.devel/6063 Tested-by: Samuli Seppänen <sa...@op...> Signed-off-by: David Sommerseth <da...@re...> kind regards, David Sommerseth |
From: Samuli S. <sa...@op...> - 2012-04-27 08:54:23
|
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 <alo...@gm...> > --- > 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 (); |
From: Alon Bar-L. <alo...@gm...> - 2012-04-27 08:59:21
|
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 <sa...@op...>: > 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 <alo...@gm...> >> --- >> 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 (); > |
From: Heiko H. <hei...@so...> - 2012-04-27 09:19:10
|
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 |
From: Samuli S. <sa...@op...> - 2012-04-27 11:15:39
|
> 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 |