Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support
It is currently Thu Jul 24, 2014 6:58 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: trunk/0.8.7: PHP segfaults if there's no database [PATCH]
PostPosted: Wed Sep 02, 2009 5:32 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 4584
Location: United Kingdom
Couldn't see a trunk or 0.88 option in mantis. If you go to the cacti startup page and you haven't imported the database, but have created the (empty) database, PHP segfaults! At least on Centos5.3 64-bit with PHP 5.1.6

Having said that, why doesn't Cacti do what (e.g.) Drupal or Gallery do and create the tables anyway?

_________________
Weathermap 0.97c is out! & QuickTree 0.2. Superlinks is over there now.
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

Security Notice: CVE-2013-2618 Network Weathermap 0.97a - editor security issues

My System: CentOS5 64 bit, 4 2GHz cores (Intel E5405), 8GB, Cacti 0.8.7e, Spine 0.8.7e, Weathermap 0.98dev, Superlinks 0.8, ReportIt 0.7.1, THold 0.3.9hj, Explain 0.1, Uptime 0.4hj, Realtime 0.36hj, QuickTree 0.2 - 17000 DS, 320 Hosts. 150 seconds poll.


Last edited by Howie on Thu Sep 03, 2009 6:22 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 02, 2009 8:43 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 4584
Location: United Kingdom
Actually this also happens with 0.8.7e. include/global_form.php tries to call read_config_option()

Impressive that it crashes php though.

I started looking at how to stop it doing that, and get as far as the install script properly, or at least give a useful message.

_________________
Weathermap 0.97c is out! & QuickTree 0.2. Superlinks is over there now.
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

Security Notice: CVE-2013-2618 Network Weathermap 0.97a - editor security issues

My System: CentOS5 64 bit, 4 2GHz cores (Intel E5405), 8GB, Cacti 0.8.7e, Spine 0.8.7e, Weathermap 0.98dev, Superlinks 0.8, ReportIt 0.7.1, THold 0.3.9hj, Explain 0.1, Uptime 0.4hj, Realtime 0.36hj, QuickTree 0.2 - 17000 DS, 320 Hosts. 150 seconds poll.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 03, 2009 4:54 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 4584
Location: United Kingdom
ADODB dies with 32M of memory_limit - added memory_limit check.
(didn't the manual used to say to increase to 128M? I can't find that anymore - 128 is the default on newer PHPs but not older ones (8M I think)).

Several parts of global.php use read_config_option() - added check for empty database so that we will make it as far as install/index.php

install/index.php doesn't check for empty database either, before calling read_config_option(), so it dies before getting the chance to tell you to import the cacti.sql file. Added a check for that.

Also, the install guide says that php5-snmp is a required module, but it's not checked for in verify_php_extensions. And preg_match/preg_replace are used all over the place but are actually in a php extension too - pcre - which is not checked for.

So - is 128M required? is php_snmp required?

_________________
Weathermap 0.97c is out! & QuickTree 0.2. Superlinks is over there now.
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

Security Notice: CVE-2013-2618 Network Weathermap 0.97a - editor security issues

My System: CentOS5 64 bit, 4 2GHz cores (Intel E5405), 8GB, Cacti 0.8.7e, Spine 0.8.7e, Weathermap 0.98dev, Superlinks 0.8, ReportIt 0.7.1, THold 0.3.9hj, Explain 0.1, Uptime 0.4hj, Realtime 0.36hj, QuickTree 0.2 - 17000 DS, 320 Hosts. 150 seconds poll.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 03, 2009 5:33 am 
Offline
Cacti Guru User
User avatar

Joined: Thu Sep 16, 2004 5:53 am
Posts: 4584
Location: United Kingdom
Here's my patch. It is against 0.8.7e (trunk produces lots of empty pages - just nav, no forms - for me, so it's hard to say if it breaks anything).

It includes:
- early check for mysql module and memory_limit >=128M
(needs to happen before db_connect_real in global.php - I can't think of a nice way to make it do it only once)

- check in global.php for empty database. Avoid including include files that will call read_config_option(). Sets $database_empty to true.

- small change in auth.php to check for $database_empty, so that db_fetch_cell is not always called to check the version, and still redirect to install/

- small change to install/index.php to check $database_empty so that it doesn't use db_fetch_cell() if there's no db yet. Allows it to get as far as the 'please import cacti.sql' message.

- another small change to install/index.php to check for the presence of 'pcre' extension.

- two new functions in functions.php - one to check memory_limit and mysql module, and another to parse the memory_limit value.


Attachments:
File comment: Patch against 0.8.7e to stop install from crashing before database is created.
install-crashes-patch.txt [6.82 KiB]
Downloaded 429 times

_________________
Weathermap 0.97c is out! & QuickTree 0.2. Superlinks is over there now.
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)

Security Notice: CVE-2013-2618 Network Weathermap 0.97a - editor security issues

My System: CentOS5 64 bit, 4 2GHz cores (Intel E5405), 8GB, Cacti 0.8.7e, Spine 0.8.7e, Weathermap 0.98dev, Superlinks 0.8, ReportIt 0.7.1, THold 0.3.9hj, Explain 0.1, Uptime 0.4hj, Realtime 0.36hj, QuickTree 0.2 - 17000 DS, 320 Hosts. 150 seconds poll.
Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 05, 2009 1:41 pm 
Offline
Developer
User avatar

Joined: Thu Dec 02, 2004 2:46 am
Posts: 22461
Location: Muenster, Germany
Howie,
please post to the mantis forum as given by http://www.cacti.net/bugs.php. It is very likely that we include such contributions, then. But we need the tracker.
Reinhard

_________________
Official Cacti Documentation
Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group