]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #815 from dwalton76/CMD_WARNING_take2
authorRuss White <russ@riw.us>
Fri, 14 Jul 2017 10:24:01 +0000 (06:24 -0400)
committerGitHub <noreply@github.com>
Fri, 14 Jul 2017 10:24:01 +0000 (06:24 -0400)
vtysh: return non-zero for configuration failures

1  2 
babeld/babel_zebra.c
vtysh/vtysh.c

diff --combined babeld/babel_zebra.c
index 438dc9911970afc92d9beff299251eb442345eb4,4e96198e035be1aa837531d162dca830a5dc2460..a3217076f3d642c57976b2ceeeaf85a27b5f7c38
@@@ -223,11 -223,10 +223,11 @@@ DEFUN (babel_redistribute_type
  
      if (type < 0) {
          vty_outln (vty, "Invalid type %s", argv[1]->arg);
-         return CMD_WARNING;
+         return CMD_WARNING_CONFIG_FAILED;
      }
  
      zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
 +    zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
      return CMD_SUCCESS;
  }
  
@@@ -245,11 -244,10 +245,11 @@@ DEFUN (no_babel_redistribute_type
  
      if (type < 0) {
          vty_outln (vty, "Invalid type %s", argv[2]->arg);
-         return CMD_WARNING;
+         return CMD_WARNING_CONFIG_FAILED;
      }
  
      zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
 +    zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
      /* perhaps should we remove xroutes having the same type... */
      return CMD_SUCCESS;
  }
@@@ -281,7 -279,7 +281,7 @@@ DEFUN (debug_babel
  
      vty_outln (vty, "Invalid type %s", argv[2]->arg);
  
-     return CMD_WARNING;
+     return CMD_WARNING_CONFIG_FAILED;
  }
  
  /* [Babel Command] */
@@@ -311,7 -309,7 +311,7 @@@ DEFUN (no_debug_babel
  
      vty_outln (vty, "Invalid type %s", argv[3]->arg);
  
-     return CMD_WARNING;
+     return CMD_WARNING_CONFIG_FAILED;
  }
  #endif /* NO_DEBUG */
  
