mirror of
https://github.com/webmin/webmin.git
synced 2025-08-12 02:18:16 +00:00
Catch query failure
This commit is contained in:
@ -760,14 +760,14 @@ sub quotestr
|
||||
return "\"$_[0]\"";
|
||||
}
|
||||
|
||||
# execute_sql_file(database, file, [user, pass])
|
||||
# execute_sql_file(database, file, [user, pass], [unix-user])
|
||||
# Executes some file of SQL statements, and returns the exit status and output
|
||||
sub execute_sql_file
|
||||
{
|
||||
local ($db, $file, $user, $pass, $unixuser) = @_;
|
||||
if (&is_readonly_mode()) {
|
||||
return (0, undef);
|
||||
}
|
||||
local ($db, $file, $user, $pass) = @_;
|
||||
if (!defined($user)) {
|
||||
$user = $postgres_login;
|
||||
$pass = $postgres_pass;
|
||||
@ -780,6 +780,9 @@ local $cmd = "e_path($config{'psql'})." -f "."e_path($file).
|
||||
if ($postgres_sameunix && defined(getpwnam($postgres_login))) {
|
||||
$cmd = &command_as_user($postgres_login, 0, $cmd);
|
||||
}
|
||||
elsif ($unixuser && $unixuser ne 'root' && $< == 0) {
|
||||
$cmd = &command_as_user($unixuser, 0, $cmd);
|
||||
}
|
||||
$cmd = &command_with_login($cmd, $user, $pass);
|
||||
local $out = &backquote_logged("$cmd 2>&1");
|
||||
return ($out =~ /ERROR/i ? 1 : 0, $out);
|
||||
|
Reference in New Issue
Block a user