From: Alan T. DeKok Date: Mon, 11 Mar 2019 17:26:47 +0000 (-0400) Subject: re-add "show client config" command X-Git-Tag: release_3_0_19~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78fa15f0e4a09cb5f641e78ad4deef8a103f39f9;p=thirdparty%2Ffreeradius-server.git re-add "show client config" command --- diff --git a/doc/ChangeLog b/doc/ChangeLog index 0abf1c62559..3e70521021d 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -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 diff --git a/man/man8/radmin.8 b/man/man8/radmin.8 index b64a6fa4d85..b58a2e39511 100644 --- a/man/man8/radmin.8 +++ b/man/man8/radmin.8 @@ -138,6 +138,8 @@ set state for given home server do sub-command of show .IP show\ client\ do sub-command of client +.IP show\ client\ config\ \ [udp|tcp] +shows configuration for a given client. .IP show\ client\ list shows list of global clients .IP show\ debug\ @@ -176,7 +178,7 @@ Prints out configuration as XML do sub-command of stats .IP stats\ client\ [auth/acct]\ show statistics for given client, or for all clients (auth or acct) -.IP stats\ home_server\ [/auth/acct]\ +.IP stats\ home_server\ [|auth|acct]\ show statistics for given home server (ipaddr and port), or for all home servers (auth or acct) .IP stats\ detail\ show statistics for the given detail file diff --git a/src/main/command.c b/src/main/command.c index c62d74d9c95..1d777c1c1d6 100644 --- a/src/main/command.c +++ b/src/main/command.c @@ -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 " +#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 },