initial commit of file from CVS for smeserver-sogo on Sat Sep 7 16:42:51 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 16:42:51 +10:00
parent 6d95628cf6
commit ac311161a2
122 changed files with 3844 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
[Unit]
After=wan.service
After=networking.service
[Install]
WantedBy=sme-server.target

View File

@@ -0,0 +1,52 @@
package Apache::FilterChangeLength;
use strict;
use warnings FATAL => 'all';
use Apache2::RequestRec ();
use APR::Table ();
use APR::Bucket ();
use APR::Brigade ();
use base qw(Apache2::Filter);
use Apache2::Const -compile => qw(OK);
use APR::Const -compile => ':common';
sub handler {
my ($filter, $bb) = @_;
my $ctx = $filter->ctx;
my $data = exists $ctx->{data} ? $ctx->{data} : '';
$ctx->{invoked}++;
my ($bdata, $seen_eos) = flatten_bb($bb);
$data .= $bdata if $bdata;
if ($seen_eos) {
my $len = length $data;
$filter->r->headers_out->set('Content-Length', $len);
$filter->print($data) if $data;
}
else {
# store context for all but the last invocation
$ctx->{data} = $data;
$filter->ctx($ctx);
}
return Apache2::Const::OK;
}
sub flatten_bb {
my ($bb) = shift;
my $seen_eos = 0;
my @data;
for (my $b = $bb->first; $b; $b = $bb->next($b)) {
$seen_eos++, last if $b->is_eos;
$b->read(my $bdata);
push @data, $bdata;
}
return (join('', @data), $seen_eos);
}
1;

View File

@@ -0,0 +1,84 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2011 Firewall-Services
# 2014 Stephane de Labrusse <stephdl@de-labrusse.fr>
# 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
#----------------------------------------------------------------------
package esmith::FormMagick::Panel::sogo;
use strict;
use esmith::FormMagick;
use esmith::AccountsDB;
use esmith::ConfigDB;
use esmith::cgi;
use esmith::util;
use Exporter;
use Carp qw(verbose);
our @ISA = qw(esmith::FormMagick Exporter);
our @EXPORT = qw(
get_prop
apply
);
our $accountdb = esmith::AccountsDB->open();
our $configdb = esmith::ConfigDB->open();
sub new {
shift;
my $self = esmith::FormMagick->new();
$self->{calling_package} = (caller)[0];
bless $self;
return $self;
}
sub get_prop{
my ($fm, $prop, $default) = @_;
return $configdb->get_prop("sogod", $prop) || $default;
}
sub apply {
my ($self) = @_;
my $q = $self->{cgi};
$configdb->set_prop('sogod', 'status', $q->param("status"));
$configdb->set_prop('sogod', 'ACLsSendEMailNotifications', $q->param("aclSendMail"));
$configdb->set_prop('sogod', 'MailAuxiliaryUserAccountsEnabled', $q->param("auxAccounts"));
$configdb->set_prop('sogod', 'PublicAccess', $q->param("publicAccess"));
$configdb->set_prop('sogod', 'ActiveSync', $q->param("activeSync"));
$configdb->set_prop('sogod', 'EnableEMailAlarms', $q->param("enableEMailAlarms"));
my $sogo_status = $configdb->get_prop('sogod','status');
if ($sogo_status eq 'disabled') {
unless ( system ('/etc/init.d/sogod stop >/dev/null 2>&1') == 0 ){
return $self->error('ERROR_OCCURED', 'First');
}
}
elsif ($sogo_status eq 'enabled') {
unless ( system ("/sbin/e-smith/signal-event", "sogo-modify") == 0 ){
return $self->error('ERROR_OCCURED', 'First');
}
}
return $self->success('SUCCESS','First');
}
1;

View File

@@ -0,0 +1,52 @@
#!/usr/bin/perl -wT
=head1 NAME
fix_headers_case
=head1 DESCRIPTION
SOGo adds lower case headers, which some mail servers do not like.
This plugin just rewrite them to have the first letter uppercase
=head1 AUTHOR
Daniel Berteaud <daniel@firewall-services.com>
=head1 LICENSE
GNU GPL (GNU General Public License)
=cut
sub register {
my ($self, $qp, %arg) = @_;
$self->register_hook("data_post", "fix_headers_case");
}
sub fix_headers_case {
my ($self, $transaction) = @_;
my $mailer = $self->get_header($transaction,'User-Agent') or return DECLINED;
$mailer =~ m/^SOGoMail/ or return DECLINED;
$self->log(LOGINFO, "SOGo mailer detected, going to fix headers case");
foreach my $header (qw/From To Cc Subject Message-ID Content-Type Date Content-Length Content-Transfer-Encoding/){
my $value = $self->get_header($transaction,$header) or next;
$self->set_header($transaction, $header, $value);
}
return DECLINED;
}
sub get_header {
my ($self, $transaction, $header) = @_;
my $ret = $transaction->header->get($header) or return;
return $ret;
}
sub set_header {
my ($self, $transaction, $header, $value) = @_;
my $ret = $transaction->header->delete($header) or return;
$ret = $transaction->header->add($header, $value) or return;
return $ret;
}