From: cajus Date: Fri, 4 Jan 2008 13:48:13 +0000 (+0000) Subject: Updated package to write goto information, too X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b1ea8a125ced4a00920b94ebac8fd8d7af390b34;p=gosa.git Updated package to write goto information, too git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8221 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index b69c34782..efb794374 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -41,7 +41,7 @@ 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, $ldap_config, $pam_config, $nss_config); -my ($input_socket, $rbits, $wbits, $ebits, $xml, $known_hosts); +my ($input_socket, $rbits, $wbits, $ebits, $xml, $known_hosts, $ldap_enabled); my (@events); # default variables @@ -55,6 +55,7 @@ $foreground = 0 ; }, "client" => {"client_port" => [\$client_port, "20083"], + "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"], @@ -858,9 +859,7 @@ sub process_incoming_msg { close(DIR); daemon_log("could not assign the msg $header to an event", 5); - - - if ($header eq 'new_ldap_config') { &new_ldap_config($msg_hash)} + if ($header eq 'new_ldap_config') { if ($ldap_enabled == 1) {&new_ldap_config($msg_hash)}} elsif ($header eq 'ping') { &got_ping($msg_hash) } elsif ($header eq 'wake_up') { &execute_event($msg_hash)} elsif ($header eq 'new_passwd') { &new_passwd()} @@ -935,6 +934,8 @@ sub new_ldap_config { my @ldap_options; my @pam_options; my @nss_options; + my $goto_admin; + my $goto_secret; # Transform input into array while ( my ($key, $value) = each(%$msg_hash) ) { @@ -951,6 +952,14 @@ sub new_ldap_config { $ldap_base= $element; next; } + if ($key =~ /^goto_admin$/) { + $goto_admin= $element; + next; + } + if ($key =~ /^goto_secret$/) { + $goto_secret= $element; + next; + } if ($key =~ /^ldap_cfg$/) { push (@ldap_options, "$element"); next; @@ -1006,6 +1015,18 @@ sub new_ldap_config { close (file1); daemon_log("wrote $pam_config", 5); + # Create goto.secrets if told so + if (defined $goto_admin){ + open(file1, "> /etc/goto/secret"); + close(file1); + chown(0,0, "/etc/goto/secret"); + chmod(0600, "/etc/goto/secret"); + open(file1, "> /etc/goto/secret"); + print file1 $goto_admin.":".$goto_secret."\n"; + close(file1); + daemon_log("wrote /etc/goto/secret", 5); + } + return; } diff --git a/gosa-si/modules/ServerPackages.pm b/gosa-si/modules/ServerPackages.pm index b5fa53c44..846eed111 100644 --- a/gosa-si/modules/ServerPackages.pm +++ b/gosa-si/modules/ServerPackages.pm @@ -21,7 +21,7 @@ my ($server_activ, $server_port, $server_passwd, $max_clients, $ldap_uri, $ldap_ my ($bus_activ, $bus_passwd, $bus_ip, $bus_port); my $server; my $no_bus; -my (@ldap_cfg, @pam_cfg, @nss_cfg); +my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret); my %cfg_defaults = ("server" => @@ -154,6 +154,13 @@ sub read_configfile { push (@nss_cfg, "$param ".$cfg->val('nss_ldap', $param)); } } + if ($cfg->SectionExists('goto')){ + $goto_admin= $cfg->val('goto', 'terminal_admin'); + $goto_secret= $cfg->val('goto', 'terminal_secret'); + } else { + $goto_admin= undef; + $goto_secret= undef; + } } @@ -547,67 +554,75 @@ sub new_ldap_config { return; } - # Build LDAP connection - my $ldap; - $ldap= Net::LDAP->new($ldap_uri); + # Build LDAP connection + my $ldap; + $ldap= Net::LDAP->new($ldap_uri); - # Bind to a directory with dn and password - my $mesg= $ldap->bind($ldap_admin_dn, $ldap_admin_password); + # Bind to a directory with dn and password + my $mesg= $ldap->bind($ldap_admin_dn, $ldap_admin_password); - # Perform search - $mesg = $ldap->search( base => $ldap_base, - scope => 'sub', - attrs => ['dn', 'gotoLdapServer'], - filter => "(&(objectClass=GOhard)(macaddress=$mac_address))"); - $mesg->code && die $mesg->error; + # Perform search + $mesg = $ldap->search( base => $ldap_base, + scope => 'sub', + attrs => ['dn', 'gotoLdapServer'], + filter => "(&(objectClass=GOhard)(macaddress=$mac_address))"); + $mesg->code && die $mesg->error; - # Sanity check - if ($mesg->count != 1) { - &main::daemon_log("WARNING: client mac address $mac_address not found/not unique", 1); - return; - } - - my $entry= $mesg->entry(0); - my $dn= $entry->dn; - my @servers= $entry->get_value("gotoLdapServer"); - my @ldap_uris; - my $server; - my $base; - - # Do we need to look at an object class? - if ($#servers < 1){ - $mesg = $ldap->search( base => $ldap_base, - scope => 'sub', - attrs => ['dn', 'gotoLdapServer'], - filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))"); - $mesg->code && die $mesg->error; - - # Sanity check - if ($mesg->count != 1) { - &main::daemon_log("WARNING: no LDAP information found for client mac $mac_address", 1); - return; - } + # Sanity check + if ($mesg->count != 1) { + &main::daemon_log("WARNING: client mac address $mac_address not found/not unique", 1); + return; + } - $entry= $mesg->entry(0); - $dn= $entry->dn; - @servers= $entry->get_value("gotoLdapServer"); - } + my $entry= $mesg->entry(0); + my $dn= $entry->dn; + my @servers= $entry->get_value("gotoLdapServer"); + my @ldap_uris; + my $server; + my $base; + + # Do we need to look at an object class? + if ($#servers < 1){ + $mesg = $ldap->search( base => $ldap_base, + scope => 'sub', + attrs => ['dn', 'gotoLdapServer'], + filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))"); + $mesg->code && die $mesg->error; + + # Sanity check + if ($mesg->count != 1) { + &main::daemon_log("WARNING: no LDAP information found for client mac $mac_address", 1); + return; + } + + $entry= $mesg->entry(0); + $dn= $entry->dn; + @servers= $entry->get_value("gotoLdapServer"); + } - @servers= sort (@servers); + @servers= sort (@servers); - foreach $server (@servers){ - $base= $server; - $server =~ s%^[^:]+:[^:]+:(ldap.*://[^/]+)/.*$%$1%; - $base =~ s%^[^:]+:[^:]+:ldap.*://[^/]+/(.*)$%$1%; - push (@ldap_uris, $server); - } + foreach $server (@servers){ + $base= $server; + $server =~ s%^[^:]+:[^:]+:(ldap.*://[^/]+)/.*$%$1%; + $base =~ s%^[^:]+:[^:]+:ldap.*://[^/]+/(.*)$%$1%; + push (@ldap_uris, $server); + } - # Unbind - $mesg = $ldap->unbind; + # Unbind + $mesg = $ldap->unbind; - # Send information + # Assemble data package my %data = ( 'ldap_uri' => \@ldap_uris, 'ldap_base' => $base, 'ldap_cfg' => \@ldap_cfg, 'pam_cfg' => \@pam_cfg,'nss_cfg' => \@nss_cfg ); + + # Need to append GOto settings? + if (defined $goto_admin and defined $goto_secret){ + $data{'goto_admin'}= $goto_admin; + $data{'goto_secret'}= $goto_secret; + } + + # Send information send_msg("new_ldap_config", $server_address, $address, \%data); return;