Skip to contentSkip to conversation

Fix some more wrong defines in config-msvc.h

PATCH In review [email protected]... 3 participants 10 messages Oct 15, 2021 – Oct 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix some more wrong defines in config-msvc.h

From: Selva Nair <[email protected]...>

Not sure where these came from, but here goes:

S_IRUSR = 0 --> _S_IREAD
S_IWUSR = 0 --> _S_IWRITE

ENABLE_DEBUG is on, but I do not think we want it in production build. Changed to ENABLE_DEBUG 0

S_IRGRP is not defined but seems to be used. I have added it, remove if not required.
This define is based on mingw and matches MS docs on <filesystem>
(https://docs.microsoft.com/en-us/cpp/standard-library/filesystem-enumerations?view=msvc-160)

Should fix Trac #1430 but untested (I do not have a setup at hand for msvc build).

---
 config-msvc.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
config-msvc.h +4 -3
index b28d8742..301e7ebc 100644
@@ -4,7 +4,7 @@
 
 #define ENABLE_PF 1
 #define ENABLE_CRYPTO_OPENSSL 1
-#define ENABLE_DEBUG 1
+#define ENABLE_DEBUG 0
 #define ENABLE_FRAGMENT 1
 #define ENABLE_HTTP_PROXY 1
 #define ENABLE_LZO 1
@@ -67,8 +67,9 @@
 #define in_addr_t uint32_t
 #define ssize_t SSIZE_T
 
-#define S_IRUSR 0
-#define S_IWUSR 0
+#define S_IRUSR _S_IREAD
+#define S_IWUSR _S_IWRITE
+#define S_IRGRP (S_IRUSR >> 3)
 #define R_OK 4
 #define W_OK 2
 #define X_OK 1
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 Fix some more wrong defines in config-msvc.h

From: Selva Nair <[email protected]...>

Not sure where these came from, but here goes:

S_IRUSR = 0 --> _S_IREAD
S_IWUSR = 0 --> _S_IWRITE

ENABLE_DEBUG is on, but I do not think we want it in production build. Changed to ENABLE_DEBUG 0

S_IRGRP is not defined but seems to be used. I have added it, remove if not required.
This define is based on mingw and matches MS docs on <filesystem>
(https://docs.microsoft.com/en-us/cpp/standard-library/filesystem-enumerations?view=msvc-160)

Should fix Trac #1430 but untested (I do not have a setup at hand for msvc build).

---
 config-msvc.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
config-msvc.h +4 -4
index a39eeed8..9fc8d1cc 100644
@@ -5,8 +5,7 @@
 #define ENABLE_DEF_AUTH 1
 #define ENABLE_PF 1
 #define ENABLE_CRYPTO_OPENSSL 1
-#define ENABLE_DEBUG 1
-#define ENABLE_EUREPHIA 1
+#define ENABLE_DEBUG 0
 #define ENABLE_FRAGMENT 1
 #define ENABLE_HTTP_PROXY 1
 #define ENABLE_LZO 1
@@ -144,8 +143,9 @@
 #define in_addr_t uint32_t
 #define ssize_t SSIZE_T
 
-#define S_IRUSR 0
-#define S_IWUSR 0
+#define S_IRUSR _S_IREAD
+#define S_IWUSR _S_IWRITE
+#define S_IRGRP (S_IRUSR >> 3)
 #define R_OK 4
 #define W_OK 2
 #define X_OK 1
Signature · 1 line
2.20.1
author
#6 lore raw
In reply to [email protected]...
Quoted 17 lines · On Fri, Oct 15, 2021 at 1:53 PM <[email protected]...> wrote:

From: Selva Nair <[email protected]...>

Not sure where these came from, but here goes:

S_IRUSR = 0 --> _S_IREAD
S_IWUSR = 0 --> _S_IWRITE

ENABLE_DEBUG is on, but I do not think we want it in production build. Changed to ENABLE_DEBUG 0

S_IRGRP is not defined but seems to be used. I have added it, remove if not required.
This define is based on mingw and matches MS docs on <filesystem> (
https://docs.microsoft.com/en-us/cpp/standard-library/filesystem-enumerations?view=msvc-160
)

Quoted 3 lines

Should fix Trac #1430 but untested (I do not have a setup at hand for msvc build).

The patch for master doesn't apply cleantly to 2.5. Please use the next one marked "for 2.5" on the release branch.

Selva

Acked-by on v1 1/1
#7 lore raw
In reply to [email protected]...

Hi,

Quoted 1 line

Not sure where these came from, but here goes:

According to git blame, those dates back to 2012:

https://github.com/OpenVPN/openvpn/commit/4b1a82db0975088dbfe69c2a97f0a96ef972b2a4#diff-f17c6f8c8df2b2934b574e407cbde107338969c6898ce8e8965dc289ae979fc6R97

Quoted 2 lines

S_IRUSR = 0 --> _S_IREAD
S_IWUSR = 0 --> _S_IWRITE

MSFT docs says that:

"If a value other than some combination of _S_IREAD and _S_IWRITE is specified for pmode—even if it would specify a valid pmode in another operating system—or if any value other than the allowed oflag values is specified, the function generates an assertion in Debug mode and invokes the invalid parameter handler, as described in Parameter Validation."

I tried Debug build with --status but haven't seen any assertions. Anyway, it is clear that passing 0 was incorrect.

Quoted 1 line

Should fix Trac #1430 but untested (I do not have a setup at hand for msvc build).

If you push your branch to GitHub, it will kick off GitHub Actions build which produces MSVC-built artifacts.

Built and tested locally, works as expected - status file is created without "readonly" attribute.

#8 lore raw

I am sorry, I need to take the ack back. Probably cron2 can fix it in place?

-#define ENABLE_DEBUG 1
+#define ENABLE_DEBUG 0

This doesn't really undef ENABLE_DEBUG. Can we just remove "-#define ENABLE_DEBUG 1" ?

--
-Lev

#2 lore raw
In reply to [email protected]...

Looks good (I commented already in 2.5 version) apart from

config-msvc.h line 8

Quoted 2 lines
config-msvc.h +1 -1
-#define ENABLE_DEBUG 1
+#define ENABLE_DEBUG 0

which doesn't undef it.

If cron2 can fix it during commit, consider this as ack.

Signature · 1 line
-Lev
author
#3 lore raw

Hi

Quoted 7 lines · Lev Stipakov

Looks good (I commented already in 2.5 version) apart from

config-msvc.h line 8

Quoted 2 lines
config-msvc.h +1 -1
-#define ENABLE_DEBUG 1
+#define ENABLE_DEBUG 0

which doesn't undef it.

Right, we check it using #ifdef, not #if.

Gert: do you need a v2 or can you remove the line please?

Selva

#4 lore raw

Hi,

Quoted 1 line · Selva Nair

Gert: do you need a v2 or can you remove the line please?

I'll do it on the fly. The intent is clear.

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#5 lore raw
In reply to [email protected]...

Thanks.

I have adjusted the commit message ("should fix Trac #1430") and removed the #define ENABLE_DEBUG 0, as instructed.

Your patch has been applied to the release/2.5 branch.

commit c699c0d85cf2028796cdb0592271f1167709e6ac

Author: Selva Nair
Date:   Fri Oct 15 14:47:33 2021 -0400
     Fix some more wrong defines in config-msvc.h

     Signed-off-by: Selva Nair <[email protected]...>
     Acked-by: Lev Stipakov <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22943.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#9 lore raw
In reply to [email protected]...

Thanks. As with the 2.5 patch, removed the DEBUG #define, and changed commit message to just refer to trac with "Trac: #1430"

Your patch has been applied to the master branch.

commit 077445d0d82128dc90e50043546d4a2d8647eb9c

Author: Selva Nair
Date:   Fri Oct 15 13:53:30 2021 -0400
     Fix some more wrong defines in config-msvc.h

     Acked-by: Lev Stipakov <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22942.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering