stuart: devel/kolab Kolab.pm,1.4,1.5 kolabd,1.3,1.4

cvs at intevation.de cvs at intevation.de
Thu May 13 14:05:46 CEST 2004


Author: stuart

Update of /kolabrepository/devel/kolab
In directory doto:/tmp/cvs-serv11879

Modified Files:
	Kolab.pm kolabd 
Log Message:
The daemon/conf scripts should be able to run now, using the new template system.


Index: Kolab.pm
===================================================================
RCS file: /kolabrepository/devel/kolab/Kolab.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Kolab.pm	12 May 2004 14:41:06 -0000	1.4
+++ Kolab.pm	13 May 2004 12:05:44 -0000	1.5
@@ -71,6 +71,9 @@
 sub KOLAB_DEBUG()               {  4 }
 sub KOLAB_VERBOSE_DEBUG()       {  5 }
 
+# This modules' logging prefix
+sub PREFIX()                    { "Kolab.pm" }
+
 # Prefixes for each log level
 our %logLevelPrefixes = (
     KOLAB_SUPER,               '',
@@ -168,6 +171,12 @@
 # files are specified.
 sub loadConfig
 {
+    # We shouldn't log in this procedure, as logging has not been set up when
+    # this is called. Instead we just die - not pretty, but it's probably the
+    # safest option. Otherwise we run the risk of misconfiguring everything,
+    # as the only real cause of problems in this function is not being able
+    # to read in the configuration variables from one of our sources.
+
     # Reset the config hash to its default state
     resetConfig();
 
@@ -182,44 +191,127 @@
     # Go through our config files sequentially, reading in the cvars
     my $configFile;
     foreach $configFile (@configFiles) {
-        %config = readHash($configFile, \%config);
+        %config = readHash($configFile, \%config, 1);
+        die "Unable to read config file $configFile, aborting..." if !defined %config;
+    }
+
+    my $tempval;
+    # Get the LDAP ip and port where our Kolab object resides
+    if (!($tempval = URI->new($config{'ldap_uri'}))) {
+        die "Unable to parse ldap_uri $config{'ldap_uri'}, aborting...";
+        #&log(PREFIX, "Unable to parse ldap_uri $config{'ldap_uri'}", KOLAB_WARN);
+    } else {
+        $config{'ldap_ip'} = $tempval->host;
+        $config{'ldap_port'} = $tempval->port;
     }
 
     # Read in LDAP configuration values, if we have specified a Kolab object in LDAP
-    # TODO: fix this up, specifically what cvars we should be using to access this
-#     if ($config{'kolab_dn'}) {
-#         my $ldap;
-#         if (!($ldap = Net::LDAP->new($config{'ldap_ip'}, port => $config{'ldap_port'}))) {
-#             &log(PREFIX, "Unable to connect to LDAP server '$config{'ldap_ip'}:$config{'ldap_port'}'", KOLAB_WARN);
-#         } else {
-#             my $mesg = $ldap->bind($config{'bind_dn'}, password => $config{'bind_pw'});
-#             if ($mesg->code) {
-#                 &log(PREFIX, "Unable to bind to DN '$config{'bind_dn'}'", KOLAB_WARN);
-#             } else {
-#                 $mesg = $ldap->search(
-#                     base    => $config{'kolab_dn'},
-#                     scope   => 'base',
-#                     filter  => '(objectclass=*)'
-#                 );
-#                 if ($mesg->code) {
-#                     &log(PREFIX, "Unable to find kolab object '$config{'kolab_dn'}'", KOLAB_WARN);
-#                 } else {
-#                     my $ldapobject = $mesg->pop_entry;
-#                     foreach $tempval ($ldapobject->attributes) {
-#                         $config{$tempval} = $ldapobject->get_value($tempval);
-#                     }
-#                 }
-#             }
-#         }
-#
-#         if (defined($ldap) && $ldap->isa('Net::LDAP')) {
-#             $ldap->unbind;
-#             $ldap->disconnect;
-#         }
-#     }
+    $config{'kolab_dn'} = "k=kolab,$config{'base_dn'}" if !exists $config{'kolab_dn'};
+    my $ldap;
+    if (!($ldap = Net::LDAP->new($config{'ldap_ip'}, port => $config{'ldap_port'}))) {
+        die "Unable to connect to LDAP server $config{'ldap_ip'}:$config{'ldap_port'}, aborting...";
+        #&log(PREFIX, "Unable to connect to LDAP server $config{'ldap_ip'}:$config{'ldap_port'}", KOLAB_WARN);
+    } else {
+        my $mesg = $ldap->bind($config{'bind_dn'}, password => $config{'bind_pw'});
+        if ($mesg->code) {
+            die "Unable to bind to DN $config{'bind_dn'}, aborting...";
+            #&log(PREFIX, "Unable to bind to DN $config{'bind_dn'}", KOLAB_WARN);
+        } else {
+            $mesg = $ldap->search(
+                base    => $config{'kolab_dn'},
+                scope   => 'base',
+                filter  => '(objectclass=*)'
+            );
+            if ($mesg->code) {
+                die "Unable to find Kolab object $config{'kolab_dn'}, aborting...";
+                #&log(PREFIX, "Unable to find Kolab object $config{'kolab_dn'}", KOLAB_WARN);
+            } else {
+                my $ldapobject = $mesg->pop_entry;
+                foreach $tempval ($ldapobject->attributes) {
+                    $config{$tempval} = $ldapobject->get_value($tempval);
+                }
+            }
+        }
+    }
 
-    # TODO: set any necessary defaults
-    # TODO: interpolate any necessray vars
+    if (defined($ldap) && $ldap->isa('Net::LDAP')) {
+        $ldap->unbind;
+        $ldap->disconnect;
+    }
+
+    # At this point we have read in all the configuration variables we can, so
+    # now we set up any other dependant variables that need setting.
+
+    $config{'fqdn'} = trim(`hostname`);
+
+    # ProFTPd password
+    if (exists $config{'proftpd-userPassword'}) {
+        my $salt = substr($config{'proftpd-userPassword'}, 0, 2);
+        $config{'proftpd-userPassword'} = crypt($config{'proftpd-userPassword'}, $salt);
+    } else {
+        $config{'proftpd-userPassword'} = '';
+    }
+
+    # Apache legacy mode
+    $config{'legacy-mode'} = "# no legacy configuration";
+    $config{'legacy-mode'} = "Include \"$config{'kolab_root'}/etc/apache/legacy.conf\""
+        if exists $config{'apache-http'} && $config{'apache-http'} =~ /true/i;
+
+    # Primary Cyrus admin account
+    $tempval = $config{'cyrus-admins'} || 'manager';
+    (my $cmanager, my $dummy) = split(/ /, $tempval, 2);
+    $config{'cyrus_admin'} = $cmanager if !exists $config{'cyrus_admin'};
+    $config{'cyrus_admin_pw'} = $config{'bind_pw'} if !exists $config{'cyrus_admin_pw'};
+
+    # Cyrus interfaces
+    $config{'cyrus_imap_cmd'} = ''
+        if $config{'cyrus-imap'} !~ /true/i;
+
+    $config{'cyrus_pop3_cmd'} = ''
+        if $config{'cyrus-pop3'} !~ /true/i;
+
+    $config{'cyrus_imaps_cmd'} = ''
+        if $config{'cyrus-imaps'} !~ /true/i;
+
+    $config{'cyrus_pop3s_cmd'} = ''
+        if $config{'cyrus-pop3s'} !~ /true/i;
+
+    $config{'cyrus_sieve_cmd'} = ''
+        if $config{'cyrus-sieve'} !~ /true/i;
+
+    # User object defaults
+    $config{'user_ldap_uri'} = $config{'ldap_uri'} if !exists $config{'user_ldap_uri'};
+
+    if (!($tempval = URI->new($config{'user_ldap_uri'}))) {
+        die "Unable to parse user_ldap_uri $config{'user_ldap_uri'}";
+        #&log(PREFIX, "Unable to parse user_ldap_uri $config{'user_ldap_uri'}", KOLAB_WARN);
+    } else {
+        $config{'user_ldap_ip'} = $tempval->host;
+        $config{'user_ldap_port'} = $tempval->port;
+    }
+
+    $config{'user_bind_dn'} = $config{'bind_dn'} if !exists $config{'user_bind_dn'};
+    $config{'user_bind_pw'} = $config{'bind_pw'} if !exists $config{'user_bind_pw'};
+    $config{'user_dn_list'} = $config{'base_dn'} if !exists $config{'user_dn_list'};
+    $config{'user_directory_mode'} = $config{'directory_mode'} if !exists $config{'user_directory_mode'};
+
+    # Shared folder object defaults
+    $config{'sf_ldap_uri'} = $config{'ldap_uri'} if !exists $config{'sf_ldap_uri'};
+
+    if (!($tempval = URI->new($config{'sf_ldap_uri'}))) {
+        die "Unable to parse sf_ldap_uri $config{'sf_ldap_uri'}";
+        #&log(PREFIX, "Unable to parse sf_ldap_uri $config{'sf_ldap_uri'}", KOLAB_WARN);
+    } else {
+        $config{'sf_ldap_ip'} = $tempval->host;
+        $config{'sf_ldap_port'} = $tempval->port;
+    }
+
+    $config{'sf_bind_dn'} = $config{'bind_dn'} if !exists $config{'sf_bind_dn'};
+    $config{'sf_bind_pw'} = $config{'bind_pw'} if !exists $config{'sf_bind_pw'};
+    $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'};
+
+    # Do we need to set anything else?
 }
 
 resetConfig();

Index: kolabd
===================================================================
RCS file: /kolabrepository/devel/kolab/kolabd,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- kolabd	12 May 2004 14:41:06 -0000	1.3
+++ kolabd	13 May 2004 12:05:44 -0000	1.4
@@ -166,7 +166,7 @@
 Kolab::LDAP::Backend::load;
 Kolab::LDAP::Backend::load('user');
 Kolab::LDAP::Backend::load('sf');
-Kolab::LDAP::Backend::load('dirservd',1);
+Kolab::LDAP::Backend::load('dirservd', 1);
 
 Kolab::log(PREFIX, 'Performing backend startup');
 &Kolab::LDAP::Backend::startup;





More information about the commits mailing list