diff options
| author | Lauri Aarnio <Lauri.Aarnio@iki.fi> | 2008-03-12 08:54:35 +0200 |
|---|---|---|
| committer | Lauri Leukkunen <lle@rahina.org> | 2008-03-14 07:42:55 +0200 |
| commit | 80fa17a48449506499d1795161b9b4b9318a1033 (patch) | |
| tree | 35216eae870044bd3273780d02d20f1c67797645 /utils | |
| parent | 6e880fd4c8c8deaafc00a8bc0030f0307cbc9164 (diff) | |
sb2-monitor now appends libsb2 to an existing LD_PRELOAD variable
- previously the LD_PRELOAD env.var. was always overwritten
- This change makes it possible to use "fakeroot" to start "sb2".
e.g. "fakeroot sb2 -e" can be used to add packages to the rootstrap,
as in this case LD_PRELOAD must contain two preloadable libraries.
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/sb2-monitor.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/utils/sb2-monitor.c b/utils/sb2-monitor.c index 9350f77..f057629 100644 --- a/utils/sb2-monitor.c +++ b/utils/sb2-monitor.c @@ -279,7 +279,32 @@ int main(int argc, char *argv[]) */ sbox_libsb2 = getenv("SBOX_LIBSB2"); if (sbox_libsb2) { - setenv("LD_PRELOAD", sbox_libsb2, 1); + char *old_ld_preload = getenv("LD_PRELOAD"); + char *new_ld_preload = NULL; + + if (old_ld_preload) { + char *p_libsb2 = strstr(old_ld_preload, + sbox_libsb2); + + DEBUG_MSG("child: LD_PRELOAD was '%s'\n", + old_ld_preload); + if (!p_libsb2) { + /* LD_PRELOAD is defined, but libsb2 + * was not included. Add it now. */ + asprintf(&new_ld_preload, "%s:%s", + old_ld_preload, sbox_libsb2); + } /* else libsb2 seems to be already included */ + } else { + /* LD_PRELOAD was not set. */ + DEBUG_MSG("child: no previous LD_PRELOAD\n"); + new_ld_preload = sbox_libsb2; + } + if (new_ld_preload) { + /* need to set/modify LD_PRELOAD */ + DEBUG_MSG("child: setting LD_PRELOAD to '%s'\n", + new_ld_preload); + setenv("LD_PRELOAD", new_ld_preload, 1); + } } else { DEBUG_MSG("child: WARNING: " "no SBOX_LIBSB2 => LD_PRELOAD not set\n"); @@ -370,7 +395,7 @@ int main(int argc, char *argv[]) DEBUG_MSG("parent: child returned\n"); - /* deretmine reason why it exited, to be forwarded to the + /* determine reason why it exited, to be forwarded to the * report generator */ if (WIFEXITED(status)) { @@ -387,7 +412,7 @@ int main(int argc, char *argv[]) exit_reason = "UNKNOWN"; *exit_status = '\0'; } - DEBUG_MSG("%s %s", exit_reason, exit_status); + DEBUG_MSG("%s %s\n", exit_reason, exit_status); /* time to exec the external script */ execlp(command_to_exec_at_end, command_to_exec_at_end, |
