Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 047701337B97 for ; Thu, 5 May 2011 18:08:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 25422-08 for ; Thu, 5 May 2011 21:08:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from momjian.us (momjian.us [70.90.9.53]) by mail.postgresql.org (Postfix) with ESMTP id 918FF1337A5D for ; Thu, 5 May 2011 18:08:01 -0300 (ADT) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id p45L82w27520; Thu, 5 May 2011 17:08:02 -0400 (EDT) From: Bruce Momjian Message-Id: <201105052108.p45L82w27520@momjian.us> Subject: Re: [BUGS] BUG #5957: createdb with description and md5 auth forces to provide password twice In-Reply-To: <201103300120.p2U1KBNN038382@wwwmaster.postgresql.org> To: Grzegorz Szpetkowski Date: Thu, 5 May 2011 17:08:02 -0400 (EDT) CC: PostgreSQL-development X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ELM1304629682-4673-0_" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/223 X-Sequence-Number: 187257 --ELM1304629682-4673-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Grzegorz Szpetkowski wrote: > > The following bug has been logged online: > > Bug reference: 5957 > Logged by: Grzegorz Szpetkowski > Email address: gszpetkowski@gmail.com > PostgreSQL version: 9.0.3 > Operating system: Ubuntu 10.10 > Description: createdb with description and md5 auth forces to provide > password twice > Details: > > How to reproduce the problem: > > 1.Create new role with (encrypted password): > createuser -SdRP user > 2.In PostgreSQL 9.0.3 I found pg_hba.conf with local all all ident, so > change to local all all md5 > 3.Restart/Reload used cluster > 4.Execute createdb -U user mydb "My DB Description" > > Output: > > Password: > Password: > > creatdb command prompts password twice and I think it's improper behaviour > (and documentation is silent about that). Interesting. This is happening because we are connecting to one database to create the new database, and then connecting to the new database to add the comment. Prior to PG 8.2, this was necessary to put the comment on the database, but now that we have the shared comment/description table pg_shdescription, this is not necessary. Do we need createdb to be able to create databases for pre-8.2 clusters? If not, the attached patch fixes the double-prompting. Also, why is this code used to create the new database? conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres", host, port, username, prompt_password, progname); Do we assume more users can connect to the 'postgres' database, but we want 'postgres' to connect to 'template1' in case it wants to drop the 'postgres' database? Whatever the purpose, this code certainly needs a comment. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --ELM1304629682-4673-0_ Content-Transfer-Encoding: 7bit Content-Type: text/x-diff Content-Disposition: inline; filename="/pgpatches/createdb" diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c new file mode 100644 index 9b72eac..b1c417b *** a/src/bin/scripts/createdb.c --- b/src/bin/scripts/createdb.c *************** main(int argc, char *argv[]) *** 208,219 **** } PQclear(result); - PQfinish(conn); if (comment) { - conn = connectDatabase(dbname, host, port, username, prompt_password, progname); - printfPQExpBuffer(&sql, "COMMENT ON DATABASE %s IS ", fmtId(dbname)); appendStringLiteralConn(&sql, comment, conn); appendPQExpBuffer(&sql, ";\n"); --- 208,216 ---- *************** main(int argc, char *argv[]) *** 231,239 **** } PQclear(result); - PQfinish(conn); } exit(0); } --- 228,237 ---- } PQclear(result); } + PQfinish(conn); + exit(0); } --ELM1304629682-4673-0_--