From: cajus Date: Thu, 3 Jan 2008 16:56:43 +0000 (+0000) Subject: Added support for writing ldap configs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=da8d9cefa9174b3cfa792f5550a113eed574e573;p=gosa.git Added support for writing ldap configs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8199 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 141aa3e1d..b261e3d8c 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -3,7 +3,7 @@ # # FILE: gosa-server # -# USAGE: ./gosasc +# USAGE: gosa-si-client # # DESCRIPTION: # @@ -40,12 +40,12 @@ use GOSA::GosaSupportDaemon; my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file); my ($server_address, $server_ip, $server_port, $server_domain, $server_passwd, $server_cipher, $server_timeout); -my ($client_address, $client_ip, $client_port, $client_mac_address); +my ($client_address, $client_ip, $client_port, $client_mac_address, $ldap_config, $pam_config, $nss_config); my ($input_socket, $rbits, $wbits, $ebits, $xml, $known_hosts); my (@events); # default variables -my $event_dir = "/etc/gosac/events"; +my $event_dir = "/etc/gosa-si/client/events"; $known_hosts = {}; $foreground = 0 ; %cfg_defaults = @@ -55,6 +55,9 @@ $foreground = 0 ; }, "client" => {"client_port" => [\$client_port, "20083"], + "ldap_config" => [\$ldap_config, "/etc/ldap/ldap.conf"], + "pam_config" => [\$pam_config, "/etc/pam_ldap.conf"], + "nss_config" => [\$nss_config, "/etc/libnss_ldap.conf"], }, "server" => {"server_ip" => [\$server_ip, ""], @@ -306,7 +309,7 @@ sub register_at_server { # detect all client accepted events opendir(DIR, $event_dir) - or daemon_log("cannot find directory $event_dir!\ngosac starts without any accepting events!", 1); + or daemon_log("cannot find directory $event_dir!\ngosa-si-client starts without any accepting events!", 1); my $file_name; @events = (); while(defined($file_name = readdir(DIR))){ @@ -926,10 +929,84 @@ sub got_ping { sub new_ldap_config { my ($msg_hash) = @_ ; + my $element; + my @ldap_uris; + my $ldap_base; + my @ldap_options; + my @pam_options; + my @nss_options; + + # Transform input into array + while ( my ($key, $value) = each(%$msg_hash) ) { + if ($key =~ /^(source|target|header)$/) { + next; + } + + foreach $element (@$value) { + if ($key =~ /^ldap_uri$/) { + push (@ldap_uris, $element); + next; + } + if ($key =~ /^ldap_base$/) { + $ldap_base= $element; + next; + } + if ($key =~ /^ldap_/) { + my $post =~ s/^ldap_//; + push (@ldap_options, "$post $element"); + next; + } + if ($key =~ /^pam_/) { + my $post =~ s/^pam_//; + push (@pam_options, "$post $element"); + next; + } + if ($key =~ /^nss_/) { + my $post =~ s/^nss_//; + push (@nss_options, "$post $element"); + next; + } + } + } - my @gotoLdapServer = &get_content_from_xml_hash($msg_hash, "new_ldap_config"); - print Dumper @gotoLdapServer; - + # Setup ldap.conf + my $file; + my $file2; + open(file, "> $ldap_config"); + print file "# This file was automatically generated by gosa-si-client. Do not change.\n"; + print file "URI"; + foreach $element (@ldap_uris) { + print file " $element"; + } + print file "\nBASE $ldap_base\n"; + foreach $element (@ldap_options) { + print file "$element"; + } + close (file); + daemon_log("wrote $ldap_config", 5); + + # Setup pam_ldap.conf / libnss_ldap.conf + open(file, "> $pam_config"); + open(file2, "> $nss_config"); + print file "# This file was automatically generated by gosa-si-client. Do not change.\n"; + print file2 "# This file was automatically generated by gosa-si-client. Do not change.\n"; + print file "uri"; + print file2 "uri"; + foreach $element (@ldap_uris) { + print file " $element"; + print file2 " $element"; + } + print file "\nbase $ldap_base\n"; + foreach $element (@pam_options) { + print file "$element"; + } + foreach $element (@nss_options) { + print file2 "$element"; + } + close (file2); + daemon_log("wrote $nss_config", 5); + close (file); + daemon_log("wrote $pam_config", 5); return; @@ -938,7 +1015,7 @@ sub new_ldap_config { sub execute_event { my ($msg_hash)= @_; - my $configdir= '/etc/gosac/events/'; + my $configdir= '/etc/gosa-si/client/events/'; my $result; my $header = &get_content_from_xml_hash($msg_hash, 'header'); @@ -949,7 +1026,7 @@ sub execute_event { if((not defined $source) && (not defined $target) && (not defined $header)) { - daemon_log("ERROR: Entries missing in XML msg for gosa events under /etc/gosac/events"); + daemon_log("ERROR: Entries missing in XML msg for gosa events under $configdir"); } else { my $parameters=""; my @params = &get_content_from_xml_hash($msg_hash, $header); diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index d6a7f0044..bc5458af4 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -2,7 +2,7 @@ package GOSA::GosaSupportDaemon; use Exporter; @ISA = qw(Exporter); -@EXPORT = qw(create_xml_hash send_msg_hash2address get_content_from_xml_hash add_content2xml_hash create_xml_string encrypt_msg decrypt_msg create_ciphering transform_msg2hash); +@EXPORT = qw(create_xml_hash send_msg_hash2address get_content_from_xml_hash add_content2xml_hash create_xml_string encrypt_msg decrypt_msg create_ciphering transform_msg2hash send_msg); use strict; use warnings;