Skip to contentSkip to conversation

Single patch:

PATCH In review Paolo Cerrito 2 participants 2 messages Jun 6, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Single patch:

1) changed lenght of remote to 46

2) refactored call to get_env

---
 src/plugins/auth-pam/auth-pam.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
src/plugins/auth-pam/auth-pam.c +7 -3
index 9d8dfb95..c03e178b 100644
@@ -48,7 +48,7 @@
 #include <signal.h>
 #include <syslog.h>
 #include "utils.h"
-
+#include <arpa/inet.h>
 #include <openvpn-plugin.h>
 
 #define DEBUG(verb) ((verb) >= 4)
@@ -115,7 +115,7 @@ struct user_pass {
     char password[128];
     char common_name[128];
     char response[128];
-    char remote[128];
+    char remote[INET6_ADDRSTRLEN];
 
     const struct name_value_list *name_value_list;
 };
@@ -518,7 +518,11 @@ openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, const cha
         const char *username = get_env("username", envp);
         const char *password = get_env("password", envp);
         const char *common_name = get_env("common_name", envp) ? get_env("common_name", envp) : "";
-        const char *remote = get_env("untrusted_ip", envp) ? get_env("untrusted_ip", envp) : get_env("untrusted_ip6", envp);
+        const char *remote = get_env("untrusted_ip6", envp);
+        
+        if (remote == NULL){ 
+                remote = get_env("untrusted_ip", envp); //if Null, try to take ipv4 if not set ipv6
+        }
 
         if (username && strlen(username) > 0 && password)
         {
Signature · 1 line
2.36.1
#1 lore raw

Hi,

Quoted 21 lines · Paolo Cerrito

1) changed lenght of remote to 46

2) refactored call to get_env

---
 src/plugins/auth-pam/auth-pam.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
src/plugins/auth-pam/auth-pam.c +1 -1
index 9d8dfb95..c03e178b 100644
@@ -48,7 +48,7 @@
 #include <signal.h>
 #include <syslog.h>
 #include "utils.h"
-
+#include <arpa/inet.h>
 #include <openvpn-plugin.h>
 
 #define DEBUG(verb) ((verb) >= 4)

src/plugins/auth-pam/auth-pam.c struct user_pass { · line 118

Quoted 5 lines
src/plugins/auth-pam/auth-pam.c +1 -1
@@ -115,7 +115,7 @@ struct user_pass {
     char password[128];
     char common_name[128];
     char response[128];
-    char remote[128];
+    char remote[INET6_ADDRSTRLEN];

This seems to be the second patch only (the changes according to the comments received).

Please combine all changes into a single patch, and do also include a commit message that describes the overall change.

(To combine multiple patches into one, look at "git rebase --interactive" and "squash")

Part of the reason we do this review dance is that we want patches that are all "good in itself", not "need a second patch to fix the first one".

thanks,

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]...