From b7e05bb315f3e76124f6a8ef1cb09f7f8e0be018 Mon Sep 17 00:00:00 2001 From: w00t Date: Mon, 27 Oct 2008 20:15:53 +0000 Subject: [PATCH] Improvments to valdebug-unattended [danieldg] git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10727 e03df62e-2008-0410-955e-edbf42e46eb7 --- .inspircd.inc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.inspircd.inc b/.inspircd.inc index 781e745af..b0933f07d 100644 --- a/.inspircd.inc +++ b/.inspircd.inc @@ -177,11 +177,20 @@ sub valdebugunattended # NOTE: Saving the debug log (redirected stdout), while useful, is a potential security risk AND one hell of a spacehog. DO NOT SAVE THIS WHERE EVERYONE HAS ACCESS! # Redirect stdout to /dev/null if you're worried about the security. # - # Note the & at the end. We *must* detach otherwise the script hangs. - system("valgrind -v --tool=memcheck --leak-check=yes --num-callers=10 --time-stamp=yes --log-file=$valgrindlogpath/valdebug.%p $binpath/$executable -nofork -debug -nolog >> $basepath/valdebug.insp.out &"); + my $pid = fork; + if ($pid == 0) { + POSIX::setsid(); + umask 066; + open STDIN, '/dev/null' or die $!; + open STDOUT, '>', "$valgrindlogpath/out.$$" or die $!; + open STDERR, '>', "$valgrindlogpath/err.$$" or die $!; + umask 022; + exec "valgrind -v --tool=memcheck --leak-check=yes --num-callers=10 --time-stamp=yes --log-file=$valgrindlogpath/valdebug.\%p $binpath/$executable -nofork -debug -nolog"; + exit 1; + } # Sleep 5 seconds to give valgrind time to initialize before chmodding the logdir for apache access. sleep(5); - system("chmod 644 $valgrindlogpath/*"); + system("chmod 644 $valgrindlogpath/valdebug.*"); } sub screenvaldebug -- 2.39.5