Skip to contentSkip to conversation

don't mix settings when crl-verify option appears more than once

PATCH In review Antonio Quartulli 3 participants 6 messages Oct 26, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't mix settings when crl-verify option appears more than once

clr-verify can be specified multiple times in the config file and the expected behaviour is that the last occurrence should be used.

Therefore, reset the optional flags everytime a new crl-verify option is found.

---
 src/openvpn/options.c | 8 ++++++++
 1 file changed, 8 insertions(+)
src/openvpn/options.c +8 -0
index 281ef0b..5192198 100644
@@ -6966,6 +6966,14 @@ add_option (struct options *options,
 		  || (p[2] && streq (p[1], INLINE_FILE_TAG) ) || !p[2]) && !p[3])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
+      /*
+       * If crl-verify appears more than once in the config file, we have to
+       * to keep settings belonging to the last occurrence only.
+       * Reset optional settings each time.
+       */
+      options->ssl_flags &= ~SSLF_CRL_VERIFY_DIR;
+      options->crl_file_inline = NULL;
+
       if (p[2] && streq(p[2], "dir"))
 	options->ssl_flags |= SSLF_CRL_VERIFY_DIR;
       options->crl_file = p[1];
Signature · 1 line
2.10.1
#1 lore raw

Hi,

Quoted 20 lines · Antonio Quartulli

clr-verify can be specified multiple times in the config file and the expected behaviour is that the last occurrence should be used.

Therefore, reset the optional flags everytime a new crl-verify option is found.

---
 src/openvpn/options.c | 8 ++++++++
 1 file changed, 8 insertions(+)
src/openvpn/options.c +1 -0
index 281ef0b..5192198 100644
@@ -6966,6 +6966,14 @@ add_option (struct options *options,
 		  || (p[2] && streq (p[1], INLINE_FILE_TAG) ) || !p[2]) && !p[3])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
+      /*

src/openvpn/options.c add_option (struct options *options, · line 6979

Quoted 10 lines
src/openvpn/options.c +7 -0
+       * If crl-verify appears more than once in the config file, we have to
+       * to keep settings belonging to the last occurrence only.
+       * Reset optional settings each time.
+       */
+      options->ssl_flags &= ~SSLF_CRL_VERIFY_DIR;
+      options->crl_file_inline = NULL;
+
       if (p[2] && streq(p[2], "dir"))
 	options->ssl_flags |= SSLF_CRL_VERIFY_DIR;
       options->crl_file = p[1];

Feature-ACK. I think this is a great idea. This allows us to do an if(inline_file), instead of doing a strcmp against the 'magic inline string' everywhere.

However, I think it would be better to keep all inline file handling consistent. So I would prefer a patch that does this for all inline options, and replaces the strcmp()s at various places with if(inline).

(Thinking about refactoring this, wouldn't it be even prettier to change crl_file_inline to a bool, indicating whether crl_file contains a file path or the file contents? Might be a matter of style though, so feel free to ignore if you disagree.)

-Steffan

#2 lore raw
Quoted 38 lines · Steffan Karger

Hi,

Quoted 20 lines · Antonio Quartulli

clr-verify can be specified multiple times in the config file and the expected behaviour is that the last occurrence should be used.

Therefore, reset the optional flags everytime a new crl-verify option is found.

---
 src/openvpn/options.c | 8 ++++++++
 1 file changed, 8 insertions(+)
src/openvpn/options.c +1 -0
index 281ef0b..5192198 100644
@@ -6966,6 +6966,14 @@ add_option (struct options *options,
 		  || (p[2] && streq (p[1], INLINE_FILE_TAG) ) || !p[2]) && !p[3])
     {
       VERIFY_PERMISSION (OPT_P_GENERAL);
+      /*

src/openvpn/options.c add_option (struct options *options, · line 6979

Quoted 10 lines
src/openvpn/options.c +7 -0
+       * If crl-verify appears more than once in the config file, we have to
+       * to keep settings belonging to the last occurrence only.
+       * Reset optional settings each time.
+       */
+      options->ssl_flags &= ~SSLF_CRL_VERIFY_DIR;
+      options->crl_file_inline = NULL;
+
       if (p[2] && streq(p[2], "dir"))
 	options->ssl_flags |= SSLF_CRL_VERIFY_DIR;
       options->crl_file = p[1];

Feature-ACK. I think this is a great idea. This allows us to do an if(inline_file), instead of doing a strcmp against the 'magic inline string' everywhere.

Quoted 8 lines

However, I think it would be better to keep all inline file handling consistent. So I would prefer a patch that does this for all inline options, and replaces the strcmp()s at various places with if(inline).

(Thinking about refactoring this, wouldn't it be even prettier to change crl_file_inline to a bool, indicating whether crl_file contains a file path or the file contents? Might be a matter of style though, so feel free to ignore if you disagree.)

I totally agree on this.

I was planning to do the rest of the refactoring in a second patch.

At this point I think it would make sense to reject this patch and wait for a full patchset set where I will:

1) "fix" every inline option to be sure that we don't carry around bogus settings
2) switch any *_inline field to bool
3) refactor the code to avoid strcmp()

Thanks for the quick reply!

Cheers,

Signature · 1 line
Antonio Quartulli
#3 lore raw
Quoted 9 lines · Antonio Quartulli

I was planning to do the rest of the refactoring in a second patch.

At this point I think it would make sense to reject this patch and wait for a full patchset set where I will:

1) "fix" every inline option to be sure that we don't carry around bogus settings
2) switch any *_inline field to bool
3) refactor the code to avoid strcmp()

Yes, consider your patch rejected ;)

For me the proposed changes would be fine as a single patch - this is strongly related and not very complex. In particular 2 and 3 should probably go together.

-Steffan

#4 lore raw

Am 26.10.16 um 14:48 schrieb Steffan Karger:

Quoted 11 lines · Antonio Quartulli
Quoted 9 lines

I was planning to do the rest of the refactoring in a second patch.

At this point I think it would make sense to reject this patch and wait for a full patchset set where I will:

1) "fix" every inline option to be sure that we don't carry around bogus settings
2) switch any *_inline field to bool
3) refactor the code to avoid strcmp()

Beware that the [[inline]] also serves as a filename and you have to add extra logic everywhere a file name is printed.

Arne

#5 lore raw
Quoted 9 lines · Arne Schwabe

Am 26.10.16 um 14:48 schrieb Steffan Karger:

Quoted 6 lines · Antonio Quartulli
Quoted 5 lines

I was planning to do the rest of the refactoring in a second patch.

At this point I think it would make sense to reject this patch and wait for a full patchset set where I will:

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

1) "fix" every inline option to be sure that we don't carry around bogus settings
2) switch any *_inline field to bool
3) refactor the code to avoid strcmp()

Beware that the [[inline]] also serves as a filename and you have to add extra logic everywhere a file name is printed.

Thanks for the hint! I was just fighting with that :)

Cheers,

Signature · 1 line
Antonio Quartulli