pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedProgrammatically changing passwords
8+ messages / 4 participants
[nested] [flat]
* Programmatically changing passwords
@ 2006-08-10 04:12 David Leangen <postgres@leangen.net>
0 siblings, 2 replies; 8+ messages in thread
From: David Leangen @ 2006-08-10 04:12 UTC (permalink / raw)
To: pgsql-admin
Hello!
I am trying to build an RPM package that will put my Postgres
installation into a known (usable) state, without requiring any
interaction.
To this effect, I need to do the following:
1. set password for superuser
2. createuser user
3. createdb -O user dbname
No problems with (3) above. But for (1) and (2), how can I set the
passwords programmatically, since createuser does not let me do this
(requires interactive prompt from user)?
Thank you!
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 04:54 Tom Lane <tgl@sss.pgh.pa.us>
parent: David Leangen <postgres@leangen.net>
1 sibling, 1 reply; 8+ messages in thread
From: Tom Lane @ 2006-08-10 04:54 UTC (permalink / raw)
To: David Leangen <postgres@leangen.net>; +Cc: pgsql-admin
David Leangen <postgres@leangen.net> writes:
> I am trying to build an RPM package that will put my Postgres
> installation into a known (usable) state, without requiring any
> interaction.
> To this effect, I need to do the following:
> 1. set password for superuser
Basically, you can't. The entire concept of RPM is built around
the assumption that there is no user interaction during an RPM
install or update. (Do "yum update" after not having done it for
awhile ... watch several hundred package updates go by ... now
imagine that each one of those felt that it could demand some input
from you. Multiply by 10 if doing a system install from scratch.)
The standard RPM-ization of Postgres does not actually have any
superuser password set at all: you pretty much have to be root
to get into the database the first time. Considering you also
have to be root to install the package or start the service,
I don't see any fundamental problem with that.
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 04:59 Joshua D. Drake <jd@commandprompt.com>
parent: David Leangen <postgres@leangen.net>
1 sibling, 1 reply; 8+ messages in thread
From: Joshua D. Drake @ 2006-08-10 04:59 UTC (permalink / raw)
To: David Leangen <postgres@leangen.net>; +Cc: pgsql-admin
David Leangen wrote:
>
> Hello!
>
> I am trying to build an RPM package that will put my Postgres
> installation into a known (usable) state, without requiring any
> interaction.
>
> To this effect, I need to do the following:
>
> 1. set password for superuser
> 2. createuser user
> 3. createdb -O user dbname
>
>
> No problems with (3) above. But for (1) and (2), how can I set the
> passwords programmatically, since createuser does not let me do this
> (requires interactive prompt from user)?
ALTER USER foo with encrypted password 'bar';
CREATE USER foo;
CREATE DATABASE bar owner foo;
>
>
> Thank you!
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
--
=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 05:11 David Leangen <postgres@leangen.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 8+ messages in thread
From: David Leangen @ 2006-08-10 05:11 UTC (permalink / raw)
To: pgsql-admin
Thank you. Reply below.
On Aug 10, 2006, at 13:54, Tom Lane wrote:
> David Leangen <postgres@leangen.net> writes:
>> I am trying to build an RPM package that will put my Postgres
>> installation into a known (usable) state, without requiring any
>> interaction.
>
>> To this effect, I need to do the following:
>
>> 1. set password for superuser
>
> Basically, you can't. The entire concept of RPM is built around
> the assumption that there is no user interaction during an RPM
> install or update.
Yes, that is my point. After having installed the standard postgresql
package, I would then install my custom-postgres-config package. In
this package, I tinker with the default configuration so I can put
postgres into a known state programmatically, without any user
interaction.
The problem is that createuser doesn't allow for this: it prompts the
user for a password, which does not work in this situation, as you
pointed out.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 05:12 David Leangen <postgres@leangen.net>
parent: Joshua D. Drake <jd@commandprompt.com>
0 siblings, 1 reply; 8+ messages in thread
From: David Leangen @ 2006-08-10 05:12 UTC (permalink / raw)
To: pgsql-admin
Thank you! Reply below.
On Aug 10, 2006, at 13:59, Joshua D. Drake wrote:
> David Leangen wrote:
>> Hello!
>> I am trying to build an RPM package that will put my Postgres
>> installation into a known (usable) state, without requiring any
>> interaction.
>> To this effect, I need to do the following:
>> 1. set password for superuser
>> 2. createuser user
>> 3. createdb -O user dbname
>> No problems with (3) above. But for (1) and (2), how can I set the
>> passwords programmatically, since createuser does not let me do
>> this (requires interactive prompt from user)?
>
> ALTER USER foo with encrypted password 'bar';
> CREATE USER foo;
> CREATE DATABASE bar owner foo;
That makes perfect sense, but how can I do this from the shell? Is
there an easy way to wrap these so I can send them to postgres from
the shell?
Thank you!
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 05:36 Tom Lane <tgl@sss.pgh.pa.us>
parent: David Leangen <postgres@leangen.net>
0 siblings, 0 replies; 8+ messages in thread
From: Tom Lane @ 2006-08-10 05:36 UTC (permalink / raw)
To: David Leangen <postgres@leangen.net>; +Cc: pgsql-admin
David Leangen <postgres@leangen.net> writes:
> Yes, that is my point. After having installed the standard postgresql
> package, I would then install my custom-postgres-config package. In
> this package, I tinker with the default configuration so I can put
> postgres into a known state programmatically, without any user
> interaction.
> The problem is that createuser doesn't allow for this: it prompts the
> user for a password, which does not work in this situation, as you
> pointed out.
I rather doubt that: the default RPM installation uses ident
authentication. Which has got plenty of downsides, but unexpected
password prompts is not one of them. Perhaps you are making your
configuration changes in a bad order?
regards, tom lane
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 05:36 Thomas Pundt <mlists@rp-online.de>
parent: David Leangen <postgres@leangen.net>
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Pundt @ 2006-08-10 05:36 UTC (permalink / raw)
To: pgsql-admin@postgresql.org, David Leangen <postgres@leangen.net>
On Thursday 10 August 2006 07:12, David Leangen wrote:
| > ALTER USER foo with encrypted password 'bar';
| > CREATE USER foo;
| > CREATE DATABASE bar owner foo;
|
| That makes perfect sense, but how can I do this from the shell? Is
| there an easy way to wrap these so I can send them to postgres from
| the shell?
yes; the following should work:
#!/bin/bash
psql <<_EOT_
ALTER USER foo with encrypted password 'bar';
CREATE USER foo;
CREATE DATABASE bar owner foo;
_EOT_
Ciao,
Thomas
--
Thomas Pundt <thomas.pundt@rp-online.de> ---- http://rp-online.de/ ----
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Programmatically changing passwords
@ 2006-08-10 06:06 David Leangen <postgres@leangen.net>
parent: Thomas Pundt <mlists@rp-online.de>
0 siblings, 0 replies; 8+ messages in thread
From: David Leangen @ 2006-08-10 06:06 UTC (permalink / raw)
To: pgsql-admin
Awesome, thank you!
That is exactly what I needed.
Didn't know it was that simple... duh!
On Aug 10, 2006, at 14:36, Thomas Pundt wrote:
> On Thursday 10 August 2006 07:12, David Leangen wrote:
> | > ALTER USER foo with encrypted password 'bar';
> | > CREATE USER foo;
> | > CREATE DATABASE bar owner foo;
> |
> | That makes perfect sense, but how can I do this from the shell? Is
> | there an easy way to wrap these so I can send them to postgres from
> | the shell?
>
> yes; the following should work:
>
> #!/bin/bash
> psql <<_EOT_
> ALTER USER foo with encrypted password 'bar';
> CREATE USER foo;
> CREATE DATABASE bar owner foo;
> _EOT_
>
>
> Ciao,
> Thomas
>
> --
> Thomas Pundt <thomas.pundt@rp-online.de> ---- http://rp-online.de/
> ----
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2006-08-10 06:06 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-10 04:12 Programmatically changing passwords David Leangen <postgres@leangen.net>
2006-08-10 04:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-08-10 05:11 ` David Leangen <postgres@leangen.net>
2006-08-10 05:36 ` Tom Lane <tgl@sss.pgh.pa.us>
2006-08-10 04:59 ` Joshua D. Drake <jd@commandprompt.com>
2006-08-10 05:12 ` David Leangen <postgres@leangen.net>
2006-08-10 05:36 ` Thomas Pundt <mlists@rp-online.de>
2006-08-10 06:06 ` David Leangen <postgres@leangen.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox