Add list permissions command
This commit is contained in:
@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Process\InputStream;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class BackupService
|
||||
|
@ -5,12 +5,10 @@ namespace App\Service;
|
||||
class DatabaseCredentials
|
||||
{
|
||||
public function __construct(
|
||||
private string $hostname,
|
||||
private string $user,
|
||||
private string $password,
|
||||
)
|
||||
{
|
||||
}
|
||||
private readonly string $hostname,
|
||||
private readonly string $user,
|
||||
private readonly string $password,
|
||||
) {}
|
||||
|
||||
public function getHostname(): string
|
||||
{
|
||||
|
@ -110,4 +110,16 @@ class DatabaseService
|
||||
throw new Exception(sprintf('User delete error: %s', $this->conn->error));
|
||||
}
|
||||
}
|
||||
|
||||
public function listPermissions(string $user, ?string $host = 'localhost'): array
|
||||
{
|
||||
$results = $this->conn->query(sprintf("SHOW GRANTS FOR '%s'@'%s'", $user, $host), );
|
||||
|
||||
$permissions = [];
|
||||
while ($result = $results->fetch_array()) {
|
||||
$permissions[] = $result[0];
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user