Skip to content

Fix false positive non-superuser errors #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix broken insufficient privileges detection
This hasn't worked for quite some time because `pg_stat_activity` columns
`state_change` and `backend_type` are `null` when the user isn't a
superuser.
  • Loading branch information
jcoleman committed Feb 2, 2022
commit 6b029f73ae58e7e39b4d827be0517bc19e22459b
4 changes: 2 additions & 2 deletions check_postgres.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6931,7 +6931,7 @@ sub check_query_time {
msg('queries'),
msg('query-time'),
'query_start',
q{query_start IS NOT NULL AND current_query NOT LIKE '<IDLE>%'});
q{current_query NOT LIKE '<IDLE>%'});

return;

Expand Down Expand Up @@ -8703,7 +8703,7 @@ sub check_txn_idle {
$SQL3 =~ s/query_start/state_change/g;

## For Pg 10 and above, consider only client backends
($SQL4 = $SQL3) =~ s/ WHERE / WHERE backend_type = 'client backend' AND /;
($SQL4 = $SQL3) =~ s/ WHERE / WHERE (backend_type = 'client backend' OR backend_type IS NULL) AND /;

my $info = run_command($SQL, { emptyok => 1 , version => [ "<8.3 $SQL2", ">9.6 $SQL4", ">9.1 $SQL3" ] } );

Expand Down
29 changes: 28 additions & 1 deletion t/02_query_time.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use 5.008;
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 13;
use Test::More tests => 14;
use lib 't','.';
use CP_Testing;

Expand Down Expand Up @@ -75,4 +75,31 @@ like ($cp->run(q{-w 1 -vv}), qr{$label WARNING:}, $t);
$dbh->rollback();
$dbh->disconnect();

waitpid $child, 0;

## Tests for non-superuser

my $cp_nosuper = CP_Testing->new( {default_action => 'query_time', testuser => 'non_superuser', testuser_is_nosuper => 1 } );

# Test that a non-superuser shows the unknown data alert.
$child = fork();
if (0 == $child) {
my $kiddbh = $cp->test_database_handle();
$cp->database_sleep($kiddbh, 3);
$kiddbh->rollback();
$kiddbh->disconnect();
exit;
}

my $dbh_nosuper = $cp_nosuper->test_database_handle();
sleep 1;
$t = qq{$S detects non-superuser access};
like ($cp_nosuper->run(q{-w 1 -vv}), qr{$label UNKNOWN.+superuser}, $t);
$dbh_nosuper->rollback();
$dbh_nosuper->disconnect();

$dbh->disconnect();

waitpid $child, 0;

exit;
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