]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
radmin: Add support to keep the history in ~/.radmin_history
authorJorge Pereira <jpereira@freeradius.org>
Fri, 30 Aug 2019 22:12:37 +0000 (19:12 -0300)
committerAlan DeKok <aland@freeradius.org>
Mon, 2 Sep 2019 21:19:10 +0000 (17:19 -0400)
doc/ChangeLog
src/main/radmin.c

index 921850fb4009bc8e74fbe5bfed513e48cd0f1862..5b64f6681d295dfcbd29a567bc0af4327700d471 100644 (file)
@@ -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.
index 3b6c588fe6415b802ca529b9fc99b697ae097911..cf695ad8936563471f4f0db2ea9bb317564f7d31 100644 (file)
@@ -38,6 +38,10 @@ RCSID("$Id$")
 #  include <sys/stat.h>
 #endif
 
+#ifndef READLINE_MAX_HISTORY_LINES
+#      define READLINE_MAX_HISTORY_LINES 1000
+#endif
+
 #ifdef HAVE_LIBREADLINE
 
 # include <stdio.h>
@@ -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