summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMika Westerberg <ext-mika.1.westerberg@nokia.com>2009-02-17 15:50:25 +0200
committerLauri Leukkunen <lle@rahina.org>2009-02-17 20:52:41 +0200
commit1391a4a5fd99b13d58daf329daa742801b4f2e8f (patch)
tree4ed9f587c3ce9e73ebdbc62b386365cef6680924
parent0c0dc08f56beebf95942511c1aef1f77170c9702 (diff)
Bugfix: __SB2_BINARYNAME was not correctly set with interpreted scripts.1.99.0.31
- Now __SB2_BINARYNAME comes from the mapped interpreter name and not from the name of the script as it was before.
-rw-r--r--preload/sb_exec.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/preload/sb_exec.c b/preload/sb_exec.c
index 364bcfe..40ef414 100644
--- a/preload/sb_exec.c
+++ b/preload/sb_exec.c
@@ -492,6 +492,7 @@ static int prepare_hashbang(
char hashbang[SBOX_MAXPATH]; /* only 60 needed on linux, just be safe */
char interpreter[SBOX_MAXPATH];
char *interp_arg = NULL;
+ char *tmp, *mapped_binaryname;
int result = 0;
if ((fd = open_nomap(*mapped_file, O_RDONLY)) < 0) {
@@ -565,6 +566,18 @@ static int prepare_hashbang(
"failed to map script interpreter=%s", interpreter);
return(-1);
}
+
+ /*
+ * Binaryname (the one expected by the rules) comes still from
+ * the interpreter name so we set it here. Note that it is now
+ * basename of the mapped interpreter (not the original one)!
+ */
+ tmp = strdup(mapped_interpreter);
+ mapped_binaryname = strdup(basename(tmp));
+ change_environment_variable(*envpp, "__SB2_BINARYNAME=",
+ mapped_binaryname);
+ free(mapped_binaryname);
+ free(tmp);
SB_LOG(SB_LOGLEVEL_DEBUG, "prepare_hashbang(): interpreter=%s,"
"mapped_interpreter=%s", interpreter,