aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-12-18 09:38:11 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-12-18 09:38:11 +0000
commit6ce4a658a369609377aceab5c16cd2a555214ac7 (patch)
tree92fefb83e55bc54b1e548bc27452ee6f9c5f9078
parentAdded "nclients" command to management interface to (diff)
downloadopenvpn-6ce4a658a369609377aceab5c16cd2a555214ac7.tar.xz
Added n_clients environmental variable to information passed
to management interface client when management-client-auth is enabled. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3718 e7ae566f-a301-0410-adde-c780ea21d3b5
-rw-r--r--manage.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/manage.c b/manage.c
index 7eff627..a9878c6 100644
--- a/manage.c
+++ b/manage.c
@@ -2066,7 +2066,7 @@ management_set_state (struct management *man,
#ifdef MANAGEMENT_DEF_AUTH
static void
-man_output_env (const struct env_set *es)
+man_output_env (const struct env_set *es, const bool tail)
{
if (es)
{
@@ -2077,7 +2077,22 @@ man_output_env (const struct env_set *es)
msg (M_CLIENT, ">CLIENT:ENV,%s", e->string);
}
}
- msg (M_CLIENT, ">CLIENT:ENV,END");
+ if (tail)
+ msg (M_CLIENT, ">CLIENT:ENV,END");
+}
+
+static void
+man_output_extra_env (struct management *man)
+{
+ struct gc_arena gc = gc_new ();
+ struct env_set *es = env_set_create (&gc);
+ if (man->persist.callback.n_clients)
+ {
+ const int nclients = (*man->persist.callback.n_clients) (man->persist.callback.arg);
+ setenv_int (es, "n_clients", nclients);
+ }
+ man_output_env (es, false);
+ gc_free (&gc);
}
void
@@ -2092,7 +2107,8 @@ management_notify_client_needing_auth (struct management *management,
if (mdac->flags & DAF_CONNECTION_ESTABLISHED)
mode = "REAUTH";
msg (M_CLIENT, ">CLIENT:%s,%lu,%u", mode, mdac->cid, mda_key_id);
- man_output_env (es);
+ man_output_extra_env (management);
+ man_output_env (es, true);
mdac->flags |= DAF_INITIAL_AUTH;
}
}
@@ -2112,7 +2128,7 @@ management_notify_client_close (struct management *management,
if ((mdac->flags & DAF_INITIAL_AUTH) && !(mdac->flags & DAF_CONNECTION_CLOSED))
{
msg (M_CLIENT, ">CLIENT:DISCONNECT,%lu", mdac->cid);
- man_output_env (es);
+ man_output_env (es, true);
mdac->flags |= DAF_CONNECTION_CLOSED;
}
}