Hi.

I finally got PHP safe_mode working on our production monitoring web server.
As you know, the Ganglia PHP scripts launch the rrdtool executable. Various 
arguments are passed to rrdtool and safe_mode forces all of the arguments to be 
treated as 1 argument by enclosing them in quotes. The problem is that some of 
these arguments already contain quotes which is why the executable fails to 
parse the arguments correctly when safe mode is on.

Here's my fix:

#!/bin/sh
# Workaround to parse quotes that are retained by php passthru() function # 
When safe_mode is on. 
# Yemi Adesanya ([EMAIL PROTECTED])

sh -c "/usr/bin/rrdtool $*"

The Ganglia PHP scripts now execute this script which resides in my 
safe_mode_exec_dir.

----
Yemi
 
> -----Original Message-----
> From: Adesanya, Adeyemi 
> Sent: Friday, June 04, 2004 11:12 AM
> To: 'ganglia-developers@lists.sourceforge.net'
> Cc: 'Federico Sacerdoti'
> Subject: [Ganglia-developers] safe_mode problems
> 
> 
> Hi.
> 
> I'm having an interesting time with the Ganglia webfrontend 
> and PHP safe mode. I'll start off by saying that safe_mode 
> works just fine on my MacOS X webserver ( Apache 1.3.29 with 
> PHP 4.3.6 ). I set safe_mode_exec_dir to point to the 
> directory containing the "rrdtool" executable and it all 
> works as advertised.
> 
> My Linux RedHat Enterprise 3.0 production webserver (running 
> Apache 2.0.46 with PHP 4.3.2) is giving me different results. 
> With safe mode = On, rrdtool gets called but with 'bad' 
> arguments. I spotted this by simply replacing the rrdtool 
> executable with a shell script that echoed the command line 
> arguments to a file.
> 
> Here's an excerpt from the file when safe mode is off:
> 
> rrdtool args: graph - --start -3600 --end N --width 300 
> --height 75 --lower-limit 0 --rigid --title BaBarCM2 Grid 
> Load last hour --vertical-label Load/Procs 
> DEF:load_one=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/load_on
> e.rrd:sum:AVERAGE 
> DEF:proc_run=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/proc_ru
> n.rrd:sum:AVERAGE 
> DEF:cpu_num=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_num.
> rrd:sum:AVERAGE 
> DEF:num_nodes=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_nu
> m.rrd:num:AVERAGE AREA:load_one#CCCCCC:1-min Load 
> LINE2:num_nodes#00FF00:Nodes LINE2:cpu_num#FF0000:CPUs 
> LINE2:proc_run#0000FF:Running Processes
> 
> And here's a similar excerpt when safe mode is on:
> 
> rrdtool args: graph - --start -3600 --end N --width 300 
> --height 75 --lower-limit 0 --rigid --title 'BaBarCM2 Grid 
> Load last hour' --vertical-label 'Load/Procs' 
> DEF:'load_one'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/load
> _one.rrd':'sum':AVERAGE 
> DEF:'proc_run'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/proc
> _run.rrd':'sum':AVERAGE 
> DEF:'cpu_num'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_n
> um.rrd':'sum':AVERAGE 
> DEF:'num_nodes'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu
> _num.rrd':'num':AVERAGE AREA:'load_one'#CCCCCC:'1-min Load' 
> LINE2:'num_nodes'#00FF00:'Nodes' 
> LINE2:'cpu_num'#FF0000:'CPUs' 
> LINE2:'proc_run'#0000FF:'Running Processes'
> 
> The rrdtool command is invoked in graph.php via the passthru 
> function. According to the docs, when safe mode is turned on, 
> passthru will treat all command arguments as a single 
> argument. This may explain why the quotes are not removed 
> when safe mode is turned on but why does it work just fine 
> for me on my Mac??
> 
> -----
> Yemi
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by the new InstallShield X.
> From Windows to Linux, servers to mobile, InstallShield X is 
> the one installation-authoring solution that does it all. 
> Learn more and evaluate today! 
> http://www.installshield.com/Dev2Dev/0504
> _______________________________________________
> Ganglia-developers mailing list
> Ganglia-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ganglia-developers
> 

Reply via email to