Discussion:
password in recovery.conf
Nelson Green
2014-09-26 19:58:04 UTC
Permalink
Hello all,

I am setting up a streaming replication stand-by, and the replication role
password has a single quote in it. I am unable to properly reference the
password in the conninfo setting of recovery.conf so it will authenticate
to the master. Doubling the quote gives me a syntax error, and escaping it
or quoting it with double-quotes gives me an authentication error. The
password is correct because I can copy it from the recovery.conf and supply
it when prompted by pg_basebackup, so if I may, what is the proper way to
handle single quotes within the conninfo string?

Obviously I can change the password, but we use an automated password
generator so I'd like to not have to keep generating passwords, and
checking them, until I get one that will work, unless that my only option.

Thanks,
Nelson
Bosco Rama
2014-09-26 20:24:59 UTC
Permalink
Post by Nelson Green
I am setting up a streaming replication stand-by, and the replication
role password has a single quote in it. I am unable to properly
reference the password in the conninfo setting of recovery.conf so it
will authenticate to the master. Doubling the quote gives me a syntax
error, and escaping it or quoting it with double-quotes gives me an
authentication error.
You may have to double it twice -- once for recovery.conf and once for
the actual usage in the connection.

Thus for password abc'123 you would want to use:
'user=user_name password=abc''''123 host=primary_host'

Or possibly even a combination of doubling and escaping:
'user=user_name password=abc\''123 host=primary_host'
or:
'user=user_name password=abc\\''123 host=primary_host'

This is just conjecture. I don't use this method of recovery myself.

HTH.

Bosco.
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
DrakoRod
2014-09-26 22:02:52 UTC
Permalink
Hi!

Have you tried escape the Single or Double quote? Maybe this information can
help you:

http://stackoverflow.com/questions/12316953/insert-varchar-with-single-quotes-in-postgresql
http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html

Best Regards!





-----
Dame un poco de fe, eso me bastarĂ¡.
Rozvo Ware Solutions
--
View this message in context: http://postgresql.1045698.n5.nabble.com/password-in-recovery-conf-tp5820725p5820737.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Adrian Klaver
2014-09-26 22:51:06 UTC
Permalink
Post by Nelson Green
Hello all,
I am setting up a streaming replication stand-by, and the replication
role password has a single quote in it. I am unable to properly
reference the password in the conninfo setting of recovery.conf so it
will authenticate to the master. Doubling the quote gives me a syntax
error, and escaping it or quoting it with double-quotes gives me an
authentication error. The password is correct because I can copy it from
the recovery.conf and supply it when prompted by pg_basebackup, so if I
may, what is the proper way to handle single quotes within the conninfo
string?
Doubling the quote seems to work here.

***@panda:~> psql 'dbname=test user=test_user password=test''pwd'
psql (9.0.17)
Type "help" for help.

test=>

What is the syntax error you get?

Another option:

http://www.postgresql.org/docs/9.3/static/standby-settings.html

A password needs to be provided too, if the primary demands password
authentication. It can be provided in the primary_conninfo string, or in
a separate ~/.pgpass file on the standby server (use replication as the
database name)

So you might look at setting up a .pgpass
file(http://www.postgresql.org/docs/9.3/static/libpq-pgpass.html)
Post by Nelson Green
Obviously I can change the password, but we use an automated password
generator so I'd like to not have to keep generating passwords, and
checking them, until I get one that will work, unless that my only option.
Thanks,
Nelson
--
Adrian Klaver
***@aklaver.com
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Continue reading on narkive:
Loading...