diff --git a/sbin/ngcp-sync-grants b/sbin/ngcp-sync-grants index 5ddbbcdc..32226c39 100755 --- a/sbin/ngcp-sync-grants +++ b/sbin/ngcp-sync-grants @@ -261,10 +261,6 @@ sub apply_copy_grants { sub apply_drop_users { my $forced_user = shift; # to drop a specific user - my $ch = $dbh->prepare(<prepare(<execute($user, $host_rx) or die "Cannot select user $user -- $host_rx: ".$DBI::errstr; while (my ($host) = $ch_sel->fetchrow_array) { - $ch->execute($user, $host_rx) + $dbh->do("DROP USER '$user'\@'$host_rx'") or die "Cannot drop user $user -- $host_rx: ".$DBI::errstr; log_info(sprintf "drop: %s\@%s", $user, $host); $rc++; @@ -293,7 +289,6 @@ SQL } } - $ch->finish; $ch_sel->finish; return $rc; @@ -347,6 +342,7 @@ sub grants_helper { my $user = $TEMP_GRANT_USER; my $host = $TEMP_GRANT_HOST; + flush_privs(); set_user_protected_password($user, $host); $dbh->do("REVOKE ALL PRIVILEGES, GRANT OPTION FROM '$user'\@'$host'"); @@ -378,6 +374,7 @@ sub grants_helper { $dbh->do("DROP USER '$user'\@'$host'"); die "Cannot drop grant temp user: ".$DBI::errstr if $DBI::err; + flush_privs(); @$grants = ( map { $_->[0] } @$temp_grants );