Re: [qmailtoaster] DKIM after upgrade

2019-09-15 Thread Eric Broch

This is the fix if issues occur:

# yum --enablerepo=qmt-testing clean all  &&  yum -y reinstall 
--enablerepo=qmt-testing qmail


# cd /root

# wget https://raw.githubusercontent.com/qmtoaster/dkim/master/qmail-remote
# qmailctl stop
# mv /var/qmail/bin/qmail-remote /var/qmail/bin/qmail-remote.orig && mv 
qmail-remote /var/qmail/bin && chmod 777 /var/qmail/bin/qmail-remote && 
chown root:qmail /var/qmail/bin/qmail-remote

# qmailctl start


On 9/15/2019 9:03 AM, Remo Mattei wrote:

Thanks Eric,
I have it already, looks like mail works fine outlook is stuck on 
sending out mail.


Not sure what could be the issue.

Will dig.

Remo

On Sep 15, 2019, at 07:55, Eric Broch > wrote:


cat /var/qmail/bin/qmail-remote




Re: [qmailtoaster] DKIM after upgrade

2019-09-15 Thread Remo Mattei
Thanks Eric, 
I have it already, looks like mail works fine outlook is stuck on sending out 
mail. 

Not sure what could be the issue. 

Will dig.

Remo 

> On Sep 15, 2019, at 07:55, Eric Broch  wrote:
> 
> cat /var/qmail/bin/qmail-remote



Re: [qmailtoaster] DKIM after upgrade

2019-09-15 Thread Eric Broch

# ls -l /var/qmail/bin/qmail-remote*
-rwxrwxrwx 1 root qmail  7545 Sep  9 20:41 /var/qmail/bin/qmail-remote
-rwx--x--x 1 root qmail 60320 Sep  9 20:37 /var/qmail/bin/qmail-remote.orig

https://raw.githubusercontent.com/qmtoaster/dkim/master/qmail-remote

# cat /var/qmail/bin/qmail-remote
#!/usr/bin/perl
#
# Copyright (C) 2007 Manuel Mausz (man...@mausz.at)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use strict;
use warnings;
our $VERSION = '0.2';

use Mail::DKIM 0.29;
use Mail::DKIM::Signer;

# enable support for "pretty" signatures, if available
eval 'require Mail::DKIM::TextWrap';

=head
config file structure
 - missing settings will be merged from the global-node
 - domain-entry will also match its subdomains
 - create empty domain-node to omit signing (or specify "none" as id)


  
  keyfile="/var/qmail/control/dkim/global.key" method="simple" 
selector="beta">

    
  

  
  
    
    
  

  
  

=cut

my $configfile = undef;
$configfile    = '/var/qmail/control/dkim/signconf.xml';
my $debugfile  = undef;
#$debugfile    = '/tmp/dkim.debug';
my $qremote    = '/var/qmail/bin/qmail-remote.orig';
my $binary = 0;
our $config;
$config->{'global'} = {
  types => { dkim => {} },
  keyfile   => '/var/qmail/control/dkim/global.key',
  algorithm => 'rsa-sha256',
  method    => 'simple',
  selector  => 'beta',
  # either string or file (first line of file will be used)
  domain    => '/var/qmail/control/me'
};

#---

# read config file. safely
if (defined($configfile) && -r $configfile)
{
  eval 'use XML::Simple';
  if (!$@)
  {
    my $xmlconf;
    eval { $xmlconf = XMLin($configfile, ForceArray => ['types'], 
KeyAttr => ['id']); };

    qexit_deferral('Unable to read config file: ', $@)
  if ($@);
    ConfigMerge::merge($config, $xmlconf);
  }
}

# open debug file
my $debugfh = undef;
if (defined($debugfile))
{
  open($debugfh, '>', $debugfile)
    or qexit_deferral('Unable to open ', $debugfile, ' to writing: ', $!);
}

# generate signatures
my $dkim;
my $mailbuf = '';
eval
{
  my $conf = $config->{'global'};
  $dkim =  Mail::DKIM::Signer->new(
    Policy => 'MySignerPolicy',
    Debug_Canonicalization => $debugfh
  );

  if ($binary)
  {
    binmode STDIN;
  }

  while ()
  {
    $mailbuf .= $_;
    unless ($binary)
    {
  chomp $_;
  s/\015?$/\015\012/s;
    }
    $dkim->PRINT($_);
  }
  $dkim->CLOSE();
};
qexit_deferral('Error while signing: ', $@)
  if ($@);

# close debug file
close($debugfh)
  if (defined($debugfh));

# execute qmail-remote
unshift(@ARGV, $qremote);
open(QR, '|-') || exec { $ARGV[0] } @ARGV
  or qexit_deferral('Unable to run qmail-remote: ', $!);
foreach my $dkim_signature ($dkim->signatures)
{
  my $sig = $dkim_signature->as_string;
  $sig =~ s/\015\012\t/\012\t/g;
  print QR $sig."\012";
}
print QR $mailbuf;
close(QR);

#---

sub qexit
{
  print @_, "\0";
  exit(0);
}

sub qexit_deferral
{
  return qexit('Z', @_);
}

sub qexit_failure
{
  return qexit('D', @_);
}

sub qexit_success
{
  return qexit('K', @_);
}

#---

package ConfigMerge;

# merge config hashes. arrays and scalars will be copied.
sub merge
{
  my ($left, $right) = @_;
  foreach my $rkey (keys(%$right))
  {
    my $rtype = ref($right->{$rkey}) eq 'HASH' ? 'HASH'
  : ref($right->{$rkey}) eq 'ARRAY' ? 'ARRAY'
  : defined($right->{$rkey}) ? 'SCALAR'
  : '';
    my $ltype = ref($left->{$rkey}) eq 'HASH' ? 'HASH'
  : ref($left->{$rkey}) eq 'ARRAY' ? 'ARRAY'
  : defined($left->{$rkey}) ? 'SCALAR'
  : '';
    if ($rtype ne 'HASH' || $ltype ne 'HASH')
    {
  $left->{$rkey} = $right->{$rkey};
    }
    else
    {
  merge($left->{$rkey}, $right->{$rkey});
    }
  }
  return;
}

#---

package MySignerPolicy;
use Mail::DKIM::SignerPolicy;
use base 'Mail::DKIM::SignerPolicy';
use Mail::DKIM::Signature;
use Mail::DKIM::DkSignature;
use Carp;
use strict;
use warnings;

sub apply
{
  my ($self, $signer) = @_;
  my $domain = undef;
  $domain = lc($signer->message_sender->host)
    if 

[qmailtoaster] DKIM after upgrade

2019-09-15 Thread Remo Mattei
Hello all, 
I did have some issues with the upgrade looks like the repos where not in 
synced after the changes it worked, but looks like the upgrade also killed the 
DKIM, so I redownloaded the qmail-remote file and looks like outlook does not 
send mail anymore… Eric can you check and see if the file qmail-remote is the 
correct version for the new upgraded qmail:

qmailadmin-1.2.16-2.qt.el7.x86_64
qmailmrtg-4.2-3.qt.el7.x86_64
qmail-1.03-3.1.1.qt.el7.x86_64

Thanks 
-
To unsubscribe, e-mail: qmailtoaster-list-unsubscr...@qmailtoaster.com
For additional commands, e-mail: qmailtoaster-list-h...@qmailtoaster.com