From: df7cb (@df7cb) <noreply+df7cb@github.com>
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
Subject: [pgaudit/pgaudit] PR #330: Do not hard-code the postgres user in the stack check test.
Date: Thu, 30 Jul 2026 09:12:05 +0000
Message-ID: <gh-pgaudit-pgaudit-330@github.com> (raw)
Use the current user name. The temp cluster was created using it.
Close #329.
inline patch 1: t/010_check_stack.pl (+7/-3 lines) download inline-1.patchdiff --git a/t/010_check_stack.pl b/t/010_check_stack.plindex 5563671..4ea1761 100644--- a/t/010_check_stack.pl+++ b/t/010_check_stack.pl@@ -136,7 +136,7 @@ sub read_until_ready
# Open a raw socket to the node and complete startup (trust auth, no password).
sub pg_connect
{
- my ($node) = @_;+ my ($node, $user) = @_;
my $host = $node->host;
my $sock;
@@ -154,7 +154,7 @@ sub pg_connect
$sock->autoflush(1);
binmode($sock);
- print $sock startup_msg(user => 'postgres', database => 'postgres');+ print $sock startup_msg(user => $user, database => 'postgres');
read_until_ready($sock);
return $sock;
@@ -171,6 +171,10 @@ sub pg_connect
$node->append_conf('postgresql.conf', "logging_collector = off");
$node->start;
+# initdb created the cluster with the current operating system user as its+# bootstrap superuser, which is not necessarily postgres+my $superuser = $node->safe_psql('postgres', 'SELECT current_user');+
# One scenario per command tag that pgaudit_ProcessUtility_hook() allows to
# remain on the stack. Each statement returns more than one row, so the
# row-limited Execute below suspends its portal and leaves the tag behind.
@@ -216,7 +220,7 @@ sub pg_connect
{
# Connect and begin transaction
my $name = $test->{name};
- my $sock = pg_connect($node);+ my $sock = pg_connect($node, $superuser);
my $offset = -s $node->logfile;
print $sock query_msg('BEGIN');