Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit300e430

Browse files
committed
Allow ssl_passphrase_command to prompt the terminal
Previously the command could not access the terminal for a passphrase.Backpatch-through: master
1 parent62afb42 commit300e430

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,18 +1452,18 @@ include_dir 'conf.d'
14521452
mechanism is used.
14531453
</para>
14541454
<para>
1455-
The command must print the passphrase to the standard output and exit
1456-
with code 0.In the parameter value, <literal>%p</literal> is
1457-
replaced by a prompt string.(Write <literal>%%</literal> for a
1458-
literal<literal>%</literal>.) Note thattheprompt string will
1459-
probably contain whitespace, so be sure to quote adequately. Asingle
1460-
newline is stripped from the end of the output if present.
1461-
</para>
1462-
<para>
1463-
The command does not actually have to prompt the userfor a
1464-
passphrase. It can read it from a file, obtain it from a keychain
1465-
facility, or similar. It is uptothe user to make sure the chosen
1466-
mechanism is adequately secure.
1455+
The command must print the passphrase to the standard output
1456+
and exitwith code 0.It can prompt from the terminal if
1457+
<option>--authprompt</option> is used.In the parameter value,
1458+
<literal>%R</literal> representsthefile descriptor number opened
1459+
to the terminal that started the server. Afile descriptor is only
1460+
available if enabled at server start. If <literal>%R</literal>
1461+
is used and no file descriptor is available, the server will not
1462+
start. Value <literal>%p</literal> is replaced by a pre-defined
1463+
prompt string. (Write <literal>%%</literal>for a literal
1464+
<literal>%</literal>.) Note that the prompt string will probably
1465+
contain whitespace, so be suretoquote its use adequately.
1466+
Newlines are stripped from the end of the output if present.
14671467
</para>
14681468
<para>
14691469
This parameter can only be set in the <filename>postgresql.conf</filename>
@@ -1486,10 +1486,12 @@ include_dir 'conf.d'
14861486
parameter is off (the default), then
14871487
<varname>ssl_passphrase_command</varname> will be ignored during a
14881488
reload and the SSL configuration will not be reloaded if a passphrase
1489-
is needed. That setting is appropriate for a command that requires a
1490-
TTY for prompting, which might not be available when the server is
1491-
running. Setting this parameter to on might be appropriate if the
1492-
passphrase is obtained from a file, for example.
1489+
is needed. This setting is appropriate for a command that requires a
1490+
terminal for prompting, which will likely not be available when the server is
1491+
running. (<option>--authprompt</option> closes the terminal file
1492+
descriptor soon after server start.) Setting this parameter on
1493+
might be appropriate, for example, if the passphrase is obtained
1494+
from a file.
14931495
</para>
14941496
<para>
14951497
This parameter can only be set in the <filename>postgresql.conf</filename>

‎doc/src/sgml/ref/pg_ctl-ref.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ PostgreSQL documentation
380380
<term><option>--authprompt</option></term>
381381
<listitem>
382382
<para>
383-
Allows the <option>--cluster-key-command</option> command
384-
to prompt for a passphrase or PIN.
383+
Allows <option>ssl_passphrase_command</option> or
384+
<option>cluster_key_command</option> to prompt for a passphrase
385+
or PIN.
385386
</para>
386387
</listitem>
387388
</varlistentry>

‎doc/src/sgml/ref/pgupgrade.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ PostgreSQL documentation
170170
<varlistentry>
171171
<term><option>-R</option></term>
172172
<term><option>--authprompt</option></term>
173-
<listitem><para>allows prompting for a passphrase or PIN
173+
<listitem><para>allows <option>ssl_passphrase_command</option> or
174+
<option>cluster_key_command</option> to prompt for a passphrase
175+
or PIN.
174176
</para></listitem>
175177
</varlistentry>
176178

‎src/backend/libpq/be-secure-common.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include<sys/stat.h>
2323
#include<unistd.h>
2424

25+
#include"postmaster/postmaster.h"
2526
#include"common/string.h"
2627
#include"libpq/libpq.h"
2728
#include"storage/fd.h"
@@ -61,6 +62,19 @@ run_ssl_passphrase_command(const char *prompt, bool is_server_start, char *buf,
6162
appendStringInfoString(&command,prompt);
6263
p++;
6364
break;
65+
case'R':
66+
{
67+
charfd_str[20];
68+
69+
if (terminal_fd==-1)
70+
ereport(ERROR,
71+
(errcode(ERRCODE_INTERNAL_ERROR),
72+
errmsg("ssl_passphrase_command referenced %%R, but -R not specified")));
73+
p++;
74+
snprintf(fd_str,sizeof(fd_str),"%d",terminal_fd);
75+
appendStringInfoString(&command,fd_str);
76+
break;
77+
}
6478
case'%':
6579
appendStringInfoChar(&command,'%');
6680
p++;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp