summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d427e71)
raw | patch | inline | side by side (parent: d427e71)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 20 Mar 2008 15:06:33 +0000 (15:06 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 20 Mar 2008 15:06:33 +0000 (15:06 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9956 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index d3328ea86c32088a2d72ad4a31f545b8f61e4c21..fc71afdc8c33cf66d5933a6f83018cd70feedb9b 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
$client_address= "$client_ip:$client_port";
$client_mac_address = $local_mac;
$client_dnsname = $dnsname;
+ last;
# delivery of registration msg failed
} else {
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 75d9e340d43ab284c14b70d35a9d51e15a03afb7..cb759af22cdd18b31ae4d14ab575408d268cc7b2 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
# - ist es nicht vorhanden, wird es erzeugt, im heap für spätere ldap anfragen gespeichert und zurückgegeben
# - sessions die kein ldap handle brauchen, sollen auch keins haben
# - wird eine session geschlossen, muss das ldap verbindung vorher beendet werden
-#our $global_kernel;
+our $global_kernel;
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
our $verbose;
our $forground;
our $cfg_file;
-our ($ldap_handle, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+#our ($ldap_handle, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+our ($ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
# specifies the verbosity of the daemon_log
sub sig_int_handler {
my ($signal) = @_;
- if (defined($ldap_handle)) {
- $ldap_handle->disconnect;
- }
+# if (defined($ldap_handle)) {
+# $ldap_handle->disconnect;
+# }
+ # TODO alle verbliebenden ldap verbindungen aus allen heaps beenden
+
daemon_log("shutting down gosa-si-server", 1);
system("killall gosa-si-server");
if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
# if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client
# could not understand a msg from its server the client cause a re-registering process
+ daemon_log("$session_id INFO cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}."' to cause a re-registering of the client if necessary", 5);
my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')";
my $query_res = $known_clients_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
my ($session_id) = @_;
my $heap;
my $ldap_handle;
-
- if (not defined $session_id) {
- daemon_log("0 DEBUG: need a session_id to fetch the correct ldap handle", 7);
- return;
- }
-
- my $session_reference = $global_kernel->ID_id_to_session($session_id);
- if( defined $session_reference ) {
- $heap = $session_reference->get_heap();
- }
-
- if (not defined $heap) {
- daemon_log("$session_id DEBUG: cannot get heap for session_id '$session_id'", 7);
- return;
- }
-
- if (not exists $heap->{ldap_handle}) {
- # create new ldap handle
- my $ldap_handle = Net::LDAP->new( $ldap_uri );
- # add ldap handle to heap
- $heap->{ldap_handle} = $ldap_handle;
- }
-
- $ldap_handle = $heap->{ldap_handle};
+ if (not defined $session_id ) { $session_id = 0 };
- return \$ldap_handle;
-}
+ if ($session_id == 0) {
+ daemon_log("$session_id DEBUG: get_ldap_handle invoked without a session_id, create a new ldap_handle", 7);
+ $ldap_handle = Net::LDAP->new( $ldap_uri );
+ } else {
+ my $session_reference = $global_kernel->ID_id_to_session($session_id);
+ if( defined $session_reference ) {
+ $heap = $session_reference->get_heap();
+ }
-sub refresh_ldap_handle {
- my ($session_id) = @_ ;
- if (not defined $session_id) { $session_id = 0; }
-
- my $mesg;
-
- daemon_log("$session_id DEBUG: Trying to create a connection to URI '$ldap_uri'", 7);
- # Get an ldap handle, if we don't have one
- if( ! defined $ldap_handle ){
- $ldap_handle = Net::LDAP->new( $ldap_uri );
- }
- # Still not defined?
- if( ! defined $ldap_handle ) {
- daemon_log( "$session_id ERROR: ch $$: Net::LDAP constructor failed: $!\n" );
- return 0;
- }
+ if (not defined $heap) {
+ daemon_log("$session_id DEBUG: cannot get heap for session_id '$session_id'", 7);
+ return;
+ }
- # Bind to ldap server - eventually authenticate
- if( defined $ldap_admin_dn ) {
- if( defined $ldap_admin_password ) {
- $mesg = $ldap_handle->bind( $ldap_admin_dn, password => $ldap_admin_password );
- } else {
- $mesg = $ldap_handle->bind( $ldap_admin_dn );
+ if (not exists $heap->{ldap_handle}) {
+ # create new ldap handle
+ $ldap_handle = Net::LDAP->new( $ldap_uri );
+ # add ldap handle to heap
+ $heap->{ldap_handle} = $ldap_handle;
+ }
}
- } else {
- $mesg = $ldap_handle->bind();
- }
- if( 0 != $mesg->code ) {
- undef( $ldap_handle ) if( 81 == $mesg->code );
- daemon_log( "$session_id ERROR: ch $$: LDAP bind: error (". $mesg->code . ') - ' . $mesg->error . "\n", 1);
- return 0;
- }
- daemon_log("$session_id DEBUG: create a new connection to URI '$ldap_uri'", 7);
- return 1;
+
+ return $ldap_handle;
}
my $state= $mapActions{ $st };
- &refresh_ldap_handle();
-# my $ldap_handle = get_ldap_handle($session_id);
+ my $ldap_handle = get_ldap_handle($session_id);
if( defined($ldap_handle) ) {
# Build search filter for hosts
} else {
daemon_log("$session_id ERROR: no LDAP handle defined for update FAIstate", 1);
}
+
}
# Switch on or off?
my $state= $st eq 'active' ? 'active': 'locked';
- &refresh_ldap_handle();
+ my $ldap_handle = &get_ldap_handle($session_id);
if( defined($ldap_handle) ) {
# Build search filter for hosts
sub create_fai_server_db {
my ($table_name, $kernel) = @_;
my $result;
-
+ my $ldap_handle = &get_ldap_handle();
if(defined($ldap_handle)) {
daemon_log("INFO: create_fai_server_db: start", 5);
my $mesg= $ldap_handle->search(
daemon_log("INFO: create_fai_server_db: finished", 5);
# TODO: Find a way to post the 'create_packages_list_db' event
- &create_packages_list_db();
+ &create_packages_list_db($ldap_handle);
}
-
+
+ $ldap_handle->disconnect;
return $result;
}
my ($table_name) = @_;
my $result;
+ my $ldap_handle = &get_ldap_handle();
if(defined($ldap_handle)) {
daemon_log("INFO: create_fai_release_db: start",5);
my $mesg= $ldap_handle->search(
my @sql_list;
my $timestamp= &get_time();
foreach my $ou (@{$mesg->{entries}}) {
- my $tmp_classes= resolve_fai_classes($ou->dn);
+ my $tmp_classes= resolve_fai_classes($ou->dn, $ldap_handle);
if(defined($tmp_classes) && ref($tmp_classes) eq 'HASH') {
my @tmp_array=get_fai_release_entries($tmp_classes);
if(@tmp_array) {
}
daemon_log("INFO: create_fai_release_db: finished",5);
}
-
+ $ldap_handle->disconnect;
return $result;
}
sub run_create_fai_release_db {
}
sub resolve_fai_classes {
+ my ($fai_base, $ldap_handle) = @_;
my $result;
- my $fai_base= shift;
my @possible_fai_classes= ("FAIscript", "FAIhook", "FAIpartitionTable", "FAItemplate", "FAIvariable", "FAIprofile", "FAIpackageList");
my $fai_filter= "(|(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))(objectClass=FAIbranch))";
my $fai_classes;
}
sub create_sources_list {
+ my ($ldap_handle) = @_;
my $result="/tmp/gosa_si_tmp_sources_list";
# Remove old file
}
sub create_packages_list_db {
- my ($sources_file) = @_ || &create_sources_list;
+ my ($ldap_handle, $sources_file) = @_ ;
+
+ if (not defined $ldap_handle) {
+ daemon_log("0 ERROR: no ldap_handle available to create_packages_list_db", 1);
+ return;
+ }
+ if (not defined $sources_file) {
+ $sources_file = &create_sources_list($ldap_handle);
+ }
+
my $line;
daemon_log("INFO: create_packages_list_db: start", 5);
index e920e623045883c54244cb46fe5b5bb634d9d7f2..d6da11d4b204733ac2ee10e7c1a3b1998ba9270e 100644 (file)
&main::daemon_log("Loading OUI cache file suceeded!", 6);
}
}
+ my $ldap_handle = &main::get_ldap_handle();
if(defined($ldap_uri) && length($ldap_uri)>0) {
- &main::refresh_ldap_handle();
- if (!$main::ldap_handle) {
+ if (!$ldap_handle) {
&main::daemon_log("Could not connect to LDAP Server at $ldap_uri!\n$@", 1);
}
} else {
- $main::ldap_handle= undef;
+ $ldap_handle= undef;
}
# When interface is not configured (or 'all'), start arpwatch on all possible interfaces
my $capture_device = sprintf "%s", $kernel->alias_list($sender) =~ /^arp_watch_(.*)$/;
- if(!exists($hosts_database->{$packet->{source_haddr}})) {
+ my $ldap_handle = &main::get_ldap_handle();
+ if(!exists($hosts_database->{$packet->{source_haddr}})) {
my $dnsname= gethostbyaddr(inet_aton($packet->{source_ipaddr}), AF_INET) || $packet->{source_ipaddr};
my $ldap_result=&get_host_from_ldap($packet->{source_haddr});
if(exists($ldap_result->{dn})) {
": ".$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}.
"/".$hosts_database->{$packet->{source_haddr}}->{macAddress},4);
&add_ldap_entry(
- $main::ldap_handle,
+ $ldap_handle,
$ldap_base,
$hosts_database->{$packet->{source_haddr}}->{macAddress},
'new-system',
"->".$packet->{source_ipaddr}, 4);
$hosts_database->{$packet->{source_haddr}}->{ipHostNumber}= $packet->{source_ipaddr};
&change_ldap_entry(
- $main::ldap_handle,
+ $ldap_handle,
$ldap_base,
$hosts_database->{$packet->{source_haddr}}->{macAddress},
'ip-changed',
my $mac=shift;
my $result={};
- if(defined($main::ldap_handle)) {
+ my $ladp_handle = &get_ldap_handle();
+ if(defined($ldap_handle)) {
my $ldap_result= &search_ldap_entry(
- $main::ldap_handle,
+ $ldap_handle,
$ldap_base,
"(|(macAddress=$mac)(dhcpHWAddress=ethernet $mac))"
);
if (defined($ip)) {
$replace->{'ipHostNumber'} = $ip;
}
- my $result = $main::ldap_handle->modify( $dn, replace => $replace );
+ my $result = $ldap_tree->modify( $dn, replace => $replace );
# for $result->code constants please look at Net::LDAP::Constant
if($result->code == 32) { # entry doesnt exists
index daaa161e18e40c6af1f200de1987d0492d699f9a..265b72416811b3e02254709ee2649e8b73710a31 100644 (file)
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
# Read gosaUnitTag from LDAP
- &main::refresh_ldap_handle();
- if( defined($main::ldap_handle) ) {
+
+ my $ldap_handle = &main::get_ldap_handle();
+ if( defined($ldap_handle) ) {
&main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $main::server_mac_address",5);
# Perform search for Unit Tag
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
my $hostname= `hostname -f`;
chomp($hostname);
&main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
$hostname= `hostname -s`;
chomp($hostname);
&main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5);
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['gosaUnitTag'],
}
# Build LDAP connection
- &main::refresh_ldap_handle();
- if( not defined $main::ldap_handle ) {
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
&main::daemon_log("$session_id ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
# Perform search
- $mesg = $main::ldap_handle->search( base => $ldap_base,
+ $mesg = $ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'gotoLdapServer', 'gosaUnitTag', 'FAIclass'],
filter => "(&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))");
# Do we need to look at an object class?
if (length(@servers) < 1){
- $mesg = $main::ldap_handle->search( base => $ldap_base,
+ $mesg = $ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'gotoLdapServer', 'FAIclass'],
filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
if (defined $unit_tag){
# Find admin base and department name
- $mesg = $main::ldap_handle->search( base => $ldap_base,
+ $mesg = $ldap_handle->search( base => $ldap_base,
scope => 'sub',
attrs => ['dn', 'ou'],
filter => "(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$unit_tag))");
}
# Build LDAP connection
- &main::refresh_ldap_handle();
- if( not defined $main::ldap_handle ) {
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
# Perform search
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
if (defined($entry->get_value("gotoHardwareChecksum"))) {
if (! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) {
$entry->replace(gotoHardwareChecksum => $gotoHardwareChecksum);
- if($entry->update($main::ldap_handle)) {
+ if($entry->update($ldap_handle)) {
&main::daemon_log("$session_id INFO: Hardware changed! Detection triggered.", 5);
}
} else {
index 7c15ab22b5fc22faf0f9e4f5933cbe77cc9fc65b..b95f0d5c955a6693266fbe95938cedb57da61b7e 100644 (file)
}
+ my $ldap_handle = &main::get_ldap_handle($session_id);
# resolve groups to users
if( @group_list ) {
# build ldap connection
- &main::refresh_ldap_handle();
- if( not defined $main::ldap_handle ) {
+ if( not defined $ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap", 1);
return ();
}
foreach my $group (@group_list) {
# Perform search
- my $mesg = $main::ldap_handle->search(
+ my $mesg = $ldap_handle->search(
base => $main::ldap_base,
scope => 'sub',
attrs => ['memberUid'],
index 53ae3d58fc916564ea2bf1fb035105d9ed7f644d..104cd8f1fbf1d9f9e1299c96f45ceba2b5488e80 100644 (file)
return;
}
# Build LDAP connection
- &main::refresh_ldap_handle();
- if( not defined $main::ldap_handle ) {
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
&main::daemon_log("ERROR: cannot connect to ldap: $ldap_uri", 1);
return;
}
# Perform search
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
$entry->add("objectClass" => "gosaAdministrativeUnitTag");
$entry->add("gosaUnitTag" => $main::gosa_unit_tag);
}
- my $res=$entry->update($main::ldap_handle);
+ my $res=$entry->update($ldap_handle);
if(defined($res->{'errorMessage'}) &&
length($res->{'errorMessage'}) >0) {
&main::daemon_log("ERROR: can not add entries to LDAP: ".$res->{'errorMessage'}, 1);
return;
} else {
# Fill $mesg again
- $mesg = $main::ldap_handle->search(
+ $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
filter => "(&(objectClass=GOhard)(|(macAddress=$macaddress)(dhcpHWaddress=ethernet $macaddress)))"
}
}
- my $res=$entry->update($main::ldap_handle);
+ my $res=$entry->update($ldap_handle);
if(defined($res->{'errorMessage'}) &&
length($res->{'errorMessage'}) >0) {
&main::daemon_log("ERROR: can not add entries to LDAP: ".$res->{'errorMessage'}, 1);
index 6bf855f1626d239addabb2b478eeed0d17e9b698..5b81853b0f5928c0e3a19ee0dc8ad6b5964f5f7c 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_gen_smb_hash</header> <source>GOSA</source><target>GOSA</target><password>tester</password></xml>";
# Reload ldap config
-#$data = "<xml> <header>gosa_trigger_reload_ldap_config</header> <source>GOSA</source><target>00:01:6c:9d:b9:fa</target></xml>";
+$data = "<xml> <header>gosa_trigger_reload_ldap_config</header> <source>GOSA</source><target>00:01:6c:9d:b9:fa</target></xml>";
# jobdb update
#$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase> <id>1</id></phrase></clause></where> <update><timestamp>19700101000000</timestamp></update></xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>job_trigger_action_wake</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp></xml>";
#$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
-$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>19700101000000</timestamp> </xml>";
+#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>19700101000000</timestamp> </xml>";
#$data = "<xml> <header>job_trigger_action_instant_update</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp> </xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";