]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow trailing space for tab completion
authorAlan T. DeKok <aland@freeradius.org>
Tue, 3 Sep 2019 21:57:52 +0000 (17:57 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 3 Sep 2019 21:58:26 +0000 (17:58 -0400)
src/modules/proto_control/proto_control_unix.c
src/modules/proto_control/radmin.c

index ae65cf9ea4794724dea788e74864b572aaa6c17b..a31b44325ef7bbe6e774fed5a634603cb3d9470c 100644 (file)
@@ -197,6 +197,8 @@ static ssize_t mod_read_command(fr_listen_t *li, UNUSED void **packet_ctx, UNUSE
                start = (string[0] << 8) | string[1];
 
                thread->misc_conduit = FR_CONDUIT_COMPLETE;
+
+               fprintf(stderr, "COMPLETE %d %d %s\n", hdr->length - 2, start, string + 2);
                fr_radmin_complete(thread->misc, string + 2, start);
                thread->misc_conduit = FR_CONDUIT_STDOUT;
                status = FR_CONDUIT_SUCCESS;
index 7fdd384dba955cce7004b25fd0fcf15d7d5e862f..6fafd1edacd91278ac8e73c75161067d8454a276 100644 (file)
@@ -501,6 +501,14 @@ static ssize_t cmd_copy(char const *cmd)
 
        if (stack_depth > 0) *(p++) = ' ';
 
+       /*
+        *      No input, allow a trailing space so that tab
+        *      completion works.
+        */
+       if (!*cmd) {
+               return p - cmd_buffer;
+       }
+
        len = strlcpy(p, cmd, cmd_buffer + sizeof(cmd_buffer) - p);
        if ((p + len) >= (cmd_buffer + sizeof(cmd_buffer))) {
                fprintf(stderr, "Command too long\n");
@@ -578,16 +586,16 @@ radmin_completion(const char *text, int start, UNUSED int end)
 
        radmin_num_expansions = 0;
 
-       start += stack[stack_depth] - cmd_buffer;
+       len = cmd_copy(rl_line_buffer);
+       if (len < 0) return NULL;
+
+       start += len;
 
        if (start > 65535) return NULL;
 
        io_buffer[0] = (start >> 8) & 0xff;
        io_buffer[1] = start & 0xff;
 
-       len = cmd_copy(rl_line_buffer);
-       if (len < 0) return NULL;
-
        /*
         *      Note that "text" is the PARTIAL thing we're trying to complete.
         *      And "start" is the OFFSET from rl_line_buffer where we want to