vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I want to run some sql scripts through psql from a process that runs as root. Since I have no reason to trust the sql scripts, I want to run them in psql as a specific database user that doesn't have a corresponding login account, i.e. I want to do something like [start as root] su - postgres psql DBNAME DBUSER < script.sql or [start as root] su - postgres psql \connect DBNAME DBUSER \i script.sql The problem is that I haven't been able to do this without being prompted for a password. Is this possible, i.e. is there a way to go from a superuser (postgres) to a less privileged user without having to supply the password ? thanks, David ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| On Fri, Feb 03, 2006 at 15:48:35 -0800, David Lutterkort <dlutter@redhat.com> wrote: > Hi, > > I want to run some sql scripts through psql from a process that runs as > root. Since I have no reason to trust the sql scripts, I want to run > them in psql as a specific database user that doesn't have a > corresponding login account, i.e. I want to do something like > > [start as root] > su - postgres > psql DBNAME DBUSER < script.sql > > or > [start as root] > su - postgres > psql > \connect DBNAME DBUSER > \i script.sql > > The problem is that I haven't been able to do this without being > prompted for a password. Is this possible, i.e. is there a way to go > from a superuser (postgres) to a less privileged user without having to > supply the password ? You could use ident authentication and let the OS 'postgres' user connect as any postgres user. ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq |
| ||||
| Bruno Wolff III wrote: > On Fri, Feb 03, 2006 at 15:48:35 -0800, > David Lutterkort <dlutter@redhat.com> wrote: > > [start as root] > > su - postgres > > psql > > \connect DBNAME DBUSER > > \i script.sql Instead of using \connect, use SET SESSION AUTHORIZATION (and connect to the right database in the first place). -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc. ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |