From b6e065cda1db37a6c8ed52dac3432468e1277323 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 17 Jun 2013 14:36:37 +0200 Subject: tools: Only use our private path when looking for external commands Instead of looking for external commands in the path, just look for them in our private directory. We want to be conservative early on, and limit what sorta things we have to maintain later. We can later remove this restriction if a real use case presents itself. --- tools/tool.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'tools/tool.c') diff --git a/tools/tool.c b/tools/tool.c index a2dbcbd..dcbb1a5 100644 --- a/tools/tool.c +++ b/tools/tool.c @@ -194,20 +194,17 @@ exec_external (const char *command, char *argv[]) { char *filename; - const char *path; - char *env; + char *path; if (!asprintf (&filename, "p11-kit-%s", command) < 0) return_if_reached (); /* Add our libexec directory to the path */ - path = getenv ("PATH"); - if (!asprintf (&env, "PATH=%s%s%s", path ? path : "", path ? P11_PATH_SEP : "", PRIVATEDIR)) - return_if_reached (); - putenv (env); + path = p11_path_build (PRIVATEDIR, filename, NULL); + return_if_fail (path != NULL); argv[0] = filename; - execvp (filename, argv); + execvp (path, argv); } static void -- cgit v1.1 From e32481727387460d5900d0bbb495d3694facf64b Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 17 Jun 2013 14:45:36 +0200 Subject: tools: Fix passing args to external commands There were various bugs passing arguments, with duplicates being passed, as well as certain arguments being skipped.t --- tools/tool.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/tool.c') diff --git a/tools/tool.c b/tools/tool.c index dcbb1a5..313484a 100644 --- a/tools/tool.c +++ b/tools/tool.c @@ -204,6 +204,8 @@ exec_external (const char *command, return_if_fail (path != NULL); argv[0] = filename; + argv[argc] = NULL; + execvp (path, argv); } @@ -245,6 +247,8 @@ main (int argc, char *argv[]) if (!command) { skip = true; command = argv[in]; + } else { + skip = false; } /* The global long options */ -- cgit v1.1