]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Moved no-password warnings into header file
authorPascal Mathis <mail@pascalmathis.com>
Sun, 13 May 2018 17:11:43 +0000 (19:11 +0200)
committerPascal Mathis <mail@pascalmathis.com>
Tue, 29 May 2018 18:08:37 +0000 (20:08 +0200)
The warning string which appears when the users executes 'no (enable)
password' was moved into command.h and declared as a constant named
'NO_PASSWD_CMD_WARNING'.

This avoids duplicate code and makes it easy to change the warning
message in all places at once.

Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
(cherry picked from commit 4911ca9cab5d75b5031edb83b52423ed47798324)

lib/command.c
lib/command.h
vtysh/vtysh.c

index e06db4deeea4116242f1793957106aeff06af42d..dc50193f60664a267ed88af0c1b3ef96bf040d6e 100644 (file)
@@ -1945,10 +1945,7 @@ DEFUN (no_config_password,
 
        if (host.password) {
                if (!vty_shell_serv(vty)) {
-                       vty_out(vty,
-                               "Please be aware that removing the password is "
-                               "a security risk and you should think twice "
-                               "about this command\n");
+                       vty_out(vty, NO_PASSWD_CMD_WARNING);
                        warned = true;
                }
                XFREE(MTYPE_HOST, host.password);
@@ -1957,10 +1954,7 @@ DEFUN (no_config_password,
 
        if (host.password_encrypt) {
                if (!warned && !vty_shell_serv(vty))
-                       vty_out(vty,
-                               "Please be aware that removing the password is "
-                               "a security risk and you should think twice "
-                               "about this command\n");
+                       vty_out(vty, NO_PASSWD_CMD_WARNING);
                XFREE(MTYPE_HOST, host.password_encrypt);
        }
        host.password_encrypt = NULL;
@@ -2033,10 +2027,7 @@ DEFUN (no_config_enable_password,
 
        if (host.enable) {
                if (!vty_shell_serv(vty)) {
-                       vty_out(vty,
-                               "Please be aware that removing the password is "
-                               "a security risk and you should think twice "
-                               "about this command\n");
+                       vty_out(vty, NO_PASSWD_CMD_WARNING);
                        warned = true;
                }
                XFREE(MTYPE_HOST, host.enable);
@@ -2045,10 +2036,7 @@ DEFUN (no_config_enable_password,
 
        if (host.enable_encrypt) {
                if (!warned && !vty_shell_serv(vty))
-                       vty_out(vty,
-                               "Please be aware that removing the password is "
-                               "a security risk and you should think twice "
-                               "about this command\n");
+                       vty_out(vty, NO_PASSWD_CMD_WARNING);
                XFREE(MTYPE_HOST, host.enable_encrypt);
        }
        host.enable_encrypt = NULL;
index f18de3417cae810bbe0df47f87d7614cf025bd42..26e8fc7e1198cad8b4eea2bf26b3bcd52cbbc1b3 100644 (file)
@@ -376,6 +376,10 @@ struct cmd_node {
 
 #define CONF_BACKUP_EXT ".sav"
 
+/* Command warnings. */
+#define NO_PASSWD_CMD_WARNING                                                  \
+       "Please be aware that removing the password is a security risk and you should think twice about this command.\n"
+
 /* IPv4 only machine should not accept IPv6 address for peer's IP
    address.  So we replace VTY command string like below. */
 #define NEIGHBOR_ADDR_STR  "Neighbor address\nIPv6 address\n"
index 84b28b18b5703f41ff3a6145fd1d27115d6c9880..4182ca50ab40534eb128c223498f0bef0389df09 100644 (file)
@@ -2372,9 +2372,7 @@ DEFUNSH(VTYSH_ALL, no_vtysh_config_password, no_vtysh_password_cmd,
        "no password", NO_STR
        "Modify the terminal connection password\n")
 {
-       vty_out(vty,
-               "Please be aware that removing the password is a security risk "
-               "and you should think twice about this command\n");
+       vty_out(vty, NO_PASSWD_CMD_WARNING);
 
        return CMD_SUCCESS;
 }
@@ -2394,9 +2392,7 @@ DEFUNSH(VTYSH_ALL, no_vtysh_config_enable_password,
        "Modify enable password parameters\n"
        "Assign the privileged level password\n")
 {
-       vty_out(vty,
-               "Please be aware that removing the password is a security risk "
-               "and you should think twice about this command\n");
+       vty_out(vty, NO_PASSWD_CMD_WARNING);
 
        return CMD_SUCCESS;
 }