Skip to content
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

take an optional param database to save audit info to #16

Open
wants to merge 1 commit into
base: integration
Choose a base branch
from
Open
Changes from all commits
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
7 changes: 5 additions & 2 deletions bin/pgaudit_analyze
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pgaudit_analyze [options] <pg-log-path>
--socket-path socket directory used by PostgreSQL (default to system default directory)
--log-file location of the log file for pgaudit_analyze (defaults to /var/log/pgaudit_analyze.log)
--user specify postgres user instead of using pgaudit_analyze invoker
--database specify database name to save audit info to (default is database from log)

General Options:
--help display usage and exit
Expand Down Expand Up @@ -121,14 +122,16 @@ my $iPort = 5432;
my $strSocketPath;
my $strLogOutFile = '/var/log/pgaudit_analyze.log';
my $strDbUser = getpwuid($<);
my $strDbOverride;


GetOptions ('help' => \$bHelp,
'daemon' => \$bDaemon,
'port=s' => \$iPort,
'socket-path=s' => \$strSocketPath,
'log-file=s' => \$strLogOutFile,
'user=s' => \$strDbUser)
'user=s' => \$strDbUser,
'database=s' => \$strDbOverride)
or pod2usage(2);

# Display version and exit if requested
Expand Down Expand Up @@ -688,7 +691,7 @@ while(!$bDone)
my $strSessionId = $$stryRow[LOG_FIELD_SESSION_ID];
my $lSessionLineNum = $$stryRow[LOG_FIELD_SESSION_LINE_NUM];
my $strUserName = $$stryRow[LOG_FIELD_USER_NAME];
my $strDatabaseName = $$stryRow[LOG_FIELD_DATABASE_NAME];
my $strDatabaseName = $strDbOverride || $$stryRow[LOG_FIELD_DATABASE_NAME];

if (defined($strUserName) && $strAuditUserName ne $strUserName &&
defined($strDatabaseName) && databaseGet($strDatabaseName) &&
Expand Down