daemon: Don't set LD_PRELOAD for guestfsd children.

Commit c598e14052 exports
LD_PRELOAD=/lib64/libSegFault.so so that guestfsd and processes that
it runs will produce descriptive stack traces.

However if we chroot into /sysroot (ie. CHROOT_IN/CHROOT_OUT) and if
the libSegFault.so library does not exist inside the chroot (as is the
case on Debian guests) then we cannot run any processes.  In any case
we *don't* want to necessarily run this library from the guest.

The proper way to fix this is to confine all chrooting to a
subprocess, but that's a big change to guestfsd which we'll have to do
one day.  For now, unset LD_PRELOAD once guestfsd starts up.
This commit is contained in:
Richard W.M. Jones
2013-10-03 21:38:18 +01:00
parent 8abd0a83b3
commit 21e5fc811e

View File

@@ -160,6 +160,16 @@ main (int argc, char *argv[])
#endif
#endif
/* XXX The appliance /init script sets LD_PRELOAD=../libSegFault.so.
* However if we CHROOT_IN to the sysroot that file might not exist,
* resulting in all commands failing. What we'd really like to do
* is to have LD_PRELOAD only set while outside the chroot. I
* suspect the proper way to solve this is to remove the
* CHROOT_IN/_OUT hack and replace it properly (fork), but that is
* for another day.
*/
unsetenv ("LD_PRELOAD");
struct stat statbuf;
if (stat ("/", &statbuf) == 0)
root_device = statbuf.st_dev;