Guest User

*[VIRTUALMIN QUICKFIX]* for MariaDB 10.2 - 10.4.6 !!!

a guest
Jul 31st, 2019
792
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /usr/libexec/webmin/virtual-server/feature-mysql.pl    Line: 2747 >>>>>>>>>>>>>>>>>>>>>>>>>>
  2.  
  3. if (($variant eq "mysql" && &compare_versions($ver, "8") >= 0 ||
  4.      $variant eq "mariadb" && &compare_versions($ver, "10.2") >= 0) &&
  5.     $plainpass) {
  6.     my $native = &is_domain_mysql_remote($d) ?
  7.             "with mysql_native_password" : "";
  8.     #return ("insert into user (host, user, ssl_type, ssl_cipher, x509_issuer, x509_subject) values ('$host', '$user', '', '', '', '')", "flush privileges", "alter user '$user'\@'$host' identified $native by '".&mysql_escape($plainpass)."'");
  9.     use Digest::SHA1  qw(sha1 sha1_hex);
  10.     return ("INSERT INTO `global_priv` (`Host`, `User`, `Priv`) VALUES ('$host', '$user', '{\"access\":".time().",\"plugin\":\"mysql_native_password\",\"authentication_string\":\""."*".uc sha1_hex(sha1($plainpass))."\",\"password_last_changed\":".time()."}')");
  11.     }
  12. elsif (&compare_versions($ver, "5.7.6") >= 0) {
  13.     #return ("insert into user (host, user, ssl_type, ssl_cipher, x509_issuer, x509_subject, plugin, authentication_string) values ('$host', '$user', '', '', '', '', 'mysql_native_password', $encpass)");
  14.     use Digest::SHA1  qw(sha1 sha1_hex);
  15.     return ("INSERT INTO `global_priv` (`Host`, `User`, `Priv`) VALUES ('$host', '$user', '{\"access\":".time().",\"plugin\":\"mysql_native_password\",\"authentication_string\":\""."*".uc sha1_hex(sha1($plainpass))."\",\"password_last_changed\":".time()."}')");
  16.     }
  17. elsif (&compare_versions($ver, 5) >= 0) {
  18.     return ("insert into user (host, user, ssl_type, ssl_cipher, x509_issuer, x509_subject) values ('$host', '$user', '', '', '', '')", "flush privileges", "set password for '$user'\@'$host' = $encpass");
  19.     }
  20. else {
  21.     return ("insert into user (host, user, password) values ('$host', '$user', $encpass)");
  22.     }
  23. }
  24.  
  25. # execute_password_change_sql(&domain, user, password-sql, [force-user-table],
  26. #                 [no-flush], [plaintext-pass])
  27. # Update a MySQL user's password for all hosts
  28. sub execute_password_change_sql
  29. {
  30. my ($d, $user, $encpass, $forceuser, $noflush, $plainpass) = @_;
  31. if (!$encpass && $plainpass) {
  32.     # Hash password for insertion
  33.     my $qpass = &mysql_escape($plainpass);
  34.     $encpass = "$password_func('$qpass')";
  35.     }
  36. my $rv = &execute_dom_sql($d, $mysql::master_db,
  37.         "select host from user where user = ?", $user);
  38. my $flush = 0;
  39. foreach my $host (&unique(map { $_->[0] } @{$rv->{'data'}})) {
  40.     my $sql;
  41.     my ($ver, $variant) = &get_dom_remote_mysql_version($d);
  42.     if (($variant eq "mysql" && &compare_versions($ver, "8") >= 0 ||
  43.          $variant eq "mariadb" && &compare_versions($ver, "10.2") >= 0) &&
  44.         $plainpass) {
  45.         # Use the plaintext password wherever possible
  46.         #$sql = "set password for '$user'\@'$host' = '".
  47.         #       &mysql_escape($plainpass)."'";
  48.         my $mpass=uc sha1_hex(sha1($plainpass));
  49.         $sql = "update global_priv set Priv = '{\"access\":".time().",\"plugin\":\"mysql_native_password\",\"authentication_string\":\"*$mpass\",\"password_last_changed\":".time()."}' where user = '$user'";
  50.         }
  51.  
  52.  
  53. --------- END
  54. Christos Tzeremes
  55. IT Expert @ nasa.gr
  56. Thessalonikh GREECE [MACEDONIA]
  57. ctzeremes[at]nasa.gr
RAW Paste Data