[MacPorts] #16591: php5 > 5.2.0_0 snmpget error via apache2 ok via cli
MacPorts
noreply at macports.org
Fri Sep 19 01:41:39 PDT 2008
#16591: php5 > 5.2.0_0 snmpget error via apache2 ok via cli
----------------------------------+-----------------------------------------
Reporter: news at braendle-net.de | Owner: macports-tickets at lists.macosforge.org
Type: defect | Status: new
Priority: Normal | Milestone: Port Bugs
Component: ports | Version: 1.6.0
Keywords: php5 snmpget | Port: php5 > 5.2.0_0
----------------------------------+-----------------------------------------
Hi there,
just stepped into a strange problem with snmpget in php5 build on OSX
10.4.11.
If i try to do something like that (examples from the nedi port):
{{{
<?php
//===============================
// SNMPget utility.
//===============================
session_start();
require_once ('libmisc.php');
require_once ("../languages/$_SESSION[lang]/gui.php");
if( !preg_match("/net/",$_SESSION['group']) ){
echo $nokmsg;
die;
}
$_GET = sanitize($_GET);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=<?=$charset?>">
<link href="../themes/<?=$_SESSION[theme]?>.css" type="text/css"
rel="stylesheet">
</head>
<body>
<h1><?=$_GET['ip']?> (<?=$_GET['c']?>)</h1>
<div class="net1">
<h2><img src="../img/32/brgt.png" hspace="10"> <?=$_GET['oid']?></h2>
</div>
<div class="net2 code">
<?
if($_GET['ip'] and $_GET['c'] and $_GET['oid']){
echo snmpget($_GET['ip'],$_GET['c'],".$_GET[oid]");
}else{
echo "<h4>No IP, community or OID?</h4>";
}
?>
</div>
</body>
</html>
}}}
via apache2 i get an error
So i googled a bit and found two similar problems in:
[http://bugs.php.net/bug.php?id=32680]
and
[http://bugs.php.net/bug.php?id=38613&edit=1]
Then I tried to get any results by checking the same funktion in the cli:
{{{
<?php
//===============================
// SNMPget utility.
//===============================
session_start();
require_once ('libmisc.php');
require_once ("../languages/deutsch/gui.php");
#if( !preg_match("/net/",$_SESSION['group']) ){
# echo $nokmsg;
# die;
#}
$_GET['ip']=$argv[1];
$_GET['c']=$argv[2];
$_GET[oid]=$argv[3];
$_GET = sanitize($_GET);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=<?=$charset?>">
<link href="../themes/<?=$_SESSION[theme]?>.css" type="text/css"
rel="stylesheet">
</head>
<body>
<h1><?=$_GET['ip']?> (<?=$_GET['c']?>)</h1>
<div class="net1">
<h2><img src="../img/32/brgt.png" hspace="10"> <?=$_GET['oid']?></h2>
</div>
<div class="net2 code">
<?
if($_GET['ip'] and $_GET['c'] and $_GET['oid']){
echo snmpget($_GET['ip'],$_GET['c'],".$_GET[oid]");
}else{
echo "<h4>No IP, community or OID?</h4>";
}
?>
</div>
</body>
</html>
}}}
And if I call it like that:
php snmpget2.php 172.16.xxx.xxx ******** 1.3.6.1.2.1.47.1.1.1.1.11.1
i get a valid output:
{{{
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<link href="../themes/.css" type="text/css" rel="stylesheet">
</head>
<body>
<h1>172.16.xxx.xxx (******)</h1>
<div class="net1">
<h2><img src="../img/32/brgt.png" hspace="10">
1.3.6.1.2.1.47.1.1.1.1.11.1</h2>
</div>
<div class="net2 code">
STRING: "SAL0803SYDB"</div>
</body>
</html>
}}}
So I thinks this proofs, that the snmpget is ok but fails via apache.
So i tried to get rid of that problem and found a dirty solution.
{{{
################################################################################
1. get the actual php5 source:
medianet at intermac1:/opt/local/var/macports/build$ sudo port -v fetch php5
medianet at intermac1:/opt/local/var/macports/build$ sudo port -v checksum
php5
---> Verifying checksum(s) for php5
---> Checksumming php-5.2.6.tar.bz2
################################################################################
2. patch snmp.c :
! Could lead into another problem!!
see : [http://bugs.php.net/bug.php?id=38613&edit=1]
pwd
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_www_php5/work/php-5.2.6/ext/snmp
diff snmp.c snmp.c.orig
223c223
< /* snmp_shutdown("snmpapp"); */
---
> snmp_shutdown("snmpapp");
################################################################################
3. compile php5 :
medianet at intermac1:~$ sudo port clean php5
---> Cleaning php5
medianet at intermac1:~$ sudo port -v patch php5 +apache2+macosx+mysql5+snmp
medianet at intermac1:~$ sudo port -v configure php5
+apache2+macosx+mysql5+snmp
medianet at intermac1:~$ sudo port -v build php5 +apache2+macosx+mysql5+snmp
################################################################################
4. ! install only works after deaktivating the old version manually:
medianet at intermac1:~$ sudo port -v install php5
+apache2+macosx+mysql5+snmp
---> Activating php5 5.2.6_1+apache2+macosx+mysql5+snmp
Error: Target org.macports.activate returned: Image error: Another
version of this port (php5 @5.2.0_0+apache2+darwin_8+macosx+mysql5+snmp)
is already active.
Warning: the following items did not execute (for php5):
org.macports.activate
Error: Status 1 encountered during processing.
medianet at intermac1:~$ sudo port deactivate php5
@5.2.0_0+apache2+darwin_8+macosx+mysql5+snmp
---> Deactivating php5 5.2.0_0+apache2+darwin_8+macosx+mysql5+snmp
medianet at intermac1:~$ sudo port -v install php5
+apache2+macosx+mysql5+snmp
---> Activating php5 5.2.6_1+apache2+macosx+mysql5+snmp
---> Cleaning php5
---> Removing build directory for php5
medianet at intermac1:~$ port installed php5
The following ports are currently installed:
php5 @5.2.0_0+apache2+darwin_8+macosx+mysql5+snmp
php5 @5.2.6_1+apache2+macosx+mysql5+snmp (active)
}}}
Maybe anyone can find a better solution
Greetings from Germany
Jürgen
--
Ticket URL: <http://trac.macports.org/ticket/16591>
MacPorts <http://www.macports.org/>
Ports system for Mac OS
More information about the macports-tickets
mailing list