Skip to contentSkip to conversation

A few questions related to the management interface

Openvpn-devel Adrien Bustany 2 participants 3 messages May 7, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

I was toying with the management interface of openvpn (on server side), to monitor the connections/disconnections of my clients. The clients are authenticated with TLS certificates, without a password. I needed to patch two things in order to get things working as I wanted, but since I'm new to the code base, I'm not sure at all that those patches make sense, especially the second one. I still attach them to this email, in the hope that people here will point where I'm wrong :)

Cheers

Adrien

From b3f7a1bc9b0d6510f20b7e27d2385f716590d6fb Mon Sep 17 00:00:00 2001
From: Adrien Bustany <[email protected]>
Date: Mon, 7 May 2012 14:26:59 +0300
Subject: [PATCH 1/2] Don't call management_notify_client_close twice for
multi clients

management_notify_client_close is already called in multi_client_disconnect_script for those.

---
 src/openvpn/init.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
src/openvpn/init.c +3 -1
index 61ced5d..159d67d 100644
@@ -3569,7 +3569,9 @@ close_instance (struct context *c)
 	do_close_tun (c, false);
 
 #ifdef MANAGEMENT_DEF_AUTH
-	if (management)
+	// For child contexts, we already called management_notify_client_close
+	// in multi_client_disconnect_script
+	if (management && c->mode != CM_CHILD_UDP && c->mode != CM_CHILD_TCP)
 	  management_notify_client_close (management, &c->c2.mda_context, NULL);
 #endif
 
Signature · 1 line
1.7.8.1

From d6364de14ba629bb6000c7252929050f9625d5cc Mon Sep 17 00:00:00 2001
From: Adrien Bustany <[email protected]>
Date: Mon, 7 May 2012 14:42:07 +0300
Subject: [PATCH 2/2] management: Don't require DAF_INITIAL_AUTH to send
DISCONNECT message

DAF_INITIAL_AUTH will only be set if a password was needed for client authentication. This means that for password-less certificate authentication, no DISCONNECT message would be sent.

---
 src/openvpn/manage.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
src/openvpn/manage.c +1 -1
index 1dddd41..51f41bb 100644
@@ -2474,7 +2474,7 @@ management_notify_client_close (struct management *management,
 				struct man_def_auth_context *mdac,
 				const struct env_set *es)
 {
-  if ((mdac->flags & DAF_INITIAL_AUTH) && !(mdac->flags & DAF_CONNECTION_CLOSED))
+  if (!(mdac->flags & DAF_CONNECTION_CLOSED))
     {
       msg (M_CLIENT, ">CLIENT:DISCONNECT,%lu", mdac->cid);
       man_output_env (es, true, management->connection.env_filter_level, "CLIENT");
Signature · 1 line
1.7.8.1
#1 lore raw
Quoted 10 lines · Adrien Bustany

Hi,

I was toying with the management interface of openvpn (on server side), to monitor the connections/disconnections of my clients. The clients are authenticated with TLS certificates, without a password. I needed to patch two things in order to get things working as I wanted, but since I'm new to the code base, I'm not sure at all that those patches make sense, especially the second one. I still attach them to this email, in the hope that people here will point where I'm wrong :)

Quoted 4 lines

Cheers

Adrien

Hello,

Yes, they are making sense.
But please next time submit them using git send-email and separately, so we can discuss each.

Regarding 001 - As far as I can see, the code does exactly that... if not DAF_CONNECTION_CLOSED, issue disconnect message and turn DAF_CONNECTION_CLOSED, otherwise do nothing. So what is the problem?

Regarding 002 - I think this is correct, but then we need to modify management_learn_addr as well, no? Or the mdac->cid is not initialized all the time and the flag marks that this is client session... Did not test.

Alon.

#2 lore raw

Le 2012-05-07 16:51, Alon Bar-Lev a écrit :

Quoted 13 lines · Adrien Bustany
Quoted 12 lines

Hi,

I was toying with the management interface of openvpn (on server side), to monitor the connections/disconnections of my clients. The clients are authenticated with TLS certificates, without a password. I needed to patch two things in order to get things working as I wanted, but since I'm new to the code base, I'm not sure at all that those patches make sense, especially the second one. I still attach them to this email, in the hope that people here will point where I'm wrong :)

Cheers

Quoted 8 lines
Quoted 2 lines

Adrien

Hello,

Yes, they are making sense.
But please next time submit them using git send-email and separately, so we can discuss each.

Sure, I could have done that even though those patches were not meant to be merged as-is. I'll do that next time.

Quoted 5 lines

Regarding 001 - As far as I can see, the code does exactly that... if not DAF_CONNECTION_CLOSED, issue disconnect message and turn DAF_CONNECTION_CLOSED, otherwise do nothing. So what is the problem?

Hmm you're right, it does not matter if the method is called twice since the second time it'll return early and won't send anything. So that patch is useless.

Quoted 5 lines

Regarding 002 - I think this is correct, but then we need to modify management_learn_addr as well, no? Or the mdac->cid is not initialized all the time and the flag marks that this is client session... Did not test.

That sounds right, I haven't tested this "learn" feature either, but I'll have a more thorough review of the use of DAF_INITIAL_AUTH across the file, and will do a real patch submission.

Quoted 1 line

Alon.

Thanks for the comments

Adrien