vty: install 'exit', 'end',... commands on *all* nodes

In many callers of the VTY API, we are lacking the vty_install_default() step
at certain node levels. This creates nodes that lack the 'exit' command, and
hence the only way to exit such a node is to restart the telnet session.

Historically, the VTY looked for missing commands on the immediate parent node,
and hence possibly found the parent's 'exit' command when the local node was
missing it. That is why we so far did not notice the missing default commands.

Furthermore, some callers call install_default() instead of
vty_install_default(). Only vty_install_default() also includes the 'exit' and
'end' commands. There is no reason why there are two sets of default commands.

To end this confusion, to catch all missing 'exit' commands and to prevent this
from re-appearing in the future, simply *always* install all default commands
implicitly when calling install_node().

In cmd_init(), there are some top-level nodes that apparently do not want the
default commands installed. Keep those the way they are, by changing the
invocation to new install_node_bare() ({VIEW,AUTH,AUTH_ENABLE}_NODE).

Make both install_default() and vty_install_default() no-ops so that users of
the API may still call them without harm. Do not yet deprecate yet, which
follows in Icf5d83f641e838cebcccc635a043e94ba352abff.

Drop all invocations to these two functions found in libosmocore.

Change-Id: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
diff --git a/src/vty/command.c b/src/vty/command.c
index 8ad2e97..21b26b4 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -149,8 +149,10 @@
 	return name_buf;
 }
 
-/*! Install top node of command vector. */
-void install_node(struct cmd_node *node, int (*func) (struct vty *))
+static void install_basic_node_commands(int node);
+
+/*! Install top node of command vector, without adding basic node commands. */
+static void install_node_bare(struct cmd_node *node, int (*func) (struct vty *))
 {
 	vector_set_index(cmdvec, node->node, node);
 	node->func = func;
@@ -159,6 +161,13 @@
 		node_name_from_prompt(node->prompt, node->name, sizeof(node->name));
 }
 
+/*! Install top node of command vector. */
+void install_node(struct cmd_node *node, int (*func) (struct vty *))
+{
+	install_node_bare(node, func);
+	install_basic_node_commands(node->node);
+}
+
 /* Compare two command's string.  Used in sort_node (). */
 static int cmp_node(const void *p, const void *q)
 {
@@ -3599,8 +3608,23 @@
 	host.config = talloc_strdup(tall_vty_cmd_ctx, filename);
 }
 
+/*! Deprecated, now happens implicitly when calling install_node().
+ * Users of the API may still attempt to call this function, hence
+ * leave it here as a no-op. */
 void install_default(int node)
 {
+}
+
+/*! Deprecated, now happens implicitly when calling install_node().
+ * Users of the API may still attempt to call this function, hence
+ * leave it here as a no-op. */
+void vty_install_default(int node)
+{
+}
+
+/*! Install common commands like 'exit' and 'list'. */
+static void install_basic_node_commands(int node)
+{
 	install_element(node, &config_help_cmd);
 	install_element(node, &config_list_cmd);
 
@@ -3609,11 +3633,6 @@
 	install_element(node, &config_write_memory_cmd);
 	install_element(node, &config_write_cmd);
 	install_element(node, &show_running_config_cmd);
-}
-
-void vty_install_default(int node)
-{
-	install_default(node);
 
 	install_element(node, &config_exit_cmd);
 
@@ -3681,10 +3700,10 @@
 	host.motdfile = NULL;
 
 	/* Install top nodes. */
-	install_node(&view_node, NULL);
+	install_node_bare(&view_node, NULL);
 	install_node(&enable_node, NULL);
-	install_node(&auth_node, NULL);
-	install_node(&auth_enable_node, NULL);
+	install_node_bare(&auth_node, NULL);
+	install_node_bare(&auth_enable_node, NULL);
 	install_node(&config_node, config_write_host);
 
 	/* Each node's basic commands. */
@@ -3701,7 +3720,6 @@
 	}
 
 	if (terminal) {
-		vty_install_default(ENABLE_NODE);
 		install_element(ENABLE_NODE, &config_disable_cmd);
 		install_element(ENABLE_NODE, &config_terminal_cmd);
 		install_element (ENABLE_NODE, &copy_runningconfig_startupconfig_cmd);
@@ -3714,8 +3732,6 @@
 		install_element(ENABLE_NODE, &config_terminal_length_cmd);
 		install_element(ENABLE_NODE, &config_terminal_no_length_cmd);
 		install_element(ENABLE_NODE, &echo_cmd);
-
-		vty_install_default(CONFIG_NODE);
 	}
 
 	install_element(CONFIG_NODE, &hostname_cmd);