summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b1d7ab5)
raw | patch | inline | side by side (parent: b1d7ab5)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 5 Dec 2007 15:19:09 +0000 (15:19 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 5 Dec 2007 15:19:09 +0000 (15:19 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8023 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/daemon/gosa-sc | patch | blob | history | |
contrib/daemon/gosa-sd-bus | patch | blob | history |
diff --git a/contrib/daemon/gosa-sc b/contrib/daemon/gosa-sc
index 767d0c80fd37811aa8656a652bd638fdd5a3e13a..4f917dff9e9638287064f5f4d5a2b7e90e19afda 100755 (executable)
--- a/contrib/daemon/gosa-sc
+++ b/contrib/daemon/gosa-sc
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, $mac_address);
+my ($client_address, $client_ip, $client_port, $client_mac_address);
my ($input_socket, $rbits, $wbits, $ebits, $xml, $known_hosts);
# default variables
"pid_file" => [\$pid_file, "/var/run/".$0.".pid"],
},
"client" =>
- {"client_ip" => [\$client_ip, "10.89.1.155"],
- "client_port" => [\$client_port, "10010"],
- "mac_address" => [\$mac_address, ""],
+ {"client_port" => [\$client_port, "10010"],
},
"server" =>
{"server_ip" => [\$server_ip, "10.89.1.155"],
}
+#=== FUNCTION ================================================================
+# NAME: get_ip_and_mac
+# PARAMETERS: nothing
+# RETURNS: (ip, mac)
+# DESCRIPTION: executes /sbin/ifconfig and parses the output, the first occurence
+# of a inet address is returned as well as the mac address in the line
+# above the inet address
+#===============================================================================
+sub get_ip_and_mac {
+ my $ip = "0.0.0.0.0"; # Defualt-IP
+ my $mac = "00:00:00:00:00:00"; # Default-MAC
+ my @ifconfig = qx(/sbin/ifconfig);
+ foreach(@ifconfig) {
+ if (/Hardware Adresse (\S{2}):(\S{2}):(\S{2}):(\S{2}):(\S{2}):(\S{2})/) {
+ $mac = "$1:$2:$3:$4:$5:$6";
+ next;
+ }
+ if (/inet Adresse:(\d+).(\d+).(\d+).(\d+)/) {
+ $ip = "$1.$2.$3.$4";
+ last;
+ }
+ }
+ return ($ip, $mac);
+}
+
+
#=== FUNCTION ================================================================
# NAME: usage
# PARAMETERS:
# create msg hash
my $register_hash = &create_xml_hash("here_i_am", $client_address, $server);
&add_content2xml_hash($register_hash, "new_passwd", $new_server_passwd);
- &add_content2xml_hash($register_hash, "mac_address", $mac_address);
+ &add_content2xml_hash($register_hash, "client_mac_address", $client_mac_address);
&add_content2xml_hash($register_hash, "events", $events);
# send xml hash to server with general server passwd
my $msg = $my_cipher->decrypt($crypted_msg);
#my $msg = $crypted_msg;
#$msg =~ s/^a*//gi;
+ $msg =~ s/\0$//gi;
return $msg;
}
if( !$foreground ) { exit( 0 ) };
}
+# detect own ip and mac address
+($client_ip, $client_mac_address) = &get_ip_and_mac();
+if (not defined $client_ip) {
+ die "EXIT: ip address of $0 could not be detected";
+}
+daemon_log("client ip address detected: $client_ip", 1);
+daemon_log("client mac address detected: $client_mac_address", 1);
+
# prepare variables
if (defined $server_ip && defined $server_port) {
$server_address = $server_ip.":".$server_port;
index 6035fb4a35bd1555a25def3f88283cd4b87ed573..d928002388852ce32d6fb26c2e370bdbc0d719bc 100755 (executable)
IPC::Shareable->clean_up_all;
my ($cfg_file, $default_cfg_file, %cfg_defaults, $foreground, $verbose);
-my ($bus_activ, $bus_passwd, $bus_ip, $bus_port, $bus_address, $bus);
+my ($bus_activ, $bus_passwd, $bus_ip, $bus_port, $bus_address, $bus, $bus_mac_address);
my ($pid_file, $procid, $pid, $log_file, $my_own_address);
my (%free_child, %busy_child, $child_max, $child_min, %child_alive_time, $child_timeout);
my ($xml, $bus_cipher, $known_daemons, $shmkh);
"bus" =>
{"bus_activ" => [\$bus_activ, "on"],
"bus_passwd" => [\$bus_passwd, "tester"],
- "bus_ip" => [\$bus_ip, "10.89.1.155"],
+# "bus_ip" => [\$bus_ip, "10.89.1.155"],
"bus_port" => [\$bus_port, "10001"],
"child_max" => [\$child_max, 10],
"child_min" => [\$child_min, 3],
$SIG{INT} = \&sig_int_handler;
+#=== FUNCTION ================================================================
+# NAME: get_ip_and_mac
+# PARAMETERS: nothing
+# RETURNS: (ip, mac)
+# DESCRIPTION: executes /sbin/ifconfig and parses the output, the first occurence
+# of a inet address is returned as well as the mac address in the line
+# above the inet address
+#===============================================================================
+sub get_ip_and_mac {
+ my $ip = "0.0.0.0.0"; # Defualt-IP
+ my $mac_address = "00:00:00:00:00:00"; # Default-MAC
+ my @ifconfig = qx(/sbin/ifconfig);
+ foreach(@ifconfig) {
+ if (/Hardware Adresse (\S{2}):(\S{2}):(\S{2}):(\S{2}):(\S{2}):(\S{2})/) {
+ $mac_address = "$1:$2:$3:$4:$5:$6";
+ next;
+ }
+ if (/inet Adresse:(\d+).(\d+).(\d+).(\d+)/) {
+ $ip = "$1.$2.$3.$4";
+ last;
+ }
+ }
+ return ($ip, $mac_address);
+}
+
+
+
#=== FUNCTION ================================================================
# NAME: activating_child
# PARAMETERS: msg - string - incoming message
my $msg = $my_cipher->decrypt($crypted_msg);
#my $msg = $crypted_msg;
#$msg =~ s/^a*//gi;
+ $msg =~ s/\0$//gi;
return $msg;
}
# restart daemon log file
if(-e $log_file ) { unlink $log_file }
-daemon_log("started!");
+daemon_log("$0 started!");
# Just fork, if we"re not in foreground mode
if( ! $foreground ) { $pid = fork(); }
if( !$foreground ) { exit( 0 ) };
}
-# detect own ip, port and address(= ip:port)
-
+# detect own ip and mac address
+($bus_ip, $bus_mac_address) = &get_ip_and_mac();
+if (not defined $bus_ip) {
+ die "EXIT: ip address of $0 could not be detected";
+}
+daemon_log("bus ip address detected: $bus_ip", 1);
+daemon_log("bus mac address detected: $bus_mac_address", 1);
# setup xml parser