aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-01-19 12:00:00 -0500
committerPeter Eisentraut <peter_e@gmx.net>2017-01-19 16:17:36 -0500
commit8b0fec93ecc788c8d8b329d41ab795712d8dcc5a (patch)
tree85a4d7acf7821fd5c1dad48c920956ff0c07a89c /src
parentc3978149536a9c3fb837524407c58dec2b103c60 (diff)
downloadpostgresql-8b0fec93ecc788c8d8b329d41ab795712d8dcc5a.tar.gz
postgresql-8b0fec93ecc788c8d8b329d41ab795712d8dcc5a.zip
initdb: Fix for mixed-case superuser names
The previous coding did not properly quote the user name before casting it to regrole. To avoid all that, just pass in BOOTSTRAP_SUPERUSERID numerically. Also fix one place where the BOOTSTRAP_SUPERUSERID was hardcoded as 10.
Diffstat (limited to 'src')
-rw-r--r--src/bin/initdb/initdb.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index eb1be100c85..443c2ee4685 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -61,6 +61,7 @@
#endif
#include "catalog/catalog.h"
+#include "catalog/pg_authid.h"
#include "common/file_utils.h"
#include "common/restricted_token.h"
#include "common/username.h"
@@ -1617,7 +1618,7 @@ setup_collation(FILE *cmdfd)
PG_CMD_PUTS("SELECT pg_import_system_collations(if_not_exists => false, schema => 'pg_catalog');\n\n");
/* Add an SQL-standard name */
- PG_CMD_PRINTF2("INSERT INTO pg_collation (collname, collnamespace, collowner, collencoding, collcollate, collctype) VALUES ('ucs_basic', 'pg_catalog'::regnamespace, '%s'::regrole, %d, 'C', 'C');\n\n", escape_quotes(username), PG_UTF8);
+ PG_CMD_PRINTF2("INSERT INTO pg_collation (collname, collnamespace, collowner, collencoding, collcollate, collctype) VALUES ('ucs_basic', 'pg_catalog'::regnamespace, %u, %d, 'C', 'C');\n\n", BOOTSTRAP_SUPERUSERID, PG_UTF8);
}
/*
@@ -1688,7 +1689,7 @@ setup_privileges(FILE *cmdfd)
" SET relacl = (SELECT array_agg(a.acl) FROM "
" (SELECT E'=r/\"$POSTGRES_SUPERUSERNAME\"' as acl "
" UNION SELECT unnest(pg_catalog.acldefault("
- " CASE WHEN relkind = 'S' THEN 's' ELSE 'r' END::\"char\",10::oid))"
+ " CASE WHEN relkind = 'S' THEN 's' ELSE 'r' END::\"char\"," CppAsString2(BOOTSTRAP_SUPERUSERID) "::oid))"
" ) as a) "
" WHERE relkind IN ('r', 'v', 'm', 'S') AND relacl IS NULL;\n\n",
"GRANT USAGE ON SCHEMA pg_catalog TO PUBLIC;\n\n",