vtysh: fix pathspec option -N

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
This commit is contained in:
Christian Franke 2018-04-11 22:15:00 +02:00
parent b39404c189
commit 1dede1f8fc

View File

@ -306,6 +306,7 @@ int main(int argc, char **argv, char **env)
char *homedir = NULL; char *homedir = NULL;
int ditch_suid = 0; int ditch_suid = 0;
char sysconfdir[MAXPATHLEN]; char sysconfdir[MAXPATHLEN];
const char *pathspace_arg = NULL;
char pathspace[MAXPATHLEN] = ""; char pathspace[MAXPATHLEN] = "";
/* SUID: drop down to calling user & go back up when needed */ /* 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"); "slashes or dots are not permitted in the --pathspace option.\n");
exit(1); exit(1);
} }
snprintf(pathspace, sizeof(pathspace), "/%s", optarg); pathspace_arg = optarg;
snprintf(pathspace, sizeof(pathspace), "%s/", optarg);
break; break;
case 'd': case 'd':
daemon_name = optarg; daemon_name = optarg;
@ -419,7 +421,11 @@ int main(int argc, char **argv, char **env)
pathspace, VTYSH_CONFIG_NAME); pathspace, VTYSH_CONFIG_NAME);
snprintf(frr_config, sizeof(frr_config), "%s%s%s", sysconfdir, snprintf(frr_config, sizeof(frr_config), "%s%s%s", sysconfdir,
pathspace, FRR_CONFIG_NAME); 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. */ /* Initialize user input buffer. */
line_read = NULL; line_read = NULL;