Fix pg_enc not working if both -p and -P are provided. master
authorTatsuo Ishii <ishii@postgresql.org>
Wed, 24 Sep 2025 01:26:14 +0000 (10:26 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Wed, 24 Sep 2025 01:26:14 +0000 (10:26 +0900)
In the original report (https://github.com/pgpool/pgpool2/issues/129:

[root@test1 bin]# ./pg_enc -p -P
db password:
encryption key:
encryption key not provided

Also I found a misleading comment:
case 'p': /* prompt for postgres password */

This is not appropriate since the password is not provided to
PostgreSQL. It is totally unrelated to the issue but I replaced it
with following in this opportunity:

case 'p': /* prompt for password to be encrypted */

Author: jinyang liu <liujy@highgo.com>
Discussion: https://www.postgresql.org/message-id/7f18c30b.237.1997555ca11.Coremail.liujy%40highgo.com
Backpatch-through: v4.2

src/tools/pgenc/pg_enc.c

index 83c6d3b4f947a7c608f14db63f76309a62ad6140..7e5143843c1523632942022d811badefd9dbf399 100644 (file)
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2022     PgPool Global Development Group
+ * Copyright (c) 2003-2025     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -98,7 +98,7 @@ main(int argc, char *argv[])
        {
                switch (opt)
                {
-                       case 'p':                       /* prompt for postgres password */
+                       case 'p':                       /* prompt for password to be encrypted */
                                prompt = true;
                                break;
 
@@ -246,6 +246,7 @@ main(int argc, char *argv[])
                        exit(EXIT_FAILURE);
                }
                stpncpy(enc_key, buf, sizeof(enc_key));
+               pool_key = enc_key;
        }
        else
        {