From: Jorge Pereira Date: Fri, 30 Aug 2019 22:12:37 +0000 (-0300) Subject: radmin: Add support to keep the history in ~/.radmin_history X-Git-Tag: release_3_0_20~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfa1721959a4f300ccdec53c46ee25dbc7541610;p=thirdparty%2Ffreeradius-server.git radmin: Add support to keep the history in ~/.radmin_history --- diff --git a/doc/ChangeLog b/doc/ChangeLog index 921850fb400..5b64f6681d2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -33,6 +33,7 @@ FreeRADIUS 3.0.20 Wed 10 Apr 2019 09:00:00 EDT urgency=low * sqlippool now re-allocates unexpired leases, to prevent IP pool exhaustion when clients perform multiple reauthentication attempts. Patch from Terry Burton. + * Add support to radmin keep the history in ~/.radmin_history Bug fixes * Allow listen.ipaddr to reference an IPv6-only host. Fixes #2627. diff --git a/src/main/radmin.c b/src/main/radmin.c index 3b6c588fe64..cf695ad8936 100644 --- a/src/main/radmin.c +++ b/src/main/radmin.c @@ -38,6 +38,10 @@ RCSID("$Id$") # include #endif +#ifndef READLINE_MAX_HISTORY_LINES +# define READLINE_MAX_HISTORY_LINES 1000 +#endif + #ifdef HAVE_LIBREADLINE # include @@ -339,6 +343,7 @@ int main(int argc, char **argv) char const *radius_dir = RADIUS_DIR; char const *dict_dir = DICTDIR; + char history_file[PATH_MAX]; char *commands[MAX_COMMANDS]; int num_commands = -1; @@ -582,6 +587,10 @@ int main(int argc, char **argv) if (!quiet) { #ifdef USE_READLINE_HISTORY using_history(); + stifle_history(READLINE_MAX_HISTORY_LINES); + + snprintf(history_file, sizeof(history_file), "%s/%s", getenv("HOME"), ".radmin_history"); + read_history(history_file); #endif rl_bind_key('\t', rl_insert); } @@ -643,6 +652,7 @@ int main(int argc, char **argv) #ifdef USE_READLINE_HISTORY add_history(line); + write_history(history_file); #endif } else /* quiet, or no readline */ #endif