]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
"status" management interface command (version >= 2) will now
authorJames Yonan <james@openvpn.net>
Fri, 19 Aug 2011 03:15:25 +0000 (03:15 +0000)
committerDavid Sommerseth <davids@redhat.com>
Wed, 24 Aug 2011 12:05:13 +0000 (14:05 +0200)
include the username for each connected user.  This should
generally be backward compatible with existing management
interface clients since the new username field is added
to the CLIENT_LIST header as well.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@7539 e7ae566f-a301-0410-adde-c780ea21d3b5

Conflicts:
multi.c - hash_iterator_init() takes only 2 arguments now.

Signed-off-by: David Sommerseth <davids@redhat.com>
multi.c
ssl.c
ssl.h

diff --git a/multi.c b/multi.c
index 15bea2268d21b504f0c63b03f0d9871b69331a63..3a2fe9a92265bf0e8550cd00185cea961af7449c 100644 (file)
--- a/multi.c
+++ b/multi.c
@@ -782,8 +782,8 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int
           */
          status_printf (so, "TITLE%c%s", sep, title_string);
          status_printf (so, "TIME%c%s%c%u", sep, time_string (now, 0, false, &gc_top), sep, (unsigned int)now);
-         status_printf (so, "HEADER%cCLIENT_LIST%cCommon Name%cReal Address%cVirtual Address%cBytes Received%cBytes Sent%cConnected Since%cConnected Since (time_t)",
-                        sep, sep, sep, sep, sep, sep, sep, sep);
+         status_printf (so, "HEADER%cCLIENT_LIST%cCommon Name%cReal Address%cVirtual Address%cBytes Received%cBytes Sent%cConnected Since%cConnected Since (time_t)%cUsername",
+                        sep, sep, sep, sep, sep, sep, sep, sep, sep);
          hash_iterator_init (m->hash, &hi);
          while ((he = hash_iterator_next (&hi)))
            {
@@ -792,14 +792,15 @@ multi_print_status (struct multi_context *m, struct status_output *so, const int
 
              if (!mi->halt)
                {
-                 status_printf (so, "CLIENT_LIST%c%s%c%s%c%s%c" counter_format "%c" counter_format "%c%s%c%u",
+                 status_printf (so, "CLIENT_LIST%c%s%c%s%c%s%c" counter_format "%c" counter_format "%c%s%c%u%c%s",
                                 sep, tls_common_name (mi->context.c2.tls_multi, false),
                                 sep, mroute_addr_print (&mi->real, &gc),
                                 sep, print_in_addr_t (mi->reporting_addr, IA_EMPTY_IF_UNDEF, &gc),
                                 sep, mi->context.c2.link_read_bytes,
                                 sep, mi->context.c2.link_write_bytes,
                                 sep, time_string (mi->created, 0, false, &gc),
-                                sep, (unsigned int)mi->created);
+                                sep, (unsigned int)mi->created,
+                                sep, tls_username (mi->context.c2.tls_multi, false));
                }
              gc_free (&gc);
            }
diff --git a/ssl.c b/ssl.c
index 12c167c8f081128e1ec98aac23437bd6699576f5..94b4250f5eb4dd69830361fe4b9316618e2d672d 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -1404,6 +1404,20 @@ tls_lock_username (struct tls_multi *multi, const char *username)
   return true;
 }
 
+const char *
+tls_username (const struct tls_multi *multi, const bool null)
+{
+  const char *ret = NULL;
+  if (multi)
+    ret = multi->locked_username;
+  if (ret && strlen (ret))
+    return ret;
+  else if (null)
+    return NULL;
+  else
+    return "UNDEF";
+}
+
 #ifdef ENABLE_X509_TRACK
 
 void
diff --git a/ssl.h b/ssl.h
index 8d7b3633cb4065527fa5c80bedc31e3cdebdc236..0f05728e4a3d986519aacde3ad562f88b03f0266 100644 (file)
--- a/ssl.h
+++ b/ssl.h
@@ -849,6 +849,7 @@ bool tls_rec_payload (struct tls_multi *multi,
                      struct buffer *buf);
 
 const char *tls_common_name (const struct tls_multi* multi, const bool null);
+const char *tls_username(const struct tls_multi *multi, const bool null);
 void tls_set_common_name (struct tls_multi *multi, const char *common_name);
 void tls_lock_common_name (struct tls_multi *multi);
 void tls_lock_cert_hash_set (struct tls_multi *multi);