initial commit of file from CVS for e-smith-email on Wed 12 Jul 08:53:55 BST 2023

This commit is contained in:
Brian Read
2023-07-12 08:53:55 +01:00
parent 3e32600b26
commit 7b4659df54
267 changed files with 10708 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2001-2005 Mitel Networks Corporation
#
# 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;
package esmith;
use Errno;
use esmith::ConfigDB;
# Run fetchmail if required
my $fetchmail = esmith::ConfigDB->open_ro->get('fetchmail') or
die "Could not get fetchmail record from config db";
exit 0 if ($fetchmail->prop('NoIPUP'));
my $status = $fetchmail->prop('status') || "disabled";
exit 0 unless ($status eq "enabled");
my $EmailRetrieval = $fetchmail->prop('Method') || 'standard';
exit 0 unless ($EmailRetrieval =~ /^(etrn|multidrop)$/);
exit 0 if ( ($fetchmail->prop('FreqOffice') eq 'never') and
($fetchmail->prop('FreqOutside') eq 'never') and
($fetchmail->prop('FreqWeekend') eq 'never') );
exec("/etc/startmail");

View File

@@ -0,0 +1,13 @@
#!/usr/bin/perl
my $original_file = "/run/lock/fetchmail/.fetchids";
my $new_file = "/var/lib/fetchmail/.fetchids";
exit 0 if ( -f $new_file ) ;
exit 0 unless ( -f $original_file ) ;
while ( -f "/run/lock/fetchmail/fetchmail.pid" ) {
print "waiting for fetchmail to finish";
sleep 10;
}
system("/usr/bin/mv $original_file $new_file") == 0 or warn "The move $original_file to $new_file operation failed: $!";

View File

@@ -0,0 +1,67 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999-2007 Mitel Networks Corporation
#----------------------------------------------------------------------
use strict;
use esmith::ConfigDB;
use esmith::AccountsDB;
use User::pwent;
use File::Find;
sub purgedir;
my $db = esmith::ConfigDB->open_ro or
die("Could not open config db");;
my $adb = esmith::AccountsDB->open_ro or
die("Could not open accounts db");;
my $sa = $db->get('spamassassin') or
die("Could not get spamassassin record from config db\n");
my $age = $sa->prop('MessageRetentionTime') || '0';
exit 0 unless $age;
my @users = ("admin", map { $_->key } $adb->users);
foreach my $user ( @users )
{
my $pwent = getpwnam($user)
or die "Couldn't get password entry for $user\n";
chdir $pwent->dir or die "Couldn't chdir " . $pwent->dir . ":$!\n";
unless (chdir "Maildir/.junkmail")
{
warn("Couldn't chdir to junkmail folder of user $user: $!\n");
next;
}
foreach my $dir (qw(new tmp cur))
{
if (-d $dir)
{
purgedir($dir, $age);
}
else
{
warn("Somebody has been fiddling - ~$user/Maildir/.junkmail/$dir is missing\n");
}
}
}
exit 0;
sub purgedir
{
# Unlink all files in dir $dir which are more than $age days old
my ($dir, $age) = @_;
use DirHandle;
my $dh = DirHandle->new($dir);
unlink grep { -M > $age } # choose files older than $age days
grep { -f } # Choose only plain files
map { "$dir/$_" } # create full paths
$dh->read;
}

View File

@@ -0,0 +1,107 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999-2005 Mitel Networks Corporation
#
# 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;
use strict;
use Errno;
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open();
#------------------------------------------------------------
# This program should be called by the post-upgrade or post-restore
# events. It will add missing First.Last and First_Last pseudonyms
# for users that don't already have them. It should be called AFTER
# the update-uids action.
#------------------------------------------------------------
sub byUid
{
$a->prop('Uid') <=> $b->prop('Uid');
}
sub makePseudonyms ($$)
{
#------------------------------------------------------------
# Generate First.Last and First_Last pseudonyms
#------------------------------------------------------------
my ($firstName, $lastName) = @_;
my $dot_pseudonym = "$firstName $lastName";
$dot_pseudonym =~ s/^\s+//; # Strip leading whitespace
$dot_pseudonym =~ s/\s+$//; # Strip trailing whitespace
$dot_pseudonym =~ s/\s+/ /g; # Multiple spaces become single spaces
$dot_pseudonym =~ s/\s/./g; # Change all spaces to dots
$dot_pseudonym = lc $dot_pseudonym; # Change to lower case
my $underbar_pseudonym = $dot_pseudonym;
$underbar_pseudonym =~ s/\./_/g; # Change dots to underbars
return ($dot_pseudonym, $underbar_pseudonym);
}
###########################################################################
# Handle each of the users. Process each user account in order of
# increasing user id. This will hopefully preserve the order in which they
# were created thereby ensuring seniority in the creation of pseudonyms.
my %users;
foreach my $account ( sort byUid $adb->users )
{
my $firstName = $account->prop('FirstName');
my $lastName = $account->prop('LastName');
my ($dot_pseudonym, $underbar_pseudonym)
= makePseudonyms($firstName, $lastName);
my $a = $adb->get($dot_pseudonym);
if (defined $a)
{
my $user = $a->prop('Account');
warn "$dot_pseudonym pseudonym is assigned to $user instead of " .
$account->key . ".\n" if ($user ne $account->key)
}
else
{
$adb->new_record($dot_pseudonym, { type => 'pseudonym', Account => $account->key });
}
$a = $adb->get($underbar_pseudonym);
if (defined $a)
{
my $user = $a->prop('Account');
warn "$underbar_pseudonym pseudonym is assigned to $user instead of " .
$account->key . ".\n" if ($user ne $account->key)
}
else
{
$adb->new_record($underbar_pseudonym, { type => 'pseudonym', Account => $account->key });
}
}
exit (0);