blob: 89951a2f19d56da9c4c98c1c246062ca1fe9038d [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From 4ffecddf5433d65a6f01241990c9d516586b1c79 Mon Sep 17 00:00:00 2001
2From: Victor Kamensky <kamensky@cisco.com>
3Date: Mon, 19 Mar 2018 08:53:51 -0500
4Subject: [PATCH] Delay adding sysroot path to module name in case of non
5 absolute executable
6
7Current stap code adds sysroot prematurely for probes that specify non
8absolute path name, i.e like "foo", so when find_executable called it
9receives full path as <sysroot>/foo and find_executable does not search
10PATH while applying sysroot.
11
12Fix delays adding sysroot till path inside of sysroot is searched first.
13
14Also fix missing sysroot addition in glob expansion case.
15
16Upstream-Status: Backport
17Signed-off-by: Victor Kamensky <kamensky@cisco.com>
18---
19 tapsets.cxx | 8 ++++----
20 1 file changed, 4 insertions(+), 4 deletions(-)
21
22Index: git/tapsets.cxx
23===================================================================
24--- git.orig/tapsets.cxx
25+++ git/tapsets.cxx
26@@ -746,7 +746,7 @@ base_query::base_query(dwflpp & dw, lite
27 pid_val = 0;
28 get_string_param(params, TOK_PROCESS, module_val);
29 }
30- module_val = find_executable (module_val, "", sess.sysenv);
31+ module_val = find_executable (module_val, sess.sysroot, sess.sysenv);
32 if (!is_fully_resolved(module_val, "", sess.sysenv))
33 throw SEMANTIC_ERROR(_F("cannot find executable '%s'",
34 module_val.to_string().c_str()));
35@@ -8287,7 +8287,6 @@ dwarf_builder::build(systemtap_session &
36 }
37 else
38 {
39- module_name = (string)sess.sysroot + (string)module_name;
40 filled_parameters[TOK_PROCESS] = new literal_string(module_name);
41 }
42 }
43@@ -8321,7 +8320,8 @@ dwarf_builder::build(systemtap_session &
44 assert (lit);
45
46 // Evaluate glob here, and call derive_probes recursively with each match.
47- const auto& globs = glob_executable (module_name);
48+ const auto& globs = glob_executable (sess.sysroot
49+ + string(module_name));
50 unsigned results_pre = finished_results.size();
51 for (auto it = globs.begin(); it != globs.end(); ++it)
52 {
53@@ -8413,7 +8413,7 @@ dwarf_builder::build(systemtap_session &
54 // PR13338: unquote glob results
55 module_name = unescape_glob_chars (module_name);
56 user_path = find_executable (module_name, "", sess.sysenv); // canonicalize it
57- if (!is_fully_resolved(user_path, "", sess.sysenv))
58+ if (!is_fully_resolved(user_path, sess.sysroot, sess.sysenv))
59 throw SEMANTIC_ERROR(_F("cannot find executable '%s'",
60 user_path.to_string().c_str()));
61