Create user/create database outside template1

Started by Bruce Momjianover 25 years ago7 messages
#1Bruce Momjian
pgman@candle.pha.pa.us

What happens if people issue create user or create database outside
template1. Do we need to prevent it? Seems they work, but am not sure
it is OK. Do we need to add a check?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: Create user/create database outside template1

Bruce Momjian <pgman@candle.pha.pa.us> writes:

What happens if people issue create user or create database outside
template1. Do we need to prevent it? Seems they work, but am not sure
it is OK. Do we need to add a check?

Works fine, no, and no. The reason the scripts like to connect to
template1 is that it's the only database they can be sure is there.
But the commands themselves don't care where you're connected.

regards, tom lane

#3Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#2)
Re: Create user/create database outside template1

Bruce Momjian <pgman@candle.pha.pa.us> writes:

What happens if people issue create user or create database outside
template1. Do we need to prevent it? Seems they work, but am not sure
it is OK. Do we need to add a check?

Works fine, no, and no. The reason the scripts like to connect to
template1 is that it's the only database they can be sure is there.
But the commands themselves don't care where you're connected.

Well, thanks. I was going over that for my book. If I do createdb from
another database, I guess I get a copy of that database, right?
Interesting feature that I am sure few people realize.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#4Vince Vielhaber
vev@michvhf.com
In reply to: Bruce Momjian (#3)
Re: Create user/create database outside template1

On Thu, 25 May 2000, Bruce Momjian wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

What happens if people issue create user or create database outside
template1. Do we need to prevent it? Seems they work, but am not sure
it is OK. Do we need to add a check?

Works fine, no, and no. The reason the scripts like to connect to
template1 is that it's the only database they can be sure is there.
But the commands themselves don't care where you're connected.

Well, thanks. I was going over that for my book. If I do createdb from
another database, I guess I get a copy of that database, right?
Interesting feature that I am sure few people realize.

Say what? That might explain a few things.

Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev@michvhf.com http://www.pop4.net
128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
Online Campground Directory http://www.camping-usa.com
Online Giftshop Superstore http://www.cloudninegifts.com
==========================================================================

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#3)
Re: Create user/create database outside template1

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Well, thanks. I was going over that for my book. If I do createdb from
another database, I guess I get a copy of that database, right?

No, it's always a copy of template1. CREATE DATABASE really doesn't
care which database you're connected to (nor does CREATE USER).

regards, tom lane

#6Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#5)
Re: Create user/create database outside template1

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Well, thanks. I was going over that for my book. If I do createdb from
another database, I guess I get a copy of that database, right?

No, it's always a copy of template1. CREATE DATABASE really doesn't
care which database you're connected to (nor does CREATE USER).

Yes, I see that. Interesting.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#7Peter Mount
petermount@it.maidstone.gov.uk
In reply to: Bruce Momjian (#6)
RE: Create user/create database outside template1

Isn't template1 just that, a template?

If a user has the ability to create a user or database, then they should
be able to do it from anywhere.

Personally, I think normal users shouldn't have access to template1,
simply because they could create objects in there that can be copied
into _any_new_ database.

Peter

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council.

-----Original Message-----
From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
Sent: Thursday, May 25, 2000 5:18 PM
To: PostgreSQL-development
Subject: [HACKERS] Create user/create database outside template1

What happens if people issue create user or create database outside
template1. Do we need to prevent it? Seems they work, but am not sure
it is OK. Do we need to add a check?

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