mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
fix: use $this->tryCreateDbUser condition
This commit is contained in:
parent
f490a4e8c0
commit
67c52d202c
1 changed files with 13 additions and 12 deletions
|
|
@ -40,8 +40,7 @@ class PostgreSQL extends AbstractDatabase {
|
|||
} catch (DatabaseException $e) {
|
||||
$canCreateRoles = false;
|
||||
}
|
||||
|
||||
$connectionMainDatabase;
|
||||
|
||||
if ($canCreateRoles) {
|
||||
$connectionMainDatabase = $this->connect();
|
||||
//use the admin login data for the new database user
|
||||
|
|
@ -65,16 +64,18 @@ class PostgreSQL extends AbstractDatabase {
|
|||
// the connection to dbname=postgres is not needed anymore
|
||||
$connection->close();
|
||||
|
||||
if ($canCreateRoles) {
|
||||
// Go to the main database and grant create on the public schema
|
||||
// The code below is implemented to make installing possible with PostgreSQL version 15:
|
||||
// https://www.postgresql.org/docs/release/15.0/
|
||||
// From the release notes: For new databases having no need to defend against insider threats, granting CREATE permission will yield the behavior of prior releases
|
||||
// Therefore we assume that the database is only used by one user/service which is Nextcloud
|
||||
// Additional services should get installed in a separate database in order to stay secure
|
||||
// Also see https://www.postgresql.org/docs/15/ddl-schemas.html#DDL-SCHEMAS-PATTERNS
|
||||
$connectionMainDatabase->executeQuery('GRANT CREATE ON SCHEMA public TO "' . addslashes($this->dbUser) . '"');
|
||||
$connectionMainDatabase->close();
|
||||
if ($this->tryCreateDbUser) {
|
||||
if ($canCreateRoles) {
|
||||
// Go to the main database and grant create on the public schema
|
||||
// The code below is implemented to make installing possible with PostgreSQL version 15:
|
||||
// https://www.postgresql.org/docs/release/15.0/
|
||||
// From the release notes: For new databases having no need to defend against insider threats, granting CREATE permission will yield the behavior of prior releases
|
||||
// Therefore we assume that the database is only used by one user/service which is Nextcloud
|
||||
// Additional services should get installed in a separate database in order to stay secure
|
||||
// Also see https://www.postgresql.org/docs/15/ddl-schemas.html#DDL-SCHEMAS-PATTERNS
|
||||
$connectionMainDatabase->executeQuery('GRANT CREATE ON SCHEMA public TO "' . addslashes($this->dbUser) . '"');
|
||||
$connectionMainDatabase->close();
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->warning('Error trying to connect as "postgres", assuming database is setup and tables need to be created', [
|
||||
|
|
|
|||
Loading…
Reference in a new issue