473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

restricting non superuser from accessing other databases

I am setting up a single PostgreSQL installation to be used by several
users. Can I restrict a database user from connecting and creating
objects in other databases but his/her own? So far I can only restrict a
user from creating more databases or users.

(Yes, I have set up a proper pg_hba.conf, but once a user is connected,
he can switch to another database, e.g. with "\c otherdb" in psql).

--
dave
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #1
5 1214
On Tue, 2004-09-07 at 11:28, David Garamond wrote:
I am setting up a single PostgreSQL installation to be used by several
users. Can I restrict a database user from connecting and creating
objects in other databases but his/her own? So far I can only restrict a
user from creating more databases or users.

(Yes, I have set up a proper pg_hba.conf, but once a user is connected,
he can switch to another database, e.g. with "\c otherdb" in psql).


Not unless pg_hba.conf allows it. You could set up explicit
database/user combinations there.

Another thing you can do is to delete the public schema in new
databases. The public schema is, by default, accessible to all users;
other schemas are accessible only to their creators unless permissions
are granted on them.

--
Oliver Elphick ol**@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"For whosoever shall call upon the name of the Lord
shall be saved." Romans 10:13
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #2
Oliver Elphick wrote:
I am setting up a single PostgreSQL installation to be used by several
users. Can I restrict a database user from connecting and creating
objects in other databases but his/her own? So far I can only restrict a
user from creating more databases or users.

(Yes, I have set up a proper pg_hba.conf, but once a user is connected,
he can switch to another database, e.g. with "\c otherdb" in psql).


Not unless pg_hba.conf allows it. You could set up explicit
database/user combinations there.


Thanks! So I must modify and kill -HUP postmaster everytime a new db is
added. Is there something like this in pg_hba.conf?

local owndb all md5

where "owndb" means only allow a user to connect only to db he/she owns.

--
dave

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
On Tue, 2004-09-07 at 14:35, David Garamond wrote:
Oliver Elphick wrote:
I am setting up a single PostgreSQL installation to be used by several
users. Can I restrict a database user from connecting and creating
objects in other databases but his/her own? So far I can only restrict a
user from creating more databases or users.

(Yes, I have set up a proper pg_hba.conf, but once a user is connected,
he can switch to another database, e.g. with "\c otherdb" in psql).


Not unless pg_hba.conf allows it. You could set up explicit
database/user combinations there.


Thanks! So I must modify and kill -HUP postmaster everytime a new db is
added. Is there something like this in pg_hba.conf?

local owndb all md5

where "owndb" means only allow a user to connect only to db he/she owns.


No. You would have to have:

local his_db that_user md5

for each user/database combination.
There is an option db_user_namespace in postgresql.conf, which is
normally off. See
http://www.postgresql.org/docs/7.4/i...me-config.html under
section 16.4.1. I haven't ever used this facility.

--
Oliver Elphick ol**@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"For whosoever shall call upon the name of the Lord
shall be saved." Romans 10:13
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #4
Oliver Elphick <ol**@lfix.co.uk> writes:
On Tue, 2004-09-07 at 14:35, David Garamond wrote:
Thanks! So I must modify and kill -HUP postmaster everytime a new db is
added. Is there something like this in pg_hba.conf?

local owndb all md5
No. You would have to have:
local his_db that_user md5
for each user/database combination.


CVS-tip documentation alleges that "sameuser" does what David wants,
at least as long as he names databases the same as their owners.

I'm too lazy to look to see if it's in any released versions ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #5
On Tue, 2004-09-07 at 15:38, Tom Lane wrote:
Oliver Elphick <ol**@lfix.co.uk> writes:
On Tue, 2004-09-07 at 14:35, David Garamond wrote:
Thanks! So I must modify and kill -HUP postmaster everytime a new db is
added. Is there something like this in pg_hba.conf?

local owndb all md5

No. You would have to have:
local his_db that_user md5
for each user/database combination.


CVS-tip documentation alleges that "sameuser" does what David wants,
at least as long as he names databases the same as their owners.

I'm too lazy to look to see if it's in any released versions .


I had overlooked that. It is in 7.4, at least:

database

Specifies which databases this record matches. The value all
specifies that it matches all databases. The value sameuser
specifies that the record matches if the requested database has
the same name as the requested user. The value samegroup
specifies that the requested user must a member of the group
with the same name as the requested database. Otherwise, this is
the name of a specific PostgreSQL database. Multiple database
names can be supplied by separating them with commas. A file
containing database names can be specified by preceding the file
name with @. The file must be in the same directory as
pg_hba.conf.

--
Oliver Elphick ol**@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"For whosoever shall call upon the name of the Lord
shall be saved." Romans 10:13
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xenophobe | last post by:
I have a popup window (required by the client) containing a form and would like to prevent users from accessing it directly. They are instead required to access the page via a hyperlink on another...
2
by: Frosty Madness | last post by:
Does anyone know if it's possible to set a policy in Windows to stop developers from accessing the debugger? Frosty
2
by: zuhans | last post by:
hello, i'm rather new to postgresql and am now standing in front of a big problem. if i want to host my database on any provider out there, i don't now see any chance to get my own right to...
1
by: marcelo Cortez | last post by:
Hi folks My application fail with 'Non-superuser connection limit exceeded' error , the client application is connected via ODBC AND GPF MESSAGE appear there. the 'Non-superuser connection...
10
by: nd02tsk | last post by:
Hello I know it is possible to time isolated queries through the settting of the \timing option in psql. This makes PgSQL report the time it took to perform one operation. I would like to...
1
by: Ed L. | last post by:
I'd like to have a DB client connect using a username ('psuedodba') different from the creator/owner ('dba') of the DB and its tables, but still have that username be able to do everything the...
1
by: james2 | last post by:
I am trying to write a perl script that will do remote machine. I have done user loging using simple command; $telnet->login('test', 'test123'); But now I want to do root login or superuser...
0
by: WebMatrix | last post by:
Hello, What's the best way to keep email templates as html files on the server, so ASP.NET application can get file access to it, while restricting web users from accessing it through their...
2
by: runway27 | last post by:
i am using apache server and presently when i try accessing any folders of my website i am able to browse the files ex = www.website.com/images which is a serious security risk as i am building a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.