]> source.dussan.org Git - nextcloud-server.git/commitdiff
prefix the mysql user name to avoid collissions
authorRobin Appelman <icewind1991@gmail.com>
Tue, 21 Jun 2011 21:58:02 +0000 (23:58 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Tue, 21 Jun 2011 21:58:02 +0000 (23:58 +0200)
lib/setup.php

index 281f24db5077ba6bded86b01408f191e63fcdce3..0a8c9650cbc1e7145d66525bba20b730482ed2b8 100644 (file)
@@ -97,13 +97,20 @@ class OC_SETUP {
                                else {
                                        $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql
                                        if(mysql_query($query, $connection)) {
-                                               self::createDBUser($username, $password, $connection);
                                                //use the admin login data for the new database user
-                                               OC_CONFIG::setValue('dbuser', $username);
-                                               OC_CONFIG::setValue('dbpassword', $password);
+
+                                               //add prefix to the mysql user name to prevent collissions
+                                               $dbusername='oc_mysql_'.$username;
+                                               //hash the password so we don't need to store the admin config in the config file
+                                               $dbpassowrd=md5(time().$password);
+                                               
+                                               self::createDBUser($dbusername, $dbpassowrd, $connection);
+                                               
+                                               OC_CONFIG::setValue('dbuser', $dbusername);
+                                               OC_CONFIG::setValue('dbpassword', $dbpassowrd);
 
                                                //create the database
-                                               self::createDatabase($dbname, $username, $connection);
+                                               self::createDatabase($dbname, $dbusername, $connection);
                                        }
                                        else {
                                                OC_CONFIG::setValue('dbuser', $dbuser);