diff --combined vtysh/vtysh.c
index 6fc0e3917b1fdc1d0c979c41d73dc317ccb8c124,4613ab5926a87468a2aba3a0bf3fd706feeb2f36..c20d1f56bf82f8060b576ea6581414d3443a388e
@@@ -291,6 -291,7 +291,7 @@@ vtysh_execute_func (const char *line, i
     * Changing vty->node is enough to try it just out without actual walkup in
     * the vtysh. */
    while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING
+          && ret != CMD_WARNING_CONFIG_FAILED
         && vty->node > CONFIG_NODE)
      {
        vty->node = node_parent(vty->node);
    switch (ret)
      {
      case CMD_WARNING:
+     case CMD_WARNING_CONFIG_FAILED:
        if (vty->type == VTY_FILE)
        fprintf (stdout,"Warning...\n");
        break;
@@@ -553,6 -555,7 +555,7 @@@ vtysh_mark_file (const char *filename
         * Changing vty->node is enough to try it just out without actual walkup in
         * the vtysh. */
        while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING
+              && ret != CMD_WARNING_CONFIG_FAILED
             && vty->node > CONFIG_NODE)
        {
          vty->node = node_parent(vty->node);
        switch (ret)
        {
        case CMD_WARNING:
+       case CMD_WARNING_CONFIG_FAILED:
          if (vty->type == VTY_FILE)
            fprintf (stderr,"line %d: Warning...: %s\n", lineno, vty->buf);
          fclose(confp);
          vty_close(vty);
            XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
-         return CMD_WARNING;
+         return ret;
        case CMD_ERR_AMBIGUOUS:
          fprintf (stderr,"line %d: %% Ambiguous command: %s\n", lineno, vty->buf);
          fclose(confp);
@@@ -674,9 -678,10 +678,10 @@@ vtysh_config_from_file (struct vty *vty
        switch (ret)
        {
        case CMD_WARNING:
+       case CMD_WARNING_CONFIG_FAILED:
          if (vty->type == VTY_FILE)
            fprintf (stderr,"line %d: Warning[%d]...: %s\n", lineno, vty->node, vty->buf);
-         retcode = CMD_WARNING;                /* once we have an error, we remember & return that */
+         retcode = ret;                /* once we have an error, we remember & return that */
          break;
        case CMD_ERR_AMBIGUOUS:
          fprintf (stderr,"line %d: %% Ambiguous command[%d]: %s\n", lineno, vty->node, vty->buf);
@@@ -2445,10 -2450,20 +2450,10 @@@ DEFUNSH (VTYSH_ALL
  DEFUNSH (VTYSH_ALL,
         vtysh_config_password,
         vtysh_password_cmd,
 -       "password [(8-8)] WORD",
 +       "password [(8-8)] LINE",
         "Assign the terminal connection password\n"
         "Specifies a HIDDEN password will follow\n"
 -       "The HIDDEN line password string\n")
 -{
 -  return CMD_SUCCESS;
 -}
 -
 -DEFUNSH (VTYSH_ALL,
 -       vtysh_password_text,
 -       vtysh_password_text_cmd,
 -       "password LINE",
 -       "Assign the terminal connection password\n"
 -       "The UNENCRYPTED (cleartext) line password\n")
 +       "The password string\n")
  {
    return CMD_SUCCESS;
  }
  DEFUNSH (VTYSH_ALL,
         vtysh_config_enable_password,
         vtysh_enable_password_cmd,
 -       "enable password (8-8) WORD",
 +       "enable password [(8-8)] LINE",
         "Modify enable password parameters\n"
         "Assign the privileged level password\n"
         "Specifies a HIDDEN password will follow\n"
 -       "The HIDDEN 'enable' password string\n")
 -{
 -  return CMD_SUCCESS;
 -}
 -
 -DEFUNSH (VTYSH_ALL,
 -       vtysh_enable_password_text,
 -       vtysh_enable_password_text_cmd,
 -       "enable password LINE",
 -       "Modify enable password parameters\n"
 -       "Assign the privileged level password\n"
 -       "The UNENCRYPTED (cleartext) 'enable' password\n")
 +       "The 'enable' password string\n")
  {
    return CMD_SUCCESS;
  }
@@@ -2612,7 -2638,7 +2617,7 @@@ vtysh_write_config_integrated(void
      {
        fprintf (stdout,"%% Error: failed to open configuration file %s: %s\n",
               quagga_config, safe_strerror(errno));
-       return CMD_WARNING;
+       return CMD_WARNING_CONFIG_FAILED;
      }
    fd = fileno (fp);
  
@@@ -2714,7 -2740,7 +2719,7 @@@ DEFUN (vtysh_write_memory
    /* If integrated frr.conf explicitely set. */
    if (want_config_integrated())
      {
-       ret = CMD_WARNING;
+       ret = CMD_WARNING_CONFIG_FAILED;
        for (i = 0; i < array_size(vtysh_client); i++)
          if (vtysh_client[i].flag == VTYSH_WATCHFRR)
            break;
@@@ -3016,7 -3042,7 +3021,7 @@@ vtysh_connect (struct vtysh_client *vcl
      {
        fprintf  (stderr, "vtysh_connect(%s): stat = %s\n", 
                  path, safe_strerror(errno));
-       exit(1);
+       exit (1);
      }
    
    if (ret >= 0)
@@@ -3609,6 -3635,8 +3614,6 @@@ vtysh_init_vty (void
    install_element (CONFIG_NODE, &no_vtysh_service_password_encrypt_cmd);
  
    install_element (CONFIG_NODE, &vtysh_password_cmd);
 -  install_element (CONFIG_NODE, &vtysh_password_text_cmd);
    install_element (CONFIG_NODE, &vtysh_enable_password_cmd);
 -  install_element (CONFIG_NODE, &vtysh_enable_password_text_cmd);
    install_element (CONFIG_NODE, &no_vtysh_enable_password_cmd);
  }