diff options
author | Christian Franke <chris@opensourcerouting.org> | 2018-04-11 22:15:00 +0200 |
---|---|---|
committer | Christian Franke <chris@opensourcerouting.org> | 2018-04-11 22:15:00 +0200 |
commit | 1dede1f8fcfda59d228f2ead3239beedc5cc711d (patch) | |
tree | 8135171fe54beb325b5797f3ab369e3c0cb08609 | |
parent | lib: fix pathspace option -N (diff) | |
download | frr-1dede1f8fcfda59d228f2ead3239beedc5cc711d.tar.xz frr-1dede1f8fcfda59d228f2ead3239beedc5cc711d.zip |
vtysh: fix pathspec option -N
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
-rw-r--r-- | vtysh/vtysh_main.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 4de671b7f..cd59d8094 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -306,6 +306,7 @@ int main(int argc, char **argv, char **env) char *homedir = NULL; int ditch_suid = 0; char sysconfdir[MAXPATHLEN]; + const char *pathspace_arg = NULL; char pathspace[MAXPATHLEN] = ""; /* SUID: drop down to calling user & go back up when needed */ @@ -363,7 +364,8 @@ int main(int argc, char **argv, char **env) "slashes or dots are not permitted in the --pathspace option.\n"); exit(1); } - snprintf(pathspace, sizeof(pathspace), "/%s", optarg); + pathspace_arg = optarg; + snprintf(pathspace, sizeof(pathspace), "%s/", optarg); break; case 'd': daemon_name = optarg; @@ -419,7 +421,11 @@ int main(int argc, char **argv, char **env) pathspace, VTYSH_CONFIG_NAME); snprintf(frr_config, sizeof(frr_config), "%s%s%s", sysconfdir, pathspace, FRR_CONFIG_NAME); - strlcat(vtydir, pathspace, sizeof(vtydir)); + + if (pathspace_arg) { + strlcat(vtydir, "/", sizeof(vtydir)); + strlcat(vtydir, pathspace_arg, sizeof(vtydir)); + } /* Initialize user input buffer. */ line_read = NULL; |