Skip to content

Commit ab91b57

Browse files
author
David Christensen
committed
Add --role flag to explicitly set the role of the user after connecting
1 parent 6847e9b commit ab91b57

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

check_postgres.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ package check_postgres;
193193
'no-match-slot' => q{No matching replication slots found due to exclusion/inclusion options},
194194
'no-match-slotok' => q{No replication slots found},
195195
'no-parse-psql' => q{Could not parse psql output!},
196+
'no-role' => q{Need psql 9.6 or higher to use --role},
196197
'no-time-hires' => q{Cannot find Time::HiRes, needed if 'showtime' is true},
197198
'opt-output-invalid' => q{Invalid output: must be 'nagios' or 'mrtg' or 'simple' or 'cacti'},
198199
'opt-psql-badpath' => q{Invalid psql argument: must be full path to a file named psql},
@@ -1695,6 +1696,7 @@ package check_postgres;
16951696
'dbuser|u|dbuser1|u1=s@',
16961697
'dbpass|dbpass1=s@',
16971698
'dbservice|dbservice1=s@',
1699+
'role=s',
16981700

16991701
'PGBINDIR=s',
17001702
'PSQL=s',
@@ -3083,6 +3085,14 @@ sub run_command {
30833085
local $SIG{ALRM} = sub { die "Timed out\n" };
30843086
alarm 0;
30853087

3088+
if ($opt{role}) {
3089+
if ($psql_version < 9.6) {
3090+
ndie msg('no-role')
3091+
}
3092+
else {
3093+
push @args, '-c', "SET ROLE $opt{role}";
3094+
}
3095+
}
30863096
push @args, '-c', $string;
30873097

30883098
$VERBOSE >= 3 and warn Dumper \@args;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy