Thread: Createdb problem report

Createdb problem report

From
"Oliver Elphick"
Date:
The attached report is still correct as of 6.5.3; but will having a
database name that has to be quoted cause problems anywhere that SQL
queries are constructed to do internal operations?

The SQL command `CREATE DATABASE "www-data"' works correctly.

------- Forwarded Message

Date:    Thu, 18 Nov 1999 20:39:51 +0100
From:    Eric Gentilini <eric.gentilini@eleve.emn.fr>
To:      olly@lfix.co.uk
Subject: [POSTGRESQL] Does createdb belong to postgresql ?

hi !

I fixed a _very_ little bug in createdb and destroydb that prevents the
creation of postgresql users whose name contains special characters, and
especially '-', useful when accessing a database through a CGI script, whose
user is 'www-data' by default.

But I don't know if this prog is debian specific or if it belongs to
postrgesql.

Can you help me ?
thx !


============================================================================                       POSTGRESQL BUG
REPORTTEMPLATE
 
============================================================================


Your name               :       Eric Gentilini
Your email address      :       eric.gentilini@eleve.emn.fr


System Configuration
- --------------------- Architecture (example: Intel Pentium)         : Intel Pentium&PentiumII
 Operating System (example: Linux 2.0.26 ELF)  : Linux 2.2.13 ELF
 PostgreSQL version (example: PostgreSQL-6.5.2): PostgreSQL-6.5.2 
 Compiler used (example:  gcc 2.8.0)           : not compiled by me


Please enter a FULL description of your problem:
- ------------------------------------------------
I don't know if it is really a bug or if it is intentionnal, but
I found out that createdb and destroydb prevented the
creation/destruction of postgresql users whose
name contained special characters, and
especially '-', useful when accessing a database through a CGI script, whose
user is 'www-data' by default.
(In this case, createdb is executed by createuser)
The query aborts with the message "ERROR:  parser: parse error at or near "-""

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
- ----------------------------------------------------------------------
for instance : createdb www-data


If you know how this problem might be fixed, list the solution below:
- ---------------------------------------------------------------------
The simplest solution I found is to modify the scripts createdb and destroydb.
createdb : replace line 114 with :
psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create
database \"$dbname\" $location $encoding" template1       ^^^      ^^^
destroydb : replace line 78 with :
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database \"$dbname\"" template
1                                                        ^^^      ^^^

Eric (Yam) Gentilini

Linux à Nantes sur http://www.linux-nantes.fr.eu.org


------- End of Forwarded Message


--      Vote against SPAM: http://www.politik-digital.de/spam/                ========================================
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver              PGP key from public servers; key
ID32B8FAA1                ========================================    "A Song for the sabbath day. It is a good thing
to     give thanks unto the LORD, and to sing praises unto      thy name, O most High."   Psalms 92:1 
 




Re: [HACKERS] Createdb problem report

From
Bruce Momjian
Date:
Applied.  Will appear in 7.0


[Charset iso-8859-1 unsupported, filtering to ASCII...]
> The attached report is still correct as of 6.5.3; but will having a
> database name that has to be quoted cause problems anywhere that SQL
> queries are constructed to do internal operations?
> 
> The SQL command `CREATE DATABASE "www-data"' works correctly.
> 
> ------- Forwarded Message
> 
> Date:    Thu, 18 Nov 1999 20:39:51 +0100
> From:    Eric Gentilini <eric.gentilini@eleve.emn.fr>
> To:      olly@lfix.co.uk
> Subject: [POSTGRESQL] Does createdb belong to postgresql ?
> 
> hi !
> 
> I fixed a _very_ little bug in createdb and destroydb that prevents the
> creation of postgresql users whose name contains special characters, and
> especially '-', useful when accessing a database through a CGI script, whose
> user is 'www-data' by default.
> 
> But I don't know if this prog is debian specific or if it belongs to
> postrgesql.
> 
> Can you help me ?
> thx !
> 
> 
> ============================================================================
>                         POSTGRESQL BUG REPORT TEMPLATE
> ============================================================================
> 
> 
> Your name               :       Eric Gentilini
> Your email address      :       eric.gentilini@eleve.emn.fr
> 
> 
> System Configuration
> - ---------------------
>   Architecture (example: Intel Pentium)         : Intel Pentium&PentiumII
> 
>   Operating System (example: Linux 2.0.26 ELF)  : Linux 2.2.13 ELF
> 
>   PostgreSQL version (example: PostgreSQL-6.5.2): PostgreSQL-6.5.2 
> 
>   Compiler used (example:  gcc 2.8.0)           : not compiled by me
> 
> 
> Please enter a FULL description of your problem:
> - ------------------------------------------------
> I don't know if it is really a bug or if it is intentionnal, but
> I found out that createdb and destroydb prevented the
> creation/destruction of postgresql users whose
> name contained special characters, and
> especially '-', useful when accessing a database through a CGI script, whose
> user is 'www-data' by default.
> (In this case, createdb is executed by createuser)
> The query aborts with the message "ERROR:  parser: parse error at or near "-""
> 
> Please describe a way to repeat the problem.   Please try to provide a
> concise reproducible example, if at all possible: 
> - ----------------------------------------------------------------------
> for instance : createdb www-data
> 
> 
> If you know how this problem might be fixed, list the solution below:
> - ---------------------------------------------------------------------
> The simplest solution I found is to modify the scripts createdb and destroydb.
> createdb : replace line 114 with :
> psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create
> database \"$dbname\" $location $encoding" template1
>         ^^^      ^^^
> destroydb : replace line 78 with :
> psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database \"$dbname\"" template
> 1
>                                                          ^^^      ^^^
> 
> Eric (Yam) Gentilini
> 
> Linux _ Nantes sur http://www.linux-nantes.fr.eu.org
> 
> 
> ------- End of Forwarded Message
> 
> 
> -- 
>       Vote against SPAM: http://www.politik-digital.de/spam/
>                  ========================================
> Oliver Elphick                                Oliver.Elphick@lfix.co.uk
> Isle of Wight                              http://www.lfix.co.uk/oliver
>                PGP key from public servers; key ID 32B8FAA1
>                  ========================================
>      "A Song for the sabbath day. It is a good thing to 
>       give thanks unto the LORD, and to sing praises unto 
>       thy name, O most High."   Psalms 92:1 
> 
> 
> 
> ************
> 


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] Createdb problem report

From
Peter Eisentraut
Date:
The cleanup on the scripts I recently did contained that, too. I think
it's on hold now because I'm going to fix up the create user SQL statement
to allow picking your user id first. Or was there any other reason?
Anyway, just letting you know that this problem has been recognized.
-Peter

On 1999-11-18, Bruce Momjian mentioned:

> 
> Applied.  Will appear in 7.0
> 
> 
> > I fixed a _very_ little bug in createdb and destroydb that prevents the
> > creation of postgresql users whose name contains special characters, and
> > especially '-', useful when accessing a database through a CGI script, whose
> > user is 'www-data' by default.



> 

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden