diff --git a/mysql/adminer/index.php b/mysql/adminer/index.php index 2f9f265..6f663da 100644 --- a/mysql/adminer/index.php +++ b/mysql/adminer/index.php @@ -5,7 +5,7 @@ * @copyright 2007 Jakub Vrana * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) -* @version 4.6.3 +* @version 4.6.3 patched: removed PASSWORD at IDENTIFIED BY for MySQL 8.0.x */error_reporting(6135);$Wc=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($Wc||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$Di=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($Di)$$X=$Di;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");function connection(){global$g;return$g;}function adminer(){global$b;return$b;}function @@ -1877,7 +1877,7 @@ enum_input($U,$Ka,$o,$Y,$uc=null){global$b;preg_match_all("~'((?:[^']|'')*)'~",$ ';if($C!=""){echo'',confirm(lang(174,$C));}echo' ';}elseif(isset($_GET["user"])){$ha=$_GET["user"];$mg=array(""=>array("All privileges"=>""));foreach(get_rows("SHOW PRIVILEGES")as$J){foreach(explode(",",($J["Privilege"]=="Grant option"?"":$J["Context"]))as$Bb)$mg[$Bb][$J["Privilege"]]=$J["Comment"];}$mg["Server Admin"]+=$mg["File access on server"];$mg["Databases"]["Create routine"]=$mg["Procedures"]["Create routine"];unset($mg["Procedures"]["Create routine"]);$mg["Columns"]=array();foreach(array("Select","Insert","Update","References")as$X)$mg["Columns"][$X]=$mg["Tables"][$X];unset($mg["Server Admin"]["Usage"]);foreach($mg["Tables"]as$y=>$X)unset($mg["Databases"][$y]);$Xe=array();if($_POST){foreach($_POST["objects"]as$y=>$X)$Xe[$X]=(array)$Xe[$X]+(array)$_POST["grants"][$y];}$nd=array();$kf="";if(isset($_GET["host"])&&($H=$g->query("SHOW GRANTS FOR ".q($ha)."@".q($_GET["host"])))){while($J=$H->fetch_row()){if(preg_match('~GRANT (.*) ON (.*) TO ~',$J[0],$B)&&preg_match_all('~ *([^(,]*[^ ,(])( *\([^)]+\))?~',$B[1],$Ce,PREG_SET_ORDER)){foreach($Ce -as$X){if($X[1]!="USAGE")$nd["$B[2]$X[2]"][$X[1]]=true;if(preg_match('~ WITH GRANT OPTION~',$J[0]))$nd["$B[2]$X[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$J[0],$B))$kf=$B[1];}}if($_POST&&!$n){$lf=(isset($_GET["host"])?q($ha)."@".q($_GET["host"]):"''");if($_POST["drop"])query_redirect("DROP USER $lf",ME."privileges=",lang(237));else{$Ze=q($_POST["user"])."@".q($_POST["host"]);$Uf=$_POST["pass"];if($Uf!=''&&!$_POST["hashed"]){$Uf=$g->result("SELECT PASSWORD(".q($Uf).")");$n=!$Uf;}$Gb=false;if(!$n){if($lf!=$Ze){$Gb=queries((min_version(5)?"CREATE USER":"GRANT USAGE ON *.* TO")." $Ze IDENTIFIED BY PASSWORD ".q($Uf));$n=!$Gb;}elseif($Uf!=$kf)queries("SET PASSWORD FOR $Ze = ".q($Uf));}if(!$n){$Og=array();foreach($Xe +as$X){if($X[1]!="USAGE")$nd["$B[2]$X[2]"][$X[1]]=true;if(preg_match('~ WITH GRANT OPTION~',$J[0]))$nd["$B[2]$X[2]"]["GRANT OPTION"]=true;}}if(preg_match("~ IDENTIFIED BY '([^']+)~",$J[0],$B))$kf=$B[1];}}if($_POST&&!$n){$lf=(isset($_GET["host"])?q($ha)."@".q($_GET["host"]):"''");if($_POST["drop"])query_redirect("DROP USER $lf",ME."privileges=",lang(237));else{$Ze=q($_POST["user"])."@".q($_POST["host"]);$Uf=$_POST["pass"];if($Uf!=''&&!$_POST["hashed"]){$Uf=$g->result("SELECT PASSWORD(".q($Uf).")");$n=!$Uf;}$Gb=false;if(!$n){if($lf!=$Ze){$Gb=queries((min_version(5)?"CREATE USER":"GRANT USAGE ON *.* TO")." $Ze IDENTIFIED BY ".q($Uf));$n=!$Gb;}elseif($Uf!=$kf)queries("SET PASSWORD FOR $Ze = ".q($Uf));}if(!$n){$Og=array();foreach($Xe as$ff=>$md){if(isset($_GET["grant"]))$md=array_filter($md);$md=array_keys($md);if(isset($_GET["grant"]))$Og=array_diff(array_keys(array_filter($Xe[$ff],'strlen')),$md);elseif($lf==$Ze){$if=array_keys((array)$nd[$ff]);$Og=array_diff($if,$md);$md=array_diff($md,$if);unset($nd[$ff]);}if(preg_match('~^(.+)\s*(\(.*\))?$~U',$ff,$B)&&(!grant("REVOKE",$Og,$B[2]," ON $B[1] FROM $Ze")||!grant("GRANT",$md,$B[2]," ON $B[1] TO $Ze"))){$n=true;break;}}}if(!$n&&isset($_GET["host"])){if($lf!=$Ze)queries("DROP USER $lf");elseif(!isset($_GET["grant"])){foreach($nd as$ff=>$Og){if(preg_match('~^(.+)(\(.*\))?$~U',$ff,$B))grant("REVOKE",array_keys($Og),$B[2]," ON $B[1] FROM $Ze");}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?lang(238):lang(239)),!$n);if($Gb)$g->query("DROP USER $Ze");}}page_header((isset($_GET["host"])?lang(36).": ".h("$ha@$_GET[host]"):lang(145)),$n,array("privileges"=>array('',lang(72))));if($_POST){$J=$_POST;$nd=$Xe;}else{$J=$_GET+array("host"=>$g->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$J["pass"]=$kf;if($kf!="")$J["hashed"]=true;$nd[(DB==""||$nd?"":idf_escape(addcslashes(DB,"%_\\"))).".*"]=array();}echo'
diff --git a/mysql/create_mysqladmin.sql b/mysql/create_mysqladmin.sql index ae888c5..0467cf8 100644 --- a/mysql/create_mysqladmin.sql +++ b/mysql/create_mysqladmin.sql @@ -1,4 +1,4 @@ /* create mysql webadmin */; -CREATE USER 'mysqladmin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqladmin'; -GRANT ALL PRIVILEGES ON *.* TO 'mysqladmin'@'localhost' WITH GRANT OPTION; +CREATE USER 'mysqladmin' IDENTIFIED WITH mysql_native_password BY 'mysqladmin'; +GRANT ALL PRIVILEGES ON *.* TO 'mysqladmin' WITH GRANT OPTION; FLUSH privileges; diff --git a/mysql/mysql-config.php b/mysql/mysql-config.php index 0f9ee53..7942204 100644 --- a/mysql/mysql-config.php +++ b/mysql/mysql-config.php @@ -135,7 +135,7 @@ function get_process_pid() { else { chown("{$config['websrv']['documentroot']}/{$clientDir}", "www"); chmod("{$config['websrv']['documentroot']}/{$clientDir}", 0775); - $dbClientMsg = "
".gettext("SQL Database Client")." ".gettext("has been installed.")."
"; + $dbClientMsg = "
".gettext("SQL Database Client")." ".gettext("has been installed."); } } // write mySQL config file @@ -168,30 +168,26 @@ function get_process_pid() { } if ((isset($_POST['stop']) && $_POST['stop']) || ((isset($_POST['save']) && $_POST['save']) && !$configuration['enable'])) { - if (empty($input_errors)) { - $return_val = mwexec("{$configuration['rootfolder']}/mysqlinit -p", true); - if ($return_val == 0) { - $savemsg .= sprintf(gettext("%s stopped successfully."), $appName); - exec("echo '{$date}: {$configuration['appname']} successfully stopped' >> {$logfile}"); - } - else { - $input_errors[] = sprintf(gettext("%s stop failed."), $appName); - exec("echo '{$date}: {$configuration['appname']} stop failed' >> {$logfile}"); - } + $return_val = mwexec("{$configuration['rootfolder']}/mysqlinit -p", true); + if ($return_val == 0) { + $savemsg .= sprintf(gettext("%s stopped successfully."), $appName); + exec("echo '{$date}: {$configuration['appname']} successfully stopped' >> {$logfile}"); + } + else { + $input_errors[] = sprintf(gettext("%s stop failed."), $appName); + exec("echo '{$date}: {$configuration['appname']} stop failed' >> {$logfile}"); } } if ((isset($_POST['restart']) && $_POST['restart']) || ((isset($_POST['save']) && $_POST['save']) && $configuration['enable'])) { - if (empty($input_errors)) { - $return_val = mwexec("{$configuration['rootfolder']}/mysqlinit -r", true); - if ($return_val == 0) { - $savemsg .= sprintf(gettext("%s restarted successfully."), $appName); - exec("echo '{$date}: {$configuration['appname']} successfully restarted' >> {$logfile}"); - } - else { - $input_errors[] = sprintf(gettext("%s restart failed."), $appName); - exec("echo '{$date}: {$configuration['appname']} restart failed' >> {$logfile}"); - } + $return_val = mwexec("{$configuration['rootfolder']}/mysqlinit -r", true); + if ($return_val == 0) { + $savemsg .= sprintf(gettext("%s restarted successfully."), $appName); + exec("echo '{$date}: {$configuration['appname']} successfully restarted' >> {$logfile}"); + } + else { + $input_errors[] = sprintf(gettext("%s restart failed."), $appName); + exec("echo '{$date}: {$configuration['appname']} restart failed' >> {$logfile}"); } } @@ -279,6 +275,11 @@ function enable_change(enable_change) { document.iform.backuppath.disabled = endis; document.iform.backuppathbrowsebtn.disabled = endis; document.iform.dbclient.disabled = endis; + document.iform.start.disabled = endis; + document.iform.stop.disabled = endis; + document.iform.restart.disabled = endis; + document.iform.upgrade.disabled = endis; + document.iform.backup.disabled = endis; } //--> @@ -313,7 +314,7 @@ function enable_change(enable_change) { html_inputbox("port", gettext("Port"), $pconfig['port'], sprintf(gettext("Port to listen on. Only dynamic or private ports can be used (from %d through %d). Default port is %d."), 1025, 65535, 3306), true, 5); html_inputbox("listen", gettext("IP Address"), $pconfig['listen'], sprintf(gettext("IP address to listen on. Use 0.0.0.0 for all host IPs. Default is %s."), "127.0.0.1"), true, 25); html_textarea("auxparam", gettext("Additional Parameters"), $pconfig['auxparam'], sprintf(gettext("These parameters are added to the %s section of the %s configuration."), "[mysqld]", $configuration['appname']), false, 65, 3, false, false); - html_filechooser("backuppath", gettext("Backup directory"), $pconfig['backuppath'], gettext("Directory to store archive.tar files of the mysqldata folder."), $pconfig['backuppath'], true, 60); + html_filechooser("backuppath", gettext("Backup Directory"), $pconfig['backuppath'], sprintf(gettext("Directory to store compressed archive files of the %s folder."), "mysqldata"), $pconfig['backuppath'], true, 60); html_checkbox("dbclient", gettext("SQL Database Administration Client"), $pconfig['dbclient'], gettext("Install the client.")." ".$webServerMsg); if ($configuration['dbclient'] && $webServerReady) html_text("url", "┕── ".gettext("URL"), $urlWebUI, false); ?> diff --git a/mysql/mysql-install.php b/mysql/mysql-install.php index 88fe6eb..ddd14b8 100644 --- a/mysql/mysql-install.php +++ b/mysql/mysql-install.php @@ -25,7 +25,7 @@ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$version = "v0.1b1"; // extension version +$version = "v0.1b2"; // extension version $appName = "MySQL"; $configName = strtolower($appName); @@ -40,11 +40,11 @@ global $savemsg; // fetch release archive -$return_val = mwexec("fetch {$verify_hostname} -vo {$install_dir}/master.zip 'https://github.com/crestAT/nas4free-{$configName}/releases/download/{$version}/{$configName}-{$version_striped}.zip'", false); +$return_val = 0;#mwexec("fetch {$verify_hostname} -vo {$install_dir}/master.zip 'https://github.com/crestAT/nas4free-{$configName}/releases/download/{$version}/{$configName}-{$version_striped}.zip'", false); if ($return_val == 0) { - $return_val = mwexec("tar -xf {$install_dir}/master.zip -C {$install_dir} --exclude='.git*' --strip-components 2", true); + $return_val = 0;#mwexec("tar -xf {$install_dir}/master.zip -C {$install_dir} --exclude='.git*' --strip-components 2", true); if ($return_val == 0) { - exec("rm {$install_dir}/master.zip"); + #exec("rm {$install_dir}/master.zip"); exec("chmod -R 775 {$install_dir}"); require_once("{$install_dir}/ext/extension-lib.inc"); $configFile = "{$install_dir}/ext/{$configName}.conf"; @@ -80,9 +80,10 @@ ext_create_rc_commands($appName, $configuration['rc_uuid_start'], $configuration['rc_uuid_stop']); ext_save_config($configFile, $configuration); -#exec("su -m root -c 'cat {$install_dir}/create_mysqladmin.sql | mysql'"); -exec("cat {$install_dir}/create_mysqladmin.sql | mysql"); -require_once("{$install_dir}/{$configName}-stop.php"); -require_once("{$install_dir}/{$configName}-start.php"); -if ($new_installation) echo "\nInstallation completed, use WebGUI | Extensions | {$appName} to configure the application!\n"; +if ($new_installation) { + mwexec("{$configuration['rootfolder']}/{$configName}init", false); // initialze and start mySQL + exec("cat {$configuration['rootfolder']}/create_mysqladmin.sql | mysql"); // create admin user +} +require_once("{$configuration['rootfolder']}/{$configName}-start.php"); // initialize extension and eventually start mySQL if already set up +echo "\nInstallation completed, use WebGUI | Extensions | {$appName} to configure the application!\n"; ?> diff --git a/mysql/mysql-start.php b/mysql/mysql-start.php index 4cd681f..e31d47d 100644 --- a/mysql/mysql-start.php +++ b/mysql/mysql-start.php @@ -56,6 +56,6 @@ if ($return_val == 0) exec("logger {$configName}-extension: started"); else exec("logger {$configName}-extension: error(s) during startup, failed with return value = {$return_val}"); -mwexec("{$configuration['rootfolder']}/{$configName}init -o", true); // initialize -if (!$configuration['enable']) mwexec("{$configuration['rootfolder']}/{$configName}init -p", true); // stop if not enabled +mwexec("{$configuration['rootfolder']}/{$configName}init", false); // initialze +if (!$configuration['enable']) mwexec("{$configuration['rootfolder']}/{$configName}init -p", false); // stop if disabled ?> diff --git a/mysql/mysqlinit b/mysql/mysqlinit index 40c86f7..73b61ef 100644 --- a/mysql/mysqlinit +++ b/mysql/mysqlinit @@ -261,10 +261,10 @@ platform_check() mysql_initial_download mysql_pkg_extract mysql_symlinkdir - postinit_cmd + # postinit_cmd elif [ "${PRDPLATFORM}" = "x64-full" ]; then mysql_native_download - postinit_cmd + # postinit_cmd fi } diff --git a/mysql/release_notes.txt b/mysql/release_notes.txt index 3e7063e..2ab4058 100644 --- a/mysql/release_notes.txt +++ b/mysql/release_notes.txt @@ -1,4 +1,5 @@ Version Date Description +0.1b2 2018.09.21 some improvements for SQL admin user and changes in mysqlinit 0.1b1 2018.09.16 first beta N: ... new feature diff --git a/mysql/version.txt b/mysql/version.txt index d72b43e..d1a6a54 100644 --- a/mysql/version.txt +++ b/mysql/version.txt @@ -1 +1 @@ -0.1b1 \ No newline at end of file +0.1b2 \ No newline at end of file