Code

Hard coded ldap-shell.conf. Need to place it somewhere else later.
[gosa.git] / gosa-si / client / events / corefunctions.pm
index 892a561f04b335d7daeadf39426958ea658de474..70d3bff70d5ff16501bdb9ed69baa455d324ebfa 100644 (file)
@@ -18,12 +18,9 @@ use strict;
 use warnings;
 use Data::Dumper;
 use Fcntl;
-use utf8;
-use open ':utf8';
 use GOSA::GosaSupportDaemon;
 use File::Basename;
 
-
 my ($ldap_enabled, $ldap_config, $pam_config, $nss_config, $fai_logpath);
 
 
@@ -32,7 +29,7 @@ my %cfg_defaults = (
         "ldap" => [\$ldap_enabled, 1],
         "ldap-config" => [\$ldap_config, "/etc/ldap/ldap.conf"],
         "pam-config" => [\$pam_config, "/etc/pam_ldap.conf"],
-        "nss-config" => [\$nss_config, "/etc/libnss_ldap.conf"],
+        "nss-config" => [\$nss_config, "/etc/libnss-ldap.conf"],
         "fai-logpath" => [\$fai_logpath, "/var/log/fai/fai.log"],
     },
 );
@@ -114,6 +111,7 @@ sub registered {
     my $opts_file_FH;
     my $hostname= $main::client_dnsname;
     $hostname =~ s/\..*$//;
+    $hostname =~ tr/A-Z/a-z/;
     open($opts_file_FH, ">$main::opts_file");
     print $opts_file_FH "MAC=\"$main::client_mac_address\"\n";
     print $opts_file_FH "IPADDRESS=\"$main::client_ip\"\n";
@@ -123,6 +121,11 @@ sub registered {
                   @{$msg_hash->{'ldap_available'}}[0] eq "true") {
        print $opts_file_FH "LDAP_AVAILABLE=\"true\"\n";
        }
+    if(defined(@{$msg_hash->{'error'}})) {
+               my $errormsg= @{$msg_hash->{'error'}}[0];
+       print $opts_file_FH "GOSA_SI_ERROR=\"$errormsg\"\n";
+               &write_to_file($errormsg, $fai_logpath);
+       }
     close($opts_file_FH);
      
     my $out_msg = &create_xml_string($out_hash);
@@ -233,6 +236,7 @@ sub new_ldap_config {
     my $file1;
     my $file2;
     open(file1, "> $ldap_config");
+#print STDERR Dumper(PerlIO::get_layers(file1, output => 1));
     print file1 "# This file was automatically generated by gosa-si-client. Do not change.\n";
     print file1 "URI";
     foreach $element (@ldap_uris) {
@@ -245,7 +249,7 @@ sub new_ldap_config {
     close (file1);
     daemon_log("wrote $ldap_config", 5);
 
-    # Setup pam_ldap.conf / libnss_ldap.conf
+    # Setup pam_ldap.conf / libnss-ldap.conf
     open(file1, "> $pam_config");
     open(file2, "> $nss_config");
     print file1 "# This file was automatically generated by gosa-si-client. Do not change.\n";
@@ -282,7 +286,7 @@ sub new_ldap_config {
     }
 
     # Write shell based config
-    my $cfg_name= dirname($ldap_config)."/ldap-shell.conf";
+    my $cfg_name= "/etc/ldap/ldap-shell.conf";
 
     # Get first LDAP server
     my $ldap_server= $ldap_uris[0];
@@ -291,6 +295,7 @@ sub new_ldap_config {
     open(file1, "> $cfg_name");
     print file1 "LDAP_BASE=\"$ldap_base\"\n";
     print file1 "LDAP_SERVER=\"$ldap_server\"\n";
+    print file1 "LDAP_URIS=\"@ldap_uris\"\n";
     print file1 "ADMIN_BASE=\"$admin_base\"\n";
     print file1 "DEPARTMENT=\"$department\"\n";
     print file1 "RELEASE=\"$release\"\n";
@@ -309,6 +314,11 @@ sub new_key {
 
     my $out_hash = &create_xml_hash("new_key", $main::client_address, $main::server_address, $new_server_key);    
     my $out_msg = &create_xml_string($out_hash);
+
+    # set global $NEW_KEY_FLAG, gosa-si-client cause a reregistering process if no 'confirm_new_key'-msg 
+    # comes from gosa-si-server within a given time
+    
+
     return $out_msg; 
 }