From 1dede1f8fcfda59d228f2ead3239beedc5cc711d Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Wed, 11 Apr 2018 22:15:00 +0200 Subject: [PATCH] vtysh: fix pathspec option -N Signed-off-by: Christian Franke --- vtysh/vtysh_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 4de671b7fa..cd59d8094b 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; -- 2.39.5