]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
re-add "show client config" command
authorAlan T. DeKok <aland@freeradius.org>
Mon, 11 Mar 2019 17:26:47 +0000 (13:26 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 11 Mar 2019 17:29:46 +0000 (13:29 -0400)
doc/ChangeLog
man/man8/radmin.8
src/main/command.c

index 0abf1c62559c0b90cc2c982cdb2075874a6f75f0..3e70521021d3716c84a93d5d7b89ae74405abd1d 100644 (file)
@@ -4,6 +4,7 @@ FreeRADIUS 3.0.19 Mon 25 Feb 2019 15:00:00 EST urgency=low
        * Update sqlippool to allow for stored procedures with
          PostgreSQL.  This increases performance substantially.
          Patch from Nathan Ward.  Fixes #2540.
+       * Re-added "show client config" command to radmin.
 
        Bug fixes
        * Update dynamic_client module and server core so that the
index b64a6fa4d855160464402bcbf54ca99184104b7a..b58a2e3951154d9b30fc379f464e897d7163453c 100644 (file)
@@ -138,6 +138,8 @@ set state for given home server
 do sub-command of show
 .IP show\ client\ <command>
 do sub-command of client
+.IP show\ client\ config\ <ipaddr>\ [udp|tcp]
+shows configuration for a given client.
 .IP show\ client\ list
 shows list of global clients
 .IP show\ debug\ <command>
@@ -176,7 +178,7 @@ Prints out configuration as XML
 do sub-command of stats
 .IP stats\ client\ [auth/acct]\ <ipaddr>
 show statistics for given client, or for all clients (auth or acct)
-.IP stats\ home_server\ [<ipaddr>/auth/acct]\ <port>
+.IP stats\ home_server\ [<ipaddr>|auth|acct]\ <port>
 show statistics for given home server (ipaddr and port), or for all home servers (auth or acct)
 .IP stats\ detail\ <filename>
 show statistics for the given detail file
index c62d74d9c9519a52ae08f454235f633e39ef9bf8..1d777c1c1d6ccc218d958b7f13a010050e52da4c 100644 (file)
@@ -926,6 +926,56 @@ static void cprint_conf_parser(rad_listen_t *listener, int indent, CONF_SECTION
        cprintf(listener, "%.*s}\n", indent, tabs);
 }
 
+static void cprint_conf_section(rad_listen_t *listener, int indent, CONF_SECTION *cs)
+{
+       char const *name1 = cf_section_name1(cs);
+       char const *name2 = cf_section_name2(cs);
+       CONF_ITEM *ci;
+
+       if (name2) {
+               cprintf(listener, "%.*s%s %s {\n", indent, tabs, name1, name2);
+       } else {
+               cprintf(listener, "%.*s%s {\n", indent, tabs, name1);
+       }
+
+       indent++;
+
+
+       for (ci = cf_item_find_next(cs, NULL);
+            ci != NULL;
+            ci = cf_item_find_next(cs, ci)) {
+               CONF_PAIR const *cp;
+               char const *value;
+
+               if (cf_item_is_section(ci)) {
+                       cprint_conf_section(listener, indent, cf_item_to_section(ci));
+                       continue;
+               }
+
+               if (!cf_item_is_pair(ci)) continue;
+
+               cp = cf_item_to_pair(ci);
+               value = cf_pair_value(cp);
+
+               if (value) {
+                       /*
+                        *      @todo - quote the value if necessary.
+                        */
+                       cprintf(listener, "%.*s%s = %s\n",
+                               indent, tabs,
+                               cf_pair_attr(cp), value);
+               } else {
+                       cprintf(listener, "%.*s%s\n",
+                               indent, tabs,
+                               cf_pair_attr(cp));
+               }
+       }
+
+       indent--;
+
+       cprintf(listener, "%.*s}\n", indent, tabs);
+}
+
 static int command_show_module_config(rad_listen_t *listener, int argc, char *argv[])
 {
        CONF_SECTION *cs;
@@ -1172,6 +1222,24 @@ static int command_show_home_servers(rad_listen_t *listener, UNUSED int argc, UN
 }
 #endif
 
+static RADCLIENT *get_client(rad_listen_t *listener, int argc, char *argv[]);
+
+static int command_show_client_config(rad_listen_t *listener, int argc, char *argv[])
+{
+       RADCLIENT *client;
+
+       client = get_client(listener, argc, argv);
+       if (!client) {
+               return 0;
+       }
+
+       if (!client->cs) return 1;
+
+       cprint_conf_section(listener, 0, client->cs);
+       return 1;
+}
+
+
 static int command_show_clients(rad_listen_t *listener, UNUSED int argc, UNUSED char *argv[])
 {
        int i;
@@ -1971,6 +2039,13 @@ static fr_command_table_t command_table_show_module[] = {
 };
 
 static fr_command_table_t command_table_show_client[] = {
+       { "config", FR_READ,
+         "show client config <ipaddr> "
+#ifdef WITH_TCP
+         "[udp|tcp] "
+#endif
+         "- show configuration for given client",
+         command_show_client_config, NULL },
        { "list", FR_READ,
          "show client list - shows list of global clients",
          command_show_clients, NULL },