summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2018-03-15 23:11:06 +0100
committerLou Berger <lberger@labn.net>2018-03-28 16:47:34 +0200
commit186f6af280a161eb75d1c6388c4dd94b421f892d (patch)
treeaf6f6f8cde303ff16c797006ba2d0f3d0cf70cab
parentvtysh: add -u/--user flag to run commands without enable (diff)
downloadfrr-186f6af280a161eb75d1c6388c4dd94b421f892d.tar.xz
frr-186f6af280a161eb75d1c6388c4dd94b421f892d.zip
vtysh: move user_mode to header file, keep checkpatch happy
Signed-off-by: Lou Berger <lberger@labn.net>
-rw-r--r--vtysh/vtysh.c1
-rw-r--r--vtysh/vtysh.h2
-rw-r--r--vtysh/vtysh_main.c7
3 files changed, 7 insertions, 3 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index dca5dafa8..f8493ae89 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -305,7 +305,6 @@ static int vtysh_execute_func(const char *line, int pager)
int closepager = 0;
int tried = 0;
int saved_ret, saved_node;
- extern int user_mode;
/* Split readline string up into the vector. */
vline = cmd_make_strvec(line);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index 52a1a4610..9b21c3376 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -100,4 +100,6 @@ extern int execute_flag;
extern struct vty *vty;
+extern int user_mode;
+
#endif /* VTYSH_H */
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index b5cc1d21d..4de671b7f 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -61,7 +61,7 @@ static char history_file[MAXPATHLEN];
int execute_flag = 0;
/* Flag to indicate if in user/unprivileged mode. */
-int user_mode = 0;
+int user_mode;
/* For sigsetjmp() & siglongjmp(). */
static sigjmp_buf jmpbuf;
@@ -315,6 +315,8 @@ int main(int argc, char **argv, char **env)
realgid = getgid();
suid_off();
+ user_mode = 0; /* may be set in options processing */
+
/* Preserve name of myself. */
progname = ((p = strrchr(argv[0], '/')) ? ++p : argv[0]);
@@ -323,7 +325,8 @@ int main(int argc, char **argv, char **env)
/* Option handling. */
while (1) {
- opt = getopt_long(argc, argv, "be:c:d:nf:mEhCwN:u", longopts, 0);
+ opt = getopt_long(argc, argv, "be:c:d:nf:mEhCwN:u",
+ longopts, 0);
if (opt == EOF)
break;