Hi PostgreSQL developers!

I'm comaintainer of the Debian package of postgresql (CC to its
maintainer) and just fixed the bug report below (see
http://bugs.debian.org/224716 for the whole thread):

----- Forwarded message from simon raven <[EMAIL PROTECTED]> -----

Subject: Bug#224716: postgresql-client: createuser fails
Reply-To: simon raven <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
From: simon raven <[EMAIL PROTECTED]>
To: Debian Bug Tracking System <[EMAIL PROTECTED]>
Date: Sun, 21 Dec 2003 13:17:01 +0000
X-Spam-Status: No, hits=-4.9 required=3.0 tests=BAYES_00 autolearn=ham 
        version=2.61

Package: postgresql-client
Version: 7.3.4-9
Severity: important
Tags: sid


(#:~)- createuser -E -U postgres -W nagios
Shall the new user be allowed to create databases? (y/n) n
Shall the new user be allowed to create more new users? (y/n) n
Password:
ERROR:  parser: parse error at or near "NOCREATEDB" at character 61
createuser: creation of user "nagios" failed

it fails if i include the -E (encrypt password) option, otherwise it
works as expected, if i do not include the -E option.

----- End forwarded message -----

The problem is that createuser.c builds a wrong SQL string if just the
'-E' option without '-P' is given. This results in an SQL string like

        CREATE USER ... ENCRYPTED NOCREATEDB

although it should read '... ENCRYPTED PASSWORD 'blabla' NOCREATEDB'

The attached patch fixes this by just ignoring -E when -P is not
given. The patch should work against your current CVS; it is already
included in the Debian package CVS.

Thanks and have a nice day!

Martin
-- 
Martin Pitt                 Debian GNU/Linux Developer
[EMAIL PROTECTED]                      [EMAIL PROTECTED]
http://www.piware.de             http://www.debian.org
diff -ruN postgresql-7.4.1-old/src/bin/scripts/createuser.c 
postgresql-7.4.1/src/bin/scripts/createuser.c
--- postgresql-7.4.1-old/src/bin/scripts/createuser.c   2003-08-04 02:43:29.000000000 
+0200
+++ postgresql-7.4.1/src/bin/scripts/createuser.c       2004-01-05 23:27:54.000000000 
+0100
@@ -189,12 +189,12 @@
        printfPQExpBuffer(&sql, "CREATE USER %s", fmtId(newuser));
        if (sysid)
                appendPQExpBuffer(&sql, " SYSID %s", sysid);
-       if (encrypted == +1)
-               appendPQExpBuffer(&sql, " ENCRYPTED");
-       if (encrypted == -1)
-               appendPQExpBuffer(&sql, " UNENCRYPTED");
        if (newpassword)
        {
+               if (encrypted == +1)
+                       appendPQExpBuffer(&sql, " ENCRYPTED");
+               if (encrypted == -1)
+                       appendPQExpBuffer(&sql, " UNENCRYPTED");
                appendPQExpBuffer(&sql, " PASSWORD ");
                appendStringLiteral(&sql, newpassword, false);
        }

Attachment: signature.asc
Description: Digital signature

Reply via email to