Re: small pg_dump RFE: new --no-prompt (password) option

Lists: pgsql-hackers
From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-01 12:46:59
Message-ID: 2A046899-4A18-4563-9C0A-13D691D083D2@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>
I'm forwarding this on behalf of Marc Hebert
>
> Hi there,
>
> As discussed recently on the jdbc mailing-list in this "Backup in
> Java" thread
>
> <http://thread.gmane.org/gmane.comp.db.postgresql.jdbc/12441/
> focus=12441>
>
> there is a significant interest in doing backups in an
> non-interactive, programmatic way. Reminder: AFAIK pg_dump is
> currently the very unique reliable way to perform a backup. There
> is no
> documented API or protocol to do this. Any program in any language is
> stuck with "scripting" pg_dump.
>
> When we implemented this scripting in Java we faced one major issue:
> pg_dump may prompt for a password in a unpredictable way (depending on
> the user misconfiguration). Taking care of this is surprisingly
> complex. The suggested --no-prompt would make scripting pg_dump
> infinitely easier. In case a password is needed, this option would
> simply fail and return immediatly with an appropriate error message.
> Or even better, with a well-defined return status.
>
> Thanks in advance for considering this new feature!
>
> Sincerely,
>
> Marc.
>
>


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-01 13:13:53
Message-ID: 20061201131353.GA23594@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 01, 2006 at 07:46:59AM -0500, Dave Cramer wrote:
> >
> I'm forwarding this on behalf of Marc Hebert

I saw it the first time.

> >When we implemented this scripting in Java we faced one major issue:
> >pg_dump may prompt for a password in a unpredictable way (depending on
> >the user misconfiguration). Taking care of this is surprisingly
> >complex. The suggested --no-prompt would make scripting pg_dump
> >infinitely easier. In case a password is needed, this option would
> >simply fail and return immediatly with an appropriate error message.
> >Or even better, with a well-defined return status.

Seems to me that you could just do this by setting stdin to be
/dev/null?

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-01 13:59:04
Message-ID: 04980DC3-41C6-44C5-8642-408E7ED98894@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1-Dec-06, at 8:13 AM, Martijn van Oosterhout wrote:

> On Fri, Dec 01, 2006 at 07:46:59AM -0500, Dave Cramer wrote:
>>>
>> I'm forwarding this on behalf of Marc Hebert
>
> I saw it the first time.
Sorry about the double posting

>
>>> When we implemented this scripting in Java we faced one major issue:
>>> pg_dump may prompt for a password in a unpredictable way
>>> (depending on
>>> the user misconfiguration). Taking care of this is surprisingly
>>> complex. The suggested --no-prompt would make scripting pg_dump
>>> infinitely easier. In case a password is needed, this option would
>>> simply fail and return immediatly with an appropriate error message.
>>> Or even better, with a well-defined return status.
>
> Seems to me that you could just do this by setting stdin to be
> /dev/null?
I think a well defined error message makes sense.
>
> Have a nice day,
> --
> Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/
> kleptog/
>> From each according to his ability. To each according to his
>> ability to litigate.


From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Dave Cramer <pg(at)fastcrypt(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, postgres hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-01 14:07:01
Message-ID: 1164982021.13204.273.camel@coppola.muc.ecircle.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> > Seems to me that you could just do this by setting stdin to be
> > /dev/null?
> I think a well defined error message makes sense.

I would think the OP doesn't care that much about the message itself but
about the fact that the thing is left hanging and never returns. In the
presence of such a flag pg_dump should never try to prompt for a
password but fail immediately and exit.

Cheers,
Csaba.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-01 15:37:07
Message-ID: 16102.1164987427@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> Seems to me that you could just do this by setting stdin to be
> /dev/null?

No, because the simple_prompt code makes a point of reading from
/dev/tty.

regards, tom lane


From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Cramer <pg(at)fastcrypt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-01 19:05:07
Message-ID: 20061201190507.GD23594@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Dec 01, 2006 at 10:37:07AM -0500, Tom Lane wrote:
> Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> > Seems to me that you could just do this by setting stdin to be
> > /dev/null?
>
> No, because the simple_prompt code makes a point of reading from
> /dev/tty.

Sure, but that would fail for any process which has detached from the
terminal. The backup is stdin, which you can also setup.

Admittedly, the OP may not be in a position to setup the environment in
such a way as to make it work, which means that such an option may be
worthwhile...

If it's going to be an option, I'd suggest something like --daemon-mode
since it's entirely possible other issues tmay come up later that might
need this kind of attention.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Cramer <pg(at)fastcrypt(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-19 13:39:03
Message-ID: 20061219133903.GC27098@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
> On Fri, Dec 01, 2006 at 10:37:07AM -0500, Tom Lane wrote:
> > Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> > > Seems to me that you could just do this by setting stdin to be
> > > /dev/null?
> >
> > No, because the simple_prompt code makes a point of reading from
> > /dev/tty.
>
> Sure, but that would fail for any process which has detached from the
> terminal. The backup is stdin, which you can also setup.
>
> Admittedly, the OP may not be in a position to setup the environment in
> such a way as to make it work, which means that such an option may be
> worthwhile...
>
> If it's going to be an option, I'd suggest something like --daemon-mode
> since it's entirely possible other issues tmay come up later that might
> need this kind of attention.

So did we get anywhere with this? I'd propose something like
--non-interactive rather than --daemon-mode. Was there a patch
submitted?

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dave Cramer <pg(at)fastcrypt(dot)com>
Subject: Re: small pg_dump RFE: new --no-prompt (password) option
Date: 2006-12-19 14:02:47
Message-ID: 200612191502.48380.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> So did we get anywhere with this? I'd propose something like
> --non-interactive rather than --daemon-mode. Was there a patch
> submitted?

With the enhanced connection string management, wouldn't it suffice to
pass a (fake/empty) password to pg_dump on the command line?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/