Re: pg_enc --input-file ability to read from stdin

From: Koshino Taiki <koshino(at)sraoss(dot)co(dot)jp>
To: zam bak <zam6ak(at)gmail(dot)com>
Cc: "pgpool-general(at)lists(dot)postgresql(dot)org" <pgpool-general(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_enc --input-file ability to read from stdin
Date: 2026-05-01 05:07:18
Message-ID: TY4PR01MB173741E9C09469A3CCD311B5C94322@TY4PR01MB17374.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-general

Hi,
I checked the behavior and implementation of pg_enc.
There is no need to escape : characters in the password, so the behavior reported is expected.
pg_enc treats only the first : in each line as the separator between username and password, and everything after it is handled as part of the password.
For example:

username1:secret:password1

is interpreted as:

* username = username1
* password = secret:password1

Best regards,

Taiki Koshino<koshino(at)sraoss(dot)co(dot)jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/

________________________________
差出人: zam bak <zam6ak(at)gmail(dot)com>
送信: 2026 年 2 月 21 日 (土曜日) 9:23
宛先: Bo Peng <pengbo(at)sraoss(dot)co(dot)jp>
Cc: pgpool-general(at)lists(dot)postgresql(dot)org <pgpool-general(at)lists(dot)postgresql(dot)org>
件名: Re: pg_enc --input-file ability to read from stdin

On Wed, Feb 18, 2026 at 9:21 PM Bo Peng <pengbo(at)sraoss(dot)co(dot)jp> wrote:
>
> hi,
>
> > P.S.
> > Documentation also does not mention if colon ':' needs to be escaped
> > (and how) when password contains colon??
>
> As far as I understand, a colon ':' in the password does not need to be escaped.
> Could you clarify what kind of case you are referring to?

For the case where credentials are being read in from the file,
documentation states that the format should be

username1:secretpassword1
username2:secretpassword2

So I was wondering if the colon - if it is a part of the password has
to be escaped (because its also a separator between the username and
the password)
I did try this, for example:

username1:secret:password1
username2:secret:password2

...and it seems to work fine - is this expected? no escaping is needed?

>
> ________________________________________
> 差出人: zam bak <zam6ak(at)gmail(dot)com>
> 送信: 2026 年 2 月 18 日 (水曜日) 1:36
> 宛先: pgpool-general(at)lists(dot)postgresql(dot)org <pgpool-general(at)lists(dot)postgresql(dot)org>
> 件名: pg_enc --input-file ability to read from stdin
>
>
> Hello
>
> Is it possible to pipe stdin output to pg_end --input-file option by
> using dash '-' as a placeholder for stdin?
> https://www.pgpool.net/docs/latest/en/html/pg-enc.html
>
> I tried both "echo" and "cat" and am not able to do it.
>
> Example 1:
> cat <<'EOF' | pg_enc --update-pass --key-file
> /etc/pgpool-II/.pgpoolkey --config-file /etc/pgpool-II/pgpool.conf
> --input-file -
> username1:secretpassword1
> username2:secretpassword2
> EOF
> trying to read key from file /etc/pgpool-II/.pgpoolkey
> trying to read username:password pairs from file -
> failed to open input_file "-" (No such file or directory)
>
> Example 2:
> echo '
> username1:secretpassword1
> username2:secretpassword2
> ' | pg_enc --update-pass --key-file /etc/pgpool-II/.pgpoolkey
> --config-file /etc/pgpool-II/pgpool.conf --input-file -
> trying to read key from file /etc/pgpool-II/.pgpoolkey
> trying to read username:password pairs from file -
> failed to open input_file "-" (No such file or directory)
>
>
> The reason for asking about this is:
> * to be able to use pg_enc in scripting setups
> * to be able to provide list of usernames/passwords without having to
> actually create a file
> * to be able to reduce escaping when autogenerated passwords contain
> special characters (by echoing literals)
>
>
> P.S.
> Documentation also does not mention if colon ':' needs to be escaped
> (and how) when password contains colon??
>
>
>
> Thanks
> Z...
>
>
>
>

In response to

Browse pgpool-general by date

  From Date Subject
Next Message Bo Peng 2026-05-12 01:54:37 Pgpool-II website has been renewed
Previous Message Zdenek.Koktan 2026-04-27 13:24:04 Re: Problems with SSL communication