diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index dca5dafa84..f8493ae89b 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 52a1a46105..9b21c3376a 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 b5cc1d21d1..4de671b7fa 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;