]> granicus.if.org Git - p11-kit/commitdiff
tools: Only use our private path when looking for external commands
authorStef Walter <stef@thewalter.net>
Mon, 17 Jun 2013 12:36:37 +0000 (14:36 +0200)
committerStef Walter <stef@thewalter.net>
Mon, 17 Jun 2013 12:44:52 +0000 (14:44 +0200)
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

index a2dbcbddf083c282f11b7e7296d8735228c3e32c..dcbb1a50435fe0b55cffaee5d77d169693c2e3e0 100644 (file)
@@ -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