From 5dbe5dfd27633ebf2cc0e37fa7036fb1a689ef81 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Fri, 26 Aug 2016 17:23:28 +0300 Subject: rpctrace: Pass prefixed_name to _hurd_exec_paths. This fixes the following test case: mkdir testy echo '#! /bin/bash' > testy/prog echo 'printf "%s\n" "$0"' >> testy/prog chmod +x testy/prog PATH=$(pwd)/testy /bin/rpctrace -E PATH=/usr/bin:/bin -o /dev/null prog Before this patch, the output is: /bin/bash: prog: No such file or directory After this patch, the output is similar to: /home/kalle/testy/prog * utils/rpctrace.c (traced_spawn): Get prefixed_name from file_name_path_lookup and pass it to _hurd_exec_paths. --- utils/rpctrace.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'utils/rpctrace.c') diff --git a/utils/rpctrace.c b/utils/rpctrace.c index 1690ae1b..b4de175c 100644 --- a/utils/rpctrace.c +++ b/utils/rpctrace.c @@ -1620,8 +1620,9 @@ traced_spawn (char **argv, char **envp) task_t traced_task; struct sender_info *ti; struct receiver_info *receive_ti; + char *prefixed_name; file_t file = file_name_path_lookup (argv[0], getenv ("PATH"), - O_EXEC, 0, 0); + O_EXEC, 0, &prefixed_name); if (file == MACH_PORT_NULL) error (1, errno, "command not found: %s", argv[0]); @@ -1662,7 +1663,8 @@ traced_spawn (char **argv, char **envp) the actual task, so the RPCs to map in the program itself do not get traced. Could have an option to use TASK_WRAPPER here instead. */ #ifdef HAVE__HURD_EXEC_PATHS - err = _hurd_exec_paths (traced_task, file, *argv, *argv, argv, envp); + err = _hurd_exec_paths (traced_task, file, prefixed_name ?: *argv, + prefixed_name ?: *argv, argv, envp); #else err = _hurd_exec (traced_task, file, argv, envp); #endif @@ -1673,6 +1675,7 @@ traced_spawn (char **argv, char **envp) cannot die and hence our TRACED_TASK ref cannot have been released. */ mach_port_deallocate (mach_task_self (), task_wrapper); + free (prefixed_name); return pid; } -- cgit v1.2.3