]> git.puffer.fish Git - matthieu/frr.git/commitdiff
More vtysh fixes. Specifying configuration from command line works now.
authorhasso <hasso>
Thu, 26 Aug 2004 22:21:31 +0000 (22:21 +0000)
committerhasso <hasso>
Thu, 26 Aug 2004 22:21:31 +0000 (22:21 +0000)
doc/ChangeLog
doc/vtysh.1
vtysh/ChangeLog
vtysh/vtysh.c
vtysh/vtysh.h
vtysh/vtysh_config.c
vtysh/vtysh_main.c

index b9326c012b51b9c2c31ee3366cc08c76d26e0ba3..63b736ccdd5d471ec52059b833d7e028796ccd93 100644 (file)
@@ -1,3 +1,7 @@
+2004-08-27 Hasso Tepper <hasso at quagga.net>
+
+       * Update vtysh man page to reflect changes in shell.
+
 2004-08-10 Hasso Tepper <hasso at quagga.net>
 
        * Updated man pages.
index f6ad62b5c1100f84cbfb01795bde83d60f7e924c..90aaff1bf884f506946a60f208a6560e9221ad00 100644 (file)
@@ -1,14 +1,22 @@
-.TH VTYSH 1 "10 August 2004" "Quagga VTY shell" "Version 0.96.5"
+.TH VTYSH 1 "27 August 2004" "Quagga VTY shell" "Version 0.96.5"
 .SH NAME
 vtysh \- a integrated shell for Quagga routing software
 .SH SYNOPSIS
 .B vtysh
 [
+.B \-f
+.I config-file
+]
+[
 .B \-b
 ]
 .br
 .B vtysh
 [
+.B \-f
+.I config-file
+]
+[
 .B \-c
 .I command
 ]
@@ -34,8 +42,11 @@ is executed and vtysh exits.
 It's useful for gathering info from Quagga routing software from shell scripts
 etc.
 .IP "\fB\-e, \-\-execute \fIcommand\fP"
-Alias for -c. It's only for compatibility with Zebra routing software and older
-Quagga versions and this might be removed in future.
+Alias for -c. It's here only for compatibility with Zebra routing software and
+older Quagga versions. This will be removed in future.
+.IP "\fB\-f, \-\-config-file \fIconfig-file\fP"
+Specifies the config file to use for startup. If not specified this option will
+likely default to \fB\fI/usr/local/etc/vtysh.conf\fR.
 .IP "\fB\-h, \-\-help\fP"
 Display a usage message on standard output and exit.
 .SH ENVIRONMENT VARIABLES
index e73317d4ad2c61444d96c798cbe9fe1274df794f..1903c7c2a7c55e86a93fe74839ed33c7d202754c 100644 (file)
@@ -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.
index e8310d7c6abad00fc8aa2fcbc3636b234ae8bf9c..503edb30aea0d6a174b1c762ef8d6f952d3a2fcd 100644 (file)
@@ -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);
index abfb3ec4c68ce285dca97b0f846e2c486fdb8e55..895c8c01ef288834a287c066ed4dba739281edef 100644 (file)
@@ -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 *);
 
index f518653f4b048815359b336632f7bbaec690a703..86f5731b46d5ef3ee6bab52ddf226e5fed168c1b 100644 (file)
@@ -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);
index 69a5358ed647b79577c1d8109a5c02ecccee5e43..e862efd638623c36adb56609b8d28395645ca132 100644 (file)
 /* 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);
     }