define access mode flag X_OK as 0 on Windows
PATCH 1/1 define access mode flag X_OK as 0 on Windows
The _access and _waccess functions in Windows don't know about X_OK (1). If you pass an uneven mode flag the C runtime's default invalid parameter handler ends execution of openvpn.
--- win/config.h.in | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
win/config.h.in +1 -1
@@ -243,7 +243,7 @@ typedef unsigned long in_addr_t; #endif #ifndef X_OK -#define X_OK 1 +#define X_OK 0 #endif #ifndef F_OK
Signature · 1 line
1.7.5.4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 7 lines · Heiko Hund
The
_accessand_waccessfunctions in Windows don't know aboutX_OK(1). If you pass an uneven mode flag the C runtime's default invalid parameter handler ends execution of openvpn.Signed-off-by Heiko Hund <[email protected]...> --- win/config.h.in| 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
ACK and applied to master branch on -testing and -stable trees.
commit 4ebc587eab73e03ef64d344a5707d84e7f8d875a
Author: Heiko Hund <[email protected]...> Date: Sat Feb 18 20:44:12 2012 +0100
define access mode flag X_OK as 0 on Windows
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: David Sommerseth <[email protected]...>
Signed-off-by: David Sommerseth <[email protected]...>kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9CHC8ACgkQDC186MBRfrrHegCfUMxu2lHG4Rso8cw1qt7eLEZN OgAAn0cAwDCQKUq5MLJd6WAZJeVsdyje
=2vak
-----END PGP SIGNATURE-----
Big NAK.
This X_OK is standard define.
It exists in mingw as 1.
OpenVPN should not check execute if unsupported by OS, not changing standard constants.
Heiko,
Where exactly is the problem?
When directories are checked or script?
Correct patch would be to have a macro for execute ok in option.c which is declared differently for windows.
Alon.
Quoted 47 lines · David Sommerseth
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 7 lines · Heiko Hund
The
_accessand_waccessfunctions in Windows don't know aboutX_OK(1). If you pass an uneven mode flag the C runtime's default invalid parameter handler ends execution of openvpn.Signed-off-by Heiko Hund <[email protected]...> --- win/config.h.in| 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
ACK and applied to master branch on -testing and -stable trees.
commit
4ebc587eab73e03ef64d344a5707d84e7f8d875a
Author: Heiko Hund <[email protected]...>
Date: Sat Feb 18 20:44:12 2012 +0100define access mode flag
X_OKas 0 on WindowsSigned-off-by Heiko Hund <[email protected]...>Signed-off-by David Sommerseth <[email protected]...>kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/iEYEARECAAYFAk9CHC8ACgkQDC186MBRfrrHegCfUMxu2lHG4Rso8cw1qt7eLEZN OgAAn0cAwDCQKUq5MLJd6WAZJeVsdyje
=2vak
-----END PGP SIGNATURE-----------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Quoted 1 line · On Monday 20 February 2012 13:44:54 Alon Bar-Lev wrote:
This
X_OKis standard define.
That's true for unixoid systems, but none of the [FWRX]_OK #defines exist in the MS C runtime headers.
Quoted 1 line
It exists in mingw as 1.
Yeah, but only for legacy glue code reasons. From io.h:
----8<-------------
/* Old versions of MSVCRT access() just ignored X_OK, while the version
shipped with Vista, returns an error code. This will restore the old behaviour */
static inline int __mingw_access (const char *__fname, int __mode) {
return _access (__fname, __mode & ~X_OK);
}
#define access(__f,__m) __mingw_access (__f, __m) ----8<-------------
Quoted 3 lines
OpenVPN should not check execute if unsupported by OS, not changing standard constants.
Where exactly is the problem?
Defining them makes code more readable, but without X_OK being 0 on Windows openvpn crashes. See my commit message again and read the MSDN page about _access at http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspx
Hence the change for the MSVC buildsystem only. Mingw handles the situation internally already.
Hope that made it clear.
Heiko
Signature · 8 lines
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
Quoted 7 lines · Heiko Hund
Defining them makes code more readable, but without
X_OKbeing 0 on Windows openvpn crashes. See my commit message again and read the MSDN page about_accessat http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspx
Hence the change for the MSVC buildsystem only. Mingw handles the situation internally already.Hope that made it clear.
Yes, it is clear.
Still, it is not correct to override well defined constants. Windows is windows, it is inappropriate to have one constant value for mingw and another for msvc.
I will submit a different patch.
Alon.
PATCH 1/1 windows: do not use X_OK as it is unsupported
Reported by Heiko Hund.
Reference [1].
Replaces 4ebc587eab73e03ef64d344a5707d84e7f8d875a
[1] http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspx
--- options.c | 38 ++++++++++++++++++++++---------------- win/config.h.in | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-)
options.c +22 -16
@@ -55,6 +55,12 @@#include "memdbg.h" +#ifdef WIN32 +#define PLATFORM_X_OK 0 +#else +#define PLATFORM_X_OK X_OK +#endif +const char title_string[] =PACKAGE_STRING " " TARGET_ALIAS
@@ -2632,7 +2638,7 @@ check_file_access(const int type, const char *file, const int mode, const char *char *fullpath =strdup (file);/* POSIX dirname() implementaion may modify its arguments */ char *dirpath =dirname (fullpath); -if (openvpn_access (dirpath, mode|X_OK ) !=0 ) +if (openvpn_access (dirpath, mode|PLATFORM_X_OK ) !=0 ) errcode = errno;free (fullpath); }
@@ -2678,7 +2684,7 @@ options_postprocess_filechecks (struct options *options) "--pkcs12");if (options->ssl_flags &SSLF_CRL_VERIFY_DIR ) - errs |=check_file_access (CHKACC_FILE , options->crl_file,R_OK |X_OK , + errs |=check_file_access (CHKACC_FILE , options->crl_file,R_OK |PLATFORM_X_OK ,"--crl-verify directory" );else errs |= check_file_access (CHKACC_FILE, options->crl_file, R_OK,
@@ -2713,11 +2719,11 @@ options_postprocess_filechecks (struct options *options)/* ** System related ** */ errs |=check_file_access (CHKACC_FILE , options->chroot_dir, -R_OK |X_OK ,"--chroot directory" ); +R_OK |PLATFORM_X_OK ,"--chroot directory" ); errs |=check_file_access (CHKACC_DIRPATH |CHKACC_FILEXSTWR , options->writepid,R_OK |W_OK ,"--writepid" ); errs |=check_file_access (CHKACC_FILE , options->tmp_dir, -R_OK |W_OK |X_OK ,"Temporary directory (--tmp-dir)" ); +R_OK |W_OK |PLATFORM_X_OK ,"Temporary directory (--tmp-dir)" );/* ** Log related ** */ errs |= check_file_access (CHKACC_DIRPATH|CHKACC_FILEXSTWR, options->status_file,
@@ -2726,32 +2732,32 @@ options_postprocess_filechecks (struct options *options)/* ** Config related ** */ #ifdef USE_SSL errs |=check_file_access (CHKACC_FILE , options->tls_export_cert, -R_OK |W_OK |X_OK ,"--tls-export-cert" ); +R_OK |W_OK |PLATFORM_X_OK ,"--tls-export-cert" );#endif /* USE_SSL */ #if P2MP_SERVER errs |=check_file_access (CHKACC_FILE , options->client_config_dir, -R_OK |X_OK ,"--client-config-dir" ); +R_OK |PLATFORM_X_OK ,"--client-config-dir" );/* ** Script hooks ** */ errs |=check_file_access (CHKACC_FILE , options->client_connect_script, -R_OK |X_OK ,"--client-connect script" ); +R_OK |PLATFORM_X_OK ,"--client-connect script" ); errs |=check_file_access (CHKACC_FILE , options->client_disconnect_script, -R_OK |X_OK ,"--client-disconnect script" ); +R_OK |PLATFORM_X_OK ,"--client-disconnect script" ); errs |=check_file_access (CHKACC_FILE , options->auth_user_pass_verify_script, -R_OK |X_OK ,"--auth-user-pass-verify script" ); +R_OK |PLATFORM_X_OK ,"--auth-user-pass-verify script" ); errs |=check_file_access (CHKACC_FILE , options->tls_verify, -R_OK |X_OK ,"--tls-verify script" ); +R_OK |PLATFORM_X_OK ,"--tls-verify script" ); errs |=check_file_access (CHKACC_FILE , options->up_script, -R_OK |X_OK ,"--up script" ); +R_OK |PLATFORM_X_OK ,"--up script" ); errs |=check_file_access (CHKACC_FILE , options->down_script, -R_OK |X_OK ,"--down script" ); +R_OK |PLATFORM_X_OK ,"--down script" ); errs |=check_file_access (CHKACC_FILE , options->ipchange, -R_OK |X_OK ,"--ipchange script" ); +R_OK |PLATFORM_X_OK ,"--ipchange script" ); errs |=check_file_access (CHKACC_FILE , options->route_script, -R_OK |X_OK ,"--route-up script" ); +R_OK |PLATFORM_X_OK ,"--route-up script" ); errs |=check_file_access (CHKACC_FILE , options->route_predown_script, -R_OK |X_OK ,"--route-pre-down script" ); +R_OK |PLATFORM_X_OK ,"--route-pre-down script" ); errs |=check_file_access (CHKACC_FILE , options->learn_address_script, -R_OK |X_OK ,"--learn-address script" ); +R_OK |PLATFORM_X_OK ,"--learn-address script" );#endif /* P2MP_SERVER */ if (errs)
win/config.h.in +1 -1
@@ -243,7 +243,7 @@ typedef unsigned long in_addr_t; #endif #ifndef X_OK -#define X_OK 0 +#define X_OK 1 #endif #ifndef F_OK
Signature · 1 line
1.7.3.4
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
options.c
Quoted 12 lines · Alon Bar-Lev
Reported by Heiko Hund. Reference [1].
Replaces
4ebc587eab73e03ef64d344a5707d84e7f8d875a[1]
http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspxSigned-off-by Alon Bar-Lev <[email protected]...> --- options.c| 38 ++++++++++++++++++++++---------------- win/config.h.in | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-)options.c +0
-0
I'm not convinced about this at all. It *is* the proper way to do it, from an intellectual point of view. But this complicates the reading of the code in places where I don't see it really improve any thing else - except of being pedantically correct.
The reason for this argument is that the following lines of code is in the source tree already:
(win/config.h.in)
#ifndef X_OK
#define X_OK 0
#endif
This is *well contained* inside the build tree which MSVS depends on. This build-platform does not define these macros at all. [RWX]_OK are all defined in unistd.h, which is non-existent in non-POSIX compliant environment (basically what MSVS falls in under).
So my point of view is that win/config.h.in covers the definition of the required macros which MSVS is lacking. Of course, it can be argued that such declarations should be in compat.h - as it a compatibility issue. For me that's a slightly different discussion.
The OpenVPN code base is primarily written for the POSIX platform. MSVS is not a really POSIX friendly platform and mingw is somewhere in between
- - but seems to be far more POSIX oriented than MSVS. We should focus on keeping the POSIX part of OpenVPN as pure as possible, from a POSIX point of view. And to be fair, the compat.[ch] files exists purely because of the issues we have with MSVS.
Bottom line is that I'm NACKing this patch, as it complicates things more than make things more clear. I do admit it is a more correct approach in its principles, but I don't like the complication it implies by "recasting" well defined POSIX macros.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9Cb38ACgkQDC186MBRfrqKhwCghAxMG/X+xKZdiy6gU9FR8Yhf n7oAnjxkrDDjpQngfM1TwTZgLkKVlmdH
=Vupy
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
David,
Again,
This has nothing to do with POSIX.
mingw *DOES* define this constant in *WINDOWS*.
We do not want to have a different constants (and different values) at the MSVC and mingw build.
Build should be consistent when possible, but not override environment SDK. Anyway, If this will not enter here it will enter my rewrite... I thought it is better to do this sooner than later.
The definition of PLATFORM_X_OK will be moved to autoconf.
Alon.
Quoted 64 lines · David Sommerseth
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1options.c
Quoted 12 lines · Alon Bar-Lev
Reported by Heiko Hund. Reference [1].
Replaces
4ebc587eab73e03ef64d344a5707d84e7f8d875a[1]
http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspxSigned-off-by Alon Bar-Lev <[email protected]...> --- options.c| 38 ++++++++++++++++++++++---------------- win/config.h.in | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-)options.c +0
-0I'm not convinced about this at all. It *is* the proper way to do it, from an intellectual point of view. But this complicates the reading of the code in places where I don't see it really improve any thing else - except of being pedantically correct.
The reason for this argument is that the following lines of code is in the source tree already:
(win/config.h.in)
#ifndefX_OK
#defineX_OK0
#endifThis is *well contained* inside the build tree which MSVS depends on. This build-platform does not define these macros at all. [RWX]_OK are all defined in
unistd.h, which is non-existent in non-POSIX compliant environment (basically what MSVS falls in under).So my point of view is that win/config.h.in covers the definition of the required macros which MSVS is lacking. Of course, it can be argued that such declarations should be in
compat.h- as it a compatibility issue. For me that's a slightly different discussion.The OpenVPN code base is primarily written for the POSIX platform. MSVS is not a really POSIX friendly platform and mingw is somewhere in between
- - but seems to be far more POSIX oriented than MSVS. We should focus on keeping the POSIX part of OpenVPN as pure as possible, from a POSIX point of view. And to be fair, the compat.[ch] files exists purely because of the issues we have with MSVS.Bottom line is that I'm NACKing this patch, as it complicates things more than make things more clear. I do admit it is a more correct approach in its principles, but I don't like the complication it implies by "recasting" well defined POSIX macros.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/iEYEARECAAYFAk9Cb38ACgkQDC186MBRfrqKhwCghAxMG/X+xKZdiy6gU9FR8Yhf n7oAnjxkrDDjpQngfM1TwTZgLkKVlmdH
=Vupy
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
Another option is to use X_OK and declare a macro PLATFORM_MASK_MODE(m)... whatever you think more readable.
Quoted 82 lines · Alon Bar-Lev
David,
Again,
This has nothing to do with POSIX.
mingw *DOES* define this constant in *WINDOWS*.We do not want to have a different constants (and different values) at the MSVC and mingw build.
Build should be consistent when possible, but not override environment SDK. Anyway, If this will not enter here it will enter my rewrite... I thought it is better to do this sooner than later.The definition of
PLATFORM_X_OKwill be moved to autoconf.Alon.
Quoted 64 lines · David Sommerseth
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1options.c
Quoted 12 lines · Alon Bar-Lev
Reported by Heiko Hund. Reference [1].
Replaces
4ebc587eab73e03ef64d344a5707d84e7f8d875a[1]
http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspxSigned-off-by Alon Bar-Lev <[email protected]...> --- options.c| 38 ++++++++++++++++++++++---------------- win/config.h.in | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-)options.c +0
-0I'm not convinced about this at all. It *is* the proper way to do it, from an intellectual point of view. But this complicates the reading of the code in places where I don't see it really improve any thing else - except of being pedantically correct.
The reason for this argument is that the following lines of code is in the source tree already:
(win/config.h.in)
#ifndefX_OK
#defineX_OK0
#endifThis is *well contained* inside the build tree which MSVS depends on. This build-platform does not define these macros at all. [RWX]_OK are all defined in
unistd.h, which is non-existent in non-POSIX compliant environment (basically what MSVS falls in under).So my point of view is that win/config.h.in covers the definition of the required macros which MSVS is lacking. Of course, it can be argued that such declarations should be in
compat.h- as it a compatibility issue. For me that's a slightly different discussion.The OpenVPN code base is primarily written for the POSIX platform. MSVS is not a really POSIX friendly platform and mingw is somewhere in between
- - but seems to be far more POSIX oriented than MSVS. We should focus on keeping the POSIX part of OpenVPN as pure as possible, from a POSIX point of view. And to be fair, the compat.[ch] files exists purely because of the issues we have with MSVS.Bottom line is that I'm NACKing this patch, as it complicates things more than make things more clear. I do admit it is a more correct approach in its principles, but I don't like the complication it implies by "recasting" well defined POSIX macros.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/iEYEARECAAYFAk9Cb38ACgkQDC186MBRfrqKhwCghAxMG/X+xKZdiy6gU9FR8Yhf n7oAnjxkrDDjpQngfM1TwTZgLkKVlmdH
=Vupy
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
Hi,
Quoted 2 lines · Alon Bar-Lev
Another option is to use
X_OKand declare a macroPLATFORM_MASK_MODE(m)... whatever you think more readable.
This is something I would like better, as it localizes the change to one place.
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
It still touches the same places...
The difference is the usage:
---
R_OK|PLATFORM_X_OK
---
or:
---PLATFORM_MODE_MASK(R_OK | X_OK)
---
Quoted 15 lines · Gert Doering
Hi,
Quoted 2 lines · Alon Bar-Lev
Another option is to use
X_OKand declare a macroPLATFORM_MASK_MODE(m)... whatever you think more readable.This is something I would like better, as it localizes the change to one place.
gert
--
USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
Hi,
Quoted 10 lines · Alon Bar-Lev
It still touches the same places...
The difference is the usage:
---
R_OK|PLATFORM_X_OK
---
or:
---PLATFORM_MODE_MASK(R_OK | X_OK)
---
Nah, that's not the way it should be.
Given that we currently use X_OK only in options.c, and have MANY lines of the form
errs |= check_file_access (CHKACC_FILE, options->crl_file, R_OK|X_OK,
"--crl-verify directory");and only a single place where it will actually call access() (or _access()), anything that makes all these lines harder to read is making the code harder to read.
This code doesn't want or need to know anything about system dependencies, that belongs inside check_file_access() - and there you have only a few access() calls that need to do PLATFORM_MODE_MASK().
Or even better, do it in the openvpn_access() wrapper, in the #ifdef WIN32 code block. That is the place where the WIN32 pain is, and nobody else needs to bother.
intopenvpn_access (const char *path, int mode)
{
#ifdef WIN32
struct gc_arena gc = gc_new ();
int ret = _waccess (wide_string (path, &gc), (mode & ~X_OK) ); gc_free (&gc);
return ret;
#else
return access (path, mode);
#endif
}
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
I think that wrapping the whole access is one step farther... The other two are better.
But it is still better than redefining X_OK... :)
Alon.
Quoted 55 lines · Gert Doering
Hi,
Quoted 10 lines · Alon Bar-Lev
It still touches the same places...
The difference is the usage:
---
R_OK|PLATFORM_X_OK
---
or:
---PLATFORM_MODE_MASK(R_OK | X_OK)
---Nah, that's not the way it should be.
Given that we currently use
X_OKonly inoptions.c, and have MANY lines of the formerrs |=
check_file_access(CHKACC_FILE,options->crl_file, R_OK|X_OK, "--crl-verify directory");and only a single place where it will actually call
access()(or_access()), anything that makes all these lines harder to read is making the code harder to read.This code doesn't want or need to know anything about system dependencies, that belongs inside
check_file_access()- and there you have only a fewaccess()calls that need to doPLATFORM_MODE_MASK().Or even better, do it in the
openvpn_access()wrapper, in the #ifdef WIN32 code block. That is the place where the WIN32 pain is, and nobody else needs to bother.int
openvpn_access(const char *path, int mode)
{
#ifdef WIN32
structgc_arenagc =gc_new();
int ret =_waccess(wide_string(path, &gc), (mode & ~X_OK) );gc_free(&gc);
return ret;
#else
return access (path, mode);
#endif
}gert
--
USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...
PATCH 1/1 mask out X_OK when calling WIN32 API _waccess()
In reply to Gert DoeringThis reverts commit 4ebc587e. Instead of defining X_OK 0 for MSVC, this undefined mode value is now simply masked out close to where it causes the trouble; in the call to _waccess() as suggested during the discussion on the development mailing list:
http://thread.gmane.org/gmane.network.openvpn.devel/5452
--- misc.c | 2 +- win/config.h.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
misc.c +1 -1
@@ -629,7 +629,7 @@ openvpn_access (const char *path, int mode) {#ifdef WIN32 struct gc_arena gc =gc_new (); -int ret =_waccess (wide_string (path, &gc), mode); +int ret =_waccess (wide_string (path, &gc), mode & ~X_OK );gc_free (&gc);return ret;#else
win/config.h.in +1 -1
@@ -243,7 +243,7 @@ typedef unsigned long in_addr_t; #endif #ifndef X_OK -#define X_OK 0 +#define X_OK 1 #endif #ifndef F_OK
Signature · 1 line
1.7.8.3
Re: [Openvpn-devel] [PATCH] mask out X_OK when calling WIN32 API _waccess()
Hi,
Quoted 7 lines · Heiko Hund
This reverts commit
4ebc587e. Instead of definingX_OK0 for MSVC, this undefined mode value is now simply masked out close to where it causes the trouble; in the call to_waccess()as suggested during the discussion on the development mailing list:
http://thread.gmane.org/gmane.network.openvpn.devel/5452Signed-off-by Heiko Hund <[email protected]...>
I suggested this approach, so I should ACK it - but I'm not happy
yet: there really should be a comment in the code explaining why this is done - without that, this looks like "just random modification of flag bits", and you need to go to the *git log* to see why this was done.
A comment like:
/* Passing X_OK to _(w)access() on windows will cause a crash on
* Vista and up. To avoid more complicated code in the calling
* functions, we just mask out X_OK on windows. See also
* http://msdn.microsoft.com/en-us/library/1w06ktdy%28v=vs.100%29.aspx
*/
should be fine.
But maybe I'm just old enough to revisit code 10 years later and ask myself "why did I do that?"...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
In reply to Alon Bar-Lev-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 4 lines · Alon Bar-Lev
David,
Again, This has nothing to do with POSIX. mingw *DOES* define this constant in *WINDOWS*.
You seem to ignore the fact that mingw provides an access() function which *behaves* like the rest of the POSIX world. MSVS does not do that, but decides to choke when its own "support variant", which is even renamed to to _access(), is used with a value which is defined in POSIX [1]. This has everything to do with POSIX compliance. If MSVS had been compliant, we would not have had this discussion.
[1] <http://pubs.opengroup.org/onlinepubs/9699919799/>
And you may try to compile this little snippet in different environments.
- ----8<-------------------------------------------------------------------
#include <stdio.h>
#include <unistd.h>
#ifndef F_OK
#define F_OK 0
#endif
int main(int argc, char **argv)
{
if( argc != 2 ) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
return 1;
}
if( access(argv[1], F_OK) == 0 ) {
printf("%s exists\n", argv[1]);
} else {
printf("Failure when checking %s\n", argv[1]);
perror("access");
return 2;
}
return 0;
}- ----8<-------------------------------------------------------------------
Compile this in mingw, and it works as expected. Compile this with MSVS, and it will complain about using deprecated functions, and using _access() instead will make it happier. However, it will most like like not behave as expected. And for the extra fun of it, you can always try to use _waccess() instead too. That will definitely not behave as expected.
Quoted 2 lines
We do not want to have a different constants (and different values) at the MSVC and mingw build.
I beg to differ. The MSVS and mingw compiler environments are two very different compiler environments - as desc. And as I said, mingw is somewhere in between a POSIX compliant compiler environment and MSVS. It is not a clearly drawn line between what is supported and not in mingw unfortunately, and a lot of things around the mingw compiler environment is debatable. However, in the case of access() and the [RWXF]_OK macros, mingw is far closer to the POSIX standard than MSVS. From the mingw web site:
"Unlike Cygwin, MinGW doesn't provide Linux or Unix system calls or a
POSIX emulation layer. *Some POSIX compatibility* is provided by the supported runtime library, msvcrt.dll. A few additional functions are provided to help with portability"
<http://mingw.org/wiki/MinGW>
Quoted 2 lines
Build should be consistent when possible, but not override environment SDK.
There *is no override* of the SDK environment. Because the [RWXF]_OK macros *does not exist* in the MSVS. Further, mingw *does* define these macros in the mingw header files (try to remove the #ifdef block in the example above). So we just define a *missing* macro with a sane value which doesn't make the openvpn binary built with MSVS choke and die due to an invalid value. Which is *why* I mean the proper place for this definition is in win/config.h.in, which is *only* used by the python build environment written *explicitly* for the MSVS build environment.
Quoted 4 lines
Anyway, If this will not enter here it will enter my rewrite... I thought it is better to do this sooner than later.
The definition of
PLATFORM_X_OKwill be moved to autoconf.
You may attempt to try to force them in. That is purely your choice, Alon.
But remember that all your patches *will* go through review as for everyone else in the community. That means either *1)* patch reviews on the mailing list, or *2)* reviewed through a sprint review in a developers meeting on the IRC. You are free to choose between which approach fits you best. But I will not accept patches into the tree unless it has been clearly ACKed publicly.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9Cy5wACgkQDC186MBRfrprOgCfeAOtyy5Ln+34dgOxPAt9y44D 2OIAnR2/pTxvkEOOK/yaYvwLEfQdDCYo
=/iMB
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
Quoted 6 lines · David Sommerseth
But remember that all your patches *will* go through review as for everyone else in the community. That means either *1)* patch reviews on the mailing list, or *2)* reviewed through a sprint review in a developers meeting on the IRC. You are free to choose between which approach fits you best. But I will not accept patches into the tree unless it has been clearly ACKed publicly.
David,
I see I wasted three days of work.
You agreed that you have a problem "Huston we have a problem, the build process of OpenVPN causes maintenance overhead".
Nobody in this community maintains the build system so it became so complex and none intuitive that it is unusable.
You won't be able to review all my changes as it is a revolution not evolution, I warned you guys ahead! It will touch almost all the sources.
What I actually do is merge all environment into one single build environment. So not overriding constant of different environment *IS* important.
I just may stop now working.
Please start go over my patches in github[1] and mark your comments, this way we know if it was a total waste of time.
Alon.
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 6 lines · Alon Bar-Lev
Please start go over my patches in github[1] and mark your comments, this way we know if it was a total waste of time.
Alon.
Alon,
If you want to have the review on the mailing list, then I want to see those patches nicely formatted as patches here - which can easily be sent as with a single git send-email command. This way it is far easier to document the review process.
The alternative, as you know, is an IRC sprint where we can go through commit by commit on a web site. Doing it this way we document the review in an e-mail with a summary of the discussions plus the chatlog itself to the mailing list. This approach was used for the PolarSSL patches.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9C0R0ACgkQDC186MBRfrqzigCfcfGrzNbFmZvfNNUix4YNgXpt ONUAnRk6N31HU/Jf5+pvyk4BrVtqbZAe
=PzyD
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
No,
The alternate way is for people to go into github and start comment inline. Did you ever tried to use github interface?
You see nice formatted patches and can comment on each line. After we see we stabilize we send the loooooooooooooooong patches to the mailing list.
Trust me it won't be productive.
Alon.
Quoted 37 lines · David Sommerseth
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 6 lines · Alon Bar-Lev
Please start go over my patches in github[1] and mark your comments, this way we know if it was a total waste of time.
Alon.
Alon,
If you want to have the review on the mailing list, then I want to see those patches nicely formatted as patches here - which can easily be sent as with a single git send-email command. This way it is far easier to document the review process.
The alternative, as you know, is an IRC sprint where we can go through commit by commit on a web site. Doing it this way we document the review in an e-mail with a summary of the discussions plus the chatlog itself to the mailing list. This approach was used for the PolarSSL patches.
kind regards,
David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/iEYEARECAAYFAk9C0R0ACgkQDC186MBRfrqzigCfcfGrzNbFmZvfNNUix4YNgXpt ONUAnRk6N31HU/Jf5+pvyk4BrVtqbZAe
=PzyD
-----END PGP SIGNATURE-----
Re: [Openvpn-devel] [PATCH] windows: do not use X_OK as it is unsupported
In reply to Alon Bar-LevQuoted 11 lines
Quoted 6 lines · David Sommerseth
But remember that all your patches *will* go through review as for everyone else in the community. That means either *1)* patch reviews on the mailing list, or *2)* reviewed through a sprint review in a developers meeting on the IRC. You are free to choose between which approach fits you best. But I will not accept patches into the tree unless it has been clearly ACKed publicly.
David,
Quoted 7 lines
I see I wasted three days of work.
You agreed that you have a problem "Huston we have a problem, the build process of OpenVPN causes maintenance overhead".
Nobody in this community maintains the build system so it became so complex and none intuitive that it is unusable.
Agreed. I would very much like to see what the alternative is. I'm not interested in details, but the whole. The goal is to have a buildsystem that sucks less.
Quoted 4 lines
You won't be able to review all my changes as it is a revolution not evolution, I warned you guys ahead! It will touch almost all the sources.
I don't think reviewing individual patches is very productive at this point. It makes perfect sense for incremental, small changes that we want to go to the repository right away. In this case I'd prefer to see a working prototype of the new buildsystem and review it as whole. If it fulfils the basic requirements[1] then we can comment on the details. And then we can start moving the code to the official repository - no need to do it right now.
Could you (the other devs) take a look at Alon's Git tree as a whole and see what you think, without getting into details? I can take a look to see how the MSVC build (w.o. the TAP-driver build) would integrate with it.
Signature · 9 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock [1] We have not clearly specified these, and we should a.s.a.p.