You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/private/Setup/PostgreSQL.php
+12-11Lines changed: 12 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,6 @@ public function setupDatabase($username) {
62
62
$canCreateRoles = false;
63
63
}
64
64
65
-
$connectionMainDatabase;
66
65
if ($canCreateRoles) {
67
66
$connectionMainDatabase = $this->connect();
68
67
//use the admin login data for the new database user
@@ -86,16 +85,18 @@ public function setupDatabase($username) {
86
85
// the connection to dbname=postgres is not needed anymore
87
86
$connection->close();
88
87
89
-
if ($canCreateRoles) {
90
-
// Go to the main database and grant create on the public schema
91
-
// The code below is implemented to make installing possible with PostgreSQL version 15:
92
-
// https://www.postgresql.org/docs/release/15.0/
93
-
// 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
94
-
// Therefore we assume that the database is only used by one user/service which is Nextcloud
95
-
// Additional services should get installed in a separate database in order to stay secure
96
-
// Also see https://www.postgresql.org/docs/15/ddl-schemas.html#DDL-SCHEMAS-PATTERNS
97
-
$connectionMainDatabase->executeQuery('GRANT CREATE ON SCHEMA public TO "' . addslashes($this->dbUser) . '"');
98
-
$connectionMainDatabase->close();
88
+
if ($this->tryCreateDbUser) {
89
+
if ($canCreateRoles) {
90
+
// Go to the main database and grant create on the public schema
91
+
// The code below is implemented to make installing possible with PostgreSQL version 15:
92
+
// https://www.postgresql.org/docs/release/15.0/
93
+
// 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
94
+
// Therefore we assume that the database is only used by one user/service which is Nextcloud
95
+
// Additional services should get installed in a separate database in order to stay secure
96
+
// Also see https://www.postgresql.org/docs/15/ddl-schemas.html#DDL-SCHEMAS-PATTERNS
97
+
$connectionMainDatabase->executeQuery('GRANT CREATE ON SCHEMA public TO "' . addslashes($this->dbUser) . '"');
98
+
$connectionMainDatabase->close();
99
+
}
99
100
}
100
101
} catch (\Exception$e) {
101
102
$this->logger->warning('Error trying to connect as "postgres", assuming database is setup and tables need to be created', [
0 commit comments