On Fri, Jul 07, 2017 at 12:44:35PM -0400, Okan Demirmen wrote:
> Hi cwm users,
>
> In converting this to use getline(3) over fgetln(3), I'm asking the question
> if
> this (imho) mis-feature belongs in a window manager. I've hinted at wanting to
> remove it in the past but there was opposition. As a compromise, we could
> just
> leave the 'ssh>' menu available, but it will not be pre-populated (nor
> auto-completed) by what's in ~/.ssh/known_hosts; just type in the
> host/ip/whatever at the menu prompt. cwm(1) does a very rudimentary pass at
> parsing the known_hosts file, and there's no reason to hoist code from ssh(1)
> just to get auto-completion in a window manager menu.
>
> Below is the minimal code part in kbfunc_menu_ssh().
>
> Preferably, I'd like to remove the whole ssh menu, but can live with the below
> if it's useful to others.
>
> Thoughts?
>
> Thanks,
> Okan
Just my opinion, users can already set short aliases in their
.ssh/config files, so having to type in the host manually
shouldn't be too difficult.
I've never used this feature, I also typically don't expect auto
completion from every window manager UI context, unless for cmds
and paths.
-Bryan.
> Index: kbfunc.c
> ===================================================================
> RCS file: /home/open/cvs/xenocara/app/cwm/kbfunc.c,v
> retrieving revision 1.145
> diff -u -p -r1.145 kbfunc.c
> --- kbfunc.c 9 May 2017 13:40:18 -0000 1.145
> +++ kbfunc.c 6 Jul 2017 19:36:13 -0000
> @@ -462,50 +462,16 @@ kbfunc_menu_ssh(void *ctx, struct cargs
> struct cmd_ctx *cmd;
> struct menu *mi;
> struct menu_q menuq;
> - FILE *fp;
> - char *buf, *lbuf, *p;
> - char hostbuf[HOST_NAME_MAX+1];
> char path[PATH_MAX];
> int l;
> - size_t len;
>
> TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
> if (strcmp(cmd->name, "term") == 0)
> break;
> }
> - TAILQ_INIT(&menuq);
>
> - if ((fp = fopen(Conf.known_hosts, "r")) == NULL) {
> - warn("%s: %s", __func__, Conf.known_hosts);
> - goto menu;
> - }
> + TAILQ_INIT(&menuq);
>
> - lbuf = NULL;
> - while ((buf = fgetln(fp, &len))) {
> - if (buf[len - 1] == '\n')
> - buf[len - 1] = '\0';
> - else {
> - /* EOF without EOL, copy and add the NUL */
> - lbuf = xmalloc(len + 1);
> - (void)memcpy(lbuf, buf, len);
> - lbuf[len] = '\0';
> - buf = lbuf;
> - }
> - /* skip hashed hosts */
> - if (strncmp(buf, HASH_MARKER, strlen(HASH_MARKER)) == 0)
> - continue;
> - for (p = buf; *p != ',' && *p != ' ' && p != buf + len; p++) {
> - /* do nothing */
> - }
> - /* ignore badness */
> - if (p - buf + 1 > sizeof(hostbuf))
> - continue;
> - (void)strlcpy(hostbuf, buf, p - buf + 1);
> - menuq_add(&menuq, NULL, "%s", hostbuf);
> - }
> - free(lbuf);
> - (void)fclose(fp);
> -menu:
> if ((mi = menu_filter(sc, &menuq, "ssh", NULL, (CWM_MENU_DUMMY),
> search_match_text, search_print_text)) != NULL) {
> if (mi->text[0] == '\0')