Skip to content

Commit 7865250

Browse files
author
Masahiko Sakamoto
committed
Fixed problem with interactive authentication handling.
Previous pgut.c didn't handle any user-input during interactive authentication.
1 parent 8ab15f2 commit 7865250

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

SPECS/pg_reorg.spec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Summary: Reorganize tables in PostgreSQL databases without any locks.
66
Name: %{sname}
7-
Version: 1.1.3
7+
Version: 1.1.4
88
Release: 1%{?dist}
99
License: BSD
1010
Group: Applications/Databases
@@ -49,6 +49,7 @@ install -m 644 lib/uninstall_pg_reorg.sql %{buildroot}%{_datadir}/pgsql/contrib/
4949
rm -rf %{buildroot}
5050

5151
%changelog
52+
* Wed Sep 22 2010 - NTT OSS Center <sakamoto.masahiko@oss.ntt.co.jp> 1.1.4-1
5253
* Thu Apr 22 2010 - NTT OSS Center <itagaki.takahiro@oss.ntt.co.jp> 1.1.2-1
5354
* Mon Jan 15 2010 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.8-1
5455
* Tue Sep 08 2009 - Toru SHIMOGAKI <shimogaki.toru@oss.ntt.co.jp> 1.0.6-1

bin/pgut/pgut.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,27 +402,33 @@ PGconn *
402402
pgut_connect(const char *info, YesNo prompt, int elevel)
403403
{
404404
char *passwd;
405-
406-
CHECK_FOR_INTERRUPTS();
405+
StringInfoData add_pass;
407406

408407
if (prompt == YES)
408+
{
409409
passwd = prompt_for_password();
410+
initStringInfo(&add_pass);
411+
appendStringInfo(&add_pass, info);
412+
appendStringInfo(&add_pass, " password=%s ", passwd);
413+
}
410414
else
411415
passwd = NULL;
412416

413417
/* Start the connection. Loop until we have a password if requested by backend. */
414418
for (;;)
415419
{
416420
PGconn *conn;
421+
CHECK_FOR_INTERRUPTS();
417422

418-
conn = PQconnectdb(info);
423+
if(!passwd)
424+
conn = PQconnectdb(info);
425+
else
426+
conn = PQconnectdb(add_pass.data);
419427

420428
if (PQstatus(conn) == CONNECTION_OK)
421429
{
422430
pgutConn *c;
423431

424-
free(passwd);
425-
426432
c = pgut_new(pgutConn);
427433
c->conn = conn;
428434
c->cancel = NULL;
@@ -432,6 +438,10 @@ pgut_connect(const char *info, YesNo prompt, int elevel)
432438
pgut_connections = c;
433439
pgut_conn_unlock();
434440

441+
if(passwd)
442+
termStringInfo(&add_pass);
443+
444+
free(passwd);
435445
return conn;
436446
}
437447

@@ -440,6 +450,9 @@ pgut_connect(const char *info, YesNo prompt, int elevel)
440450
PQfinish(conn);
441451
free(passwd);
442452
passwd = prompt_for_password();
453+
initStringInfo(&add_pass);
454+
appendStringInfo(&add_pass, info);
455+
appendStringInfo(&add_pass, " password=%s ", passwd);
443456
continue;
444457
}
445458
ereport(elevel,

0 commit comments

Comments
 (0)