diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index de1958c1513acc9424394313d144ddc1ce809535..2252d5960b9e50ef380d149d6b8f1dc8c01e8c12 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
use strict;
use warnings;
use strict;
use warnings;
+use utf8;
use Getopt::Long;
use Config::IniFiles;
use POSIX;
use Time::HiRes qw( gettimeofday );
use Getopt::Long;
use Config::IniFiles;
use POSIX;
use Time::HiRes qw( gettimeofday );
-use POE qw(Component::Server::TCP);
+use POE qw(Component::Server::TCP Wheel::FollowTail);
use IO::Socket::INET;
use NetAddr::IP;
use Data::Dumper;
use IO::Socket::INET;
use NetAddr::IP;
use Data::Dumper;
use MIME::Base64;
use XML::Simple;
use Net::DNS;
use MIME::Base64;
use XML::Simple;
use Net::DNS;
+use File::Basename;
my $event_dir = "/usr/lib/gosa-si/client/events";
use lib "/usr/lib/gosa-si/client/events";
my $event_dir = "/usr/lib/gosa-si/client/events";
use lib "/usr/lib/gosa-si/client/events";
-my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file, $fai_logpath);
+my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $opts_file, $procid, $pid, $log_file, $fai_logpath);
my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain, $server_key_lifetime);
my ($client_ip, $client_port, $client_mac_address, $ldap_enabled, $ldap_config, $pam_config, $nss_config);
my $xml;
my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain, $server_key_lifetime);
my ($client_ip, $client_port, $client_mac_address, $ldap_enabled, $ldap_config, $pam_config, $nss_config);
my $xml;
my $event_hash;
my @servers;
my $gotoHardwareChecksum;
my $event_hash;
my @servers;
my $gotoHardwareChecksum;
+my $gosa_si_client_fifo;
+my %files_to_watch;
+$verbose= 1;
# globalise variables which are used in imported events
our $cfg_file;
# globalise variables which are used in imported events
our $cfg_file;
# default variables
our $REGISTERED = 0;
# default variables
our $REGISTERED = 0;
+# path to fifo for non-gosa-si-client messages to gosa-si-server
+$gosa_si_client_fifo = "/var/run/gosa-si-client.socket";
+%files_to_watch = (fifo => $gosa_si_client_fifo);
+
+# in function register_at_gosa_si_server, after which period of seconds a new registration should be tried if a registration was
+# not successful until now
+my $delay_set_time = 5;
+our $prg= basename($0);
+
%cfg_defaults = (
"general" =>
%cfg_defaults = (
"general" =>
- {"log-file" => [\$log_file, "/var/run/".$0.".log"],
- "pid-file" => [\$pid_file, "/var/run/".$0.".pid"],
+ {"log-file" => [\$log_file, "/var/run/".$prg.".log"],
+ "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"],
+ "opts-file" => [\$opts_file, "/var/run/".$prg.".opts"],
},
"client" =>
{"port" => [\$client_port, "20083"],
},
"client" =>
{"port" => [\$client_port, "20083"],
}
}
+sub sig_int_handler {
+ my ($signal) = @_;
+
+ daemon_log("shutting down gosa-si-server", 1);
+ exit(1);
+}
+$SIG{INT} = \&sig_int_handler;
+
+
#=== FUNCTION ================================================================
# NAME: logging
# PARAMETERS: level - string - default 'info'
#=== FUNCTION ================================================================
# NAME: logging
# PARAMETERS: level - string - default 'info'
$month = $monthnames[$month];
$monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday;
$year+=1900;
$month = $monthnames[$month];
$monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday;
$year+=1900;
- my $name = $0;
- $name =~ s/\.\///;
- my $log_msg = "$month $monthday $hours:$minutes:$seconds $name $msg\n";
+ my $log_msg = "$month $monthday $hours:$minutes:$seconds $prg $msg\n";
print LOG_HANDLE $log_msg;
if( $foreground ) {
print STDERR $log_msg;
print LOG_HANDLE $log_msg;
if( $foreground ) {
print STDERR $log_msg;
return $result;
}
return $result;
}
-sub new_ldap_config {
- my ($msg_hash) = @_ ;
- my $element;
- my @ldap_uris;
- my $ldap_base;
- my @ldap_options;
- my @pam_options;
- my @nss_options;
- my $goto_admin;
- my $goto_secret;
- my $admin_base= "";
- my $department= "";
- my $release= "";
- my $unit_tag;
-
- # 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 =~ /^goto_admin$/) {
- $goto_admin= $element;
- next;
- }
- if ($key =~ /^goto_secret$/) {
- $goto_secret= $element;
- next;
- }
- if ($key =~ /^ldap_cfg$/) {
- push (@ldap_options, "$element");
- next;
- }
- if ($key =~ /^pam_cfg$/) {
- push (@pam_options, "$element");
- next;
- }
- if ($key =~ /^nss_cfg$/) {
- push (@nss_options, "$element");
- next;
- }
- if ($key =~ /^admin_base$/) {
- $admin_base= $element;
- next;
- }
- if ($key =~ /^department$/) {
- $department= $element;
- next;
- }
- if ($key =~ /^unit_tag$/) {
- $unit_tag= $element;
- next;
- }
- if ($key =~ /^release$/) {
- $release= $element;
- next;
- }
- }
- }
-
- # Unit tagging enabled?
- if (defined $unit_tag){
- push (@pam_options, "pam_filter gosaUnitTag=$unit_tag");
- push (@nss_options, "nss_base_passwd $admin_base?sub?gosaUnitTag=$unit_tag");
- push (@nss_options, "nss_base_group $admin_base?sub?gosaUnitTag=$unit_tag");
- }
-
- # Setup ldap.conf
- my $file1;
- my $file2;
- open(file1, "> $ldap_config");
- print file1 "# This file was automatically generated by gosa-si-client. Do not change.\n";
- print file1 "URI";
- foreach $element (@ldap_uris) {
- print file1 " $element";
- }
- print file1 "\nBASE $ldap_base\n";
- foreach $element (@ldap_options) {
- print file1 "$element\n";
- }
- close (file1);
- daemon_log("wrote $ldap_config", 5);
-
- # 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";
- print file2 "# This file was automatically generated by gosa-si-client. Do not change.\n";
- print file1 "uri";
- print file2 "uri";
- foreach $element (@ldap_uris) {
- print file1 " $element";
- print file2 " $element";
- }
- print file1 "\nbase $ldap_base\n";
- print file2 "\nbase $ldap_base\n";
- foreach $element (@pam_options) {
- print file1 "$element\n";
- }
- foreach $element (@nss_options) {
- print file2 "$element\n";
- }
- close (file2);
- daemon_log("wrote $nss_config", 5);
- close (file1);
- daemon_log("wrote $pam_config", 5);
-
- # Create goto.secrets if told so - for compatibility reasons
- 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 "GOTOADMIN=\"$goto_admin\"\nGOTOSECRET=\"$goto_secret\"\n";
- close(file1);
- daemon_log("wrote /etc/goto/secret", 5);
- }
-
-
-
- # Write shell based config
- my $cfg_name= dirname($ldap_config)."/ldap-shell.conf";
- open(file1, "> $cfg_name");
- print file1 "LDAP_BASE=\"$ldap_base\"\n";
- print file1 "ADMIN_BASE=\"$admin_base\"\n";
- print file1 "DEPARTMENT=\"$department\"\n";
- print file1 "RELEASE=\"$release\"\n";
- print file1 "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n";
- print file1 "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n";
- close(file1);
- daemon_log("wrote $cfg_name", 5);
-
- return;
-
-}
-
sub generate_hw_digest {
my $hw_data;
sub generate_hw_digest {
my $hw_data;
}
}
+sub create_ciphering {
+ my ($passwd) = @_;
+ if((!defined($passwd)) || length($passwd)==0) {
+ $passwd = "";
+ }
+ $passwd = substr(md5_hex("$passwd") x 32, 0, 32);
+ my $iv = substr(md5_hex('GONICUS GmbH'),0, 16);
+ my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC());
+ $my_cipher->set_iv($iv);
+ return $my_cipher;
+}
+
+
+sub encrypt_msg {
+ my ($msg, $key) = @_;
+ my $my_cipher = &create_ciphering($key);
+ {
+ use bytes;
+ $msg = "\0"x(16-length($msg)%16).$msg;
+ }
+ $msg = $my_cipher->encrypt($msg);
+ chomp($msg = &encode_base64($msg));
+ # there are no newlines allowed inside msg
+ $msg=~ s/\n//g;
+ return $msg;
+}
+
+
+sub decrypt_msg {
+
+ my ($msg, $key) = @_ ;
+ $msg = &decode_base64($msg);
+ my $my_cipher = &create_ciphering($key);
+ $msg = $my_cipher->decrypt($msg);
+ $msg =~ s/\0*//g;
+ return $msg;
+}
+
+
sub get_server_addresses {
my $domain= shift;
my @result;
my $error = 0;
my $res = Net::DNS::Resolver->new;
sub get_server_addresses {
my $domain= shift;
my @result;
my $error = 0;
my $res = Net::DNS::Resolver->new;
- my $query = $res->send("_gosad._tcp.".$domain, "SRV");
+ my $query = $res->send("_gosa-si._tcp.".$domain, "SRV");
my @hits;
if ($query) {
my @hits;
if ($query) {
}
}
}
}
-# my $dig_cmd= 'dig +nocomments srv _gosad._tcp.'.$domain;
+# my $dig_cmd= 'dig +nocomments srv _gosa-si._tcp.'.$domain;
#
# my $output= `$dig_cmd 2>&1`;
# open (PIPE, "$dig_cmd 2>&1 |");
#
# my $output= `$dig_cmd 2>&1`;
# open (PIPE, "$dig_cmd 2>&1 |");
}
}
+sub write_to_file {
+ my ($string, $file) = @_;
+ my $error = 0;
+
+ if( not defined $file || not -f $file ) {
+ &main::daemon_log("ERROR: $prg: check '-f file' failed: $file", 1);
+ $error++;
+ }
+ if( not defined $string || 0 == length($string)) {
+ &main::daemon_log("ERROR: $prg: empty string to write to file '$file'", 1);
+ $error++;
+ }
+
+ if( $error == 0 ) {
+
+ chomp($string);
+
+ open(FILE, ">> $file");
+ print FILE $string."\n";
+ close(FILE);
+ }
+
+ return;
+}
+
+
sub open_socket {
my ($PeerAddr, $PeerPort) = @_ ;
if(defined($PeerPort)){
sub open_socket {
my ($PeerAddr, $PeerPort) = @_ ;
if(defined($PeerPort)){
#===============================================================================
sub register_at_gosa_si_server {
my ($kernel) = $_[KERNEL];
#===============================================================================
sub register_at_gosa_si_server {
my ($kernel) = $_[KERNEL];
+ my $try_to_register = 0;
if( not $REGISTERED ) {
if( not $REGISTERED ) {
-
# create new passwd and ciphering object for client-server communication
$server_key = &create_passwd();
my $events = join( ", ", keys %{$event_hash} );
# create new passwd and ciphering object for client-server communication
$server_key = &create_passwd();
my $events = join( ", ", keys %{$event_hash} );
-
while(1) {
while(1) {
+ if( $try_to_register >= @servers ) {
+ last;
+ }
+
# fetch first gosa-si-server from @servers
my $server = shift(@servers);
# fetch first gosa-si-server from @servers
my $server = shift(@servers);
- if( !$server ) {
- daemon_log("no gosa-si-server left in list of servers", 1);
- daemon_log("unable to register at a gosa-si-server, force shutdown", 1);
- exit(1);
- }
+
+ # append shifted gosa-si-server at the end of @servers, so looking for servers never stop if
+ # a registration never occured
+ push( @servers, $server );
# Check if our ip is resolvable - if not: don't try to register
my $ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
my $resolver= Net::DNS::Resolver->new;
my $dnsresult= $resolver->search($ip);
# Check if our ip is resolvable - if not: don't try to register
my $ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
my $resolver= Net::DNS::Resolver->new;
my $dnsresult= $resolver->search($ip);
+ my $dnsname="";
if(!defined($dnsresult)) {
if(!defined($dnsresult)) {
- &write_to_file("goto-dns-error:Could not resolve hostname for ip $ip", $fai_logpath);
+ &write_to_file("goto-error-dns:$ip", $fai_logpath);
exit(1);
exit(1);
+ } else {
+ $dnsname=$dnsresult->{answer}[0]->{ptrdname};
}
# create registration msg
}
# create registration msg
# send xml hash to server with general server passwd
my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key);
if($res == 0) {
# send xml hash to server with general server passwd
my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key);
if($res == 0) {
+ # reset try_to_register
+ $try_to_register = 0;
+
# Set fixed client address
$client_ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
$client_address= "$client_ip:$client_port";
# Set fixed client address
$client_ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
$client_address= "$client_ip:$client_port";
+
+ # Write the MAC address to file
+ if(stat($opts_file)) {
+ unlink($opts_file);
+ }
+ my $opts_file_FH;
+ my $hostname= $dnsname;
+ $hostname =~ s/\..*$//;
+ open($opts_file_FH, ">$opts_file");
+ print $opts_file_FH "MAC=\"$local_mac\"\n";
+ print $opts_file_FH "IPADDRESS=\"$client_ip\"\n";
+ print $opts_file_FH "HOSTNAME=\"$hostname\"\n";
+ print $opts_file_FH "FQDN=\"$dnsname\"\n";
+ close($opts_file_FH);
last;
} else {
last;
} else {
+ $try_to_register++;
+ # wait 1 sec until trying to register again
+ sleep(1);
next;
}
}
next;
}
}
- daemon_log("waiting for msg 'register_at_gosa_si_server'",1);
-# $kernel->delay_set('register_at_gosa_si_server', 180);
- $kernel->delay_set('register_at_gosa_si_server', 5);
- # clear old settings and set it again
- $kernel->delay_set('trigger_new_key', $server_key_lifetime);
+
+ if( $try_to_register >= @servers ) {
+ &write_to_file("gosa-si-no-server-available", $fai_logpath);
+ $kernel->delay_set('register_at_gosa_si_server', $delay_set_time);
+ }
+ else {
+ daemon_log("waiting for msg 'register_at_gosa_si_server'",1);
+ $kernel->delay_set('register_at_gosa_si_server', $delay_set_time);
+ # clear old settings and set it again
+ $kernel->delay_set('trigger_new_key', $server_key_lifetime);
+ }
}
return;
}
}
return;
}
$msg_hash = $xml->XMLin($msg, ForceArray=>1);
$msg_hash = $xml->XMLin($msg, ForceArray=>1);
+ ##############
# check header
my $header_l = $msg_hash->{'header'};
if( 1 != @{$header_l} ) {
# check header
my $header_l = $msg_hash->{'header'};
if( 1 != @{$header_l} ) {
die 'header has length 0';
}
die 'header has length 0';
}
+ ##############
# check source
my $source_l = $msg_hash->{'source'};
if( 1 != @{$source_l} ) {
# check source
my $source_l = $msg_hash->{'source'};
if( 1 != @{$source_l} ) {
- die 'no or more sources specified';
+ die 'no or more than 1 sources specified';
}
my $source = @{$source_l}[0];
if( 0 == length $source) {
die 'source has length 0';
}
}
my $source = @{$source_l}[0];
if( 0 == length $source) {
die 'source has length 0';
}
-
- # check target
+ unless( $source =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ) {
+ die "source '$source' is neither a complete ip-address with port nor 'GOSA'";
+ }
+
+ ##############
+ # check target
my $target_l = $msg_hash->{'target'};
if( 1 != @{$target_l} ) {
my $target_l = $msg_hash->{'target'};
if( 1 != @{$target_l} ) {
- die 'no or more targets specified ';
+ die 'no or more than 1 targets specified ';
}
my $target = @{$target_l}[0];
if( 0 == length $target) {
die 'target has length 0 ';
}
}
my $target = @{$target_l}[0];
if( 0 == length $target) {
die 'target has length 0 ';
}
-
+ unless( $target =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ){
+ die "source is neither a complete ip-address with port nor 'GOSA'";
+ }
};
if($@) {
&main::daemon_log("WARNING: do not understand the message or msg is not gosa-si envelope conform:", 5);
&main::daemon_log("$@", 8);
};
if($@) {
&main::daemon_log("WARNING: do not understand the message or msg is not gosa-si envelope conform:", 5);
&main::daemon_log("$@", 8);
+ $msg = undef;
+ $msg_hash = undef;
}
return ($msg, $msg_hash);
}
}
return ($msg, $msg_hash);
}
+sub check_outgoing_xml_validity {
+ my ($msg) = @_;
+
+ my $msg_hash;
+ eval{
+ $msg_hash = $xml->XMLin($msg, ForceArray=>1);
+
+ ##############
+ # check header
+ my $header_l = $msg_hash->{'header'};
+ if( 1 != @{$header_l} ) {
+ die 'no or more than one headers specified';
+ }
+ my $header = @{$header_l}[0];
+ if( 0 == length $header) {
+ die 'header has length 0';
+ }
+
+ ##############
+ # check source
+ my $source_l = $msg_hash->{'source'};
+ if( 1 != @{$source_l} ) {
+ die 'no or more than 1 sources specified';
+ }
+ my $source = @{$source_l}[0];
+ if( 0 == length $source) {
+ die 'source has length 0';
+ }
+ unless( $source =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ||
+ $source =~ /^GOSA$/i ) {
+ die "source '$source' is neither a complete ip-address with port";
+ }
+
+ ##############
+ # check target
+ my $target_l = $msg_hash->{'target'};
+ if( 1 != @{$target_l} ) {
+ die "no or more than one targets specified";
+ }
+ foreach my $target (@$target_l) {
+ if( 0 == length $target) {
+ die "target has length 0";
+ }
+ unless( $target =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ) {
+ die "target '$target' is not a complete ip-address with port or a valid target name";
+ }
+ }
+ };
+ if($@) {
+ daemon_log("WARNING: outgoing msg is not gosa-si envelope conform", 5);
+ daemon_log("$@ $msg", 8);
+ $msg_hash = undef;
+ }
+ return ($msg_hash);
+}
+
+
sub import_events {
if (not -e $event_dir) {
sub import_events {
if (not -e $event_dir) {
}
}
}
}
+
+ my @all_events = keys %$event_hash;
+ my $all_events_string = join(", ", @all_events);
+
+ daemon_log("INFO: imported events: $all_events_string", 5);
}
sub trigger_new_key {
}
sub trigger_new_key {
}
}
+sub generic_file_reset {
+ my ( $heap, $wheel_id ) = @_[ HEAP, ARG0 ];
+
+ my $service = $heap->{services}->{$wheel_id};
+ daemon_log("INFO: '$service' watching reset", 5);
+ return;
+}
+
+sub generic_file_error {
+ my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
+ @_[ HEAP, ARG0, ARG1, ARG2, ARG3 ];
+
+ my $service = $heap->{services}->{$wheel_id};
+ daemon_log("ERROR: '$service' watcher $operation error $errno: $error_string", 1);
+ daemon_log("ERROR: shutting down '$service' file watcher", 1);
+
+ delete $heap->{services}->{$wheel_id};
+ delete $heap->{watchers}->{$wheel_id};
+ return;
+}
+
+sub fifo_got_record {
+ my $file_record = $_[ARG0];
+ my $header;
+ my $content = "";
+
+ $file_record =~ /^(\S+)[ ]?([\s\S]+)?$/;
+ if( defined $1 ) {
+ $header = $1;
+ } else {
+ return;
+ }
+
+ if( defined $2 ) {
+ $content = $2;
+ }
+
+ my $clmsg_hash = &create_xml_hash("CLMSG_$header", $client_address, $server_address, $content);
+ &add_content2xml_hash($clmsg_hash, "macaddress", $client_mac_address);
+ my $clmsg = &create_xml_string($clmsg_hash);
+ &send_msg_to_target($clmsg, $server_address, $server_key);
+ return;
+}
+
+
sub _start {
sub _start {
- my ($kernel) = $_[KERNEL];
+ my ($kernel, $heap) = @_[KERNEL, HEAP];
$kernel->alias_set('client_session');
$kernel->alias_set('client_session');
+
+ # force a registration at a gosa-si-server
$kernel->yield('register_at_gosa_si_server');
$kernel->yield('register_at_gosa_si_server');
+
+ # install all file watcher defined
+ while( my($file_name, $file) = each %files_to_watch ) {
+ my $file_watcher = POE::Wheel::FollowTail->new(
+ Filename => $file,
+ InputEvent => $file_name."_record",
+ ResetEvent => "file_reset",
+ ErrorEvent => "file_error",
+ );
+ $heap->{services}->{ $file_watcher->ID } = $file_name;
+ $heap->{watchers}->{ $file_watcher->ID } = $file_watcher;
+ }
}
}
########
# answer
if( $answer ) {
########
# answer
if( $answer ) {
- # preprocessing
- if( $answer =~ "<header>registered</header>") {
- # set registered flag to true to stop sending further registered msgs
- $REGISTERED = 1;
- }
- else {
- &send_msg_to_target($answer, $server_address, $server_key);
- }
- # postprocessing
- if( $answer =~ "<header>new_key</header>") {
- # set new key to global variable
- $answer =~ /<new_key>(\S*?)<\/new_key>/;
- my $new_key = $1;
- $server_key = $new_key;
+
+ #check gosa-si envelope validity
+ my $answer_hash = &check_outgoing_xml_validity($answer);
+
+ if( $answer_hash ) {
+ # answer is valid
+
+ # preprocessing
+ if( $answer =~ "<header>registered</header>") {
+ # set registered flag to true to stop sending further registered msgs
+ $REGISTERED = 1;
+ }
+ else {
+ &send_msg_to_target($answer, $server_address, $server_key);
+ }
+
+ # postprocessing
+ if( $answer =~ "<header>new_key</header>") {
+ # set new key to global variable
+ $answer =~ /<new_key>(\S*?)<\/new_key>/;
+ my $new_key = $1;
+ $server_key = $new_key;
+ }
}
}
+
}
return;
}
return;
}
daemon_log(" ", 1);
}
daemon_log(" ", 1);
-daemon_log("$0 started!", 1);
+daemon_log("$prg started!", 1);
# delete old DBsqlite lock files
system('rm -f /tmp/gosa_si_lock*gosa-si-client*');
# detect ip and mac address and complete host address
# delete old DBsqlite lock files
system('rm -f /tmp/gosa_si_lock*gosa-si-client*');
# detect ip and mac address and complete host address
+#if( inet_aton($client_ip) ){
+#print STDERR "ip: $client_ip\n";
+# $client_ip = inet_ntoa(inet_aton($client_ip));
+#print STDERR "ip: $client_ip\n";
+#}
$client_address = $client_ip.":".$client_port;
my $network_interface= &get_interface_for_ip($client_ip);
$client_mac_address= &get_mac($network_interface);
$client_address = $client_ip.":".$client_port;
my $network_interface= &get_interface_for_ip($client_ip);
$client_mac_address= &get_mac($network_interface);
@@ -1110,6 +1228,11 @@ daemon_log("start socket for incoming xml messages at port '$client_port' ", 1);
# prepare variables
# prepare variables
+if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); }
+############################################################
+# to change
+if( $server_ip eq "127.0.1.1" ) { $server_ip = "127.0.0.1" }
+############################################################
if (defined $server_ip && defined $server_port) {
$server_address = $server_ip.":".$server_port;
}
if (defined $server_ip && defined $server_port) {
$server_address = $server_ip.":".$server_port;
}
# add gosa-si-server address from config file at first position of server list
# add gosa-si-server address from config file at first position of server list
-if (defined $server_address) {
+my $server_check_cfg = Config::IniFiles->new( -file => $cfg_file );
+my $server_check = $server_check_cfg->val( "server", "ip");
+if( defined $server_check ) {
unshift(@servers, $server_address);
my $servers_string = join(", ", @servers);
daemon_log("found servers in configuration file: $servers_string", 5);
unshift(@servers, $server_address);
my $servers_string = join(", ", @servers);
daemon_log("found servers in configuration file: $servers_string", 5);
else {
if ( !$server_domain) {
daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
else {
if ( !$server_domain) {
daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
- exit( 1 );
+ kill 2, $$;
}
my @tmp_servers = &get_server_addresses($server_domain);
}
my @tmp_servers = &get_server_addresses($server_domain);
+ if( 0 == @tmp_servers ) {
+ daemon_log("ERROR: no gosa-si-server found in DNS for domain '$server_domain'",1);
+ daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
+ kill 2, $$;
+ }
+
foreach my $server (@tmp_servers) {
unshift(@servers, $server);
}
foreach my $server (@tmp_servers) {
unshift(@servers, $server);
}
}
}
+# open fifo for non-gosa-si-client-msgs to gosa-si-server
+POSIX::mkfifo("$gosa_si_client_fifo", "0600");
POE::Session->create(
POE::Session->create(
_start => \&_start,
register_at_gosa_si_server => \®ister_at_gosa_si_server,
trigger_new_key => \&trigger_new_key,
_start => \&_start,
register_at_gosa_si_server => \®ister_at_gosa_si_server,
trigger_new_key => \&trigger_new_key,
+
+ # handle records from each defined file differently
+ fifo_record => \&fifo_got_record,
+
+ # handle file resets and errors the same way for each file
+ file_reset => \&generic_file_reset,
+ file_error => \&generic_file_error,
}
);
}
);