summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcvs2hg <hg@kolab.org>2005-06-19 15:25:31 (GMT)
committercvs2hg <hg@kolab.org>2005-06-19 15:25:31 (GMT)
commit1a20da2d55a246e138d48b4db39492c53657f9bc (patch)
tree6927a5c2b797d7efe2c61e88c9377fa02deeef0f
parent4608af383711e041ca706fd22c4fe80cab6e7969 (diff)
downloadperl-Kolab-1a20da2d55a246e138d48b4db39492c53657f9bc.tar.gz
fixup commit for tag '2.0-proko2_m2c'2.0-proko2_m2c
-rw-r--r--Kolab-Conf/Conf.pm465
-rw-r--r--Kolab-Cyrus/Cyrus.pm23
-rw-r--r--Kolab-DirServ/DirServ.pm5
-rw-r--r--Kolab-LDAP-Backend-ad/ad.pm4
-rw-r--r--Kolab-LDAP-Backend-dirservd/dirservd.pm4
-rw-r--r--Kolab-LDAP-Backend-slurpd/slurpd.pm83
-rw-r--r--Kolab-LDAP-Backend/Backend.pm11
-rw-r--r--Kolab-LDAP/LDAP.pm189
-rw-r--r--Kolab-Mailer/Mailer.pm9
-rw-r--r--Kolab-Util/Util.pm20
-rw-r--r--Kolab/Kolab.pm101
-rw-r--r--Makefile26
-rw-r--r--perl-kolab.spec127
13 files changed, 455 insertions, 612 deletions
diff --git a/Kolab-Conf/Conf.pm b/Kolab-Conf/Conf.pm
index 6f0b091..e52c373 100644
--- a/Kolab-Conf/Conf.pm
+++ b/Kolab-Conf/Conf.pm
@@ -1,10 +1,10 @@
package Kolab::Conf;
##
-## Copyright (c) 2004 Klaraelvdalens Datakonsult AB
+## Copyright (c) 2004 Klaralvdalens Datakonsult AB
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingƫ <s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
## Portions based on work by the following people:
##
## (c) 2003 Tassilo Erlewein <tassilo.erlewein@erfrakon.de>
@@ -32,13 +32,11 @@ use warnings;
use IO::File;
use File::Copy;
use File::Temp;
-use File::stat;
use Kolab;
use Kolab::Util;
use Kolab::LDAP;
require Exporter;
-require "config.h";
our @ISA = qw(Exporter);
@@ -49,7 +47,6 @@ our %EXPORT_TAGS = (
&buildCyrusGroups
&buildLDAPReplicas
&rebuildTemplates
- &checkPermissions
%haschanged
) ]
);
@@ -70,12 +67,10 @@ sub fixup {
(my $owner, my $group) = split(/:/, $ownership, 2);
my $uid = (getpwnam($owner))[2];
my $gid = (getgrnam($group))[2];
- Kolab::log('T', sprintf("Changing permissions of %s to 0%o", $file, $perm ), KOLAB_DEBUG );
if( chmod($perm, $file) != 1 ) {
- Kolab::log('T', "Unable to change permissions of `$file' to ".sprintf("0%o",$perm), KOLAB_ERROR);
+ Kolab::log('T', "Unable to change permissions of `$file' to $perm", KOLAB_ERROR);
exit(1);
}
- Kolab::log('T', "Changing owner of $file to $owner:$group ($uid:$gid)", KOLAB_DEBUG );
if( chown($uid,$gid,$file) != 1 ) {
Kolab::log('T', "Unable to change ownership of `$file' to $uid:$gid", KOLAB_ERROR);
exit(1);
@@ -89,11 +84,9 @@ sub build {
my $perm = shift;
my $oldcfg = $cfg . '.old';
my $prefix = $Kolab::config{'prefix'};
-
- my $oldmask = umask 077;
+
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
- umask $oldmask;
#chmod(0600, $oldcfg) if ($oldcfg =~ /openldap/);
Kolab::log('T', "Creating new configuration file `$cfg' from template `$tmpl'", KOLAB_DEBUG );
@@ -107,76 +100,50 @@ sub build {
}
my $config;
if (!($config = new File::Temp( TEMPLATE => 'tmpXXXXX',
- DIR => $prefix.$ap::config->{sysconfdir}/kolab/,
+ DIR => $prefix.'/etc/kolab/',
SUFFIX => '.kolabtmp',
UNLINK => 0 ))) {
Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
exit(1);
}
- #Kolab::log('T', "Using temporary file '".$config->filename."'", KOLAB_DEBUG );
+ Kolab::log('T', "Using temporary file '".$config->filename."'", KOLAB_DEBUG );
my $skip = 0;
- my $keep = 0;
while (<$template>) {
- #Eat the meta data sections
- if (/^KOLAB_META_START$/) {
- my $found_end;
- while (!$found_end) {
- $_ = <$template>;
- $found_end = /^KOLAB_META_END$/;
- }
- $_ = <$template>;
- }
- if (/\@{3}if (\S+?)\@{3}/) {
- if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
- # Keep text
- $keep = 1;
- } else {
- # Skip text
- $skip++;
- $keep = 0;
- }
- s/\@{3}if (\S+?)\@{3}\n?//;
- } elsif (/\@{3}else\@{3}/) {
- if( $keep == 0 ) {
- # Now keep
- $keep = 1;
- $skip--;
+ if (/\@{3}if (\S+?)\@{3}/) {
+ if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
+ # Keep text
+ } else {
+ # Skip text
+ $skip++;
+ }
+ s/\@{3}if (\S+?)\@{3}//;
+ } elsif (/\@{3}endif\@{3}/) {
+ ( $skip > 0 ) && $skip--;
+ s/\@{3}endif\@{3}//;
+ } elsif (/\@{3}(\S+?)(\|.+?)?\@{3}/) {
+ my $attr = $1;
+ my $opt = $2;
+ #print STDERR "attr=$attr, opt=$opt\n";
+ if ($Kolab::config{$attr}) {
+ my $val = "";
+ if( ref $Kolab::config{$attr} eq "ARRAY" ) {
+ if( $opt && $opt =~ /\|join(.*)/ ) {
+ $val = join $1, @{$Kolab::config{$attr}};
} else {
- # Now skip
- $keep = 0;
- $skip++;
+ $val = $Kolab::config{$attr}->[0];
}
- s/\@{3}else\@{3}\n?//;
- } elsif (/\@{3}endif\@{3}/) {
- ($skip > 0) && $skip--;
- s/\@{3}endif\@{3}\n?//;
- } else {
- while (/\@{3}(\S+?)(\|.+?)?\@{3}/) {
- my $attr = $1;
- my $opt = $2;
- #print STDERR "attr=$attr, opt=$opt\n";
- if ($Kolab::config{$attr}) {
- my $val = "";
- if (ref $Kolab::config{$attr} eq "ARRAY") {
- if ($opt && $opt =~ /\|join(.*)/) {
- $val = join $1, @{$Kolab::config{$attr}};
- } else {
- $val = $Kolab::config{$attr}->[0];
- }
- } else {
- $val = $Kolab::config{$attr};
- }
- s/\@{3}(\S+?)(\|.+?)?\@{3}/$val/;
- last if ( $val eq "\@\@\@$attr\@\@\@" ); # prevent endless loop
- } else {
- Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
- s/\@{3}(\S+?)\@{3}//;
- }
- }
- }
- ($skip == 0) && print $config $_;
+ } else {
+ $val = $Kolab::config{$attr};
+ }
+ s/\@{3}(\S+?)(\|.+?)?\@{3}/$val/;
+ } else {
+ Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
+ s/\@{3}(\S+?)\@{3}//;
+ }
+ }
+ ( $skip == 0 ) && print $config $_;
}
$template->close;
@@ -218,32 +185,18 @@ sub build {
sub buildPostfixTransportMap
{
- buildPostfixMap( 'transport' );
-}
-
-sub buildPostfixVirtualMap
-{
- buildPostfixMap( 'virtual' );
-}
-
-sub buildPostfixMap
-{
- my $map = shift;
- Kolab::log('T', "Building Postfix $map map", KOLAB_DEBUG);
+ Kolab::log('T', 'Building Postfix transport map', KOLAB_DEBUG);
my $prefix = $Kolab::config{'prefix'};
- my $cfg = "$ap::config->{sysconfdir}/postfix/$map";
+ my $cfg = "$prefix/etc/postfix/transport";
my $oldcfg = $cfg . '.old';
-
- my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
- umask $oldmask;
- copy("$ap::config->{sysconfdir}/kolab/templates/$map.template", $cfg);
+ copy("$prefix/etc/kolab/templates/transport.template", $cfg);
my $transport;
if (!($transport = IO::File->new($cfg, 'a'))) {
- Kolab::log('T', "Unable to create Postfix $map map", KOLAB_ERROR);
+ Kolab::log('T', 'Unable to create Postfix transport map', KOLAB_ERROR);
exit(1);
}
@@ -260,30 +213,65 @@ sub buildPostfixMap
filter => '(objectclass=*)'
);
if ($mesg->code) {
- Kolab::log('T', "Unable to locate Postfix $map map entries in LDAP", KOLAB_ERROR);
+ Kolab::log('T', 'Unable to locate Postfix transport map entries in LDAP', KOLAB_ERROR);
exit(1);
}
my $ldapobject;
if ($mesg->code <= 0) {
foreach $ldapobject ($mesg->entries) {
- my $routes = $ldapobject->get_value("postfix-$map", asref => 1);
+ my $routes = $ldapobject->get_value('postfix-transport', asref => 1);
foreach (@$routes) {
$_ = trim($_);
- Kolab::log('T', "Adding entry `$_' to $map");
+ Kolab::log('T', "Adding SMTP route `$_'");
print $transport $_ . "\n";
}
}
} else {
- Kolab::log('T', "No Postfix $map map entries found");
+ Kolab::log('T', 'No Postfix transport map entries found');
+ }
+
+ # Build transport rules for groups
+ $mesg = $ldap->search( base => 'cn=groups,'.$Kolab::config{'base_dn'},
+ scope => 'sub',
+ filter => '(objectClass=kInetOrgPerson)' );
+ if ($mesg->code) {
+ Kolab::log('T', 'Unable to locate groups transport map entries in LDAP', KOLAB_ERROR);
+ exit(1);
+ }
+ if ($mesg->code <= 0) {
+ foreach $ldapobject ($mesg->entries) {
+ my $mail = $ldapobject->get_value('mail');
+ $mail = trim($mail);
+ print $transport "$mail \tkolabgroup:localhost\n";
+ }
+ } else {
+ Kolab::log('T', 'No Postfix transport map entries found');
+ }
+ # Build transport rules for resources
+ $mesg = $ldap->search( base => 'cn=resources,'.$Kolab::config{'base_dn'},
+ scope => 'sub',
+ filter => '(objectClass=kInetOrgPerson)' );
+ if ($mesg->code) {
+ Kolab::log('T', 'Unable to locate resources transport map entries in LDAP', KOLAB_ERROR);
+ exit(1);
+ }
+ if ($mesg->code <= 0) {
+ foreach $ldapobject ($mesg->entries) {
+ my $mail = $ldapobject->get_value('mail');
+ $mail = trim($mail);
+ print $transport "$mail \tkolabres:localhost\n";
+ }
+ } else {
+ Kolab::log('T', 'No Postfix transport map entries found');
}
Kolab::LDAP::destroy($ldap);
$transport->close;
# FIXME: bad way of doing things...
- #system("chown root:root $ap::config->{sysconfdir}/postfix/*");
- system("$ap::config->{sbindir}/postmap $ap::config->{sysconfdir}/etc/postfix/$map");
+ system("chown root:root $prefix/etc/postfix/*");
+ system("$prefix/sbin/postmap $prefix/etc/postfix/transport");
if (-f $oldcfg) {
my $rc = `diff -q $cfg $oldcfg`;
@@ -296,7 +284,7 @@ sub buildPostfixMap
$Kolab::haschanged{'postfix'} = 1;
}
- Kolab::log('T', 'Finished building Postfix $map map', KOLAB_DEBUG);
+ Kolab::log('T', 'Finished building Postfix transport map', KOLAB_DEBUG);
}
sub buildCyrusConfig
@@ -305,17 +293,15 @@ sub buildCyrusConfig
my $prefix = $Kolab::config{'prefix'};
my $cyrustemplate;
- if (!($cyrustemplate = IO::File->new("$ap::config->{sysconfdir}/kolab/templates/cyrus.conf.template", 'r'))) {
+ if (!($cyrustemplate = IO::File->new("$prefix/etc/kolab/templates/cyrus.conf.template", 'r'))) {
Kolab::log('T', "Unable to open template file `cyrus.conf.template'", KOLAB_ERROR);
exit(1);
}
- my $cfg = "$ap::config->{sysconfdir}/imapd/cyrus.conf";
+ my $cfg = "$prefix/etc/imapd/cyrus.conf";
my $oldcfg = $cfg . '.old';
- my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
- umask $oldmask;
my $cyrusconf;
if (!($cyrusconf = IO::File->new($cfg, 'w'))) {
@@ -325,23 +311,19 @@ sub buildCyrusConfig
while (<$cyrustemplate>) {
if (/\@{3}cyrus-imap\@{3}/ && ($Kolab::config{"cyrus-imap"} =~ /true/i)) {
- $_ = "imap cmd=\"imapd -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"143\" prefork=0\n";
- }
- elsif (/\@{3}cyrus-imap\@{3}/ && ($Kolab::config{"cyrus-imap"} =~ /false/i)) {
- # Even if imapd is disabled, enable it for localhost -- resource handlers depend on it
- $_ = "imap cmd=\"imapd -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"127.0.0.1:143\" prefork=0\n";
+ $_ = "imap cmd=\"imapd -C $prefix/etc/imapd/imapd.conf\" listen=\"143\" prefork=0\n";
}
elsif (/\@{3}cyrus-pop3\@{3}/ && ($Kolab::config{"cyrus-pop3"} =~ /true/i)) {
- $_ = "pop3 cmd=\"pop3d -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"110\" prefork=0\n";
+ $_ = "pop3 cmd=\"pop3d -C $prefix/etc/imapd/imapd.conf\" listen=\"110\" prefork=0\n";
}
elsif (/\@{3}cyrus-imaps\@{3}/ && ($Kolab::config{"cyrus-imaps"} =~ /true/i)) {
- $_ = "imaps cmd=\"imapd -s -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"993\" prefork=0\n";
+ $_ = "imaps cmd=\"imapd -s -C $prefix/etc/imapd/imapd.conf\" listen=\"993\" prefork=0\n";
}
elsif (/\@{3}cyrus-pop3s\@{3}/ && ($Kolab::config{"cyrus-pop3s"} =~ /true/i)) {
- $_ = "pop3s cmd=\"pop3d -s -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"995\" prefork=0\n";
+ $_ = "pop3s cmd=\"pop3d -s -C $prefix/etc/imapd/imapd.conf\" listen=\"995\" prefork=0\n";
}
elsif (/\@{3}cyrus-sieve\@{3}/ && ($Kolab::config{"cyrus-sieve"} =~ /true/i)) {
- $_ = "sieve cmd=\"timsieved -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"2000\" prefork=0\n";
+ $_ = "sieve cmd=\"timsieved -C $prefix/etc/imapd/imapd.conf\" listen=\"2000\" prefork=0\n";
}
$_ =~ s/\@{3}.*\@{3}//;
print $cyrusconf $_;
@@ -371,14 +353,11 @@ sub buildCyrusGroups
Kolab::log('T', 'Building Cyrus groups', KOLAB_DEBUG);
my $prefix = $Kolab::config{'prefix'};
- my $cfg = "$ap::config->{sysconfdir}/imapd/imapd.group";
+ my $cfg = "$prefix/etc/imapd/imapd.group";
my $oldcfg = $cfg . '.old';
-
- my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
- umask $oldmask;
- copy("$ap::config->{sysconfdir}/kolab/templates/imapd.group.template", $cfg);
+ copy("$prefix/etc/kolab/templates/imapd.group.template", $cfg);
my $groupconf;
if (!($groupconf = IO::File->new($cfg, 'a'))) {
Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
@@ -395,7 +374,7 @@ sub buildCyrusGroups
my $mesg = $ldap->search(
base => $Kolab::config{'base_dn'},
scope => 'sub',
- filter => '(objectclass=kolabgroupofnames)'
+ filter => '(objectclass=groupOfNames)'
);
if ($mesg->code) {
Kolab::log('T', 'Unable to locate Cyrus groups in LDAP', KOLAB_ERROR);
@@ -418,11 +397,8 @@ sub buildCyrusGroups
my $umesg = $ldap->search( base => $uid,
scope => 'exact',
filter => '(objectClass=*)' );
- if ( $umesg && $umesg->code() <= 0 && $umesg->count() == 1 ) {
- my $mail;
- ($mail = $umesg->entry(0)->get_value('mail')) or
- ($mail = $umesg->entry(0)->get_value('uid'));
- $group .= $mail.',';
+ if ($umesg->code <= 0 && $umesg->count() == 1 ) {
+ $group .= $umesg->entry(0)->get_value('uid').',';
}
}
$group =~ s/,$//;
@@ -439,6 +415,17 @@ sub buildCyrusGroups
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $cfg);
+ if (-f $oldcfg) {
+ my $rc = `diff -q $cfg $oldcfg`;
+ chomp($rc);
+ if ($rc) {
+ Kolab::log('T', "`$cfg' change detected: $rc", KOLAB_DEBUG);
+ $Kolab::haschanged{'imapd'} = 1;
+ }
+ } else {
+ $Kolab::haschanged{'imapd'} = 1;
+ }
+
Kolab::log('T', 'Finished building Cyrus groups', KOLAB_DEBUG );
}
@@ -447,13 +434,11 @@ sub buildLDAPReplicas
Kolab::log('T', 'Building LDAP replicas', KOLAB_DEBUG);
my $prefix = $Kolab::config{'prefix'};
- my $cfg = "$ap::config->{sysconfdir}/openldap/slapd.replicas";
+ my $cfg = "$prefix/etc/openldap/slapd.replicas";
my $oldcfg = $cfg . '.old';
-
- my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
- copy("$ap::config->{sysconfdir}/kolab/templates/slapd.replicas.template", $cfg);
+ copy("$prefix/etc/kolab/templates/slapd.replicas.template", $cfg);
my $repl;
if (!($repl = IO::File->new($cfg, 'a'))) {
Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
@@ -469,7 +454,7 @@ sub buildLDAPReplicas
@kh = ( $Kolab::config{'kolabhost'} );
}
for my $h ( @kh ) {
- next if lc($h) eq lc($Kolab::config{'fqdnhostname'});
+ next if $h eq $Kolab::config{'fqhostname'};
print $repl "replica uri=ldaps://$h\n"
." binddn=\"".$Kolab::config{'bind_dn'}."\"\n"
." bindmethod=simple credentials=".$Kolab::config{'bind_pw'}."\n\n";
@@ -495,153 +480,85 @@ sub buildLDAPReplicas
} else {
$Kolab::haschanged{'slapd'} = 1;
}
- umask $oldmask;
Kolab::log('T', 'Finished building LDAP replicas', KOLAB_DEBUG);
}
-sub loadMetaTemplates
-{
- my $templatedir = shift;
- my ($tref, $pref, $oref) = @_;
-
- Kolab::log('T', 'Collecting template files', KOLAB_DEBUG );
- opendir(DIR, $templatedir);
- my @metatemplates = grep { /\.template$/ } readdir (DIR);
- closedir(DIR);
-
- foreach my $template (@metatemplates) {
- #Open each file and check for the META
- if (open (TEMPLATE, "$templatedir/$template" )) {
- my $line = <TEMPLATE>;
- if ($line =~ /^KOLAB_META_START$/) {
- Kolab::log('T', 'Processing META template :'.$template, KOLAB_DEBUG );
- my ($found_end, $target, $permissions, $ownership);
- while (<TEMPLATE>) {
- $line = $_;
- if (!$found_end) {
- $found_end = $line =~ /^KOLAB_META_END$/;
- if (!$found_end && $line) {
- my ($key,$value) = split(/=/,$line);
- chomp($value);
- Kolab::log('T', 'META Key: '.$key.' Value: '.$value, KOLAB_DEBUG );
- if ($key =~ /^TARGET$/) {
- $target = $value;
- Kolab::log('T', 'META Target '.$target, KOLAB_DEBUG );
- }
- if ($key =~ /^PERMISSIONS$/) {
- $permissions = $value;
- Kolab::log('T', 'META Permissions '.$permissions, KOLAB_DEBUG );
- }
- if ($key =~ /^OWNERSHIP$/) {
- $ownership = $value;
- Kolab::log('T', 'META Ownership '.$ownership, KOLAB_DEBUG );
- }
- }
- }
- }
- if ($found_end && $target && $permissions && $ownership) {
- Kolab::log('T', 'All mandatory fields populated in '.$template, KOLAB_DEBUG );
- $$tref{$template} = $target;
- $$oref{$target} = $ownership;
- $permissions = oct($permissions);
- $$pref{$target} = $permissions;
- }
-
- }
- } else {
- Kolab::log('T', 'Could not open template file: '. $template, KOLAB_WARN);
- }
- }
-
-}
-
-my $prefix = $Kolab::config{'prefix'};
-my $templatedir = "$ap::config->{sysconfdir}/kolab/templates";
-
-my %templates = (
- "$templatedir/rc.conf.template" => "$ap::config->{sysconfdir}/rc.conf",
- "$templatedir/session_vars.php.template" => "$ap::config->{webadmindir}/php/admin/include/session_vars.php",
- "$templatedir/clamd.conf.template" => "$ap::config->{sysconfdir}/clamav/clamd.conf",
- "$templatedir/freshclam.conf.template" => "$ap::config->{sysconfdir}/clamav/freshclam.conf",
- "$templatedir/amavisd.conf.template" => "$ap::config->{sysconfdir}/amavisd/amavisd.conf",
- "$templatedir/main.cf.template" => "$ap::config->{sysconfdir}/postfix/main.cf",
- "$templatedir/master.cf.template" => "$ap::config->{sysconfdir}/postfix/master.cf",
- "$templatedir/saslauthd.conf.template" => "$ap::config->{sysconfdir}/sasl/saslauthd.conf",
- "$templatedir/imapd.conf.template" => "$ap::config->{sysconfdir}/imapd/imapd.conf",
- "$templatedir/httpd.conf.template" => "$ap::config->{webserver_confdir}/apache.conf",
- "$templatedir/httpd.local.template" => "$ap::config->{webserver_confdir}/apache.local",
- "$templatedir/php.ini.template" => "$ap::config->{webserver_confdir}/php.ini",
- "$templatedir/proftpd.conf.template" => "$ap::config->{ftpserver_confdir}/proftpd.conf",
- "$templatedir/ldap.conf.template" => "$ap::config->{sysconfdir}/openldap/ldap.conf",
- "$templatedir/slapd.conf.template" => "$ap::config->{sysconfdir}/openldap/slapd.conf",
- "$templatedir/DB_CONFIG.slapd.template" => "$prefix/var/openldap/openldap-data/DB_CONFIG",
- "$templatedir/freebusy.conf.template" => "$ap::config->{sysconfdir}/resmgr/freebusy.conf",
- "$templatedir/fbview.conf.template" => "$ap::config->{sysconfdir}/resmgr/fbview.conf",
- "$templatedir/resmgr.conf.template" => "$ap::config->{sysconfdir}/resmgr/resmgr.conf"
- );
-
-my %permissions = (
- "$ap::config->{sysconfdir}/rc.conf" => 0644,
- "$ap::config->{webadmindir}/php/admin/include/session_vars.php" => 0640,
- "$ap::config->{sysconfdir}/resmgr/freebusy.conf" => 0640,
- "$ap::config->{sysconfdir}/resmgr/fbview.conf" => 0640,
- "$ap::config->{sysconfdir}/resmgr/resmgr.conf" => 0640,
- "$ap::config->{sysconfdir}/postfix/main.cf" => 0640,
- "$ap::config->{sysconfdir}/postfix/master.cf" => 0640,
- "$ap::config->{sysconfdir}/clamav/clamd.conf" => 0640,
- "$ap::config->{sysconfdir}/clamav/freshclam.conf" => 0640,
- "$ap::config->{sysconfdir}/amavisd/amavisd.conf" => 0640,
- "$ap::config->{sysconfdir}/sasl/saslauthd.conf" => 0600,
- "$ap::config->{sysconfdir}/imapd/imapd.conf" => 0640,
- "$ap::config->{webserver_confdir}/apache.conf" => 0640,
- "$ap::config->{webserver_confdir}/apache.local" => 0640,
- "$ap::config->{webserver_confdir}/php.ini" => 0640,
- "$ap::config->{ftpserver_confdir}/proftpd.conf" => 0640,
- "$ap::config->{sysconfdir}/openldap/slapd.conf" => 0640,
- "$prefix/var/openldap/openldap-data/DB_CONFIG" => 0640,
- "$ap::config->{sysconfdir}/openldap/ldap.conf" => 0644,
- "$ap::config->{sysconfdir}/postfix/transport" => 0640,
- "$ap::config->{sysconfdir}/postfix/virtual" => 0640,
- "$ap::config->{sysconfdir}/imapd/cyrus.conf" => 0640,
- "$ap::config->{sysconfdir}/imapd/imapd.group" => 0640);
-
-my %ownership = (
- "$ap::config->{sysconfdir}/rc.conf" => "kolab:kolab",
- "$ap::config->{webadmindir}/php/admin/include/session_vars.php" => "kolab:kolab-n",
- "$ap::config->{sysconfdir}/resmgr/freebusy.conf" => "kolab:kolab-n",
- "$ap::config->{sysconfdir}/resmgr/fbview.conf" => "kolab:kolab-n",
- "$ap::config->{sysconfdir}/resmgr/resmgr.conf" => "kolab:kolab-n",
- "$ap::config->{sysconfdir}/postfix/main.cf" => "kolab:kolab-r",
- "$ap::config->{sysconfdir}/postfix/master.cf" => "kolab:kolab-r",
- "$ap::config->{sysconfdir}/clamav/clamd.conf" => "kolab:kolab-r",
- "$ap::config->{sysconfdir}/clamav/freshclam.conf" => "kolab:kolab-r",
- "$ap::config->{sysconfdir}/amavisd/amavisd.conf" => "kolab:kolab-r",
- "$ap::config->{sysconfdir}/sasl/saslauthd.conf" => "kolab:kolab",
- "$ap::config->{sysconfdir}/imapd/imapd.conf" => "kolab:kolab-r",
- "$ap::config->{webserver_confdir}/apache.conf" => "kolab:kolab-n",
- "$ap::config->{webserver_confdir}/apache.local" => "kolab:kolab-n",
- "$ap::config->{webserver_confdir}/php.ini" => "kolab:kolab-n",
- "$ap::config->{ftpserver_confdir}/proftpd.conf" => "kolab:kolab-n",
- "$ap::config->{sysconfdir}/openldap/ldap.conf" => "kolab:kolab",
- "$ap::config->{sysconfdir}/openldap/slapd.conf" => "kolab:kolab",
- "$prefix/var/openldap/openldap-data/DB_CONFIG" => "kolab:kolab",
- "$ap::config->{sysconfdir}/postfix/transport" => "root:kolab",
- "$ap::config->{sysconfdir}/postfix/virtual" => "root:kolab",
- "$ap::config->{sysconfdir}/imapd/cyrus.conf" => "kolab:kolab",
- "$ap::config->{sysconfdir}/imapd/imapd.group" => "kolab:kolab-r");
-
-
sub rebuildTemplates
{
my $key;
my $value;
my $section="";
+ my $prefix = $Kolab::config{'prefix'};
+ my $templatedir = "$prefix/etc/kolab/templates";
+
+ my %templates = (
+ "$templatedir/session_vars.php.template" => "$prefix/var/kolab/php/admin/include/session_vars.php",
+ "$templatedir/clamav.conf.template" => "$prefix/etc/clamav/clamav.conf",
+ "$templatedir/freshclam.conf.template" => "$prefix/etc/clamav/freshclam.conf",
+ "$templatedir/amavisd.conf.template" => "$prefix/etc/amavisd/amavisd.conf",
+ "$templatedir/main.cf.template" => "$prefix/etc/postfix/main.cf",
+ "$templatedir/master.cf.template" => "$prefix/etc/postfix/master.cf",
+ "$templatedir/saslauthd.conf.template" => "$prefix/etc/sasl/saslauthd.conf",
+ "$templatedir/imapd.conf.template" => "$prefix/etc/imapd/imapd.conf",
+ "$templatedir/httpd.conf.template" => "$prefix/etc/apache/apache.conf",
+ "$templatedir/legacy.conf.template" => "$prefix/etc/apache/legacy.conf",
+ "$templatedir/php.ini.template" => "$prefix/etc/apache/php.ini",
+ "$templatedir/proftpd.conf.template" => "$prefix/etc/proftpd/proftpd.conf",
+ "$templatedir/ldap.conf.template" => "$prefix/etc/openldap/ldap.conf",
+ "$templatedir/slapd.conf.template" => "$prefix/etc/openldap/slapd.conf",
+ "$templatedir/freebusy.conf.template" => "$prefix/etc/resmgr/freebusy.conf",
+ "$templatedir/fbview.conf.template" => "$prefix/etc/resmgr/fbview.conf",
+ "$templatedir/resmgr.conf.template" => "$prefix/etc/resmgr/resmgr.conf"
+ );
+
+ my %permissions = (
+ "$prefix/var/kolab/php/admin/include/session_vars.php" => 0640,
+ "$prefix/etc/resmgr/freebusy.conf" => 0640,
+ "$prefix/etc/resmgr/fbview.conf" => 0640,
+ "$prefix/etc/resmgr/resmgr.conf" => 0640,
+ "$prefix/etc/postfix/main.cf" => 0640,
+ "$prefix/etc/postfix/master.cf" => 0640,
+ "$prefix/etc/clamav/clamav.conf" => 0640,
+ "$prefix/etc/clamav/freshclam.conf" => 0640,
+ "$prefix/etc/amavisd/amavisd.conf" => 0640,
+ "$prefix/etc/sasl/saslauthd.conf" => 0600,
+ "$prefix/etc/imapd/imapd.conf" => 0640,
+ "$prefix/etc/apache/apache.conf" => 0640,
+ "$prefix/etc/apache/legacy.conf" => 0640,
+ "$prefix/etc/apache/php.ini" => 0640,
+ "$prefix/etc/proftpd/proftpd.conf" => 0640,
+ "$prefix/etc/openldap/slapd.conf" => 0640,
+ "$prefix/etc/openldap/ldap.conf" => 0644,
+ "$prefix/etc/postfix/transport" => 0640,
+ "$prefix/etc/imapd/cyrus.conf" => 0640,
+ "$prefix/etc/imapd/imapd.group" => 0640);
+
+ my %ownership = (
+ "$prefix/var/kolab/php/admin/include/session_vars.php" => "kolab:kolab-n",
+ "$prefix/etc/resmgr/freebusy.conf" => "kolab:kolab-n",
+ "$prefix/etc/resmgr/fbview.conf" => "kolab:kolab-n",
+ "$prefix/etc/resmgr/resmgr.conf" => "kolab:kolab-n",
+ "$prefix/etc/postfix/main.cf" => "kolab:kolab-r",
+ "$prefix/etc/postfix/master.cf" => "kolab:kolab-r",
+ "$prefix/etc/clamav/clamav.conf" => "kolab:kolab-r",
+ "$prefix/etc/clamav/freshclam.conf" => "root:kolab",
+ "$prefix/etc/amavisd/amavisd.conf" => "kolab:kolab-r",
+ "$prefix/etc/sasl/saslauthd.conf" => "kolab:kolab",
+ "$prefix/etc/imapd/imapd.conf" => "kolab:kolab-r",
+ "$prefix/etc/apache/apache.conf" => "kolab:kolab-n",
+ "$prefix/etc/apache/legacy.conf" => "kolab:kolab-n",
+ "$prefix/etc/apache/php.ini" => "kolab:kolab-n",
+ "$prefix/etc/proftpd/proftpd.conf" => "kolab:kolab-n",
+ "$prefix/etc/openldap/ldap.conf" => "kolab:kolab",
+ "$prefix/etc/openldap/slapd.conf" => "kolab:kolab",
+ "$prefix/etc/postfix/transport" => "root:kolab",
+ "$prefix/etc/imapd/cyrus.conf" => "kolab:kolab",
+ "$prefix/etc/imapd/imapd.group" => "kolab:kolab-r");
- Kolab::log('T', 'Regenerating configuration files', KOLAB_DEBUG );
- loadMetaTemplates( $templatedir, \%templates, \%permissions, \%ownership );
+ Kolab::log('T', 'Regenerating configuration files', KOLAB_DEBUG );
foreach $key (keys %templates) {
my $tpl = $templates{$key};
@@ -649,7 +566,6 @@ sub rebuildTemplates
}
buildPostfixTransportMap;
- buildPostfixVirtualMap;
buildLDAPReplicas;
buildCyrusConfig;
buildCyrusGroups;
@@ -657,33 +573,6 @@ sub rebuildTemplates
Kolab::log('T', 'Finished regenerating configuration files', KOLAB_DEBUG );
}
-sub checkPermissions {
- my $key;
- my $value;
-
- Kolab::log('T', 'Checking generated config file permissions and ownership', KOLAB_DEBUG );
-
- loadMetaTemplates( $templatedir, \%templates, \%permissions, \%ownership );
-
- my $ok = 1;
-
- foreach $key (keys %templates) {
- my $tpl = $templates{$key};
- my $st = stat($tpl);
- my $owner = getpwuid($st->uid).':'.getgrgid($st->gid);
- if( ( ($st->mode & 07777) != $permissions{$tpl}) ||
- ($owner ne $ownership{$tpl}) ) {
- my $str = 'File '.$tpl.' has the wrong persmissions/owner. Found '
- .sprintf("%lo", $st->mode&07777).' '.$owner.', expected '
- .sprintf("%lo",$permissions{$tpl}).' '.$ownership{$tpl};
- print( "$str\n" );
- Kolab::log('T', $str, KOLAB_ERROR );
- $ok = 0;
- }
- }
- return $ok;
-}
-
1;
__END__
# Below is stub documentation for your module. You'd better edit it!
@@ -699,7 +588,7 @@ Kolab::Conf - Perl extension for Kolab template generation
=head1 AUTHOR
-Stuart Bingƫ <lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-Cyrus/Cyrus.pm b/Kolab-Cyrus/Cyrus.pm
index 2f024a0..52c3ee5 100644
--- a/Kolab-Cyrus/Cyrus.pm
+++ b/Kolab-Cyrus/Cyrus.pm
@@ -3,7 +3,7 @@ package Kolab::Cyrus;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingļæ½ <s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -44,7 +44,7 @@ our %EXPORT_TAGS = (
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
-
+
);
our $VERSION = '0.9';
@@ -57,16 +57,16 @@ sub create
if (!$cyrus) {
Kolab::log('Y', 'Unable to connect to local Cyrus admin interface', KOLAB_ERROR);
- return 0;
+ exit(1);
}
-
+
if (!$cyrus->authenticate(
'User' => $Kolab::config{'cyrus_admin'},
'Password' => $Kolab::config{'cyrus_admin_pw'},
- 'Mechanism' => 'LOGIN',
+ 'mechanisms' => 'plaintext',
)) {
Kolab::log('Y', "Unable to authenticate with Cyrus admin interface, Error = `" . $cyrus->error . "'", KOLAB_ERROR);
- return 0;
+ exit(1);
}
return $cyrus;
@@ -76,14 +76,7 @@ sub createUid
{
my $user = shift;
my $sf = shift || 0;
- my $seperator = '/';
- my $uidprefix = 'user';
- if ($sf) {
- $seperator = '.';
- $uidprefix = 'shared';
- }
- return $uidprefix . $seperator . $user;
-# return 'user' . ($sf ? '.' : '/') . $user;
+ return 'user' . ($sf ? '.' : '/') . $user;
}
sub createMailbox
@@ -199,7 +192,7 @@ admin module.
=head1 AUTHOR
-Stuart Bingļæ½ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-DirServ/DirServ.pm b/Kolab-DirServ/DirServ.pm
index 9675cf7..6eedab9 100644
--- a/Kolab-DirServ/DirServ.pm
+++ b/Kolab-DirServ/DirServ.pm
@@ -38,7 +38,6 @@ use POSIX qw(tmpnam);
use vars qw(@peers);
require Exporter;
-require "config.h";
our @ISA = qw(Exporter);
@@ -63,7 +62,7 @@ our $VERSION = '0.9';
sub reloadPeers
{
- @peers = readList($Kolab::config{"$ap::config->{prefix}"} . "$ap::config->{sysconfdir}/kolab/addressbook.peers");
+ @peers = readList($Kolab::config{'prefix'} . "/etc/kolab/addressbook.peers");
foreach my $peer (@peers) {
Kolab::log('DS', "Using peer $peer", KOLAB_DEBUG);
@@ -88,7 +87,7 @@ sub genericRequest
$entry->add(
'objectClass' => 'kolabPerson',
- 'kolabhomeserver' => $Kolab::config{'dirserv_home_server'},
+ 'homeServer' => $Kolab::config{'dirserv_home_server'},
);
Kolab::log('DS', "About to send $request", KOLAB_DEBUG);
diff --git a/Kolab-LDAP-Backend-ad/ad.pm b/Kolab-LDAP-Backend-ad/ad.pm
index cebc752..0c97fd8 100644
--- a/Kolab-LDAP-Backend-ad/ad.pm
+++ b/Kolab-LDAP-Backend-ad/ad.pm
@@ -3,7 +3,7 @@ package Kolab::LDAP::Backend::ad;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingļæ½ <s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -225,7 +225,7 @@ Kolab::LDAP::Backend::ad - Perl extension for an Active Directory backend
=head1 AUTHOR
-Stuart Bingļæ½ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-LDAP-Backend-dirservd/dirservd.pm b/Kolab-LDAP-Backend-dirservd/dirservd.pm
index 85640b6..9585ad1 100644
--- a/Kolab-LDAP-Backend-dirservd/dirservd.pm
+++ b/Kolab-LDAP-Backend-dirservd/dirservd.pm
@@ -3,7 +3,7 @@ package Kolab::LDAP::Backend::dirservd;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingļæ½ <s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -111,7 +111,7 @@ Services updater.
=head1 AUTHOR
-Stuart Bingļæ½ E<lt>s.buys@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.buys@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-LDAP-Backend-slurpd/slurpd.pm b/Kolab-LDAP-Backend-slurpd/slurpd.pm
index 75acb21..25cce63 100644
--- a/Kolab-LDAP-Backend-slurpd/slurpd.pm
+++ b/Kolab-LDAP-Backend-slurpd/slurpd.pm
@@ -3,7 +3,7 @@ package Kolab::LDAP::Backend::slurpd;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing?<s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
## Portions based on work by the following people:
##
## (c) 2003 Tassilo Erlewein <tassilo.erlewein@erfrakon.de>
@@ -40,7 +40,6 @@ use Kolab::LDAP;
use vars qw($conn $server);
require Exporter;
-require "config.h";
our @ISA = qw(Exporter);
@@ -234,20 +233,19 @@ sub run
my $pdu;
my $changes = 0;
- my $listenport = $Kolab::config{'slurpd_port'};
- my $listenaddr = $Kolab::config{'slurpd_addr'} || "127.0.0.1";
+ my $port = $Kolab::config{'slurpd_port'};
TRYCONNECT:
- Kolab::log('SD', "Opening listen server on $listenaddr:$listenport");
+ Kolab::log('SD', "Opening listen server on port $port");
$server = IO::Socket::INET->new(
- LocalPort => $listenport,
+ LocalPort => $port,
Proto => "tcp",
ReuseAddr => 1,
Type => SOCK_STREAM,
- LocalAddr => $listenaddr,
+ LocalAddr => "127.0.0.1",
Listen => 10
);
if (!$server) {
- Kolab::log('SD', "Unable to open TCP listen server on $listenaddr:$listenport, Error = $@", KOLAB_ERROR);
+ Kolab::log('SD', "Unable to open TCP listen server on port $port, Error = $@", KOLAB_ERROR);
sleep 1;
goto TRYCONNECT;
}
@@ -255,17 +253,9 @@ sub run
Kolab::log('SD', 'Listen server opened, waiting for incoming connections');
while ($conn = $server->accept()) {
- # PENDING: Only accept connections from localhost and
+ # PENDING: Only accept connections from localhost and
# hosts listed in the kolabhost attribute
-
- my($peerport, $peeraddr) = sockaddr_in($conn->peername);
- $peeraddr = inet_ntoa( $peeraddr );
- Kolab::log('SD', "Incoming connection accepted, peer=$peeraddr");
- if( $Kolab::config{'slurpd_accept_addr'} && $peeraddr ne $Kolab::config{'slurpd_accept_addr'} ) {
- Kolab::log('SD', "Unauthorized connection from $peeraddr, closing connection", KOLAB_WARN);
- $conn->close;
- undef $conn;
- }
+ Kolab::log('SD', 'Incoming connection accepted');
my $select = IO::Select->new($conn);
@@ -278,20 +268,14 @@ sub run
$changes = 0;
Kolab::log('SD', 'Change detected w/ no pending LDAP messages; reloading services if needed');
Kolab::LDAP::sync;
- system($Kolab::config{'prefix'} . $ap::config->{sbindir}/kolabconf);
+ system($Kolab::config{'prefix'} . '/sbin/kolabconf');
}
Kolab::log('SD', 'Waiting for LDAP updates');
- for ($ready = 1; $conn && $ready; $ready = $select->can_read(1)) {
+ for ($ready = 1; $ready; $ready = $select->can_read(1)) {
Kolab::log('SD', 'Reading ASN', KOLAB_DEBUG);
- my $newoffset = asn_read($conn, $pdu, $offset);
- if( !$conn->connected() or $offset == $newoffset ) {
- Kolab::log('SD', 'Connection closed', KOLAB_DEBUG);
- $conn->close;
- undef $conn;
- }
- $offset = $newoffset;
+ $offset = asn_read($conn, $pdu, $offset);
defined($offset) or $offset = 0;
sleep 1;
}
@@ -300,29 +284,23 @@ sub run
$request = $LDAPRequest->decode($pdu);
if (!$request) {
Kolab::log('SD', "Unable to decode slurpd request, Error = `" . $LDAPRequest->error . "'", KOLAB_ERROR);
- $conn->close if $conn;
- undef $conn;
- undef $pdu;
- } else {
- $_ = getRequestType($request);
- Kolab::log('SD', "Request $_ received", KOLAB_DEBUG);
- undef $pdu;
-
- SWITCH: {
- if (/^bindRequest/) { $pdu = responseBind($request); last SWITCH; }
- if (/addRequest/) { $pdu = responseAdd($request); $changes = 1; last SWITCH; }
- if (/delRequest/) { $pdu = responseDel($request); $changes = 1; last SWITCH; }
- if (/modifyRequest/) { $pdu = responseMod($request); $changes = 1; last SWITCH; }
- if (/modDNRequest/) { $pdu = responseModDN($request); $changes = 1; last SWITCH; }
-
- if( $conn ) {
- Kolab::log('SD', 'Unknown request, connection closed', KOLAB_DEBUG);
- $conn->close;
- undef $conn;
- }
- }
- }
- }
+ &abort;
+ }
+ $_ = getRequestType($request);
+ Kolab::log('SD', "Request $_ received", KOLAB_DEBUG);
+ undef $pdu;
+
+ SWITCH: {
+ if (/bindRequest/) { $pdu = responseBind($request); last SWITCH; }
+ if (/addRequest/) { $pdu = responseAdd($request); $changes = 1; last SWITCH; }
+ if (/delRequest/) { $pdu = responseDel($request); $changes = 1; last SWITCH; }
+ if (/modifyRequest/) { $pdu = responseMod($request); $changes = 1; last SWITCH; }
+ if (/modDNRequest/) { $pdu = responseModDN($request); $changes = 1; last SWITCH; }
+
+ $conn->close;
+ undef $conn;
+ }
+ }
if ($pdu) {
Kolab::log('SD', 'Writing response', KOLAB_DEBUG);
@@ -330,8 +308,7 @@ sub run
$response = $LDAPResponse->decode($pdu);
if (!$response) {
Kolab::log('SD', "Unable to decode slurpd request, Error = `" . $LDAPRequest->error . "'");
- $conn->close;
- undef $conn;
+ &abort;
}
}
}
@@ -357,7 +334,7 @@ Kolab::LDAP::Backend::slurpd - Perl extension for a slurpd backend
=head1 AUTHOR
-Stuart Bingė¬ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-LDAP-Backend/Backend.pm b/Kolab-LDAP-Backend/Backend.pm
index e9f0bd5..b445b1b 100644
--- a/Kolab-LDAP-Backend/Backend.pm
+++ b/Kolab-LDAP-Backend/Backend.pm
@@ -3,7 +3,7 @@ package Kolab::LDAP::Backend;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing?<s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -68,8 +68,7 @@ sub load
Kolab::log('B', "Loading backend `$backend'");
unless (eval "require Kolab::LDAP::Backend::$backend") {
- Kolab::log('B', "Error is: $@", KOLAB_ERROR) if $@;
- Kolab::log('B', "Backend `$backend' does not exist or has errors, exiting", KOLAB_ERROR);
+ Kolab::log('B', "Backend `$backend' does not exist, exiting", KOLAB_ERROR);
exit(1);
}
@@ -86,7 +85,7 @@ sub startup
my $func = $startup{$backend};
unless (eval '&$func') {
$func = 'Kolab::LDAP::Backend::' . $backend . '::startup';
- Kolab::log('B', "Error in function `$func': $@, exiting", KOLAB_ERROR);
+ Kolab::log('B', "Function `$func' does not exist, exiting", KOLAB_ERROR);
exit(1);
}
}
@@ -100,7 +99,7 @@ sub run
my $func = $run{$backend};
unless (eval '&$func') {
$func = 'Kolab::LDAP::Backend::' . $backend . '::run';
- Kolab::log('B', "Error in function `$func': $@, exiting", KOLAB_ERROR);
+ Kolab::log('B', "Function `$func' does not exist, exiting", KOLAB_ERROR);
exit(1);
}
}
@@ -121,7 +120,7 @@ service usage
=head1 AUTHOR
-Stuart Bingė¬ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-LDAP/LDAP.pm b/Kolab-LDAP/LDAP.pm
index 632738a..31ad465 100644
--- a/Kolab-LDAP/LDAP.pm
+++ b/Kolab-LDAP/LDAP.pm
@@ -1,11 +1,9 @@
package Kolab::LDAP;
##
-## Copyright (c) 2005 Klaralvdalens Datakonsult AB
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingƫ <s.binge@codefusion.co.za>
-## Steffen Hansen <steffen@klaralvdalens-datakonsult.se>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -24,8 +22,7 @@ package Kolab::LDAP;
use 5.008;
use strict;
use warnings;
-use UNIVERSAL;
-use Net::LDAP qw( LDAP_SUCCESS LDAP_PROTOCOL_ERROR LDAP_REFERRAL );
+use Net::LDAP;
use Net::LDAPS;
use DB_File;
use Kolab;
@@ -35,7 +32,6 @@ use Kolab::DirServ;
use vars qw(%uid_db %gyard_db %newuid_db %gyard_ts_db);
require Exporter;
-require "config.h";
our @ISA = qw(Exporter);
@@ -68,19 +64,19 @@ sub startup
Kolab::log('L', 'Opening mailbox uid cache DB');
- if (!dbmopen(%uid_db, $Kolab::config{'prefix'} . $ap::config->{localstatedir}/kolab/mailbox-uidcache.db, 0666)) {
+ if (!dbmopen(%uid_db, $Kolab::config{'prefix'} . '/var/kolab/mailbox-uidcache.db', 0666)) {
Kolab::log('L', 'Unable to open mailbox uid cache DB', KOLAB_ERROR);
exit(1);
}
Kolab::log('L', 'Opening graveyard uid/timestamp cache DB');
- if (!dbmopen(%gyard_db, $Kolab::config{'prefix'} . $ap::config->{localstatedir}/kolab/graveyard-uidcache.db, 0666)) {
+ if (!dbmopen(%gyard_db, $Kolab::config{'prefix'} . '/var/kolab/graveyard-uidcache.db', 0666)) {
Kolab::log('L', 'Unable to open graveyard uid cache DB', KOLAB_ERROR);
exit(1);
}
- if (!dbmopen(%gyard_ts_db, $Kolab::config{'prefix'} . $ap::config->{localstatedir}/kolab/graveyard-tscache.db, 0666)) {
+ if (!dbmopen(%gyard_ts_db, $Kolab::config{'prefix'} . '/var/kolab/graveyard-tscache.db', 0666)) {
Kolab::log('L', 'Unable to open graveyard timestamp cache DB', KOLAB_ERROR);
exit(1);
}
@@ -111,19 +107,17 @@ sub create
$ip,
port => $pt,
version => 3,
- timeout => 20,
+ timeout => 5,
async => $as,
- verify => 'none',
- onerror => 'undef'
+ verify => 'none'
);
} else {
$ldap = Net::LDAP->new(
$ip,
port => $pt,
version => 3,
- timeout => 20,
+ timeout => 5,
async => $as,
- onerror => 'undef'
);
}
if (!$ldap) {
@@ -188,7 +182,7 @@ sub isDeleted
my $p = shift || 'user';
my $del = $object->get_value($Kolab::config{$p . '_field_deleted'}, asref => 1 );
#foreach (@$del) {
- # return 1 if lc($_) eq lc($Kolab::config{'fqdnhostname'});
+ # return 1 if lc($_) eq lc($Kolab::config{'fqhostname'});
#}
#return 0;
return $#$del > 0;
@@ -200,30 +194,19 @@ sub mapAcls {
my $sf = shift || 0;
my @acls = map {
my ($uid,$perm) = split(/\s+/,$_,2);
- Kolab::log('L', "Kolab::LDAP::mapAcls() uid=$uid perm=$perm", KOLAB_DEBUG);
- my $post = 0;
- if( $perm =~ /(.*)\/post/ ) {
- $perm = $1;
- $post = 1;
- }
- Kolab::log('L', "Kolab::LDAP::mapAcls() uid=$uid perm=$perm post=$post", KOLAB_DEBUG);
if( lc $perm eq 'none' ) { $_ = "$uid none"; }
- elsif( lc $perm eq 'post' ) { $_ = "$uid p"; }
elsif( lc $perm eq 'read' ) { $_ = "$uid lrs"; }
+ elsif( lc $perm eq 'append' ) { $_ = "$uid lrsi"; }
+ elsif( lc $perm eq 'write' ) { $_ = "$uid lrsiwcd"; }
elsif( lc $perm eq 'read anon' ) { $_ = "$uid lr"; }
elsif( lc $perm eq 'read hidden' ) { $_ = "$uid rs"; }
- elsif( lc $perm eq 'append' ) { $_ = "$uid lrsip"; }
- elsif( lc $perm eq 'write' ) { if( $sf ) { $_ = "$uid lrsiwdp"; } else { $_ = "$uid lrsiwcdp"; } }
- elsif( lc $perm eq 'all' ) { if( $sf ) { $_ = "$uid lrsiwdap"; } else { $_ = "$uid lrsiwcdap"; } }
+ elsif( lc $perm eq 'all' ) { if( $sf ) { $_ = "$uid lrsiwcd"; } else { $_ = "$uid lrsiwcda"; } }
else { $_ = "$uid $perm"; } # passthrough
- if( $post ) { $_ .= 'p'; }
- Kolab::log('L', "Kolab::LDAP::mapAcls() acl=$_", KOLAB_DEBUG);
} @$acls;
if( $sf ) {
# Do we need to push admin rights for manager?
}
- Kolab::log('L', "Kolab::LDAP::mapAcls() acls=".join(", ", @$acls), KOLAB_DEBUG);
- return $acls;
+ return \@acls;
}
sub createObject
@@ -238,7 +221,7 @@ sub createObject
Kolab::log('L', "Kolab::LDAP::createObject() called with obj uid field `$objuidfield' for obj type `$p'", KOLAB_DEBUG);
- my $kolabhomeserver = lc($object->get_value('kolabhomeserver'));
+ my $homeserver = $object->get_value('homeServer');
my $islocal = 1;
my $del = $object->get_value($Kolab::config{$p . '_field_deleted'}, asref => 1);
if( ref($del) eq 'ARRAY' && @$del > 0 ) {
@@ -246,12 +229,12 @@ sub createObject
." because it is deleted");
return;
}
- if( $kolabhomeserver && $kolabhomeserver ne lc($Kolab::config{'fqdnhostname'}) ) {
+ if( $homeserver && $homeserver ne $Kolab::config{'fqhostname'} ) {
if( $p eq 'sf' ) {
- # Dont create shared folders on other hosts than it's kolabhomeserver
+ # Dont create shared folders on other hosts than it's homeserver
return;
}
- Kolab::log('L', "Kolab::LDAP::createObject() for other server $kolabhomeserver. TODO: Create referral or something, for now we just create ", KOLAB_DEBUG);
+ Kolab::log('L', "Kolab::LDAP::createObject() for other server $homeserver. TODO: Create referral or something, for now we just create ", KOLAB_DEBUG);
$islocal = 0;
}
@@ -325,33 +308,7 @@ sub createObject
}
my $quota = $object->get_value($Kolab::config{$p . '_field_quota'});
- defined($quota) or ($quota = 0);
- Kolab::Cyrus::setQuota($cyrus, $uid, $quota*1024, ($p eq 'sf' ? 1 : 0));
-}
-
-sub createMasterLDAP {
- my $uri = $Kolab::config{'ldap_master_uri'};
-
- my $masterldap = Net::LDAP->new(
- $uri,
- version => 3,
- timeout => 20,
- verify => 'none',
- onerror => 'undef' );
- if( defined( $masterldap ) ) {
- my $mesg = $masterldap->bind(
- $Kolab::config{'bind_dn'},
- password => $Kolab::config{'bind_pw'});
- if ($mesg->code) {
- Kolab::log('L', "Unable to bind to `$uri', LDAP Error = `"
- .$mesg->error."'", KOLAB_ERROR);
- undef( $masterldap );
- }
- } else {
- Kolab::log('L', "Unable to connect to `$uri'"
- , KOLAB_ERROR);
- }
- return $masterldap;
+ Kolab::Cyrus::setQuota($cyrus, $uid, $quota, ($p eq 'sf' ? 1 : 0));
}
sub deleteObject
@@ -370,82 +327,24 @@ sub deleteObject
if ($remfromldap) {
my $dn = $object->dn;
my $del = $object->get_value($Kolab::config{$p . '_field_deleted'}, asref => 1);
- my $masterldap;
- if( lc($Kolab::config{'is_master'}) eq 'true' ) {
- # We are the master, just go ahead
- $masterldap = $ldap;
+ if( ref($del) eq 'ARRAY' && scalar(@$del) == 1 ) {
+ # Ok we are the last one...
+ Kolab::log('L', "Removing DN `$dn'");
+ my $mesg = $ldap->delete($dn);
+ if ($mesg->code) {
+ Kolab::log('L', "Unable to remove DN `$dn': ".$mesg->error, KOLAB_WARN);
+ }
} else {
- $masterldap = createMasterLDAP;
- }
- if( !defined( $masterldap ) ) {
- # Problem here, could not connect to master!
- Kolab::log('L', "Unable to remove DN `$dn', master LDAP server not available", KOLAB_WARN);
- return 0;
- }
- if( lc ($Kolab::config{'is_master'}) eq 'true' && ref($del) eq 'ARRAY' && scalar(@$del) == 1 ) {
- # Ok we are the last one and the master
- if( $Kolab::config{'kolab_remove_objectclass'} ) {
- # Remove the kolab-related objectClasses
- # Some people find it useful to integrate Kolab
- # with an existing LDAP database and when a Kolab
- # object is to be deleted, it should just remove
- # the Kolab stuff and leave the rest of the object
- # in the database.
- #
- # This is what we do here.
- # Warning: All attributes in the kolab-related
- # objectclasses will be deleted!
- #
- # PENDING(steffen): Only remove attributes that _have_ to
- # be removed.
- Kolab::log('L', "Removing Kolab objectClasses from DN `$dn'");
- my $schema = $masterldap->schema( $dn );
- # PENDING(steffen): Dont hardcode objectClasses
- foreach my $c qw(kolabInetOrgPerson kolabGroupOfNames) {
- my @may = map $_->{name}, $schema->may($c);
- my @must = map $_->{name}, $schema->must($c);
- foreach my $attr (@must,@may,split(' ',$Kolab::config{'kolab_remove_attributes'})) {
- # Remove attributes
- Kolab::log('L', "Removing attribute $attr", KOLAB_WARN);
- my $mesg = $masterldap->modify( $dn,
- delete => $attr );
- if ($mesg && $mesg->code ) {
- Kolab::log('L', "Unable to remove attribute $attr from DN `$dn': ".$mesg->error, KOLAB_WARN);
- }
- }
- # Remove objectClass
- my $mesg = $masterldap->modify( $dn,
- delete => { 'objectClass' => $c } );
- if ($mesg && $mesg->code ) {
- Kolab::log('L', "Unable to remove Kolab objectClas $_ from DN `$dn': ".$mesg->error, KOLAB_WARN);
- }
- }
- } else {
- # Default behaviour, delete the object
- Kolab::log('L', "Removing DN `$dn'");
- my $mesg = $masterldap->delete($dn);
- if ($mesg && $mesg->code ) {
- Kolab::log('L', "Unable to remove DN `$dn': ".$mesg->error, KOLAB_WARN);
- }
- }
- } elsif( lc ($Kolab::config{'is_master'}) eq 'false' ) {
- # Just remove us from the kolabdeleteflag
- # master does not perform this step as it should
- # be the last to delete and remove the object
- Kolab::log('L', "Removing ".$Kolab::config{'fqdnhostname'}." from ".
- $Kolab::config{$p . '_field_deleted'}." in `$dn'");
- my $mesg = $masterldap->modify( $dn, delete =>
- { $Kolab::config{$p . '_field_deleted'} =>
- $Kolab::config{'fqdnhostname'} } );
- if ($mesg && $mesg->code) {
- Kolab::log('L', "Unable to remove ".$Kolab::config{'fqdnhostname'}
- ." from kolabdeleteflag in `$dn': ".$mesg->error, KOLAB_WARN);
+ # Just remove us from the deleteflag
+ Kolab::log('L', "Removing ".$Kolab::config{'fqhostname'}." from deleteflag in `$dn'");
+ my $mesg = $ldap->modify( $dn, delete =>
+ { $Kolab::config{$p . '_field_deleted'} =>
+ $Kolab::config{'fqhostname'} } );
+ if ($mesg->code) {
+ Kolab::log('L', "Unable to remove ".$Kolab::config{'fqhostname'}
+ ." from deleteflag in `$dn': ".$mesg->error, KOLAB_WARN);
}
}
- if( $ldap != $masterldap ) {
- # Disconnect from master if we are the slave
- $masterldap->disconnect;
- }
}
my $guid = $object->get_value($Kolab::config{$p . '_field_guid'});
@@ -464,7 +363,7 @@ sub deleteObject
# system("rm -rf \"$fbdir\"" );
# }
delete $uid_db{$guid};
- return 1;
+ return;
}
sub sync
@@ -472,13 +371,9 @@ sub sync
Kolab::log('L', 'Synchronising');
my $cyrus = Kolab::Cyrus::create;
- if( !$cyrus ) {
- # We could not connect, bail out for now
- return 0;
- }
%newuid_db = ();
- syncBasic($cyrus, 'user', '(uid=*)', 0);
+ syncBasic($cyrus, 'user', '(mail=*)', 0);
syncBasic($cyrus, 'sf', '', 1);
# Check that all mailboxes correspond to LDAP objects
@@ -514,8 +409,8 @@ sub sync
Kolab::log('L', 'Gravekeeping (period = ' . $Kolab::config{'gyard_deletion_period'} . ' minutes)');
foreach $guid (keys %gyard_ts_db) {
if ($now - $gyard_ts_db{$guid} > $period) {
- Kolab::log('L', "Clearing graveyard database entry `" . $gyard_db{$guid} . "'");
- #Kolab::Cyrus::deleteMailbox($cyrus, $gyard_db{$guid}, 0);
+ Kolab::log('L', "Gravekeeper deleting mailbox `" . $gyard_db{$guid} . "'");
+ Kolab::Cyrus::deleteMailbox($cyrus, $gyard_db{$guid}, 0);
delete $gyard_ts_db{$guid};
delete $gyard_db{$guid};
}
@@ -530,7 +425,7 @@ sub syncBasic
{
my $cyrus = shift;
my $p = shift || 'user';
- my $add = shift || ($p eq 'user' ? '' : '');
+ my $add = shift || ($p eq 'user' ? '(mail=*)' : '');
my $doacls = shift || 0;
Kolab::log('L', "Synchronising `$p' objects");
@@ -555,7 +450,7 @@ sub syncBasic
$ldapmesg = $ldap->search(
base => $dn,
scope => 'sub',
- filter => '(&(objectClass=' . $Kolab::config{$p . '_object_class'} . ")$add(" . $Kolab::config{$p . '_field_deleted'} . '='.$Kolab::config{'fqdnhostname'}.'))',
+ filter => '(&(objectClass=' . $Kolab::config{$p . '_object_class'} . ")$add(" . $Kolab::config{$p . '_field_deleted'} . '='.$Kolab::config{'fqhostname'}.'))',
attrs => [
'*',
$Kolab::config{$p . '_field_guid'},
@@ -565,7 +460,7 @@ sub syncBasic
],
);
- if ( UNIVERSAL::isa( $ldapmesg, 'Net::LDAP::Search') && $ldapmesg->code() <= 0) {
+ if ($ldapmesg->code <= 0) {
foreach $ldapobject ($ldapmesg->entries) {
deleteObject($ldap, $cyrus, $ldapobject, 1, $p);
}
@@ -588,7 +483,7 @@ sub syncBasic
],
);
- if ( UNIVERSAL::isa( $ldapmesg, 'Net::LDAP::Search') && $ldapmesg->code() <= 0) {
+ if ($ldapmesg->code <= 0) {
foreach $ldapobject ($ldapmesg->entries) {
createObject($ldap, $cyrus, $ldapobject, 1, $p, $doacls);
}
@@ -619,7 +514,7 @@ Kolab::LDAP - Perl extension for generic LDAP code
=head1 AUTHOR
-Stuart Bingė¬ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-Mailer/Mailer.pm b/Kolab-Mailer/Mailer.pm
index 624b082..25554f0 100644
--- a/Kolab-Mailer/Mailer.pm
+++ b/Kolab-Mailer/Mailer.pm
@@ -3,7 +3,7 @@ package Kolab::Mailer;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingļæ½ <s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -27,7 +27,6 @@ use MIME::Entity;
use MIME::Body;
require Exporter;
-require "config.h";
our @ISA = qw(Exporter);
@@ -68,7 +67,7 @@ sub sendMultipart
$mesg->attach(Data => $data);
}
- open(SENDMAIL, '|' . $Kolab::config{'prefix'} . $ap::config->{sbindir} . '/sendmail -oi -t -odq');
+ open(SENDMAIL, '|' . $Kolab::config{'prefix'} . '/sbin/sendmail -oi -t -odq');
$mesg->print(\*SENDMAIL);
close(SENDMAIL);
}
@@ -87,7 +86,7 @@ sub sendText
Data => $text,
);
- open(SENDMAIL, '|' . $Kolab::config{'prefix'} . $ap::config->{sbindir} . '/sendmail -oi -t -odq');
+ open(SENDMAIL, '|' . $Kolab::config{'prefix'} . '/sbin/sendmail -oi -t -odq');
$mesg->print(\*SENDMAIL);
close(SENDMAIL);
}
@@ -107,7 +106,7 @@ Kolab::Mailer - Perl extension for sending out email
=head1 AUTHOR
-Stuart Bingļæ½ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-Util/Util.pm b/Kolab-Util/Util.pm
index 6523c6b..2c07e24 100644
--- a/Kolab-Util/Util.pm
+++ b/Kolab-Util/Util.pm
@@ -3,7 +3,7 @@ package Kolab::Util;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing?<s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -23,7 +23,6 @@ use 5.008;
use strict;
use warnings;
use IO::File;
-use Sys::Syslog;
require Exporter;
@@ -42,7 +41,6 @@ our @EXPORT = qw(
&ldapDateToEpoch
&readConfig
&readList
- &superLog
);
our $VERSION = '0.9';
@@ -69,13 +67,6 @@ sub ldapDateToEpoch
return timelocal($se, $mi, $h, $d, $m, $y);
}
-sub superLog
-{
- my $text = shift;
- #print STDERR "$text\n";
- syslog('info', "$text");
-}
-
sub readConfig
{
my $ref = shift;
@@ -94,13 +85,10 @@ sub readConfig
$sep = '\s' if ($sep eq ' ' || $sep eq '#');
my $fd;
- if (!($fd = IO::File->new($file, 'r'))) {
- superLog( "Warning: Could not read $file");
- return %cfg;
- }
+ if (!($fd = IO::File->new($file, 'r'))) { return %cfg; }
foreach (<$fd>) {
- if (/^([^$sep#]+)$sep(.*)/) {
+ if (/^([^$sep#]+)$sep+([^#]*)/) {
$cfg{trim($1)} = trim($2);
}
}
@@ -143,7 +131,7 @@ Kolab::Util - Perl extension for general utility functions
=head1 AUTHOR
-Stuart Bingė¬ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab/Kolab.pm b/Kolab/Kolab.pm
index 74c1905..f7d7907 100644
--- a/Kolab/Kolab.pm
+++ b/Kolab/Kolab.pm
@@ -3,7 +3,7 @@ package Kolab;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bingƫ <s.binge@codefusion.co.za>
+## Writen by Stuart Bingė <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -27,20 +27,19 @@ use URI;
use Net::LDAP;
use Kolab::Util;
#use Kolab::LDAP;
-use vars qw(%config %haschanged $reloadOk);
+use vars qw(%config %haschanged);
require Exporter;
-require "config.h";
our @ISA = qw(Exporter);
our %EXPORT_TAGS = (
'all' => [ qw(
%config
- $reloadOk
&reloadConfig
&reload
&log
+ &superLog
) ]
);
@@ -67,8 +66,6 @@ sub reloadConfig
my $tempval;
my $ldap;
- my $error = 0;
-
# `log_level' specifies what severity of messages we want to see in the logs.
# Possible values are:
# 0 - Silent
@@ -80,15 +77,15 @@ sub reloadConfig
# Determine the root of the kolab installation, and read `kolab.globals'
if (!($tempval = (getpwnam('kolab'))[7])) {
$config{'log_level'} = KOLAB_WARN;
- &log('C', 'Unable to determine the kolab root directory', KOLAB_ERROR);
- $error = 1;
+ &log('C', 'Unable to determine the kolab root directory', KOLAB_ERROR);
+# exit(1);
} else {
- %config = readConfig(%config, "$tempval$ap::config->{sysconfdir}/kolab/kolab.globals");
+ %config = readConfig(%config, "$tempval/etc/kolab/kolab.globals");
$config{'prefix'} = $tempval;
}
# Now read `kolab.conf', overwriting values read from `kolab.globals'
- %config = readConfig(\%config, "$tempval$ap::config->{sysconfdir}/kolab/kolab.conf");
+ %config = readConfig(\%config, "$tempval/etc/kolab/kolab.conf");
# $config{'log_level'} = KOLAB_WARN if (!exists $config{'log_level'});
&log('C', 'Reloading configuration');
@@ -96,46 +93,39 @@ sub reloadConfig
# Get the UID/GID of the `kolab' user
if (!($config{'kolab_uid'} = (getpwnam('kolab'))[2])) {
&log('C', "Unable to determine the uid of user `kolab'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
if (!($config{'kolab_gid'} = (getgrnam('kolab'))[2])) {
&log('C', "Unable to determine the gid of user `kolab'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
if (!($config{'kolab_n_uid'} = (getpwnam('kolab-n'))[2])) {
&log('C', "Unable to determine the uid of user `kolab-n'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
if (!($config{'kolab_n_gid'} = (getgrnam('kolab-n'))[2])) {
&log('C', "Unable to determine the gid of user `kolab-n'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
if (!($config{'kolab_r_uid'} = (getpwnam('kolab-r'))[2])) {
&log('C', "Unable to determine the uid of user `kolab-r'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
if (!($config{'kolab_r_gid'} = (getgrnam('kolab-r'))[2])) {
&log('C', "Unable to determine the gid of user `kolab-r'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
# Make sure the critical variables we need were defined in kolab.conf
if (!exists $config{'bind_dn'} || !exists $config{'bind_pw'} || !exists $config{'ldap_uri'} || !exists $config{'base_dn'}) {
&log('C', "One or more required configuration variables (`bind_dn', `bind_pw', `ldap_uri' and/or `base_dn') are missing in `kolab.conf'", KOLAB_ERROR);
- $error = 1;
- }
-
- # Make a hash of the bind password available too
- if( !exists $config{'bind_pw_hash'} ) {
- my $hashcmd = $config{'prefix'}."$ap::config->{sbindir}/slappasswd -s '".$config{'bind_pw'}."'";
- $config{'bind_pw_hash'} = `$hashcmd`;
- chomp($config{'bind_pw_hash'});
+# exit(1);
}
# Retrieve the LDAP values of the main kolab object to complete our config hash
if (!($tempval = URI->new($config{'ldap_uri'}))) {
&log('C', "Unable to parse ldap_uri `" . $config{'ldap_uri'} . "'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
} else {
$config{'ldap_ip'} = $tempval->host;
$config{'ldap_port'} = $tempval->port;
@@ -152,13 +142,13 @@ sub reloadConfig
if (!($ldap = Net::LDAP->new($config{'ldap_uri'}, verify => 'none' ))) {
&log('C', "Unable to connect to LDAP server `" . $config{'ldap_ip'} . ":" . $config{'ldap_port'} . "'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
$mesg = $ldap->bind($config{'bind_dn'}, password => $config{'bind_pw'}) if $ldap;
if ($ldap && $mesg->code) {
&log('C', "Unable to bind to DN `" . $config{'bind_dn'} . "'", KOLAB_ERROR);
- $error = 1;
+# exit(1);
}
#$ldap = Kolab::LDAP::create(
@@ -182,15 +172,14 @@ sub reloadConfig
# Not a ref at all???
&log('C', "Attribute $tempval does not exist", KOLAB_WARN );
} elsif( @{$vals} == 1 ) {
- $config{lc($tempval)} = $vals->[0];
+ $config{$tempval} = $vals->[0];
} else {
- $config{lc($tempval)} = $vals;
+ $config{$tempval} = $vals;
}
}
} else {
&log('C', "Unable to find kolab object `" . $config{'kolab_dn'} . "'", KOLAB_ERROR);
# exit(1);
- $error = 1;
}
} else {
&log('C', "Unable to read configuration data from LDAP", KOLAB_WARN);
@@ -209,6 +198,11 @@ sub reloadConfig
$config{'proftpd-userPassword'} = '';
}
+ # Apache legacy mode
+ $config{'legacy-mode'} = "# no legacy configuration";
+ if (exists $config{'apache-http'} && $config{'apache-http'} =~ /true/i) {
+ $config{'legacy-mode'} = 'Include "' . $config{'prefix'} . '/etc/apache/legacy.conf"';
+ }
$config{'fqdn'} = trim(`hostname`);
# Cyrus admin account
@@ -258,7 +252,6 @@ sub reloadConfig
if (!($tempval = URI->new($config{'user_ldap_uri'}))) {
&log('C', "Unable to parse user_ldap_uri `" . $config{'user_ldap_uri'} . "'", KOLAB_ERROR);
# exit(1);
- $error = 1;
} else {
$config{'user_ldap_ip'} = $tempval->host;
$config{'user_ldap_port'} = $tempval->port;
@@ -288,10 +281,10 @@ sub reloadConfig
$config{'user_field_quota'} = 'userquota' if (!exists $config{'user_field_quota'});
} else {
# slurd/default
- $config{'user_field_deleted'} = 'kolabdeleteflag' if (!exists $config{'user_field_deleted'});
+ $config{'user_field_deleted'} = 'deleteflag' if (!exists $config{'user_field_deleted'});
$config{'user_field_modified'} = 'modifytimestamp' if (!exists $config{'user_field_modified'});
$config{'user_field_guid'} = 'entryUUID' if (!exists $config{'user_field_guid'});
- $config{'user_field_quota'} = 'cyrus-userquota' if (!exists $config{'user_field_quota'});
+ $config{'user_field_quota'} = 'userquota' if (!exists $config{'user_field_quota'});
}
# The `sf_XXX' variables are the shared folder equivalents of the `user_XXX' variables
@@ -300,7 +293,6 @@ sub reloadConfig
if (!($tempval = URI->new($config{'sf_ldap_uri'}))) {
&log('C', "Unable to parse sf_ldap_uri `" . $config{'sf_ldap_uri'} . "'", KOLAB_ERROR);
# exit(1);
- $error = 1;
} else {
$config{'sf_ldap_ip'} = $tempval->host;
$config{'sf_ldap_port'} = $tempval->port;
@@ -311,7 +303,7 @@ sub reloadConfig
$config{'sf_dn_list'} = $config{'base_dn'} if (!exists $config{'sf_dn_list'});
$config{'sf_directory_mode'} = $config{'directory_mode'} if (!exists $config{'sf_directory_mode'});
- $config{'sf_object_class'} = 'kolabsharedfolder' if (!exists $config{'sf_object_class'});
+ $config{'sf_object_class'} = 'sharedfolder' if (!exists $config{'sf_object_class'});
if ($config{'sf_directory_mode'} eq 'ad') {
# AD
@@ -321,10 +313,10 @@ sub reloadConfig
$config{'sf_field_quota'} = 'userquota' if (!exists $config{'sf_field_quota'});
} else {
# slurd/default
- $config{'sf_field_deleted'} = 'kolabdeleteflag' if (!exists $config{'sf_field_deleted'});
+ $config{'sf_field_deleted'} = 'deleteflag' if (!exists $config{'sf_field_deleted'});
$config{'sf_field_modified'} = 'modifytimestamp' if (!exists $config{'sf_field_modified'});
$config{'sf_field_guid'} = 'entryUUID' if (!exists $config{'sf_field_guid'});
- $config{'sf_field_quota'} = 'cyrus-userquota' if (!exists $config{'sf_field_quota'});
+ $config{'sf_field_quota'} = 'userquota' if (!exists $config{'sf_field_quota'});
}
# `gyard_deletion_period' specifies how many minutes to leave lost users in
@@ -342,7 +334,6 @@ sub reloadConfig
}
&log('C', 'Finished reloading configuration');
- $reloadOk = !$error;
}
sub reload
@@ -351,49 +342,39 @@ sub reload
if ($haschanged{'slapd'}) {
&log('K', 'Restarting OpenLDAP...');
- system("$ap::config->{sbindir}/slurpd restart &");
+ system("$prefix/etc/rc.d/rc.openldap restart");
}
if ($haschanged{'saslauthd'}) {
&log('K', 'Restarting SASLAuthd...');
- system("$ap::config->{sbindir}/rcsaslauthd stop; sleep 1; $ap::config->{sbindir}/rcsaslauthd -a ldap -n 5");
+ system("$prefix/etc/rc.d/rc.sasl stop; sleep 1; $prefix/sbin/saslauthd -a ldap -n 5");
}
if ($haschanged{'apache'}) {
&log('K', 'Reloading Apache...');
- system("$ap::config->{sbindir}/apache2ctl graceful");
+ system("$prefix/sbin/apachectl graceful");
}
if ($haschanged{'postfix'}) {
&log('K', 'Reloading Postfix...');
- system("$ap::config->{sbindir}/rcpostfix reload");
+ system("$prefix/sbin/postfix reload");
}
if ($haschanged{'imapd'}) {
&log('K', 'Restarting imapd...');
- system("$ap::config->{sbindir}/rccyrus restart");
- }
-
- if ($haschanged{'amavisd'}) {
- &log('K', 'Restarting amavisd...');
- system("$ap::config->{sbindir}/rcamavisd restart");
- }
-
- if ($haschanged{'clamav'}) {
- &log('K', 'Restarting clamav...');
- system("$ap::config->{sbindir}/clamd restart");
+ system("$prefix/etc/rc.d/rc.imapd restart");
}
if ($config{'proftpd-ftp'} =~ /true/i) {
Kolab::log('K', 'Starting ProFTPd if not running');
- system("$ap::config->{bindir}/openpkg rc proftpd start");
+ system("$prefix/etc/rc.d/rc.proftpd start");
if ($haschanged{'proftpd'}) {
&log('K', 'Reloading ProFTPd...');
- kill('SIGHUP', `cat $ap::config->{localstatedir}/proftpd/proftpd.pid`);
+ kill('SIGHUP', `cat $prefix/var/proftpd/proftpd.pid`);
}
} else {
&log('K', 'Stopping ProFTPd, if running...');
- system("$ap::config->{bindir}/openpkg rc proftpd stop");
+ system("$prefix/etc/rc.d/rc.proftpd stop");
}
%Kolab::Conf::haschanged = ();
@@ -423,6 +404,12 @@ sub log
}
}
+sub superLog
+{
+ my $text = shift;
+ syslog('info', "$text");
+}
+
reloadConfig();
1;
@@ -440,7 +427,7 @@ Kolab - Perl extension for general Kolab settings.
=head1 AUTHOR
-Stuart Bingė¬ E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingė, E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6310a8d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+RPM = /kolab/bin/openpkg rpm
+VERSION = 0.9.2
+
+ifeq "x$(KOLABRPMSRC)" "x"
+ KOLABRPMSRC = /kolab/RPM/SRC
+endif
+
+SRCDIR=$(KOLABRPMSRC)/perl-kolab
+
+all:
+ test -d $(SRCDIR) || mkdir $(SRCDIR)
+ tar cvzf $(SRCDIR)/Kolab-$(VERSION).tar.gz Kolab
+ tar cvzf $(SRCDIR)/Kolab-Util-$(VERSION).tar.gz Kolab-Util
+ tar cvzf $(SRCDIR)/Kolab-Conf-$(VERSION).tar.gz Kolab-Conf
+ tar cvzf $(SRCDIR)/Kolab-Cyrus-$(VERSION).tar.gz Kolab-Cyrus
+ tar cvzf $(SRCDIR)/Kolab-DirServ-$(VERSION).tar.gz Kolab-DirServ
+ tar cvzf $(SRCDIR)/Kolab-LDAP-$(VERSION).tar.gz Kolab-LDAP
+ tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-$(VERSION).tar.gz Kolab-LDAP-Backend
+ tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-ad-$(VERSION).tar.gz Kolab-LDAP-Backend-ad
+ tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-dirservd-$(VERSION).tar.gz Kolab-LDAP-Backend-dirservd
+ tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-slurpd-$(VERSION).tar.gz Kolab-LDAP-Backend-slurpd
+ tar cvzf $(SRCDIR)/Kolab-Mailer-$(VERSION).tar.gz Kolab-Mailer
+ cp perl-kolab.spec $(SRCDIR)
+ cd $(SRCDIR) && $(RPM) -ba perl-kolab.spec
+binary:
+ $(RPM) -bB perl-kolab.spec
diff --git a/perl-kolab.spec b/perl-kolab.spec
index 3661a7a..5a16e67 100644
--- a/perl-kolab.spec
+++ b/perl-kolab.spec
@@ -24,56 +24,147 @@
##
# versions of individual parts
-
+%define V_perl 5.8.3
+%define V_kolab 0.9.2
+%define V_kolab_util 0.9.2
+%define V_kolab_ldap 0.9.2
+%define V_kolab_ldap_backend 0.9.2
+%define V_kolab_ldap_backend_ad 0.9.2
+%define V_kolab_ldap_backend_slurpd 0.9.2
+%define V_kolab_ldap_backend_dirservd 0.9.2
+%define V_kolab_cyrus 0.9.2
+%define V_kolab_conf 0.9.2
+%define V_kolab_dirserv 0.9.2
+%define V_kolab_mailer 0.9.2
# package information
Name: perl-kolab
Summary: Perl Modules for use with the Kolab server
-URL: http://www.kolab.org
+URL: http://kolab.kde.org
Vendor: Code Fusion, Klaraelvdalens Datakonsult AB
Packager: Klaraelvdalens Datakonsult AB
Distribution: OpenPKG
Class: PLUS
Group: Language
License: GPL/Artistic
-Version: 0.9.2
-Release: 20050421
+Version: %{V_perl}
+Release: 20040720
# list of sources
-Source0: perl-kolab-0.9.2.tar.gz
+Source0: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-%{V_kolab}.tar.gz
+Source1: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Util-%{V_kolab_util}.tar.gz
+Source2: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-%{V_kolab_ldap}.tar.gz
+Source3: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-%{V_kolab_ldap_backend}.tar.gz
+Source4: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-ad-%{V_kolab_ldap_backend_ad}.tar.gz
+Source5: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-slurpd-%{V_kolab_ldap_backend_slurpd}.tar.gz
+Source6: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-dirservd-%{V_kolab_ldap_backend_dirservd}.tar.gz
+Source7: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Cyrus-%{V_kolab_cyrus}.tar.gz
+Source8: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Conf-%{V_kolab_conf}.tar.gz
+Source9: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-DirServ-%{V_kolab_dirserv}.tar.gz
+Source10: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Mailer-%{V_kolab_mailer}.tar.gz
# build information
Prefix: %{l_prefix}
BuildRoot: %{l_buildroot}
-BuildPreReq: OpenPKG, openpkg >= 2.0, perl >= 0.9.2, perl-openpkg >= 0.9.2
-PreReq: OpenPKG, openpkg >= 2.2.0, perl >= 0.9.2, perl-openpkg >= 0.9.2, perl-db, perl-mail, perl-ldap
+BuildPreReq: OpenPKG, openpkg >= 20040130, perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20040126
+PreReq: OpenPKG, openpkg >= 20040130, perl >= %{V_perl}, perl-openpkg >= %{V_perl}-20040126, perl-db, perl-mail, perl-ldap
AutoReq: no
AutoReqProv: no
%description
Perl modules for use with the Kolab server
-%prep
+%track
+ prog perl-util:Kolab = {
+ version = %{V_kolab}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-Conf = {
+ version = %{V_kolab_conf}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-Conf-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-Cyrus = {
+ version = %{V_kolab_cyrus}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-Cyrus-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-DirServ = {
+ version = %{V_kolab_dirserv}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-DirServ-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-LDAP = {
+ version = %{V_kolab_ldap}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-LDAP-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-LDAP-Backend = {
+ version = %{V_kolab_ldap_backend}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-LDAP-Backend-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-LDAP-Backend-ad = {
+ version = %{V_kolab_ldap_backend_ad}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-LDAP-Backend-ad-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-LDAP-Backend-dirservd = {
+ version = %{V_kolab_ldap_backend_dirservd}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-LDAP-Backend-dirservd-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-LDAP-Backend-slurpd = {
+ version = %{V_kolab_ldap_backend_slurpd}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-LDAP-Backend-slurpd-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-Mailer = {
+ version = %{V_kolab_mailer}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-Mailer-(__VER__)\.tar\.gz
+ }
+ prog perl-util:Kolab-Util = {
+ version = %{V_kolab_util}
+ url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
+ regex = Kolab-Util-(__VER__)\.tar\.gz
+ }
-%setup -n %{name}-%{version}
+%prep
+ %setup -q -c
+ %setup -q -T -D -a 1
+ %setup -q -T -D -a 2
+ %setup -q -T -D -a 3
+ %setup -q -T -D -a 4
+ %setup -q -T -D -a 5
+ %setup -q -T -D -a 6
+ %setup -q -T -D -a 7
+ %setup -q -T -D -a 8
+ %setup -q -T -D -a 9
+ %setup -q -T -D -a 10
%build
- %{configure} --prefix=/usr \
- --includedir=%{perl_sitearch} \
- --localstatedir=/var \
- --sysconfdir=/etc \
- --webadmindir=/srv/www/htdocs/kolab
-
- make
%install
- make DESTDIR=%{buildroot} install
+ %{l_prefix}/bin/perl-openpkg prepare
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE0} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE1} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE2} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE3} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE4} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE5} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE6} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE7} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE8} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE9} configure build install
+ %{l_prefix}/bin/perl-openpkg -d %{SOURCE10} configure build install
%{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} `cat perl-openpkg-files`
%files -f files
%clean
- [ -d %{buildroot} -a "%{buildroot}" != "" ] && rm -rf %{buildroot}
+ rm -rf $RPM_BUILD_ROOT