Skip to content

Commit

Permalink
vtysh: fix SA warning, no need to call getenv() twice
Browse files Browse the repository at this point in the history
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
  • Loading branch information
Jafaral committed Oct 15, 2024
1 parent 0aef4e4 commit 38661a6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions vtysh/vtysh_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ int main(int argc, char **argv, char **env)
char pathspace[MAXPATHLEN] = "";
const char *histfile = NULL;
const char *histfile_env = getenv("VTYSH_HISTFILE");
const char *logpath = getenv("VTYSH_LOG");

/* SUID: drop down to calling user & go back up when needed */
elevuid = geteuid();
Expand Down Expand Up @@ -643,9 +644,7 @@ int main(int argc, char **argv, char **env)
}
}

if (getenv("VTYSH_LOG")) {
const char *logpath = getenv("VTYSH_LOG");

if (logpath != NULL) {
logfile = fopen(logpath, "a");
if (!logfile) {
fprintf(stderr, "Failed to open logfile (%s): %s\n",
Expand Down

0 comments on commit 38661a6

Please sign in to comment.