6.0.0-alpha14
7/1/25

[#8082] pgsql create script fails
Summary pgsql create script fails
Queue Horde Base
Queue Version 3.3.3
Type Bug
State Resolved
Priority 2. Medium
Owners Horde Developers (at)
Requester reg (at) debian (dot) org
Created 03/15/2009 (5952 days ago)
Due
Updated 03/26/2009 (5941 days ago)
Assigned 03/16/2009 (5951 days ago)
Resolved 03/26/2009 (5941 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch Yes

History
03/26/2009 04:46:07 AM Michael Slusarz Comment #11
State ⇒ Resolved
Reply to this comment
CREATE USER horde;
  -- ALTER USER horde WITH PASSWORD 'pass';
CREATE DATABASE horde OWNER horde;
\c horde horde;
This makes the most sense.  By default, horde should own the database 
- the admin can always change this if they don't agree.  Added to 
3.3.4 and HEAD.
03/26/2009 04:44:06 AM CVS Commit Comment #9 Reply to this comment
03/20/2009 06:56:34 PM karlnack (at) futurityinc (dot) com Comment #8 Reply to this comment
         Name        |  Owner   |          Access privileges
--------------------+----------+--------------------------------
  public             | postgres | {postgres=UC/postgres,=UC/postgres}
Ok, the default access privileges for public users are configured 
differently on our systems. The part "=UC/postgres" means public users 
can Use (i.e., select) and Create on the public schema (and these 
privileges have been granted by the user postgres). I've removed 
create privileges for public users in my database. That's why it's 
working for you and not for me.



By default, Postgres allows any account to login to any database and 
create objects on the public schema. I suppose it's possible someone 
may have gone a step further and configured their template database to 
prevent public users from logging in at all.



I imagine a foolproof version of the script would look something like this:



CREATE USER horde;

  -- ALTER USER horde WITH PASSWORD 'pass';

CREATE DATABASE horde OWNER horde;

\c horde horde;



Alternatively, if you don't want horde to own the database (I don't 
know the security implications one way or the other):



CREATE DATABASE horde;

CREATE USER horde;

  -- ALTER USER horde WITH PASSWORD 'pass';

GRANT CONNECT ON DATABASE horde TO horde;

\c horde

GRANT CREATE ON SCHEMA public TO horde;

SET ROLE horde;



I haven't test any of this, so you may want to play around and see 
how/if this works.
03/20/2009 06:27:33 PM Michael Slusarz Comment #7 Reply to this comment
I'm the original reporter of this bug. Please try running the command
'\dn+' from your template1 database and post the output.
         Name        |  Owner   |          Access privileges           
|           Description

--------------------+----------+-------------------------------------+----------------------------------

  information_schema | postgres | {postgres=UC/postgres,=U/postgres}  |

  pg_catalog         | postgres | {postgres=UC/postgres,=U/postgres}   
| system catalog schema

  pg_toast           | postgres |                                     
| reserved schema for TOAST tables

  pg_toast_temp_1    | postgres |                                     |

  public             | postgres | {postgres=UC/postgres,=UC/postgres} 
| standard public schema

(5 rows)
03/20/2009 06:18:50 PM karlnack (at) futurityinc (dot) com Comment #6 Reply to this comment
I don't see this.  The script runs fine for me (although I'm not a
postgres/SQL expert by any stretch of the imagination).
I'm the original reporter of this bug. Please try running the command 
'\dn+' from your template1 database and post the output.
03/17/2009 12:46:48 PM Michael Slusarz Comment #4 Reply to this comment
I have:

Welcome to psql 8.3.6 (server 8.3.5), the PostgreSQL interactive terminal.
The create.pgsql.sql script fails (running postgresql 8.3.5). After
creating and switching to the horde database, it fails to create new
relations with error
"permission denied for schema public".
I don't see this.  The script runs fine for me (although I'm not a 
postgres/SQL expert by any stretch of the imagination).
Also, the script should probably run inside a transaction. After the
script fails, the user is left the horde user and an empty horde
database.
This makes sense.  I have added this part.
03/17/2009 12:45:32 PM CVS Commit Comment #3 Reply to this comment
03/16/2009 11:25:24 AM Jan Schneider Comment #2
Assigned to Horde DevelopersHorde Developers
State ⇒ Assigned
Reply to this comment
Can anybody running pg look into this?
03/15/2009 03:45:25 PM reg (at) debian (dot) org Comment #1
State ⇒ Unconfirmed
Patch ⇒ Yes
Milestone ⇒
Queue ⇒ Horde Base
Summary ⇒ pgsql create script fails
Type ⇒ Bug
Priority ⇒ 2. Medium
Reply to this comment
Hi,



I forward you a bug reported by a Debian user 
(http://bugs.debian.org/508571) :



The create.pgsql.sql script fails (running postgresql 8.3.5). After 
creating and switching to the horde database, it fails to create new 
relations with error

"permission denied for schema public".



The script erroneously grants CREATE on the database, which only 
allows creation of new schemas:



GRANT CREATE on DATABASE horde to horde;

\c horde horde;





The script should grant CREATE on the schema:



\c horde

GRANT CREATE ON SCHEMA public TO horde;

SET ROLE horde;



Also, the script should probably run inside a transaction. After the 
script fails, the user is left the horde user and an empty horde 
database.


Saved Queries