summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-03-09 10:22:35 +0100
committerGitHub <noreply@github.com>2023-03-09 10:22:35 +0100
commit3dbe10856815aa2aa78797eb7d82440ed67a3e32 (patch)
treec7f20d4c9a4755f6a4fe06205ac77df409bbdd62 /lib
parent61aa0978ae9ed688673ac22773407b6e5c930a80 (diff)
parent40edac18f553a9b53dcf76a360ed5d92ec3c7865 (diff)
downloadnextcloud-server-3dbe10856815aa2aa78797eb7d82440ed67a3e32.tar.gz
nextcloud-server-3dbe10856815aa2aa78797eb7d82440ed67a3e32.zip
Merge pull request #37116 from nextcloud/enh/37114/add-quotes
postgresql installation - add quotes around user names
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Setup/PostgreSQL.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/private/Setup/PostgreSQL.php b/lib/private/Setup/PostgreSQL.php
index 8359f7b7563..490cbba69a9 100644
--- a/lib/private/Setup/PostgreSQL.php
+++ b/lib/private/Setup/PostgreSQL.php
@@ -80,7 +80,7 @@ class PostgreSQL extends AbstractDatabase {
// 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->executeQuery('GRANT CREATE ON SCHEMA public TO "' . addslashes($this->dbUser) . '"');
$connectionMainDatabase->close();
}
}
@@ -122,7 +122,7 @@ class PostgreSQL extends AbstractDatabase {
private function createDatabase(Connection $connection) {
if (!$this->databaseExists($connection)) {
//The database does not exists... let's create it
- $query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER " . addslashes($this->dbUser));
+ $query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER \"" . addslashes($this->dbUser) . '"');
try {
$query->execute();
} catch (DatabaseException $e) {
@@ -172,10 +172,10 @@ class PostgreSQL extends AbstractDatabase {
}
// create the user
- $query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
+ $query = $connection->prepare("CREATE USER \"" . addslashes($this->dbUser) . "\" CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
$query->execute();
if ($this->databaseExists($connection)) {
- $query = $connection->prepare('GRANT CONNECT ON DATABASE ' . addslashes($this->dbName) . ' TO '.addslashes($this->dbUser));
+ $query = $connection->prepare('GRANT CONNECT ON DATABASE ' . addslashes($this->dbName) . ' TO "' . addslashes($this->dbUser) . '"');
$query->execute();
}
} catch (DatabaseException $e) {