From fa2c15634ca2c5f1c3f0483f1c74c76374e52da4 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 2 Aug 2024 13:29:28 +0200 Subject: [PATCH] keyboxd: New getinfo subcommand "connections". * kbx/kbxserver.c (cmd_getinfo): Add subcommand. --- kbx/kbxserver.c | 7 +++++++ kbx/keyboxd.c | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/kbx/kbxserver.c b/kbx/kbxserver.c index 3e68bfc26..fc79209eb 100644 --- a/kbx/kbxserver.c +++ b/kbx/kbxserver.c @@ -745,6 +745,7 @@ static const char hlp_getinfo[] = "pid - Return the process id of the server.\n" "socket_name - Return the name of the socket.\n" "session_id - Return the current session_id.\n" + "connections - Return number of active connections.\n" "getenv NAME - Return value of envvar NAME\n"; static gpg_error_t cmd_getinfo (assuan_context_t ctx, char *line) @@ -792,6 +793,12 @@ cmd_getinfo (assuan_context_t ctx, char *line) err = assuan_send_data (ctx, s, strlen (s)); } } + else if (!strcmp (line, "connections")) + { + snprintf (numbuf, sizeof numbuf, "%d", + get_kbxd_active_connection_count ()); + err = assuan_send_data (ctx, numbuf, strlen (numbuf)); + } else err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for WHAT"); diff --git a/kbx/keyboxd.c b/kbx/keyboxd.c index f6332c127..042ed20b5 100644 --- a/kbx/keyboxd.c +++ b/kbx/keyboxd.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include