From cf533650074eacefef36d7086555bbb256370826 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Tue, 4 Dec 2018 10:52:49 +0100 Subject: [PATCH] update README and CONTRIBUTING files; added PULL_REQUEST_TEMPLATE; database user-creation fix for MySQL8 Signed-off-by: Michael Kaufmann --- .github/CONTRIBUTING.md | 19 +++++----- .github/PULL_REQUEST_TEMPLATE.md | 38 +++++++++++++++++++ README.md | 2 +- .../database/manager/class.DbManagerMySQL.php | 27 +++++++++---- 4 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ffa292ae..280f411c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,15 +2,12 @@ Before you start working on a PR, contact us via IRC in #froxlor on Freenode or the forum at https://forum.froxlor.org to get a clue whether someone else isn't -already working on it or if we don't want to invest the effort in favour of -working on Froxlor 2.0. -Of course, bug fixes are always welcome. +already working on it or if we don not want/need this certain change. +Of course, bugfixes are always welcome. However, at this stage of the 0.9.x branch, we are not looking for new features or refactoring, especially not the kind which requires changes to a lot of files. -Currently, we are working on a complete re-write, which, at this point in -time, is not yet public to keep delays due to discussions about internal -details to a minimum. +Please focus on our API based version 0.10.x (current master). @@ -35,7 +32,7 @@ Thanks! ### Webserver changes If you make changes to the functionality of webserver configuration, please -make sure your implementation covers both apache **and** nginx. +make sure your implementation covers all supported webservers. @@ -51,8 +48,10 @@ strings in -### New settings -If you add new settings, please make sure you add the default values to +### New settings and database-layout changnes +If you add new settings or layout changes, please make sure you add these to * `install/froxlor.sql` -* handle the update (see `install/updates/froxlor/0.9/update_0.9.inc.php`) +* and handle the update (see `install/updates/froxlor/0.10/update_0.10.inc.php`) +* if you have any question on how update-process works, please contact us + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..6b107ce3 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,38 @@ +# Description + +Please include a summary of the change and which issue is fixed if any. Please also include relevant motivation and context. List any dependencies that are required for this change. + +Fixes # (issue) + +## Type of change + +Please delete options that are not relevant. + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +# How Has This Been Tested? + +Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration + +- [ ] Test A +- [ ] Test B + +**Test Configuration**: + +* Distribution: +* Webserver: +* PHP: +* etc.etc.: + +# Checklist: + +- [ ] I have performed a self-review of my own code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes + diff --git a/README.md b/README.md index bd75d2bb..6ae500ea 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](http://services.nutime.de:8081/job/froxlor-0.10/badge/icon)](http://services.nutime.de:8081/job/froxlor-0.10/) +[![Build Status](https://travis-ci.com/Froxlor/Froxlor.svg?branch=master)](https://travis-ci.com/Froxlor/Froxlor) # Froxlor diff --git a/lib/classes/database/manager/class.DbManagerMySQL.php b/lib/classes/database/manager/class.DbManagerMySQL.php index b9a8d3ec..a4c32b55 100644 --- a/lib/classes/database/manager/class.DbManagerMySQL.php +++ b/lib/classes/database/manager/class.DbManagerMySQL.php @@ -66,12 +66,25 @@ class DbManagerMySQL { * @param bool $p_encrypted optional, whether the password is encrypted or not, default false */ public function grantPrivilegesTo($username = null, $password = null, $access_host = null, $p_encrypted = false) { - // grant privileges - $stmt = Database::prepare(" - GRANT ALL PRIVILEGES ON `" . $username . "`.* - TO :username@:host IDENTIFIED BY 'password' - "); - Database::pexecute($stmt, array("username" => $username, "host" => $access_host)); + // mysql8 compatibility + if (Database::getAttribute(PDO::ATTR_SERVER_VERSION) >= '8.0.0') { + // create user + $stmt = Database::prepare(" + CREATE USER `" . $username . "`.`" . $access_host . "` IDENTIFIED BY 'password' + "); + Database::pexecute($stmt); + // grant privileges + $stmt = Database::prepare(" + GRANT ALL ON `" . $username . "`.* TO :username@:host + "); + Database::pexecute($stmt, array("username" => $username, "host" => $access_host)); + } else { + // grant privileges + $stmt = Database::prepare(" + GRANT ALL PRIVILEGES ON `" . $username . "`.* TO :username@:host IDENTIFIED BY 'password' + "); + Database::pexecute($stmt, array("username" => $username, "host" => $access_host)); + } // set passoword if ($p_encrypted) { $stmt = Database::prepare("SET PASSWORD FOR :username@:host = :password"); @@ -102,7 +115,7 @@ class DbManagerMySQL { while ($host = $host_res_stmt->fetch(PDO::FETCH_ASSOC)) { // as of MySQL 5.0.2 this also revokes privileges. (requires MySQL 4.1.2+) - $drop_stmt = Database::prepare("DROP USER :dbname@:host"); + $drop_stmt = Database::prepare("DROP USER IF EXISTS :dbname@:host"); Database::pexecute($drop_stmt, array('dbname' => $dbname, 'host' => $host['Host']), false); }