From 54de879d1b71366b9d9f5430d624c29651ef1b7f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 25 Sep 2018 10:44:12 +0200 Subject: Remove imap password from trace log Signed-off-by: Florian Pritz --- lib/App/ImapNotify/ImapClient.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/App/ImapNotify/ImapClient.pm b/lib/App/ImapNotify/ImapClient.pm index ae91c78..c57204f 100644 --- a/lib/App/ImapNotify/ImapClient.pm +++ b/lib/App/ImapNotify/ImapClient.pm @@ -77,7 +77,7 @@ method _login() { croak "Server doesn't support AUTH=PLAIN"; } - my $response = $self->send_command("login $self->{config}->{username} $self->{config}->{password}"); + my $response = $self->send_command("login $self->{config}->{username} $self->{config}->{password}", "login $self->{config}->{username} [...]"); return if not defined $response; confess "No capabilities found in response: '".$response->[0]."'" unless $response->[0] =~ m/^OK \[(.*)\].*$/; @@ -97,12 +97,14 @@ method select($mailbox) { } -method send_command($command) { +method send_command($command, $log_command = undef) { my $id = "CMD-".$self->{command_counter}++; chomp($command); - $self->writeline("$id $command\r\n"); + $log_command = $command if !defined $log_command; + + $self->writeline("$id $command\r\n", "$id $log_command"); my @lines; @@ -164,8 +166,8 @@ method handle_fetch($first_line) { } } -method writeline($line) { - $log->tracef("%s >> %s", $self->{log_id}, $line =~ s/\r\n$//r); +method writeline($line, $log_line) { + $log->tracef("%s >> %s", $self->{log_id}, $log_line); return $self->{deps}->{sock}->writeline($line); } -- cgit v1.2.3-24-g4f1b