Disallow superuser names starting with 'pg_' in initdb
authorStephen Frost <sfrost@snowman.net>
Sun, 8 May 2016 15:55:44 +0000 (11:55 -0400)
committerStephen Frost <sfrost@snowman.net>
Sun, 8 May 2016 15:55:44 +0000 (11:55 -0400)
As with CREATE ROLE, disallow users from specifying initial
superuser names which begin with 'pg_' in initdb.

Per discussion with Tom.

src/bin/initdb/initdb.c

index 299ddfe86ac41e1a5a6cfe5234475e9b846a518c..7dedd8adc63b3aa2263ae2c5b3e702de0bc44a49 100644 (file)
@@ -3562,6 +3562,12 @@ main(int argc, char *argv[])
    if (strlen(username) == 0)
        username = effective_user;
 
+   if (strncmp(username, "pg_", 3) == 0)
+   {
+       fprintf(stderr, _("%s: superuser name \"%s\" is reserved; role names can not begin with 'pg_'\n"), progname, username);
+       exit(1);
+   }
+
    printf(_("The files belonging to this database system will be owned "
             "by user \"%s\".\n"
             "This user must also own the server process.\n\n"),