summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f4c9b1b)
raw | patch | inline | side by side (parent: f4c9b1b)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 11 Dec 2007 14:33:06 +0000 (14:33 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 11 Dec 2007 14:33:06 +0000 (14:33 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8080 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/contrib/daemon/gosa-sc b/contrib/daemon/gosa-sc
index 9f51134272a11739b150b2922601be3df5156120..ef9e6618bc926f04ed44ee7f613b1d52815d6560 100755 (executable)
--- a/contrib/daemon/gosa-sc
+++ b/contrib/daemon/gosa-sc
use Sys::Syslog qw( :DEFAULT setlogsock);
use File::Spec;
use Cwd;
-
+use 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);
my ($input_socket, $rbits, $wbits, $ebits, $xml, $known_hosts);
+my (@events);
# default variables
+my $event_dir = "/etc/gosac/events";
$known_hosts = {};
$foreground = 0 ;
%cfg_defaults =
my $new_server_cipher;
# detect all client accepted events
- opendir(DIR, "/etc/gosac/events")
- or daemon_log("cannot find directory /etc/gosac/events!\ngosac starts without any accepting events!", 1);
+ opendir(DIR, $event_dir)
+ or daemon_log("cannot find directory $event_dir!\ngosac starts without any accepting events!", 1);
my $file_name;
- my @events = ();
+ @events = ();
while(defined($file_name = readdir(DIR))){
if ($file_name eq "." || $file_name eq "..") {
next;
my ($msg_hash, $address, $passwd) = @_ ;
# fetch header for logging
- my $header = &get_content_from_xml_hash($msg_hash, "header");
+ my $header = @{$msg_hash->{header}}[0];
# generiere xml string
my $msg_xml = &create_xml_string($msg_hash);
daemon_log("msg to process:", 7);
daemon_log("\t$msg", 7);
+ #check whether msg to process is a event
+ opendir(DIR, $event_dir)
+ or daemon_log("cannot find directory $event_dir, no events specified", 5);
+ my $file_name;
+ while(defined($file_name = readdir(DIR))){
+ if ($file_name eq "." || $file_name eq "..") {
+ next;
+ }
+ if ($file_name eq $header) {
+ my $cmd = "$event_dir/$file_name '$msg'";
+ my $result_xml = "";
+ open(PIPE, "$cmd 2>&1 |");
+ while(<PIPE>) {
+ $result_xml.=$_;
+ last;
+ }
+ close(PIPE);
+ my $res_hash = &transform_msg2hash($result_xml);
+ my $res_target = @{$res_hash->{target}}[0];
+ &send_msg_hash2address($res_hash, $server_address);
+
+ return;
+ }
+ }
+ 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)}
elsif ($header eq 'ping') { &got_ping($msg_hash) }
elsif ($header eq 'wake_up') { &execute_event($msg_hash)}
diff --git a/contrib/daemon/gosa-sd b/contrib/daemon/gosa-sd
index 1b161528e63d72319db7bf774f7a96873e5e5af4..989a8238528265a1be36234626da0bddee30d17b 100755 (executable)
--- a/contrib/daemon/gosa-sd
+++ b/contrib/daemon/gosa-sd
use IPC::Shareable qw( :lock);
IPC::Shareable->clean_up_all;
-
use lib "/etc/gosad/modules";
my $modules_path = "/etc/gosad/modules";
-my ($cfg_file, %cfg_defaults, $foreground, $verbose, $ping_timeout);
+my ($cfg_file, %cfg_defaults, $foreground, $verbose, $ping_timeout, $no_bus);
my ($bus, $msg_to_bus, $bus_cipher);
my ($server, $server_mac_address, $server_events);
my ($gosa_server);
# specifies the timeout seconds while checking the online status of a registrating client
$ping_timeout = 5;
-# specifies the listening port while checking the online status of a registrating client
-# this port HAS to be different to server_port!
-my $ping_port = "12345";
+$no_bus = 0;
# holds all other gosa-sd as well as the gosa-sd-bus
our $known_daemons = {};
if (not $file =~ /(\S*?).pm$/) {
next;
}
- require $file;
+ eval { require $file; };
+ if ($@) {
+ daemon_log("ERROR: gosa-sd could not load module $file", 1);
+ daemon_log("$@", 5);
+ next;
+ }
my $mod_name = $1;
my $module_tag_hash = eval( $mod_name.'::get_module_tags()' );
$known_modules->{$mod_name} = $module_tag_hash;
# parse commandline options
Getopt::Long::Configure( "bundling" );
GetOptions("h|help" => \&usage,
- "c|config=s" => \$cfg_file,
- "f|foreground" => \$foreground,
- "v|verbose+" => \$verbose,
+ "c|config=s" => \$cfg_file,
+ "f|foreground" => \$foreground,
+ "v|verbose+" => \$verbose,
+ "no-bus+" => \$no_bus,
);
# read and set config parameters
}
# register at bus
+if ($no_bus > 0) {
+ $bus_activ = "off"
+}
if($bus_activ eq "on") {
daemon_log(" ", 1);
®ister_at_bus();
index 7b6dbe3efe5be57fa2c98abb6741feb3500c4636..c096d933deb876d79e754d61814336ecb54b01a8 100755 (executable)
$msg = &decrypt_msg($crypted_msg, $key_cipher);
daemon_log("daemon decrypted msg:$msg", 7);
$msg_hash = $xml->XMLin($msg, ForceArray=>1);
- print Dumper $msg_hash;
};
if($@) {
daemon_log("msg processing raise error", 7);
index fbce4bf9aff955c95032cd05167560084062bc59..ab5938dc6f7026865bf7e9199f6cebbb575d6209 100644 (file)
use strict;
use warnings;
-use Crypt::CBC;
+use GosaSupportDaemon;
-
-BEGIN{
- # prepare module for working
- # print "Module Gosa started!\n";
-
-}
+BEGIN{}
END{}
### START ##########################
# create general settings for this module
-my $gosa_cipher = &main::create_ciphering($main::gosa_passwd);
+my $gosa_cipher = &create_ciphering($main::gosa_passwd);
sub get_module_tags {
- # dort stehen drei packettypen, für die sich das modul anmelden kann, gosa-admin-packages, server-packages, client-packages
+ # dort stehen drei packettypen, für die sich das modul anmelden kann, gosa-admin-packages,
+ # server-packages, client-packages
my %tag_hash = (gosa_admin_packages => "yes",
server_packages => "no",
client_packages => "no");
$msg_hash = $main::xml->XMLin($msg, ForceArray=>1);
};
if($@) {
- &main::daemon_log("ERROR: GosaPackages do not understand the message: $@", 1);
+ &main::daemon_log("WARNING: GosaPackages do not understand the message:", 5);
+ &main::daemon_log("$@", 7);
return;
}
index 78093aa535a8a24c166dced9e58d1f123bd7f621..c2fc7eea99469bc917aa7e10db3886562e6ee891 100644 (file)
use strict;
use warnings;
-use Data::Dumper;
-
-
-BEGIN{
- # prepare module for working
- #print "ServerPackages loaded!\n";
-
-}
-
+use GosaSupportDaemon;
+BEGIN{}
END {}
### START ##########
+
sub get_module_tags {
# lese config file aus dort gibt es eine section Basic
- # dort stehen drei packettypen, für die sich das modul anmelden kann, gosa-admin-packages, server-packages, client-packages
+ # dort stehen drei packettypen, für die sich das modul anmelden kann, gosa-admin-packages,
+ # server-packages, client-packages
my %tag_hash = (gosa_admin_packages => "yes",
server_packages => "yes",
client_packages => "yes",
}
-#=== FUNCTION ================================================================
-# NAME: read_configfile
-# PARAMETERS: cfg_file - string -
-# RETURNS: nothing
-# DESCRIPTION: read cfg_file and set variables
-#===============================================================================
-#sub read_configfile {
-# my $cfg;
-# if( defined( $cfg_file) && ( length($cfg_file) > 0 )) {
-# if( -r $cfg_file ) {
-# $cfg = Config::IniFiles->new( -file => $cfg_file );
-# } else {
-# print STDERR "Couldn't read config file!";
-# }
-# } else {
-# $cfg = Config::IniFiles->new() ;
-# }
-# foreach my $section (keys %cfg_defaults) {
-# foreach my $param (keys %{$cfg_defaults{ $section }}) {
-# my $pinfo = $cfg_defaults{ $section }{ $param };
-# ${@$pinfo[ 0 ]} = $cfg->val( $section, $param, @$pinfo[ 1 ] );
-# }
-# }
-#}
-
-
sub process_incoming_msg {
my ($crypted_msg) = @_ ;
if(not defined $crypted_msg) {
$key_passwd = $main::server_passwd;
}
&main::daemon_log("ServerPackage: key_passwd: $key_passwd", 7);
- my $key_cipher = &main::create_ciphering($key_passwd);
- $msg = &main::decrypt_msg($crypted_msg, $key_cipher);
+ my $key_cipher = &create_ciphering($key_passwd);
+ $msg = &decrypt_msg($crypted_msg, $key_cipher);
&main::daemon_log("ServerPackages: decrypted msg: $msg", 7);
$msg_hash = $main::xml->XMLin($msg, ForceArray=>1);
#my $tmp = printf Dumper $msg_hash;
}
if($msg_flag >= $l) {
- &main::daemon_log("ERROR: ServerPackage do not understand the message:", 1);
- &main::daemon_log("\t$msg", 7);
+ &main::daemon_log("WARNING: ServerPackage do not understand the message:", 5);
+ &main::daemon_log("$@", 7);
return;
}
my $header = @{$msg_hash->{header}}[0];
my $source = @{$msg_hash->{source}}[0];
- &main::daemon_log("ServerPackages: msg from host:", 1);
- &main::daemon_log("\t$host", 1);
- &main::daemon_log("ServerPackages: header from msg:", 1);
- &main::daemon_log("\t$header", 1);
+ &main::daemon_log("ServerPackages: msg from host:", 5);
+ &main::daemon_log("\t$host", 5);
+ &main::daemon_log("ServerPackages: header from msg:", 5);
+ &main::daemon_log("\t$header", 5);
&main::daemon_log("ServerPackages: msg to process:", 5);
&main::daemon_log("\t$msg", 5);
&send_msg_hash2address($msg_hash, $target_address);
}
} else {
- # msg is for one client
+ # msg is for one host
if (exists $main::known_clients->{$target}) {
+ &send_msg_hash2address($msg_hash, $target);
+ } elsif (exists $main::known_daemons->{$target}) {
# target is known
-
&send_msg_hash2address($msg_hash, $target);
} else {
# target is not known
-
- &main::daemon_log("ERROR: ServerPackages. target $target is not known in known_clients", 1);
+ &main::daemon_log("ERROR: ServerPackages: target $target is not known neither in known_clients nor in known_daemons", 1);
}
}
}
if (exists $main::known_daemons->{$source}) {
&main::add_content2known_daemons(hostname=>$source, status=>"new_passwd", passwd=>$passwd);
- my $hash = &main::create_xml_hash("confirm_new_passwd", $main::server_address, $source);
- &main::send_msg_hash2address($hash, $source);
+ my $hash = &create_xml_hash("confirm_new_passwd", $main::server_address, $source);
+ &send_msg_hash2address($hash, $source);
} elsif (exists $main::known_clients->{$source}) {
&main::add_content2known_clients(hostname=>$source, status=>"new_passwd", passwd=>$passwd);
&main::daemon_log("number of maximal allowed clients: $main::max_clients", 5);
if($main::max_clients <= $act_nu_clients) {
- my $out_hash = &main::create_xml_hash("denied", $main::server_address, $source);
- &main::add_content2xml_hash($out_hash, "denied", "I_cannot_take_any_more_clients!");
+ my $out_hash = &create_xml_hash("denied", $main::server_address, $source);
+ &add_content2xml_hash($out_hash, "denied", "I_cannot_take_any_more_clients!");
my $passwd = @{$msg_hash->{new_passwd}}[0];
- &main::send_msg_hash2address($out_hash, $source, $passwd);
+ &send_msg_hash2address($out_hash, $source, $passwd);
return;
}
status=>"registered", passwd=>$new_passwd);
# return acknowledgement to client
- $out_hash = &main::create_xml_hash("registered", $main::server_address, $source);
- &main::send_msg_hash2address($out_hash, $source);
+ $out_hash = &create_xml_hash("registered", $main::server_address, $source);
+ &send_msg_hash2address($out_hash, $source);
# notify registered client to bus
$out_hash = &main::create_xml_hash("new_client", $main::server_address, $main::bus_address, $source);
my $dn;
my @gotoLdapServer;
open (PIPE, "$goHard_cmd 2>&1 |");
+# my $rbits = "";
+# vec($rbits, fileno PIPE, 1) = 1;
+# my $rout;
+# my $nf = select($rout=$rbits, undef, undef, $ldap_timeout);
while(<PIPE>) {
chomp $_;
# If it's a comment, goto next