summaryrefslogtreecommitdiff
path: root/vtysh
diff options
context:
space:
mode:
authorhasso <hasso>2004-08-26 22:21:31 +0000
committerhasso <hasso>2004-08-26 22:21:31 +0000
commit67e29abc5800ec77a3ee36add6adfe5fa8c38351 (patch)
tree73a93502607cac89fa3634997832b0068774fe53 /vtysh
parent9a0962651b0837b5678da0ef88715ec438f9dcb5 (diff)
More vtysh fixes. Specifying configuration from command line works now.
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/ChangeLog11
-rw-r--r--vtysh/vtysh.c1
-rw-r--r--vtysh/vtysh.h2
-rw-r--r--vtysh/vtysh_config.c38
-rw-r--r--vtysh/vtysh_main.c18
5 files changed, 35 insertions, 35 deletions
diff --git a/vtysh/ChangeLog b/vtysh/ChangeLog
index e73317d4..1903c7c2 100644
--- a/vtysh/ChangeLog
+++ b/vtysh/ChangeLog
@@ -1,4 +1,13 @@
-2004-08-26 Hasso Tepper <hasso@estpak.ee>
+2004-08-27 Hasso Tepper <hasso at quagga.net>
+
+ * vtysh.c: Enable using ssh from ENABLE_NODE.
+ * vtysh_config.c: Make enable password uniq lines appear only once in
+ configuration.
+ * vtysh_main.c, vtysh_config.c, vtysh.h: Remove useless code which
+ searched configuration files from current directory. Add -f to
+ specify conf from command line.
+
+2004-08-26 Hasso Tepper <hasso at quagga.net>
* *.c: Cosmetical changes - strip long lines, fix multiline comments
style, indentation fixes, remove useless comments.
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index e8310d7c..503edb30 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1999,6 +1999,7 @@ vtysh_init_vty ()
#endif
install_element (ENABLE_NODE, &vtysh_telnet_cmd);
install_element (ENABLE_NODE, &vtysh_telnet_port_cmd);
+ install_element (ENABLE_NODE, &vtysh_ssh_cmd);
install_element (ENABLE_NODE, &vtysh_start_shell_cmd);
install_element (ENABLE_NODE, &vtysh_start_bash_cmd);
install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index abfb3ec4..895c8c01 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -60,7 +60,7 @@ void vtysh_config_write ();
int vtysh_config_from_file (struct vty *, FILE *);
-void vtysh_read_config (char *, char *, char *);
+void vtysh_read_config (char *, char *);
void vtysh_config_parse (char *);
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index f518653f..86f5731b 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -228,7 +228,9 @@ vtysh_config_parse_line (char *line)
{
if (strncmp (line, "log", strlen ("log")) == 0
|| strncmp (line, "hostname", strlen ("hostname")) == 0
- || strncmp (line, "password", strlen ("hostname")) == 0)
+ || strncmp (line, "password", strlen ("password")) == 0
+ || strncmp (line, "enable password",
+ strlen ("enable password")) == 0)
config_add_line_uniq (config_top, line);
else
config_add_line (config_top, line);
@@ -365,7 +367,6 @@ vtysh_read_file (FILE *confp)
/* Read up configuration file from file_name. */
void
vtysh_read_config (char *config_file,
- char *config_current_dir,
char *config_default_dir)
{
char *cwd;
@@ -396,32 +397,19 @@ vtysh_read_config (char *config_file,
}
else
{
- /* Relative path configuration file open. */
- if (config_current_dir)
- confp = fopen (config_current_dir, "r");
-
- /* If there is no relative path exists, open system default file. */
+ /* No configuration specified from command line. Open system
+ * default file. */
+ confp = fopen (config_default_dir, "r");
if (confp == NULL)
{
- confp = fopen (config_default_dir, "r");
- if (confp == NULL)
- {
- fprintf (stderr, "can't open configuration file [%s]\n",
- config_default_dir);
- exit (1);
- }
- else
- fullpath = config_default_dir;
- }
+ fprintf (stderr, "can't open configuration file [%s]\n",
+ config_default_dir);
+ exit (1);
+ }
else
- {
- /* Rleative path configuration file. */
- cwd = getcwd (NULL, MAXPATHLEN);
- fullpath = XMALLOC (MTYPE_TMP,
- strlen (cwd) + strlen (config_current_dir) + 2);
- sprintf (fullpath, "%s/%s", cwd, config_current_dir);
- }
- }
+ fullpath = config_default_dir;
+ }
+
vtysh_read_file (confp);
fclose (confp);
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 69a5358e..e862efd6 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -39,12 +39,8 @@
/* VTY shell program name. */
char *progname;
-/* Configuration file name. Usually this is configurable, but vtysh
- * has static configuration file only. */
+/* Configuration file name and directory. */
char *config_file = NULL;
-
-/* Configuration file and directory. */
-char *config_current = NULL;
char config_default[] = SYSCONFDIR VTYSH_DEFAULT_CONFIG;
/* Integrated configuration file. */
@@ -146,6 +142,7 @@ usage (int status)
"Integrated shell for Quagga routing software suite. \n\n"\
"-b, --boot Execute boot startup configuration\n" \
"-c, --command Execute argument as command\n "\
+ "-f, --config_file Set configuration file name\n"\
"-h, --help Display this help and exit\n\n" \
"Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
@@ -160,6 +157,7 @@ struct option longopts[] =
{ "eval", required_argument, NULL, 'e'},
{ "command", required_argument, NULL, 'c'},
{ "help", no_argument, NULL, 'h'},
+ { "config_file", required_argument, NULL, 'f'},
{ 0 }
};
@@ -209,7 +207,7 @@ main (int argc, char **argv, char **env)
/* Option handling. */
while (1)
{
- opt = getopt_long (argc, argv, "be:c:h", longopts, 0);
+ opt = getopt_long (argc, argv, "be:c:hf:", longopts, 0);
if (opt == EOF)
break;
@@ -229,8 +227,12 @@ main (int argc, char **argv, char **env)
case 'h':
usage (0);
break;
+ /* XXX It isn't used in any way. */
case 'i':
integrated_file = strdup (optarg);
+ case 'f':
+ config_file = optarg;
+ break;
default:
usage (1);
break;
@@ -256,7 +258,7 @@ main (int argc, char **argv, char **env)
vtysh_connect_all ();
/* Read vtysh configuration file. */
- vtysh_read_config (config_file, config_current, config_default);
+ vtysh_read_config (config_file, config_default);
/* If eval mode. */
if (eval_flag)
@@ -268,7 +270,7 @@ main (int argc, char **argv, char **env)
/* Boot startup configuration file. */
if (boot_flag)
{
- vtysh_read_config (integrate_file, integrate_current, integrate_default);
+ vtysh_read_config (integrate_file, integrate_default);
exit (0);
}