From d3d4db4ab60a62954f1fe3c652ff0c4249e281ff Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 29 Sep 2017 21:54:23 -0700 Subject: [PATCH] Use the 'source' command to read in sql files, as it's more reliable that simply redirecting input https://www.virtualmin.com/node/53763 --- mysql/mysql-lib.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mysql/mysql-lib.pl b/mysql/mysql-lib.pl index c1e32cbe2..38936f061 100755 --- a/mysql/mysql-lib.pl +++ b/mysql/mysql-lib.pl @@ -979,8 +979,13 @@ local ($db, $file, $user, $pass) = @_; local $authstr = &make_authstr($user, $pass); local $cs = $sql_charset ? "--default-character-set=".quotemeta($sql_charset) : ""; +local $temp = &transname(); +&open_tempfile(TEMP, ">$temp"); +&print_tempfile(TEMP, "source ".$file.";\n"); +&close_tempfile(TEMP); +&set_ownership_permissions(undef, undef, 0644, $temp); local $cmd = "$config{'mysql'} $authstr -t ".quotemeta($db)." ".$cs. - " <".quotemeta($file); + " <".quotemeta($temp); -r $file || return (1, "$file does not exist"); if ($_[4] && $_[4] ne 'root' && $< == 0) { # Restoring as a Unix user