From cabd6f6205756a51064fb856aca2ed94d28b1cf7 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Fri, 12 Sep 2008 11:31:19 -0400 Subject: [PATCH] Disabled suphp_UserGroup directive by default to make the setup compatible with the suphp compile options from most linux distributions. If you want some extra security, enable this directive again and recompile mod_suphp with the the option --with-setid-mode=paranoid --- server/plugins-available/mysql_clientdb_plugin.inc.php | 42 ++++++++++++++++++++++++++++++++---------- 1 files changed, 32 insertions(+), 10 deletions(-) diff --git a/server/plugins-available/mysql_clientdb_plugin.inc.php b/server/plugins-available/mysql_clientdb_plugin.inc.php index bf53599..81ada6e 100644 --- a/server/plugins-available/mysql_clientdb_plugin.inc.php +++ b/server/plugins-available/mysql_clientdb_plugin.inc.php @@ -28,10 +28,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -class mysql_clientdb { +class mysql_clientdb_plugin { - var $plugin_name = 'mysql_clientdb'; - var $class_name = 'mysql_clientdb'; + var $plugin_name = 'mysql_clientdb_plugin'; + var $class_name = 'mysql_clientdb_plugin'; /* @@ -60,16 +60,18 @@ if($data["new"]["type"] == 'mysql') { if(!include_once(ISPC_LIB_PATH.'/mysql_clientdb.conf')) { $app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR); + return; } //* Connect to the database $link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password); if (!$link) { $app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR); + return; } //* Create the new database - if (mysql_create_db($data["new"]["database_name"]),$link) { + if (mysql_query('CREATE DATABASE '.addslashes($data["new"]["database_name"]),$link)) { $app->log('Created MySQL database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG); } else { $app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR); @@ -82,7 +84,8 @@ $db_host = 'localhost'; } - mysql_query("GRANT ALL ON ".addslashes($data["new"]["database_name"])." TO '".addslashes($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".addslashes($data["new"]["database_password"])."';",$link); + mysql_query("GRANT ALL ON ".addslashes($data["new"]["database_name"]).".* TO '".addslashes($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".addslashes($data["new"]["database_password"])."';",$link); + //echo "GRANT ALL ON ".addslashes($data["new"]["database_name"]).".* TO '".addslashes($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".addslashes($data["new"]["database_password"])."';"; mysql_query("FLUSH PRIVILEGES;",$link); mysql_close($link); @@ -95,12 +98,14 @@ if($data["new"]["type"] == 'mysql') { if(!include_once(ISPC_LIB_PATH.'/mysql_clientdb.conf')) { $app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR); + return; } //* Connect to the database $link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password); if (!$link) { $app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR); + return; } //* Rename User @@ -113,8 +118,10 @@ if($data["new"]["remote_access"] != $data["old"]["remote_access"]) { if($data["new"]["remote_access"] == 'y') { mysql_query("UPDATE mysql.user SET Host = '%' WHERE User = '".addslashes($data["new"]["database_user"])."' and Host = 'localhost';",$link); + mysql_query("UPDATE mysql.db SET Host = '%' WHERE User = '".addslashes($data["new"]["database_user"])."' and Host = 'localhost';",$link); } else { mysql_query("UPDATE mysql.user SET Host = 'localhost' WHERE User = '".addslashes($data["new"]["database_user"])."' and Host = '%';",$link); + mysql_query("UPDATE mysql.db SET Host = 'localhost' WHERE User = '".addslashes($data["new"]["database_user"])."' and Host = '%';",$link); } $app->log('Changing mysql remote access priveliges for database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG); } @@ -148,22 +155,37 @@ function db_delete($event_name,$data) { global $app, $conf; - if($data["new"]["type"] == 'mysql') { + if($data["old"]["type"] == 'mysql') { if(!include_once(ISPC_LIB_PATH.'/mysql_clientdb.conf')) { $app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR); + return; } //* Connect to the database $link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password); if (!$link) { $app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR); + return; } - mysql_query("DROP USER '".addslashes($data["old"]["database_user"])."';",$link); - $app->log('Dropping mysql user: '.$data["old"]["database_user"],LOGLEVEL_DEBUG); + //* Get the db host setting for the access priveliges + if($data["old"]["remote_access"] == 'y') { + $db_host = '%'; + } else { + $db_host = 'localhost'; + } - mysql_drop_db($data["old"]["database_name"],$link); - $app->log('Dropping mysql database: '.$data["old"]["database_name"],LOGLEVEL_DEBUG); + if(mysql_query("DROP USER '".addslashes($data["old"]["database_user"])."'@'$db_host';",$link)) { + $app->log('Dropping mysql user: '.$data["old"]["database_user"],LOGLEVEL_DEBUG); + } else { + $app->log('Error while dropping mysql user: '.$data["old"]["database_user"].' '.mysql_error($link),LOGLEVEL_ERROR); + } + + if(mysql_query('DROP DATABASE '.addslashes($data["old"]["database_name"]),$link)) { + $app->log('Dropping mysql database: '.$data["old"]["database_name"],LOGLEVEL_DEBUG); + } else { + $app->log('Error while dropping mysql database: '.$data["old"]["database_name"].' '.mysql_error($link),LOGLEVEL_ERROR); + } mysql_query("FLUSH PRIVILEGES;",$link); -- Gitblit v1.9.1