diff --git a/gosa-si/gosa-si-bus b/gosa-si/gosa-si-bus
index a5d50f1d2429bbd1db64e2b82ba3daeb49cdb56c..2c7be1ac5771733be8dc096de1053c8d7f3d5708 100755 (executable)
--- a/gosa-si/gosa-si-bus
+++ b/gosa-si/gosa-si-bus
"child_max" => [\$child_max, 10],
"child_min" => [\$child_min, 3],
"child_timeout" => [\$child_timeout, 180],
"child_max" => [\$child_max, 10],
"child_min" => [\$child_min, 3],
"child_timeout" => [\$child_timeout, 180],
- "bus_known_server_file_name" => [\$bus_known_server_file_name, "/var/lib/gosa-si/bus_known_server.db"]
+ "bus_known_server_file_name" => [\$bus_known_server_file_name, "/var/lib/gosa-si/gosa-si-bus_known_server.db"]
},
"bus" =>
{"bus_activ" => [\$bus_activ, "on"],
},
"bus" =>
{"bus_activ" => [\$bus_activ, "on"],
# DESCRIPTION: Uses ioctl to get mac address directly from system.
#===============================================================================
sub get_mac {
# DESCRIPTION: Uses ioctl to get mac address directly from system.
#===============================================================================
sub get_mac {
- my $ifreq= shift;
- my $result;
- if ($ifreq && length($ifreq) > 0) {
- if($ifreq eq "all") {
- $result = "00:00:00:00:00:00";
- } else {
- my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
+ my $ifreq= shift;
+ my $result;
+ if ($ifreq && length($ifreq) > 0) {
+ if($ifreq eq "all") {
+ $result = "00:00:00:00:00:00";
+ } else {
+ my $SIOCGIFHWADDR= 0x8927; # man 2 ioctl_list
- # A configured MAC Address should always override a guessed value
- if ($bus_mac_address and length($bus_mac_address) > 0) {
- return $bus_mac_address;
- }
+ # A configured MAC Address should always override a guessed value
+ if ($bus_mac_address and length($bus_mac_address) > 0) {
+ return $bus_mac_address;
+ }
- socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
- or die "socket: $!";
+ socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
+ or die "socket: $!";
- if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
- my ($if, $mac)= unpack 'h36 H12', $ifreq;
+ if(ioctl SOCKET, $SIOCGIFHWADDR, $ifreq) {
+ my ($if, $mac)= unpack 'h36 H12', $ifreq;
- if (length($mac) > 0) {
- $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
- $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
- $result = $mac;
- }
- }
+ if (length($mac) > 0) {
+ $mac=~ m/^([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$/;
+ $mac= sprintf("%s:%s:%s:%s:%s:%s", $1, $2, $3, $4, $5, $6);
+ $result = $mac;
}
}
+ }
}
}
- return $result;
+ }
+ return $result;
}
#=== FUNCTION ================================================================
}
#=== FUNCTION ================================================================
# check wether incoming msg is from a bus_known_server
if( not defined $msg ) {
# check wether incoming msg is from a bus_known_server
if( not defined $msg ) {
- my $query_res = $bus_known_server_db->select_dbentry( {table=>'bus_known_server'} );
+ my $sql_statement= "SELECT * FROM bus_known_server";
+ my $query_res = $bus_known_server_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
$host_name = $hit->{hostname};
if( not $host_name =~ "^$host") {
while( my ($hit_num, $hit) = each %{ $query_res } ) {
$host_name = $hit->{hostname};
if( not $host_name =~ "^$host") {
} elsif ($target eq "*"){
# msg is for all server
} elsif ($target eq "*"){
# msg is for all server
- my $query_res = $bus_known_server_db->select_dbentry( {table=>'known_server'} );
+ my $sql_statement= "SELECT * FROM known_server";
+ my $query_res = $bus_known_server_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
$host_name = $hit->{hostname};
$host_key = $hit->{hostkey};
while( my ($hit_num, $hit) = each %{ $query_res } ) {
$host_name = $hit->{hostname};
$host_key = $hit->{hostkey};
my $target_address;
foreach $target_address (@targets) {
my $target_address;
foreach $target_address (@targets) {
- my $query_res = $bus_known_server_db->select_dbentry( {table=>'known_server', hostname=>$target_address} );
+ my $sql_statement= "SELECT * FROM known_server WHERE hostname='$target_address'";
+ my $query_res = $bus_known_server_db->select_dbentry( $sql_statement );
if( 1 == keys %{$query_res} ) {
$host_key = $query_res->{1}->{hostkey};
&send_msg_hash2address($msg_hash, $target_address, $host_key);
next;
} else {
if( 1 == keys %{$query_res} ) {
$host_key = $query_res->{1}->{hostkey};
&send_msg_hash2address($msg_hash, $target_address, $host_key);
next;
} else {
- $query_res = $bus_known_server_db->select_dbentry( {table=>'known_server'} );
+ my $sql_statement= "SELECT * FROM known_server";
+ $query_res = $bus_known_server_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{$query_res} ) {
my $host_name = $hit->{hostname};
my $host_key = $hit->{hostkey};
while( my ($hit_num, $hit) = each %{$query_res} ) {
my $host_name = $hit->{hostname};
my $host_key = $hit->{hostkey};
}
}
-#=== FUNCTION ================================================================
-# NAME: get_content_of_known_daemons
-# PARAMETERS:
-# RETURNS:
-# DESCRIPTION:
-#===============================================================================
-#sub get_content_of_known_daemons {
-# my ($host, $content) = @_;
-# return;
-#}
-
#=== FUNCTION ================================================================
# NAME: create_passwd
#=== FUNCTION ================================================================
# NAME: create_passwd
}
}
-#=== FUNCTION ================================================================
-# NAME: create_ciphering
-# PARAMETERS: passwd - string - used to create ciphering
-# RETURNS: cipher - object
-# DESCRIPTION: creates a Crypt::Rijndael::MODE_CBC object with passwd as key
-#===============================================================================
-#sub create_ciphering {
-# my ($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;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: encrypt_msg
-# PARAMETERS: msg - string - message to encrypt
-# my_cipher - ref - reference to a Crypt::Rijndael object
-# RETURNS: crypted_msg - string - crypted message
-# DESCRIPTION: crypts the incoming message with the Crypt::Rijndael module
-#===============================================================================
-#sub encrypt_msg {
-# my ($msg, $my_cipher) = @_;
-# if(not defined $my_cipher) { print "no cipher object\n"; }
-# $msg = "\0"x(16-length($msg)%16).$msg;
-# my $crypted_msg = $my_cipher->encrypt($msg);
-# chomp($crypted_msg = &encode_base64($crypted_msg));
-# return $crypted_msg;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: decrypt_msg
-# PARAMETERS: crypted_msg - string - message to decrypt
-# my_cipher - ref - reference to a Crypt::Rijndael object
-# RETURNS: msg - string - decrypted message
-# DESCRIPTION: decrypts the incoming message with the Crypt::Rijndael module
-#===============================================================================
-#sub decrypt_msg {
-# my ($crypted_msg, $my_cipher) = @_ ;
-# $crypted_msg = &decode_base64($crypted_msg);
-# my $msg = $my_cipher->decrypt($crypted_msg);
-# $msg =~ s/^\0*//g;
-# return $msg;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: create_xml_hash
-# PARAMETERS: header - string - message header (required)
-# source - string - where the message come from (required)
-# target - string - where the message should go to (required)
-# [header_value] - string - something usefull (optional)
-# RETURNS: hash - hash - nomen est omen
-# DESCRIPTION: creates a key-value hash, all values are stored in a array
-#===============================================================================
-#sub create_xml_hash {
-# my ($header, $source, $target, $header_value) = @_ ;
-#
-# if (not defined $header || not defined $source || not defined $target) {
-# daemon_log("ERROR: create_xml_hash function is invoked with uncompleted parameters", 7);
-# }
-#
-# my $hash = {
-# header => [$header],
-# source => [$source],
-# target => [$target],
-# $header => [$header_value],
-# };
-# #daemon_log("create_xml_hash:", 7),
-# #chomp(my $tmp = Dumper $hash);
-# #daemon_log("\t$tmp\n", 7);
-# return $hash
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: create_xml_string
-# PARAMETERS: xml_hash - hash - hash from function create_xml_hash
-# RETURNS: xml_string - string - xml string representation of the hash
-# DESCRIPTION: transform the hash to a string using XML::Simple module
-#===============================================================================
-#sub create_xml_string {
-# my ($xml_hash) = @_ ;
-# my $xml_string = $xml->XMLout($xml_hash, RootName => 'xml');
-# #$xml_string =~ s/[\n]+//g;
-# return $xml_string;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: add_content2xml_hash
-# PARAMETERS: xml_ref - ref - reference to a hash from function create_xml_hash
-# element - string - key for the hash
-# content - string - value for the hash
-# RETURNS: nothing
-# DESCRIPTION: add key-value pair to xml_ref, if key alread exists, then append value to list
-#===============================================================================
-#sub add_content2xml_hash {
-# my ($xml_ref, $element, $content) = @_;
-# if(not exists $$xml_ref{$element} ) {
-# $$xml_ref{$element} = [];
-# }
-# my $tmp = $$xml_ref{$element};
-# push(@$tmp, $content);
-# return;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: get_content_from_xml_hash
-# PARAMETERS: xml_ref - ref - reference of the xml hash
-# element - string - key of the value you want
-# RETURNS: value - string - if key is either header, target or source
-# value - list - for all other keys in xml hash
-# DESCRIPTION:
-#===============================================================================
-#sub get_content_from_xml_hash {
-# my ($xml_ref, $element) = @_;
-# my $result = $xml_ref->{$element};
-# if( $element eq "header" || $element eq "target" || $element eq "source") {
-# return @$result[0];
-# }
-# return @$result;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: open_socket
-# PARAMETERS: PeerAddr - string - something like 192.168.1.1 or 192.168.1.1:10000
-# [PeerPort] - string - necessary if port not appended by PeerAddr
-# RETURNS: socket - IO::Socket::INET
-# DESCRIPTION: open a socket to PeerAddr
-#===============================================================================
-#sub open_socket {
-# my ($PeerAddr, $PeerPort) = @_ ;
-# if(defined($PeerPort)){
-# $PeerAddr = $PeerAddr.":".$PeerPort;
-# }
-# my $socket;
-# $socket = new IO::Socket::INET(PeerAddr => $PeerAddr ,
-# Porto => "tcp" ,
-# Type => SOCK_STREAM,
-# Reuse => 1,
-# Timeout => 5,
-# );
-# if(not defined $socket) {
-# return;
-# }
-# return $socket;
-#}
-
-
#=== FUNCTION ================================================================
# NAME: read_from_socket
# PARAMETERS: socket - fh - filehandel to read from
#=== FUNCTION ================================================================
# NAME: read_from_socket
# PARAMETERS: socket - fh - filehandel to read from
}
}
-#=== FUNCTION ================================================================
-# NAME: send_msg_hash2address
-# PARAMETERS: msg_hash - hash - xml_hash created with function create_xml_hash
-# PeerAddr string - socket address to send msg
-# PeerPort string - socket port, if not included in socket address
-# RETURNS: nothing
-# DESCRIPTION: ????
-#===============================================================================
-#sub send_msg_hash2address {
-# my ($msg_hash, $address) = @_ ;
-#
-# # fetch header for logging
-# my $header = &get_content_from_xml_hash($msg_hash, "header");
-#
-# # generate xml string
-# my $msg_xml = &create_xml_string($msg_hash);
-#
-# # fetch the appropriated passwd from hash
-# my $passwd = $known_daemons->{$address}->{passwd};
-#
-# # create a ciphering object
-# my $act_cipher = &create_ciphering($passwd);
-#
-# # encrypt xml msg
-# my $crypted_msg = &encrypt_msg($msg_xml, $act_cipher);
-#
-# # open socket
-# my $socket = &open_socket($address);
-# if(not defined $socket){
-# daemon_log("ERROR: cannot send '$header'-msg to $address , server not reachable", 1);
-# return;
-# }
-#
-# # send xml msg
-# print $socket $crypted_msg."\n";
-#
-# close $socket;
-# daemon_log("send '$header'-msg to $address", 5);
-# daemon_log("crypted_msg:\n\t$crypted_msg", 7);
-# return;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: send_msg_hash2all
-# PARAMETERS: msg_hash - hash - xml_hash created with function create_xml_hash
-# RETURNS: nothing
-# DESCRIPTION: send msg_hash to all registered daemons
-#===============================================================================
-#sub send_msg_hash2all {
-# my ($msg_hash) = @_;
-#
-# # fetch header for logging
-# my $header = &get_content_from_xml_hash($msg_hash, "header");
-#
-# # generate xml string
-# my $msg_xml = &create_xml_string($msg_hash);
-#
-# # fetch a list of all target addresses
-# my @targets = keys(%$known_daemons);
-#
-# # itterates through the list an send each the msg
-# foreach my $target (@targets) {
-# if($target eq $bus_address) {next}; # do not send msg to bus
-#
-# # fetch the appropriated passwd
-# my $passwd = $known_daemons->{$target}->{passwd};
-#
-# # create ciphering object
-# my $act_cipher = &create_ciphering($passwd);
-#
-# # encrypt xml msg
-# my $crypted_msg = &encrypt_msg($msg_xml, $act_cipher);
-#
-# # open socket
-# my $socket = &open_socket($target);
-# if(not defined $socket){
-# daemon_log("ERROR: cannot open socket to $target , server not reachable", 1);
-# &update_known_daemons_entry(hostname=>$target, status=>"down");
-# next;
-# }
-#
-# # send xml msg
-# print $socket $crypted_msg."\n";
-#
-# close $socket;
-# daemon_log("send '$header'-msg to $target", 5);
-# daemon_log("crypted_msg:\n\t$crypted_msg", 7);
-# }
-# return;
-#}
-
-
#=== FUNCTION ================================================================
# NAME: here_i_am
# PARAMETERS: msg_hash - hash - hash from function create_xml_hash
#=== FUNCTION ================================================================
# NAME: here_i_am
# PARAMETERS: msg_hash - hash - hash from function create_xml_hash
&send_msg_hash2address($out_hash, $source, $bus_passwd);
# change hostkey, reason
&send_msg_hash2address($out_hash, $source, $bus_passwd);
# change hostkey, reason
- my $update_hash = { table=>'bus_known_server' };
- $update_hash->{where} = [ { hostname=>[$source] } ];
- $update_hash->{update} = [ { hostkey=>[$new_key] } ];
- $bus_known_server_db->update_dbentry($update_hash);
+ my $where_str= " WHERE hostname='$source'";
+ my $update_str= " SET hostkey='$new_key'";
+ my $sql_statement= "UPDATE bus_known_server $update_str $where_str";
+ $bus_known_server_db->update_dbentry($sql_statement);
return;
}
return;
}
sub confirm_new_passwd {
my ($msg_hash) = @_ ;
my $source = @{$msg_hash->{source}}[0];
sub confirm_new_passwd {
my ($msg_hash) = @_ ;
my $source = @{$msg_hash->{source}}[0];
+ my $sql_statement= "UPDATE bus_known_server ".
+ "SET status='key_confirmed' ".
+ "WHERE hostname='$source' ";
- my $update_hash = { table=>'bus_known_server' };
- $update_hash->{where} = [ { hostname=>[$source] } ];
- $update_hash->{update} = [ { status=>['key_confirmed'] } ];
- $bus_known_server_db->update_dbentry($update_hash);
+ $bus_known_server_db->update_dbentry($sql_statement);
return;
}
return;
}
my $header = @{$msg_hash->{header}}[0];
my $source = @{$msg_hash->{source}}[0];
my $header = @{$msg_hash->{header}}[0];
my $source = @{$msg_hash->{source}}[0];
- my $update_hash = { table=>'bus_known_server',
- where=> [ { hostname=>[$source] } ],
- update=> [ { status=>$header } ],
- };
- $bus_known_server_db->update_dbentry($update_hash);
+ my $sql_statement= "UPDATE bus_known_server SET status='$header' WHERE hostname='$source'";
+ $bus_known_server_db->update_dbentry($sql_statement);
my $out_hash = &create_xml_hash("got_ping", $bus_address, $source);
my $out_hash = &create_xml_hash("got_ping", $bus_address, $source);
- my $res = $bus_known_server_db->select_dbentry( { table=>'bus_known_server', hostname=>$source } );
+ $sql_statement= "SELECT * FROM bus_known_server WHERE hostname='$source'";
+ my $res = $bus_known_server_db->select_dbentry( $sql_statement );
my $hostkey = $res->{1}->{hostkey};
&send_msg_hash2address($out_hash, $source, $hostkey);
my $hostkey = $res->{1}->{hostkey};
&send_msg_hash2address($out_hash, $source, $hostkey);
}
}
-#=== FUNCTION ================================================================
-# NAME: make ping
-# PARAMETERS: address - string - address which should be pinged
-# RETURNS: nothing
-# DESCRIPTION: send ping message to address
-#===============================================================================
-#sub make_ping {
-# my ($address) = @_;
-# daemon_log("ping:$address\n", 1);
-# my $out_hash = &create_xml_hash("ping", "$bus_ip:$bus_port", $address);
-# &send_msg_hash2address($out_hash, $address);
-# return;
-#}
-
-
#=== FUNCTION ================================================================
# NAME: got_ping
# PARAMETERS: msg_hash - hash - hash from function create_xml_hash
#=== FUNCTION ================================================================
# NAME: got_ping
# PARAMETERS: msg_hash - hash - hash from function create_xml_hash
sub got_ping {
my ($msg_hash) = @_;
my $source = @{$msg_hash->{source}}[0];
sub got_ping {
my ($msg_hash) = @_;
my $source = @{$msg_hash->{source}}[0];
-
- my $update_hash = { table=>'bus_known_server',
- where=> [ { hostname=>[$source] } ],
- update=> [ { status=>'got_ping' } ],
- };
- $bus_known_server_db->update_dbentry($update_hash);
+
+ my $sql_statement= "UPDATE bus_known_server SET status='got_ping' WHERE hostname='$source'";
+ $bus_known_server_db->update_dbentry($sql_statement);
return;
}
return;
}
my $source = @{$msg_hash->{source}}[0];
my $header = @{$msg_hash->{header}}[0];
my $new_client = @{$msg_hash->{$header}}[0];
my $source = @{$msg_hash->{source}}[0];
my $header = @{$msg_hash->{header}}[0];
my $new_client = @{$msg_hash->{$header}}[0];
-
- my $res = $bus_known_server_db->select_dbentry( { table=>'bus_known_server', hostname=>$source } );
+
+ my $sql_statement= "SELECT * FROM bus_known_server WHERE hostname='$source'";
+ my $res = $bus_known_server_db->select_dbentry( $sql_statement );
my $clients = $res->{1}->{clients};
# if host has alread more clients, than just append
my $clients = $res->{1}->{clients};
# if host has alread more clients, than just append
$clients = $new_client;
}
$clients = $new_client;
}
- my $update_hash = { table=>'bus_known_server',
- where=>[ {hostname=>[$source] } ],
- update=>[ {clients=>[$clients] } ],
- };
-
- $bus_known_server_db->update_dbentry( $update_hash );
+ $sql_statement= "UPDATE bus_known_server SET clients='$clients' WHERE hostname='$source'";
+ $bus_known_server_db->update_dbentry( $sql_statement );
return;
}
return;
}
-#=== FUNCTION ================================================================
-# NAME: delete_client
-# PARAMETERS: msg_hash - hash - hash from function create_xml_hash
-# RETURNS: nothing
-# DESCRIPTION: process this incoming message
-#===============================================================================
-#sub delete_client {
-# my ($msg_hash) = @_ ;
-# my $source = &get_content_from_xml_hash($msg_hash, "source");
-# my $header = &get_content_from_xml_hash($msg_hash, "header");
-# my $del_client = (&get_content_from_xml_hash($msg_hash, $header))[0];
-#
-# if (not exists $known_daemons->{$source}->{$del_client}) {
-# daemon_log
-# }
-# delete $known_daemons->{$source}->{$del_client};
-#
-# return;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: print_known_daemons_hash
-# PARAMETERS: nothing
-# RETURNS: nothing
-# DESCRIPTION: nome est omen
-#===============================================================================
-#sub print_known_daemons_hash {
-# my ($tmp) = @_;
-# print "####################################\n";
-# print "# status of known_daemons\n";
-# my $hosts;
-# my $host_hash;
-# $shmkh->shlock(LOCK_EX);
-# my @hosts = keys %$known_daemons;
-# foreach my $host (@hosts) {
-# my $status = $known_daemons->{$host}->{status} ;
-# my $passwd = $known_daemons->{$host}->{passwd};
-# my $timestamp = $known_daemons->{$host}->{timestamp};
-# my @clients = keys %{$known_daemons->{$host}->{clients}};
-# my $client_string = join(", ", @clients);
-# print "$host\n";
-# print "\tstatus: $status\n";
-# print "\tpasswd: $passwd\n";
-# print "\ttimestamp: $timestamp\n";
-# print "\tclients: $client_string\n";
-#
-# }
-# $shmkh->shunlock(LOCK_EX);
-# print "####################################\n\n";
-# return;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: create_known_daemons_entry
-# PARAMETERS: hostname - string - ip address and port of host
-# RETURNS: nothing
-# DESCRIPTION: nome est omen
-#===============================================================================
-#sub create_known_daemons_entry {
-# my ($hostname) = @_;
-# $shmkh->shlock(LOCK_EX);
-# $known_daemons->{$hostname} = {};
-# $known_daemons->{$hostname}->{status} = "none";
-# $known_daemons->{$hostname}->{passwd} = "none";
-# $known_daemons->{$hostname}->{timestamp} = "none";
-# $known_daemons->{$hostname}->{clients} = {};
-# $shmkh->shunlock(LOCK_EX);
-# return;
-#}
-
-
-#=== FUNCTION ================================================================
-# NAME: update_known_daemons_entry
-# PARAMETERS: hostname - string - ip address and port of host (required)
-# status - string - (optional)
-# passwd - string - (optional)
-# client - string - ip address and port of client (optional)
-# RETURNS: nothing
-# DESCRIPTION: nome est omen and updates each time the timestamp of hostname
-#===============================================================================
-#sub update_known_daemons_entry {
-# my $arg = {
-# hostname => undef, status => undef, passwd => undef,
-# client => undef,
-# @_ };
-# my $hostname = $arg->{hostname};
-# my $status = $arg->{status};
-# my $passwd = $arg->{passwd};
-# my $client = $arg->{client};
-#
-# if (not defined $hostname) {
-# daemon_log("ERROR: function add_content2known_daemons is not invoked with requiered parameter 'hostname'", 1);
-# return;
-# }
-#
-# my ($seconds, $minutes, $hours, $monthday, $month,
-# $year, $weekday, $yearday, $sommertime) = localtime(time);
-# $hours = $hours < 10 ? $hours = "0".$hours : $hours;
-# $minutes = $minutes < 10 ? $minutes = "0".$minutes : $minutes;
-# $seconds = $seconds < 10 ? $seconds = "0".$seconds : $seconds;
-# $month+=1;
-# $month = $month < 10 ? $month = "0".$month : $month;
-# $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday;
-# $year+=1900;
-# my $t = "$year$month$monthday$hours$minutes$seconds";
-#
-# $shmkh->shlock(LOCK_EX);
-# if (defined $status) {
-# $known_daemons->{$hostname}->{status} = $status;
-# }
-# if (defined $passwd) {
-# $known_daemons->{$hostname}->{passwd} = $passwd;
-# }
-# if (defined $client) {
-# $known_daemons->{$hostname}->{clients}->{$client} = "";
-# }
-# $known_daemons->{$hostname}->{timestamp} = $t;
-# $shmkh->shunlock(LOCK_EX);
-# return;
-#}
-
-
#==== MAIN = main ==============================================================
# parse commandline options
#==== MAIN = main ==============================================================
# parse commandline options
daemon_log(" ", 1);
daemon_log("$0 started!", 1);
daemon_log(" ", 1);
daemon_log("$0 started!", 1);
+# delete old DBsqlite lock files
+system('rm -f /tmp/gosa_si_lock*');
+
# forward error messages to logfile
if( ! $foreground ) {
open(STDERR, '>>', $log_file);
# forward error messages to logfile
if( ! $foreground ) {
open(STDERR, '>>', $log_file);
$pid = fork;
setsid or die "Can't start a new session: $!";
umask 0;
$pid = fork;
setsid or die "Can't start a new session: $!";
umask 0;
+} else {
+ $pid = $$;
}
}
-else { $pid = $$; }
-
# Do something useful - put our PID into the pid_file
if( 0 != $pid ) {
open( LOCK_FILE, ">$pid_file" );
print LOCK_FILE "$pid\n";
close( LOCK_FILE );
# Do something useful - put our PID into the pid_file
if( 0 != $pid ) {
open( LOCK_FILE, ">$pid_file" );
print LOCK_FILE "$pid\n";
close( LOCK_FILE );
- if( !$foreground ) { exit( 0 ) };
+ if( ! $foreground ) { exit( 0 ) };
}
# connect to bus_known_server_db
}
# connect to bus_known_server_db
# detect own ip and mac address
$network_interface= &get_interface_for_ip($bus_ip);
$bus_mac_address= &get_mac($network_interface);
# detect own ip and mac address
$network_interface= &get_interface_for_ip($bus_ip);
$bus_mac_address= &get_mac($network_interface);
-
daemon_log("bus ip address detected: $bus_ip", 1);
daemon_log("bus mac address detected: $bus_mac_address", 1);
daemon_log("bus ip address detected: $bus_ip", 1);
daemon_log("bus mac address detected: $bus_mac_address", 1);