Hi,
The ssh menu of cwm(1) doesn't filter duplicated hostnames when reading
them from ~/.ssh/known_hosts. This patch makes sure each hostname is
only displayed once to the menu.
Cheers,
Bruno
Index: app/cwm/kbfunc.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.165
diff -u -p -r1.165 kbfunc.c
--- app/cwm/kbfunc.c 7 Mar 2019 14:28:17 -0000 1.165
+++ app/cwm/kbfunc.c 12 Mar 2019 11:24:47 -0000
@@ -672,6 +672,7 @@ kbfunc_menu_ssh(void *ctx, struct cargs
lbuf = NULL;
len = 0;
+skip:
while ((slen = getline(&lbuf, &len, fp)) != -1) {
buf = lbuf;
if (buf[slen - 1] == '\n')
@@ -686,6 +687,10 @@ kbfunc_menu_ssh(void *ctx, struct cargs
if (p - buf + 1 > sizeof(hostbuf))
continue;
(void)strlcpy(hostbuf, buf, p - buf + 1);
+ /* skip duplicate hostnames */
+ TAILQ_FOREACH(mi, &menuq, entry);
+ if (strcmp(mi->text, hostbuf) == 0)
+ goto skip;
menuq_add(&menuq, NULL, "%s", hostbuf);
}
free(lbuf);