summary refs log tree commit diff
path: root/kbfunc.c
diff options
context:
space:
mode:
authorokan <okan>2015-06-29 14:24:40 +0000
committerokan <okan>2015-06-29 14:24:40 +0000
commit9ea5f25347c056fc1ad2bf61a25dcb7181d5179b (patch)
tree666446602aab96df6ae0bfbbaca6b79f69928797 /kbfunc.c
parente7b4045ecea3b063bc8238172998ce5b1ed5bb97 (diff)
downloadcwm-9ea5f25347c056fc1ad2bf61a25dcb7181d5179b.tar.gz
cwm-9ea5f25347c056fc1ad2bf61a25dcb7181d5179b.tar.xz
cwm-9ea5f25347c056fc1ad2bf61a25dcb7181d5179b.zip
Shuffle code in kbfunc_ssh so that a missing known_hosts file still
allows a (now blank) menu to appear, as opposed to nothing at all.

Behavior reported by Alex Greif.
Diffstat (limited to 'kbfunc.c')
-rw-r--r--kbfunc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kbfunc.c b/kbfunc.c
index 5011a8a..c7de00d 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -329,18 +329,17 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
 	int			 l;
 	size_t			 len;
 
-	if ((fp = fopen(Conf.known_hosts, "r")) == NULL) {
-		warn("kbfunc_ssh: %s", Conf.known_hosts);
-		return;
-	}
-
 	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("kbfunc_ssh: %s", Conf.known_hosts);
+		goto menu;
+	}
+
 	lbuf = NULL;
 	while ((buf = fgetln(fp, &len))) {
 		if (buf[len - 1] == '\n')
@@ -366,7 +365,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
 	}
 	free(lbuf);
 	(void)fclose(fp);
-
+menu:
 	if ((mi = menu_filter(sc, &menuq, "ssh", NULL, CWM_MENU_DUMMY,
 	    search_match_exec, NULL)) != NULL) {
 		if (mi->text[0] == '\0')