diff options
author | Bruce Momjian <bruce@momjian.us> | 2020-12-25 20:41:06 -0500 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2020-12-25 20:41:06 -0500 |
commit | 300e430c76644b483f70bc833d6251a6a7fb84a6 (patch) | |
tree | c3a69c42191d31f000ca24daa493579c267e663c /src | |
parent | 62afb42a7f9f533efc6c19f462c3a848fa4ddb63 (diff) | |
download | postgresql-300e430c76644b483f70bc833d6251a6a7fb84a6.tar.gz postgresql-300e430c76644b483f70bc833d6251a6a7fb84a6.zip |
Allow ssl_passphrase_command to prompt the terminal
Previously the command could not access the terminal for a passphrase.
Backpatch-through: master
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/libpq/be-secure-common.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/libpq/be-secure-common.c b/src/backend/libpq/be-secure-common.c index 94cdf4c8874..1b712cfbba3 100644 --- a/src/backend/libpq/be-secure-common.c +++ b/src/backend/libpq/be-secure-common.c @@ -22,6 +22,7 @@ #include <sys/stat.h> #include <unistd.h> +#include "postmaster/postmaster.h" #include "common/string.h" #include "libpq/libpq.h" #include "storage/fd.h" @@ -61,6 +62,19 @@ run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf, appendStringInfoString(&command, prompt); p++; break; + case 'R': + { + char fd_str[20]; + + if (terminal_fd == -1) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("ssl_passphrase_command referenced %%R, but -R not specified"))); + p++; + snprintf(fd_str, sizeof(fd_str), "%d", terminal_fd); + appendStringInfoString(&command, fd_str); + break; + } case '%': appendStringInfoChar(&command, '%'); p++; |