summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b02b13)
raw | patch | inline | side by side (parent: 0b02b13)
author | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 Jul 2010 19:30:11 +0000 (19:30 +0000) | ||
committer | opensides <opensides@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 Jul 2010 19:30:11 +0000 (19:30 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@19193 594d385d-05f5-0310-b6e9-bd551577e9d8
57 files changed:
diff --git a/gosa-si/README b/gosa-si/README
index 961e7b8269b50ad1f31c490c0852239128f336f4..8e545bc089854b679cc92827f80793fab2e2bfb4 100644 (file)
--- a/gosa-si/README
+++ b/gosa-si/README
-/usr/share/perl5/GOSA
+/usr/share/perl5/GOsaSI
common:
- GosaSupportDaemon.pm
- DBsqlite.pm
diff --git a/gosa-si/client.conf b/gosa-si/client.conf
index bf2ebfcc8290c43cb22a8b3c70c6f1c37c5ab994..88008aee523007ec5a6fa2595a68f5f9a1757cb0 100644 (file)
--- a/gosa-si/client.conf
+++ b/gosa-si/client.conf
-[general]
-log-file = /var/log/gosa-si-client.log
-pid-file = /var/run/gosa-si-client.pid
+[General]
+log-file = /var/log/gosa-si/gosa-si-client.log
+pid-file = /var/run/gosa-si/gosa-si-client.pid
-[client]
+[Client]
fai-logpath = /var/log/fai/fai.log
-[server]
+[Server]
key = secret-server-password
#[krb5]
index 6f5a2a3ad0c116b095a399d5eebb2a7a9c409c45..68b91d6d920cd647e68a2732f565d5f0b36da921 100644 (file)
--- a/gosa-si/client.conf.pod
+++ b/gosa-si/client.conf.pod
@@ -10,26 +10,26 @@ The gosa-si-client.conf file defines all parameter GOsa-SI-client needs for runn
=head1 DIRECTIVES
-=head2 [general]
+=head2 [General]
=over 4
-=item log-file = /var/run/gosa-si-client.log
+=item log-file = /var/log/gosa-si/gosa-si-client.log
Defines the location for the log file.
-=item pid-file = /var/run/gosa-si-client.pid
+=item pid-file = /var/run/gosa-si/gosa-si-client.pid
Defines the location for the pid file.
-=item opts-file = var/run/gosa-si-client.opts
+=item opts-file = var/run/gosa-si/gosa-si-client.opts
Defines the location for the opts file.
=back
-=head2 [client]
+=head2 [Client]
=over 4
=back
-=head2 [server]
+=head2 [Server]
=over 4
@@ -131,7 +131,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-
This code is part of GOsa (L<http://www.gosa-project.org>)
-Copyright (C) 2003-2009 GONICUS GmbH
+Copyright (C) 2003-2010 GONICUS GmbH
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
index 1b387e5fea97281c591a65afd510c36d49c30f84..fadd579f4f67813fc2141739a1f6aadb289378b6 100644 (file)
package corefunctions;
-use Exporter;
-@ISA = qw(Exporter);
-my @events = (
- "get_events",
- "registered",
- 'new_syslog_config',
- "new_ntp_config",
- "new_ldap_config",
- "new_key",
- "generate_hw_digest", # no implementations
- "detect_hardware",
- "confirm_new_key",
- "ping",
- "import_events", # no implementations
- );
-@EXPORT = @events;
use strict;
use warnings;
-use Fcntl;
-use GOSA::GosaSupportDaemon;
+
use File::Basename;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
+use Fcntl;
+
-my ($ldap_enabled, $offline_enabled, $ldap_config, $pam_config, $nss_config, $fai_logpath);
+our @ISA = qw(Exporter);
+
+my @events = (
+ "get_events",
+ "registered",
+ "new_syslog_config",
+ "new_ntp_config",
+ "new_ldap_config",
+ "new_key",
+ "generate_hw_digest", # no implementations
+ "detect_hardware",
+ "confirm_new_key",
+ "ping",
+ "import_events", # no implementations
+ );
+
+our @EXPORT = @events;
+
+my ($ldap_enabled, $offline_enabled, $ldap_config, $pam_config, $nss_config, $fai_logpath, $ldap_config_exit_hook);
my $chrony_file = "/etc/chrony/chrony.conf";
my $syslog_file = "/etc/syslog.conf";
+# why is it re read here, the config is read at the start of the program no !!
my %cfg_defaults = (
"client" => {
"ldap" => [\$ldap_enabled, 1],
"pam-config" => [\$pam_config, "/etc/pam_ldap.conf"],
"nss-config" => [\$nss_config, "/etc/libnss-ldap.conf"],
"fai-logpath" => [\$fai_logpath, "/var/log/fai/fai.log"],
+ "ldap-config-exit-hook" => [\$ldap_config_exit_hook, undef],
},
);
### Start ######################################################################
+# why not using the config read in the main ?? !!
&main::read_configfile($main::cfg_file, %cfg_defaults);
chomp($string);
if( not -f $file ) {
- open (FILE, "$file");
- close(FILE);
+ open (my $FD_FILE, "$file");
+ close($FD_FILE);
}
- open(FILE, ">> $file") or &main::daemon_log("ERROR in corefunctions.pm: can not open '$file' to write '$string'", 1);;
- print FILE $string."\n";
- close(FILE);
+ open(my $FD_FILE, ">>", "$file") or &main::daemon_log("ERROR in corefunctions.pm: can not open '$file' to write '$string'", 1);;
+ print $FD_FILE $string."\n";
+ close($FD_FILE);
}
- return;
+ return;
}
-
+# should be the first function of each module of gosa-si !!
sub get_events {
return \@events;
}
# registrated at new daemon
&main::register_at_server();
- return;
+ return;
}
}
# Substitute existing server with new syslog server
- open (FILE, "<$syslog_file");
- my @file = <FILE>;
- close FILE;
+ open (my $syslog, "<","$syslog_file");
+ my @file = <$syslog>;
+ close($syslog);
my $syslog_server_line = "*.*\t@".$syslog_server."\n";
foreach my $line (@file) {
if ($line =~ /^\*\.\*\s+@/) {
}
# Write changes to file and close it
- open (FILE, "+>$syslog_file");
- print FILE join("", @file);
- close FILE;
+ open (my $new_syslog, "+>","$syslog_file");
+ print $new_syslog join("", @file);
+ close($new_syslog);
&main::daemon_log("INFO: Wrote new configuration file: $syslog_file", 5);
# Restart syslog deamon
}
# Substitute existing server with new ntp server
- open (FILE, "<$chrony_file");
- my @file = <FILE>;
- close FILE;
+ open (my $ntp, "<","$chrony_file");
+ my @file = <$ntp>;
+ close($ntp);
my @new_file;
foreach my $line (@file) {
if ($line =~ /^server\s+/) {
}
# Write changes to file and close it
- open (FILE, ">$chrony_file");
- print FILE join("", @new_file);
- close FILE;
+ open (my $new_ntp, ">","$chrony_file");
+ print $new_ntp join("", @new_file);
+ close($new_ntp);
&main::daemon_log("INFO: Wrote new configuration file: $chrony_file", 5);
# Restart chrony deamon
my $department= "";
my $release= "";
my $unit_tag;
-
+ my $ldap_file;
+ my $pam_file;
+ my $nss_file;
+ my $goto_file;
+ my $goto_secret_file;
+ my $ldap_offline_file;
+ my $ldap_shell_file;
+
+ my $ldap_shell_config = "/etc/ldap/ldap-shell.conf";
+ my $ldap_offline_config = "/etc/ldap/ldap-offline.conf";
+ my $goto_secret_config = "/etc/goto/secret";
+
# Transform input into array
while ( my ($key, $value) = each(%$msg_hash) ) {
if ($key =~ /^(source|target|header)$/) {
}
# 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";
+ open($ldap_file, ">","$ldap_config");
+ print $ldap_file "# This file was automatically generated by gosa-si-client. Do not change.\n";
+ print $ldap_file "URI";
+
foreach $element (@ldap_uris) {
- print file1 " $element";
+ print $ldap_file " $element";
}
- print file1 "\nBASE $ldap_base\n";
+
+ print $ldap_file "\nBASE $ldap_base\n";
foreach $element (@ldap_options) {
- print file1 "$element\n";
+ print $ldap_file "$element\n";
}
- close (file1);
+
+ close ($ldap_file);
daemon_log("INFO: 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";
+ open($pam_file, ">","$pam_config");
+ open($nss_file, ">","$nss_config");
+ print $pam_file "# This file was automatically generated by gosa-si-client. Do not change.\n";
+ print $nss_file "# This file was automatically generated by gosa-si-client. Do not change.\n";
+ print $pam_file "uri";
+ print $nss_file "uri";
+
foreach $element (@ldap_uris) {
- print file1 " $element";
- print file2 " $element";
+ print $pam_file " $element";
+ print $nss_file " $element";
}
- print file1 "\nbase $ldap_base\n";
- print file2 "\nbase $ldap_base\n";
+
+ print $pam_file "\nbase $ldap_base\n";
+ print $nss_file "\nbase $ldap_base\n";
+
foreach $element (@pam_options) {
- print file1 "$element\n";
+ print $pam_file "$element\n";
}
+
foreach $element (@nss_options) {
- print file2 "$element\n";
+ print $nss_file "$element\n";
}
- close (file2);
+
+ close ($nss_file);
daemon_log("INFO: Wrote $nss_config", 5);
- close (file1);
+ close ($pam_file);
daemon_log("INFO: 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("INFO: Wrote /etc/goto/secret", 5);
+ open($goto_file, ">",$goto_secret_config);
+ print $goto_file "GOTOADMIN=\"$goto_admin\"\nGOTOSECRET=\"$goto_secret\"\n";
+ close($goto_file);
+ chown(0,0, $goto_file);
+ chmod(0600, $goto_file);
+ daemon_log("INFO: Wrote $goto_secret_config", 5);
}
# Write shell based config
- my $cfg_name= "/etc/ldap/ldap-shell.conf";
# Get first LDAP server
my $ldap_server= $ldap_uris[0];
$ldap_server=~ s/^ldap:\/\/([^:]+).*$/$1/;
- open(file1, "> $cfg_name");
- print file1 "LDAP_BASE=\"$ldap_base\"\n";
- print file1 "LDAP_SERVER=\"$ldap_server\"\n";
- print file1 "LDAP_URIS=\"@ldap_uris\"\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("INFO: Wrote $cfg_name", 5);
+ open($ldap_shell_file, ">","$ldap_shell_config");
+ print $ldap_shell_file "LDAP_BASE=\"$ldap_base\"\n";
+ print $ldap_shell_file "LDAP_SERVER=\"$ldap_server\"\n";
+ print $ldap_shell_file "LDAP_URIS=\"@ldap_uris\"\n";
+ print $ldap_shell_file "ADMIN_BASE=\"$admin_base\"\n";
+ print $ldap_shell_file "DEPARTMENT=\"$department\"\n";
+ print $ldap_shell_file "RELEASE=\"$release\"\n";
+ print $ldap_shell_file "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n";
+ print $ldap_shell_file "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n";
+ close($ldap_shell_file);
+
+ # Set permissions and ownership structure of
+ chown(0, 0, $ldap_shell_file);
+ chmod(0644, $ldap_shell_file);
+
+ daemon_log("INFO: Wrote $ldap_shell_config", 5);
# Write offline config
if ($offline_enabled){
- $cfg_name= "/etc/ldap/ldap-offline.conf";
# Get first LDAP server
- open(file1, "> $cfg_name");
- print file1 "LDAP_BASE=\"$ldap_base\"\n";
- print file1 "LDAP_SERVER=\"127.0.0.1\"\n";
- print file1 "LDAP_URIS=\"ldap://127.0.0.1\"\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("INFO: Wrote $cfg_name", 5);
+ open( $ldap_offline_file, ">","$ldap_offline_config");
+ print $ldap_offline_file "LDAP_BASE=\"$ldap_base\"\n";
+ print $ldap_offline_file "LDAP_SERVER=\"127.0.0.1\"\n";
+ print $ldap_offline_file "LDAP_URIS=\"ldap://127.0.0.1\"\n";
+ print $ldap_offline_file "ADMIN_BASE=\"$admin_base\"\n";
+ print $ldap_offline_file "DEPARTMENT=\"$department\"\n";
+ print $ldap_offline_file "RELEASE=\"$release\"\n";
+ print $ldap_offline_file "UNIT_TAG=\"".(defined $unit_tag ? "$unit_tag" : "")."\"\n";
+ print $ldap_offline_file "UNIT_TAG_FILTER=\"".(defined $unit_tag ? "(gosaUnitTag=$unit_tag)" : "")."\"\n";
+ close($ldap_offline_file);
+
+ # Set permissions and ownership structure of
+ chown(0, 0, $ldap_offline_file);
+ chmod(0644, $ldap_offline_file);
+
+ daemon_log("INFO: Wrote $ldap_offline_config", 5);
}
- # Set permissions and ownership structure of
- chown(0, 0, $cfg_name);
- chmod(0644, $cfg_name);
+
+
+ # Allow custom scripts to be executed
+ if (defined $ldap_config_exit_hook) {
+ system($ldap_config_exit_hook);
+ daemon_log("Hook $ldap_config_exit_hook returned with code ".($? >> 8), 5);
+ }
return;
}
$main::server_key = $new_server_key;
}
- return;
+ return;
}
&main::daemon_log("Hardware detection done!", 4);
&write_to_file('goto-hardware-detection-stop', $fai_logpath);
-
- &main::send_msg_hash_to_target(
- &main::create_xml_hash("detected_hardware", $main::client_address, $main::server_address, $result),
- $main::server_address,
- $main::server_key,
+
+ &main::send_msg_hash_to_target(
+ &main::create_xml_hash("detected_hardware", $main::client_address, $main::server_address, $result),
+ $main::server_address,
+ $main::server_key,
);
return;
index c1566a8ee0d327dd1fce049da3f2a03636143f5a..0b1cb129b7303ffb55acb64d1f273d39e5df3656 100644 (file)
# @brief Implementation of a GOsa-SI-client event module.
package dak;
+
+use strict;
+use warnings;
+
+use GOsaSI::GosaSupportDaemon;
+use MIME::Base64;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"get_dak_keyring",
"import_dak_key",
"remove_dak_key",
);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use MIME::Base64;
+our @EXPORT = @events;
BEGIN {}
"dak-user" => [\$dak_user, "deb-dak"],
},
);
-&GOSA::GosaSupportDaemon::read_configfile($main::config_file, %cfg_defaults);
+&GOsaSI::GosaSupportDaemon::read_configfile($main::config_file, %cfg_defaults);
## @method get_events()
&add_content2xml_hash($out_hash, "error", "DAK Keyring is not writable");
} else {
my $keyfile;
- open($keyfile, ">/tmp/gosa_si_tmp_dak_key");
+ open(my $keyfile, ">","/tmp/gosa_si_tmp_dak_key");
print $keyfile $key;
close($keyfile);
my $command = "$gpg --import /tmp/gosa_si_tmp_dak_key";
index e73b69f7c1bc168dfa3ba5158a707eab7caea175..4a304eb9304d70b99dacfe85499e0cc500b97b43 100644 (file)
=cut
-
package gosaTriggered;
+
+use strict;
+use warnings;
+
+use MIME::Base64;
+use File::Temp qw/ tempfile/;
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"usr_msg",
"trigger_action_instant_update",
"trigger_goto_settings_reload",
);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use MIME::Base64;
-use File::Temp qw/ tempfile/;
+
+our @EXPORT = @events;
BEGIN {}
# Check logged in user
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
- open(FILE, "> /etc/gosa-si/event");
- print FILE "trigger_action_localboot\n";
- close(FILE);
+ open(my $FILE, ">", "/etc/gosa-si/event");
+ print $FILE "trigger_action_localboot\n";
+ close($FILE);
}
}
else {
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
system( "/usr/bin/goto-notify reboot" );
- open(FILE, "> /etc/gosa-si/event");
- print FILE "reboot\n";
- close(FILE);
+ open(my $FILE, ">", "/etc/gosa-si/event");
+ print $FILE "reboot\n";
+ close($FILE);
}
}
else {
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
system( "/usr/bin/goto-notify halt" );
- open(FILE, "> /etc/gosa-si/event");
- print FILE "halt\n";
- close(FILE);
+ open(my $FILE, ">", "/etc/gosa-si/event");
+ print $FILE "halt\n";
+ close($FILE);
}
} else {
system( "/sbin/shutdown -h +$timeout &" );
my @user_list = &get_logged_in_users;
if( @user_list >= 1 ) {
system( "/usr/bin/goto-notify install" );
- open(FILE, "> /etc/gosa-si/event");
- print FILE "install\n";
- close(FILE);
+ open(my $FILE, ">", "/etc/gosa-si/event");
+ print $FILE "install\n";
+ close($FILE);
}
} else {
system( "/sbin/shutdown -r now &" );
index 9a5fa786ad1f8f9620320b81521b94a21ea5a3a7..a335948ddbbe12e0984477bb674ca9faaa5b753f 100644 (file)
package installation;
-use Exporter;
-@ISA = qw(Exporter);
-my @events = qw(get_events set_activated_for_installation);
-@EXPORT = @events;
use strict;
use warnings;
+
+use Exporter;
use Fcntl;
+our @ISA = qw(Exporter);
+
+my @events = qw(get_events set_activated_for_installation);
+
+our @EXPORT = @events;
+
BEGIN {}
END {}
my $target = @{$msg_hash->{'target'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
- my $Datei = "/var/run/gosa-si-client.activated";
- open(DATEI, ">$Datei");
- print DATEI "$msg\n";
- close DATEI;
+ my $Datei = "/var/run/gosa-si/gosa-si-client.activated";
+ open(my $FILE, ">", "$Datei");
+ print $FILE "$msg\n";
+ close($FILE);
return;
}
index c0cc930a6af67e0c82737a8ac1cf49abdafabbfb..a4ccd33bc923fbd168d3108ef8a52ade39805207 100644 (file)
package krb5;
+
+
+use strict;
+use warnings;
+
+use Authen::Krb5;
+use Authen::Krb5::Admin qw(:constants);
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"krb5_list_principals",
"krb5_del_policy",
"krb5_set_password",
);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use Authen::Krb5;
-use Authen::Krb5::Admin qw(:constants);
+
+our @EXPORT = @events;
BEGIN {}
"password" => [\$krb_password, ""],
},
);
+# why not using the main::read_configfile, the code seems exactly the same
&krb5_read_configfile($main::cfg_file, %cfg_defaults);
index d68f28107bdcd75003e963f8f0fc0f6ba6e4bc3f..be9b6a29f7e6c39fa999c1715f81c3c4d8915274 100644 (file)
package load_reporter;
-use Exporter;
-@ISA = qw(Exporter);
-my @events = (
- "get_events",
- "get_terminal_server",
- "get_load",
- "report_load",
- "set_terminal_server",
- );
-@EXPORT = @events;
+
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
+
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
BEGIN {}
END {}
+our @ISA = qw(Exporter);
+
+my @events = (
+ "get_events",
+ "get_terminal_server",
+ "get_load",
+ "report_load",
+ "set_terminal_server",
+ );
+
+our @EXPORT = @events;
+
my $ts_load_file;
my $waiting_for_ts_info;
my %cfg_defaults = (
- "client" => {
- "ts-load-file" => [\$ts_load_file, "/var/run/gosa-si-client-ts-load.txt"],
- "waiting-for-ts-info" => [\$waiting_for_ts_info, 5],
- },
+ "client" => {
+ "ts-load-file" => [\$ts_load_file, "/var/run/gosa-si/gosa-si-client-ts-load.txt"],
+ "waiting-for-ts-info" => [\$waiting_for_ts_info, 5],
+ },
);
-&GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults);
+
+# to be removed ugly !! why not using main::_read_configfile
+&GOsaSI::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults);
### FUNCTIONS #################################################################
my $file = "/proc/loadavg";
if ((not -f $file) || (not -r $file)) { return }
- open(FHD, "<$file");
- my $line = <FHD>;
- close(FHD);
+ open(my $FHD, "<", "$file");
+ my $line = <$FHD>;
+ close($FHD);
chomp($line);
$out_msg = &create_xml_string(&create_xml_hash("report_load", $target, $source, $line));
{
$file_content .= "$ts $load\n";
}
- open(FHD, ">$ts_load_file.part");
- printf FHD $file_content;
- close FHD;
+ open(my $FHD, ">", "$ts_load_file.part");
+ printf $FHD $file_content;
+ close($FHD);
system("mv $ts_load_file.part $ts_load_file");
&main::daemon_log("INFO: Wrote terminal server load information to $ts_load_file", 5);
index 7e3699cb83a746dbbac5a954daae3ac6a82d46c5..43552af74f900fa326a3943a9c3887806c3eaf88 100644 (file)
package mailqueue;
+
+
+use strict;
+use warnings;
+
+use MIME::Base64;
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"mailqueue_query",
"mailqueue_del",
"mailqueue_header",
);
-@EXPORT = @events;
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use MIME::Base64;
+our @EXPORT = @events;
BEGIN {}
my $error = 0;
my $error_string;
my $msg_id;
- my $msg_hold;
- my $msg_size;
- my $arrival_time;
+#my $msg_hold;
+#my $msg_size;
+#my $arrival_time;
my $sender;
my $recipient;
- my $status_message;
+#my $status_message;
my $out_hash;
my $out_msg;
- &main::daemon_log("DEBUG: run /usr/bin/mailq\n", 7);
+ &main::daemon_log("DEBUG: run /usr/bin/mailq\n", 7);
my $result = qx("/usr/bin/mailq");
my @result_l = split(/([0-9A-Z]{10,12})/, $result);
&main::daemon_log("$session_id WARNING: $error_string", 3);
}
- # If query was successful, add resutls to answer
+ # If query was successful, add results to answer
if ($query_positiv) {
- $j++;
+ $j++;
+ foreach my $key (keys %{ $act_result }) {
+ $act_result->{$key} =~ s/\</\<\;/g;
+ $act_result->{$key} =~ s/\>/\>\;/g;
+ }
$result_collection->{$j} = $act_result;
}
}
diff --git a/gosa-si/debian/README.source b/gosa-si/debian/README.source
--- /dev/null
@@ -0,0 +1 @@
+/usr/share/doc/dpatch/README.source.gz
index fbe9f1d7456b9fc0a3d7c86af3b258e98a13b32c..c12b49b6a5793cf0d6550ad2b576ba29fe38d33a 100644 (file)
--- a/gosa-si/debian/changelog
+++ b/gosa-si/debian/changelog
-gosa-si (2.6.7-1) unstable; urgency=low
+gosa-si (2.6.10-1) unstable; urgency=low
* Initial upload (Closes: #534303)
- -- Cajus Pollmeier <cajus@debian.org> Tue, 23 Jun 2009 16:10:48 +0200
+ -- Benoit Mortier <benoit.mortier@opensides.be> Sat, 22 May 2010 18:30:00 +0100
diff --git a/gosa-si/debian/control b/gosa-si/debian/control
index 9fc4f5427f10ffdae488867d4739d34919dfd6f2..aeff6bacfd08e5b9fd2083a3971c00e2f8415e61 100644 (file)
--- a/gosa-si/debian/control
+++ b/gosa-si/debian/control
Priority: optional
Maintainer: GOsa packages mainteners group <gosa-pkg@oss.gonicus.de>
Uploaders: Cajus Pollmeier <cajus@debian.org>, Benoit Mortier <benoit.mortier@opensides.be>
-Standards-Version: 3.8.0
-Build-Depends: debhelper(>= 4.2.32), dpatch
+Standards-Version: 3.8.4
+Build-Depends: debhelper(>= 5), dpatch
Homepage: https://oss.gonicus.de/labs/gosa/
Vcs-Browser: https://oss.gonicus.de/repositories/gosa/trunk/gosa-si
Vcs-Svn: https://oss.gonicus.de/repositories/gosa/trunk/gosa-si
Package: gosa-si-common
Architecture: any
-Depends: libconfig-inifiles-perl, libcrypt-rijndael-perl, libio-socket-ssl-perl, libxml-simple-perl, libdata-dumper-simple-perl, libmime-perl | libmime-tools-perl, libdbd-sqlite3-perl, libnet-ldap-perl, libnetaddr-ip-perl, libpoe-perl, libnet-dns-perl, libnet-pcap-perl, libconvert-asn1-perl, libdigest-hmac-perl, libnet-ip-perl, libdigest-sha1-perl, libnet-mac-vendor-perl, libpoe-component-pcap-perl, libnet-arp-perl, libdatetime-perl, libjson-rpc-perl, libxml-quote-perl, libcrypt-ssleay-perl
+Depends: ${misc:Depends}, libconfig-inifiles-perl, libcrypt-rijndael-perl, libio-socket-ssl-perl, libxml-simple-perl, libdata-dumper-simple-perl, libmime-tools-perl, libdbd-sqlite3-perl, libnet-ldap-perl, libnetaddr-ip-perl, libpoe-perl, libnet-dns-perl, libnet-pcap-perl, libconvert-asn1-perl, libdigest-hmac-perl, libnet-ip-perl, libdigest-sha1-perl, libnet-mac-vendor-perl, libpoe-component-pcap-perl, libnet-arp-perl, libdatetime-perl, libjson-rpc-perl, libxml-quote-perl, libcrypt-ssleay-perl, libnet-arp-perl, libfile-pid-perl
Suggests: gosa-si-server, gosa-si-client
Description: GOsa support infrastructure
GOsa is a combination of system-administrator and end-user web
Package: gosa-si-server
Architecture: any
-Depends: gosa-si-common, libcrypt-smbhash-perl
+Depends: ${misc:Depends}, gosa-si-common, libcrypt-smbhash-perl, wget
Suggests: gosa, gosa-si-server-postfix, gosa-si-server-dak
Description: GOsa support infrastructure server
GOsa is a combination of system-administrator and end-user web
Package: gosa-si-client
Architecture: any
-Depends: gosa-si-common, hwinfo, libdatetime-perl
+Depends: ${misc:Depends}, gosa-si-common, hwinfo, libdatetime-perl
Suggests: goto-fai-progress, gosa-si-client-krb5
Description: GOsa support infrastructure client
GOsa is a combination of system-administrator and end-user web
Package: gosa-si-server-postfix
Architecture: any
-Depends: gosa-si-server, postfix
+Depends: ${misc:Depends}, gosa-si-server, postfix
Description: GOsa support infrastructure postfix module
GOsa is a combination of system-administrator and end-user web
interface, designed to handle LDAP based setups.
Package: gosa-si-client-krb5
Architecture: any
-Depends: gosa-si-client, libauthen-krb5-perl, libauthen-krb5-admin-perl
+Depends: ${misc:Depends}, gosa-si-client, libauthen-krb5-perl, libauthen-krb5-admin-perl
Description: GOsa support infrastructure kerberos module
GOsa is a combination of system-administrator and end-user web
interface, designed to handle LDAP based setups.
Package: gosa-si-server-dak
Architecture: any
-Depends: gosa-si-server, dak
+Depends: ${misc:Depends}, gosa-si-server, dak
Description: GOsa support infrastructure dak module
GOsa is a combination of system-administrator and end-user web
interface, designed to handle LDAP based setups.
Package: gosa-si-server-opsi
Architecture: any
-Depends: gosa-si-server
+Depends: ${misc:Depends}, gosa-si-server
Description: GOsa support infrastructure opsi module
GOsa is a combination of system-administrator and end-user web
interface, designed to handle LDAP based setups.
Package: gosa-si-client-loadreporter
Architecture: any
-Depends: gosa-si-client
+Depends: ${misc:Depends}, gosa-si-client
Description: GOsa support infrastructure system load reporter module
GOsa is a combination of system-administrator and end-user web
interface, designed to handle LDAP based setups.
index 99dd31702e547a9cc9e51b11fca866038bab0566..d7541c4f1644e3f8240e9e803c45029e10aa0d43 100644 (file)
--- a/gosa-si/debian/copyright
+++ b/gosa-si/debian/copyright
Copyright:
- Copyright (C) 2001-2009 Cajus Pollmeier <pollmeier@gonicus.de>
+ (c) 2007-2009 by Andreas Rettenberger <rettenberger@gonicus.de>
+ (c) 2008-2010 by Cajus Pollmeier <pollmeier@gonicus.de>
+ (c) 2008-2009 by Jan Wenzel <wenzel@gonicus.de>
+ (c) 2010 by Benoit Mortier <benoit.mortier@opensides.be>
License:
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
-The Debian packaging is (C) 2008, Cajus Pollmeier <cajus@debian.org> and
+The Debian packaging is (C) Copyright 2001-2010, Cajus Pollmeier <cajus@debian.org> and
is licensed under the GPL, see above.
diff --git a/gosa-si/debian/gosa-si-client.default b/gosa-si/debian/gosa-si-client.default
--- /dev/null
@@ -0,0 +1,4 @@
+# Should we start the client
+START_CLIENT=1
+# Level of debugging for the client
+DEBUG=-vvvvvvv
diff --git a/gosa-si/debian/gosa-si-client.init b/gosa-si/debian/gosa-si-client.init
--- /dev/null
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Start/stop the GOsa support daemon infrastructure.
+#
+### BEGIN INIT INFO
+# Provides: gosa-si-client
+# Required-Start: $network $remote_fs $named $syslog $time
+# Required-Stop: $network $remote_fs $named $syslog $time
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: GOsa message server/client component
+# Description: gosa-si establishes the communication between a couple of
+# GOsa hosting servers and optionally clients to do event
+# signaling for all communication partners.
+### END INIT INFO
+
+# variables for the gosa-si client.
+CLIENT="gosa-si-client"
+DAEMON_CLIENT="/usr/sbin/${CLIENT}"
+RUN_DIRECTORY="/var/run/gosa-si"
+PIDFILE_CLIENT="$RUN_DIRECTORY/${CLIENT}.pid"
+
+PATH="/sbin:/usr/sbin:/bin:/usr/bin"
+
+# Load defaults
+[ -r /etc/default/gosa-si-client ] && . /etc/default/gosa-si-client
+
+# Load LSB support functions
+. /lib/lsb/init-functions
+
+if [ ! -d "/var/run/gosa-si" ]; then
+ mkdir $RUN_DIRECTORY
+fi
+
+start_client() {
+ start-stop-daemon --start --quiet --pidfile ${PIDFILE_CLIENT} --name ${CLIENT} --startas ${DAEMON_CLIENT} -- $DEBUG
+}
+
+stop_client() {
+ start-stop-daemon --stop --retry 5 --quiet --pidfile ${PIDFILE_CLIENT} --name ${CLIENT}
+}
+
+case "$1" in
+start) log_daemon_msg "Starting GOsa support infrastructure client"
+ if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
+ log_progress_msg "client"
+ start_client
+ fi
+ log_end_msg $?
+ ;;
+stop) log_daemon_msg "Stopping GOsa support infrastructure Client"
+ if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
+ log_progress_msg "client"
+ stop_client
+ fi
+ log_end_msg $?
+ ;;
+reload|force-reload|restart) log_daemon_msg "Restarting GOsa support infrastructure client"
+ if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
+ stop_client
+ start_client
+ fi
+ log_progress_msg "done"
+ log_end_msg $?
+ ;;
+status)
+ if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
+ status=0
+ pidofproc -p "${PIDFILE_CLIENT}" "${DAEMON_CLIENT}" >/dev/null || status="$?"
+ log_daemon_msg "Status of GOsa-si client" "${NAME}"
+ if [ "$status" = 0 ]; then
+ log_progress_msg "is running"
+ log_end_msg 0
+ else
+ log_progress_msg "is not running"
+ log_end_msg $status
+ fi
+ fi
+ ;;
+
+*) log_action_msg "Usage: /etc/init.d/gosa-si-client {start|stop|restart|reload|force-reload|status}"
+ exit 2
+ ;;
+esac
+exit 0
diff --git a/gosa-si/debian/gosa-si-client.lintian-overrides b/gosa-si/debian/gosa-si-client.lintian-overrides
+++ /dev/null
@@ -1 +0,0 @@
-gosa-si-client: binary-without-manpage usr/sbin/gosa-si-client
index 7e9fd81e3b0f13923eaefcdee3a502c7254b2c88..2a5a417ca07e0426cd856d5aff254c0bd9dec0a8 100644 (file)
compress
missingok
postrotate
- pkill -SIGUSR1 gosa-si-client > /dev/null || true
endscript
}
index cafe8c1cb96fec634fb46ee1240807488c6d06f6..917f50c188e74b0d02af0be6f81f2a324a7791aa 100644 (file)
*) exit 0;
esac
-[ ! -d /usr/lib/gosa-si/client/events ] && install -d -o root -g root -m 750 /usr/lib/gosa-si/client/events
+#[ ! -d /usr/lib/gosa-si/client/events ] && install -d -o root -g root -m 750 /usr/lib/gosa-si/client/events
# Fix permission
-[ -f /etc/gosa-si/client.conf ] && chmod go-rwx /etc/gosa-si/client.conf
+#[ -f /etc/gosa-si/client.conf ] && chmod go-rwx /etc/gosa-si/client.conf
# Restart daemon
-invoke-rc.d gosa-si restart
+#invoke-rc.d gosa-si-client start
exit 0
diff --git a/gosa-si/debian/gosa-si-common.default b/gosa-si/debian/gosa-si-common.default
+++ /dev/null
@@ -1,3 +0,0 @@
-# /etc/default/gosa-si - configure the init script
-START_CLIENT=1
-DEBUG=-vvv
index 2d13e8f1014b88ea5c838427755c7fa1bb5e4473..b154e52a828449a984f5aaa8c6e1642b71ed1cc7 100644 (file)
-/etc/default
-/usr/share/perl5/GOSA
+/usr/share/perl5/GOsaSI
+/var/log/gosa-si
diff --git a/gosa-si/debian/gosa-si-common.init b/gosa-si/debian/gosa-si-common.init
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/sh
-# Start/stop the GOsa support daemon infrastructure.
-#
-### BEGIN INIT INFO
-# Provides: gosa-si
-# Required-Start: $network $named $syslog $time
-# Required-Stop: $network $named $syslog $time
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: GOsa message server/client component
-# Description: gosa-si establishes the communication between a couple of
-# GOsa hosting servers and optionally clients to do event
-# signaling for all communication partners.
-### END INIT INFO
-
-# Start/stop the ctftpd daemon.
-SERVER="gosa-si-server"
-CLIENT="gosa-si-client"
-DAEMON_SERVER="/usr/sbin/${SERVER}"
-DAEMON_CLIENT="/usr/sbin/${CLIENT}"
-PIDFILE_SERVER="/var/run/${SERVER}.pid"
-PIDFILE_CLIENT="/var/run/${CLIENT}.pid"
-
-PATH="/sbin:/usr/sbin:/bin:/usr/bin"
-
-# Load defaults
-[ -r /etc/default/gosa-si ] && . /etc/default/gosa-si
-
-# Load LSB support functions
-. /lib/lsb/init-functions
-
-
-start_client() {
- start-stop-daemon --start --quiet --pidfile ${PIDFILE_CLIENT} --name ${CLIENT} --startas ${DAEMON_CLIENT} -- $DEBUG
-}
-
-
-start_server() {
- start-stop-daemon --start --quiet --pidfile ${PIDFILE_SERVER} --name ${SERVER} --startas ${DAEMON_SERVER} -- $1 $DEBUG
-}
-
-
-stop_client() {
- start-stop-daemon --stop --retry 5 --quiet --pidfile ${PIDFILE_CLIENT} --name ${CLIENT}
- kill `ps -C gosa-si-client -o pid=` > /dev/null 2>&1
- ! ps -C gosa-si-client -o pid= > /dev/null 2>&1
-}
-
-
-stop_server() {
- start-stop-daemon --stop --retry 5 --quiet --pidfile ${PIDFILE_SERVER} --name ${SERVER}
- kill `ps -C gosa-si-server -o pid=` > /dev/null 2>&1
- ! ps -C gosa-si-server -o pid= > /dev/null 2>&1
-}
-
-
-case "$1" in
-start) log_daemon_msg "Starting GOsa support infrastructure"
- if [ -x ${DAEMON_SERVER} ]; then
- log_progress_msg "daemon"
- start_server
- fi
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- log_progress_msg "client"
- start_client
- fi
- log_end_msg $?
- ;;
-stop) log_daemon_msg "Stopping GOsa support infrastructure"
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- log_progress_msg "client"
- stop_client
- fi
- if [ -x ${DAEMON_SERVER} ]; then
- log_progress_msg "daemon"
- stop_server
- fi
- log_end_msg $?
- ;;
-reload|force-reload|restart) log_daemon_msg "Restarting GOsa support infrastructure"
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- stop_client
- fi
- if [ -x ${DAEMON_SERVER} ]; then
- stop_server
- start_server
- fi
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- start_client
- fi
- log_progress_msg "done"
- log_end_msg $?
- ;;
-restart-client) log_daemon_msg "Restarting GOsa support infrastructure client"
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- stop_client
- fi
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- start_client
- fi
- log_progress_msg "done"
- log_end_msg $?
- ;;
-status)
- status=0
- pidofproc -p "${PIDFILE_SERVER}" "${DAEMON_SERVER}" >/dev/null || status="$?"
- log_daemon_msg "Status of GOsa-si server" "${NAME}"
- if [ "$status" = 0 ]; then
- log_progress_msg "is running"
- log_end_msg 0
- else
- log_progress_msg "is not running"
- log_end_msg $status
- fi
-
- if [ "$START_CLIENT" = "1" -a -x ${DAEMON_CLIENT} ]; then
- status=0
- pidofproc -p "${PIDFILE_CLIENT}" "${DAEMON_CLIENT}" >/dev/null || status="$?"
- log_daemon_msg "Status of GOsa-si client" "${NAME}"
- if [ "$status" = 0 ]; then
- log_progress_msg "is running"
- log_end_msg 0
- else
- log_progress_msg "is not running"
- log_end_msg $status
- fi
- fi
- ;;
-
-*) log_action_msg "Usage: /etc/init.d/gosa-si {start|stop|restart|restart-client|reload|force-reload|status}"
- exit 2
- ;;
-esac
-exit 0
index 4fede15d3acb2547daf430e405b3e24de71bbf36..49815e703572e9fbf4bbe9429f1f315e9f90480b 100644 (file)
-modules/GosaSupportDaemon.pm usr/share/perl5/GOSA
-modules/DBsqlite.pm usr/share/perl5/GOSA
-modules/ArpWatch.pm usr/share/perl5/POE/Component
+modules/GosaSupportDaemon.pm usr/share/perl5/GOsaSI
+modules/DBsqlite.pm usr/share/perl5/GOsaSI
+modules/ArpWatch.pm usr/share/perl5/POE/Component
index ef7bfbbd0093aac95597bc841250197cfc2ceed8..cc4606610974867d9dbf1598ba6da171a20bce0b 100644 (file)
*) exit 0;
esac
-[ -d /var/lib/gosa-si ] || install -d -o root -g root -m 750 /var/lib/gosa-si
+# create missing /var/lib/gosa-si
+[ ! -d /var/lib/gosa-si/ ] && mkdir /var/lib/gosa-si
+# start daemon
+#invoke-rc.d gosa-si-server start
+
+exit 0
diff --git a/gosa-si/debian/gosa-si-server-opsi.install b/gosa-si/debian/gosa-si-server-opsi.install
index ffe16d06d2ce6ca6adb39d1e9079faac96cc1c09..d6137aeacc4aa52a9dd6de240573605c2e0c3683 100644 (file)
-server/events/opsi_com.pm usr/lib/gosa-si/server/GosaPackages
-server/events/opsi_com.pm usr/lib/gosa-si/server/ServerPackages
-
+server/events/opsi_com.pm usr/lib/gosa-si/server/GosaPackages
+server/events/opsi_com.pm usr/lib/gosa-si/server/ServerPackages
+contrib/90_gosa.conf usr/share/doc/gosa-si-server-opsi
+contrib/README usr/share/doc/gosa-si-server-opsi
diff --git a/gosa-si/debian/gosa-si-server.default b/gosa-si/debian/gosa-si-server.default
--- /dev/null
@@ -0,0 +1,6 @@
+# Should we start the server
+START_SERVER=0
+# Configure Debuging Level
+DEBUG=-vvvvvvv
+# Debug parts of GOsa-si server see man gosa-si-server
+#DEBUGPARTS=
diff --git a/gosa-si/debian/gosa-si-server.init b/gosa-si/debian/gosa-si-server.init
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+# Start/stop the GOsa support daemon infrastructure.
+#
+### BEGIN INIT INFO
+# Provides: gosa-si-server
+# Required-Start: $network $remote_fs $named $syslog $time
+# Required-Stop: $network $remote_fs $named $syslog $time
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: GOsa message server component
+# Description: gosa-si-server establishes the communication between a couple of
+# GOsa hosting servers and optionally clients to do event
+# signaling for all communication partners.
+### END INIT INFO
+
+# variables for the gosa-si-server.
+SERVER="gosa-si-server"
+DAEMON_SERVER="/usr/sbin/${SERVER}"
+RUN_DIRECTORY="/var/run/gosa-si"
+PIDFILE_SERVER="$RUN_DIRECTORY/${SERVER}.pid"
+
+PATH="/sbin:/usr/sbin:/bin:/usr/bin"
+
+# Load defaults
+[ -r /etc/default/gosa-si-server ] && . /etc/default/gosa-si-server
+
+# Load LSB support functions
+. /lib/lsb/init-functions
+
+if [ ! -d "/var/run/gosa-si" ]; then
+ mkdir $RUN_DIRECTORY
+fi
+
+start_server() {
+ start-stop-daemon --start --quiet --pidfile ${PIDFILE_SERVER} --name ${SERVER} --startas ${DAEMON_SERVER} -- $1 $DEBUG
+}
+
+stop_server() {
+ start-stop-daemon --stop --retry 5 --quiet --pidfile ${PIDFILE_SERVER} --name ${SERVER}
+}
+
+
+case "$1" in
+ start) log_daemon_msg "Starting GOsa support infrastructure Server"
+ if [ "$START_SERVER" = "1" -a -x ${DAEMON_SERVER} ]; then
+ log_progress_msg "server"
+ start_server
+ fi
+ log_end_msg $?
+ ;;
+stop) log_daemon_msg "Stopping GOsa support infrastructure Server"
+ if [ "$START_SERVER" = "1" -a -x ${DAEMON_SERVER} ]; then
+ log_progress_msg "server"
+ stop_server
+ fi
+ log_end_msg $?
+;;
+reload|force-reload|restart) log_daemon_msg "Restarting GOsa support infrastructure Server"
+ if [ "$START_SERVER" = "1" -a -x ${DAEMON_SERVER} ]; then
+ stop_server
+ start_server
+ fi
+ log_progress_msg "done"
+ log_end_msg $?
+;;
+status)
+ if [ "$START_SERVER" = "1" -a -x ${DAEMON_SERVER} ]; then
+ status=0
+ pidofproc -p "${PIDFILE_SERVER}" "${DAEMON_SERVER}" >/dev/null || status="$?"
+ log_daemon_msg "Status of GOsa-si server" "${NAME}"
+ if [ "$status" = 0 ]; then
+ log_progress_msg "is running"
+ log_end_msg 0
+ else
+ log_progress_msg "is not running"
+ log_end_msg $status
+ fi
+ fi
+;;
+
+*) log_action_msg "Usage: /etc/init.d/gosa-si {start|stop|restart|reload|force-reload|status}"
+ exit 2
+ ;;
+esac
+exit 0
index 99882e7ad4d41cee91970ef75b9516b74dc3f9d8..ce2ed768b5637b774ca73abf56d74aa1f9704c94 100644 (file)
-gosa-si-server usr/sbin
-server.conf etc/gosa-si
-modules/ClientPackages.pm usr/lib/gosa-si/modules
-modules/GosaPackages.pm usr/lib/gosa-si/modules
-modules/ArpHandler.pm usr/lib/gosa-si/modules
-modules/oui.txt usr/lib/gosa-si/modules
-modules/ServerPackages.pm usr/lib/gosa-si/modules
-server/events/gosaTriggered.pm usr/lib/gosa-si/server/GosaPackages
-server/events/siTriggered.pm usr/lib/gosa-si/server/ClientPackages
-server/events/clMessages.pm usr/lib/gosa-si/server/ClientPackages
-server/events/databases.pm usr/lib/gosa-si/server/GosaPackages
-server/events/databases.pm usr/lib/gosa-si/server/ServerPackages
-server/events/logHandling.pm usr/lib/gosa-si/server/GosaPackages
-server/events/logHandling.pm usr/lib/gosa-si/server/ServerPackages
+gosa-si-server usr/sbin
+server.conf etc/gosa-si
+modules/ClientPackages.pm usr/lib/gosa-si/modules
+modules/GosaPackages.pm usr/lib/gosa-si/modules
+modules/ArpHandler.pm usr/lib/gosa-si/modules
+modules/oui.txt usr/lib/gosa-si/modules
+modules/ServerPackages.pm usr/lib/gosa-si/modules
+server/events/gosaTriggered.pm usr/lib/gosa-si/server/GosaPackages
+server/events/siTriggered.pm usr/lib/gosa-si/server/ClientPackages
+server/events/clMessages.pm usr/lib/gosa-si/server/ClientPackages
+server/events/databases.pm usr/lib/gosa-si/server/GosaPackages
+server/events/databases.pm usr/lib/gosa-si/server/ServerPackages
+server/events/logHandling.pm usr/lib/gosa-si/server/GosaPackages
+server/events/logHandling.pm usr/lib/gosa-si/server/ServerPackages
server/events/server_server_com.pm usr/lib/gosa-si/server/ServerPackages
diff --git a/gosa-si/debian/gosa-si-server.lintian-overrides b/gosa-si/debian/gosa-si-server.lintian-overrides
+++ /dev/null
@@ -1,2 +0,0 @@
-gosa-si-server: binary-without-manpage usr/sbin/gosa-si-server
-
index c10f95e34f9b02c5439ad41f236a57e6ad15002c..38441437e612947e05e33902231a4421c5fbfa8e 100644 (file)
compress
missingok
postrotate
- pkill -SIGUSR1 gosa-si-server > /dev/null || true
endscript
}
index c990f4ba4728b5aeacfc97b7ac0f59c9b7de5f5f..147bd40646454af201f831b6cc655b05f5b57537 100644 (file)
esac
# Fix permission
-[ -f /etc/gosa-si/server.conf ] && chmod go-rwx /etc/gosa-si/server.conf
+#[ -f /etc/gosa-si/server.conf ] && chmod go-rwx /etc/gosa-si/server.conf
-# Restart daemon
-invoke-rc.d gosa-si restart
+# start daemon
+#invoke-rc.d gosa-si-server start
exit 0
diff --git a/gosa-si/debian/rules b/gosa-si/debian/rules
index 933e5482a9f595463e3ba1bfb617686e0b78f82a..c6880978f1465d93cfde272765a9ca6f0c20341b 100755 (executable)
--- a/gosa-si/debian/rules
+++ b/gosa-si/debian/rules
-for i in *; do \
cp -R $$i debian/tmp ; \
done
- -find debian/tmp -name '*.svn' -type d -exec rm -rf {} \; 2> /dev/null
-
- -for i in gosa-si-client gosa-si-server modules/GosaPackages.pm modules/ClientPackages.pm modules/ServerPackages.pm server/events/*; do sed -i 's/use GosaSupportDaemon;/use GOSA::GosaSupportDaemon;/g;s/use DBsqlite;/use GOSA::DBsqlite;/g' debian/tmp/$$i; done
-
- -sed -i 's!"/etc/gosa-si/modules";!use lib "/usr/lib/gosa-si/modules";!g' debian/tmp/gosa-si-server
-
- -sed -i 's!"/etc/gosa-si/server/events";!"/usr/lib/gosa-si/server/events";!g' debian/tmp/modules/GosaPackages.pm
touch install-stamp
dh_install --sourcedir=debian/tmp
- install -D -m 644 debian/gosa-si-server.lintian-overrides debian/gosa-si-server/usr/share/lintian/overrides/gosa-si-server
- install -D -m 644 debian/gosa-si-client.lintian-overrides debian/gosa-si-client/usr/share/lintian/overrides/gosa-si-client
-
dh_installdocs
dh_installcron
dh_installexamples
dh_installchangelogs
dh_installman
dh_installlogrotate
- #dh_installdebconf
- dh_installinit --init-script=gosa-si -- start 00 2 3 4 5 . stop 29 1 .
-
+ dh_installinit
chmod 640 debian/gosa-si-server/etc/gosa-si/server.conf debian/gosa-si-client/etc/gosa-si/client.conf
dh_link
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 992dda4c3cbadf1065374365ae6bae7b9d7520ad..56200d9964557078bc8530c094f7acf8de4b250f 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
#!/usr/bin/perl
-#===============================================================================
-#
-# FILE: gosa-si-client
+#*********************************************************************
#
-# USAGE: gosa-si-client
+# gosa-si-client -- client for the gosa-si-server
#
-# DESCRIPTION:
+# (c) 2007-2009 by Andreas Rettenberger <rettenberger@gonicus.de>
+# (c) 2008-2010 by Cajus Pollmeier <pollmeier@gonicus.de>
+# (c) 2008-2009 by Jan Wenzel <wenzel@gonicus.de>
+# (c) 2010 by Benoit Mortier <benoit.mortier@opensides.be>
#
-# OPTIONS: ---
-# REQUIREMENTS: libnetaddr-ip-perl
-# BUGS: ---
-# NOTES:
-# AUTHOR: (Andreas Rettenberger), <rettenberger@gonicus.de>
-# COMPANY:
-# VERSION: 1.0
-# CREATED: 12.09.2007 08:54:41 CEST
-# REVISION: ---
-#===============================================================================
+#*********************************************************************
-my $client_version = '$HeadURL$:$Rev$';
+=head1 NAME
+
+gosa-si-client - Client for GOsa support infrastructure
+
+=head1 SYNOPSIS
+
+gosa-si-client [-hvf] [-c config]
+
+=head1 OPTIONS
+
+B<-h>, B<--help>
+ print out this help message
+
+B<-v>, B<--verbose>
+ be verbose (multiple v's will increase verbosity)
+ -v ERROR level
+ -vvv WARNING + ERROR level
+ -vvvvv INFO + WARNING level
+ -vvvvvvv DEBUG + INFO level
+ -vvvvvvvvv in and out going xml messages will be displayed
+
+B<-f>, B<--foreground>
+ foregroud, process will not be forked to background
+
+B<-c> I<file>, B<--config=>I<file>
+ configuration file, default F</etc/gosa-si/client.conf>
+
+B<-x> <dump>
+ dump configuration to stdout
+ ( 1 = current, 2 = default )
+
+=head1 DESCRIPTION
+
+B<gosa-si-client> belongs to the support infrastructure of GOsa.
+The client registrates at a GOsa-SI-server and accepts messages from it.
+Each message is related to a working instruction which will be executed on the client.
+Depending on the message an answer can be send back to the server.
+
+=head1 BUGS
+
+Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-devel@oss.gonicus.de> or to <https://oss.gonicus.de/labs/gosa>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+This code is part of GOsa (L<http://www.gosa-project.org>)
+
+Copyright (C) 2003-2010 GONICUS GmbH
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+=cut
use strict;
use warnings;
+
use Getopt::Long;
use Config::IniFiles;
-use POSIX;
use Time::HiRes qw( gettimeofday );
-
-use POE qw(Component::Server::TCP Wheel::FollowTail Wheel::Run);
use IO::Socket::INET;
use NetAddr::IP;
use Crypt::Rijndael;
-use GOSA::GosaSupportDaemon;
use Digest::MD5 qw(md5_hex md5 md5_base64);
use MIME::Base64;
use XML::Simple;
use File::Basename;
use File::Spec;
+use File::Pid;
+use Net::ARP;
+use GOsaSI::GosaSupportDaemon;
+
+use POE qw(Component::Server::TCP Wheel::FollowTail Wheel::Run);
use Fcntl;
+use POSIX;
# Workaround: need pure perl to make it work with UTF-8 :-(
$XML::Simple::PREFERRED_PARSER= "XML::SAX::PurePerl";
+my $client_version = '$HeadURL$:$Rev$';
+
my $client_headURL;
my $client_revision;
my $client_status;
my $event_dir = "/usr/lib/gosa-si/client/events";
use lib "/usr/lib/gosa-si/client/events";
-my (%cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file, $fai_logpath);
+my (%cfg_defaults, $foreground, $pid_file, $procid, $pid, $log_file, $fai_logpath);
my ($server_ip, $server_port, $server_timeout, $server_domain, $server_key_lifetime);
my ($client_port, $ldap_enabled, $ldap_config, $pam_config, $nss_config);
my ($root_uid, $adm_gid);
my @servers;
my $gotoHardwareChecksum;
my $system_com;
-$verbose= 1;
+my $servers_string;
+
+my $client_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};
# globalise variables which are used in imported events
our $global_kernel;
our $client_force_hostname;
our $server_key;
our $terminal_server_hash;
+our $opts_dnslookup;
+our $verbose= 0;
+
+# where is the config stored by default and his name
+our $config = '/etc/gosa-si/client.conf';
+
+# by default dumping of config is undefined
+our $dump_config = undef;
# default variables
my $REGISTERED = 0;
# path to fifo for non-gosa-si-client messages to gosa-si-server
-my $fai_com_fifo = "/var/run/gosa-si-client.socket";
-my $system_com_fifo = "/var/run/gosa-si-client-system-com.socket";
+my $fai_com_fifo = "/var/run/gosa-si/gosa-si-client.socket";
+my $system_com_fifo = "/var/run/gosa-si/gosa-si-client-system-com.socket";
my %files_to_watch = (fai_fifo => $fai_com_fifo, system_fifo => $system_com_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
+# 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 = 10;
-our $prg= basename($0);
+#our $prg= basename($0);
# all n seconds the client reports logged_in users to gosa-si-server
my $trigger_logged_in_users_report_delay = 600;
my $fai_log_dir = "/var/log/fai";
%cfg_defaults = (
-"general" =>
- {"log-file" => [\$log_file, "/var/run/".$prg.".log"],
- "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"],
- "opts-file" => [\$opts_file, "/var/run/".$prg.".opts"],
+"General" =>
+ {"log-file" => [\$log_file, "/var/log/gosa-si/gosa-si.log"],
+ "pid-file" => [\$pid_file, "/var/run/gosa-si/gosa-si-client.pid"],
+ "opts-file" => [\$opts_file, "/var/run/gosa-si/gosa-si-client.opts"],
},
-"client" =>
+"Client" =>
{"port" => [\$client_port, "20083"],
"ip" => [\$client_ip, "0.0.0.0"],
"mac-address" => [\$client_mac_address, "00:00:00:00:00:00"],
"force-hostname" => [\$client_force_hostname, "false"],
"system-com" => [\$system_com, "disabled"],
},
-"server" => {
- "ip" => [\$server_ip, "127.0.0.1"],
+"Server" => {
+ "ip" => [\$servers_string, "127.0.0.1"],
"port" => [\$server_port, "20081"],
"key" => [\$server_key, ""],
"timeout" => [\$server_timeout, 10],
- "key-lifetime" => [\$server_key_lifetime, 600],
+ "key-lifetime" => [\$server_key_lifetime, 600],
+ "dns-lookup" => [\$opts_dnslookup, "true"],
},
);
#=== FUNCTIONS = functions =====================================================
-sub usage {
- print STDERR << "EOF" ;
-usage: $prg [-hvf] [-c config]
+#############################
+#
+# @brief Display error message and/or help text.
+#
+# In correspondence to previous GetOptions
+#
+# @param $text - string to print as error message
+# @param $help - set true, if you want to show usage help
+#
+sub usage
+{
+ my( $text, $help ) = @_;
- -h : this (help) message
- -c <file> : config file
- -f : foreground, process will not be forked to background
- -v : be verbose (multiple to increase verbosity)
-
+ $text = undef if( 'h' eq $text );
+ (defined $text) && print STDERR "\n$text\n";
+
+ if( (defined $help && $help)
+ || (!defined $help && !defined $text) )
+{
+ print STDERR << "EOF";
+
+ usage: $0 [-hvf] [-c config]
+
+ -h : this (help) message
+ -c <file> : config file (default: ${config})
+ -x <cfg> : dump configuration to stdout
+ ( 1 = current, 2 = default )
+ -f : foreground (don't fork)
+ -v : be verbose (multiple to increase verbosity)
EOF
- print "\n" ;
}
+ print( "\n" );
-#=== FUNCTION ================================================================
-# NAME: check_cmdline_param
-# PARAMETERS:
-# RETURNS:
-# DESCRIPTION:
-#===============================================================================
-sub check_cmdline_param () {
- my $err_config;
- my $err_counter = 0;
- if(not defined($cfg_file)) {
- $cfg_file = "/etc/gosa-si/client.conf";
- if(! -r $cfg_file) {
- $err_config = "please specify a config file";
- $err_counter += 1;
- }
- }
- if( $err_counter > 0 ) {
- &usage( "", 1 );
- if( defined( $err_config)) { print STDERR "$err_config\n"}
- print STDERR "\n";
- exit( -1 );
- }
+ exit( -1 );
}
+#############################
+#
+# @brief Manage gosa-si-client configuration.
+#
+# Will exit after successfull dump to stdout (type = 1 | 2)
+#
+# Dump type can be:
+# 1: Current gosa-si-client configuration in config file (exit)
+# 2: Default gosa-si-client configuration (exit)
+# 3: Dump to logfile (no exit)
+#
+# @param int config type
+#
+sub dump_configuration {
-#=== FUNCTION ================================================================
-# NAME: check_pid
-# PARAMETERS:
-# RETURNS:
-# DESCRIPTION:
-#===============================================================================
-sub check_pid {
- $pid = -1;
- # Check, if we are already running
- if( open(LOCK_FILE, "<$pid_file") ) {
- $pid = <LOCK_FILE>;
- if( defined $pid ) {
- chomp( $pid );
- if( -f "/proc/$pid/stat" ) {
- my($stat) = `cat /proc/$pid/stat` =~ m/$pid \((.+)\).*/;
- if( $0 eq $stat ) {
- close( LOCK_FILE );
- exit -1;
- }
- }
- }
- close( LOCK_FILE );
- unlink( $pid_file );
- }
+ my( $cfg_type ) = @_;
+
+ return if( ! defined $cfg_type );
+
+ if(1==$cfg_type ) {
+ print( "# Current gosa-si-client configuration\n" );
+ } elsif (2==$cfg_type) {
+ print( "# Default gosa-si-client configuration\n" );
+ } elsif (3==$cfg_type) {
+ daemon_log( "Dumping gosa-si-client configuration\n", 2 );
+ } else {
+ return;
+ }
+
+ foreach my $section (keys %cfg_defaults) {
+ if( 3 != $cfg_type ) {
+ print( "\n[${section}]\n" );
+ } else {
+ daemon_log( "\n [${section}]\n", 3 );
+ }
+
+ foreach my $param (sort( keys %{$cfg_defaults{ $section }})) {
+ my $pinfo = $cfg_defaults{ $section }{ $param };
+ my $value;
+ if (1==$cfg_type) {
+ if( defined( ${@$pinfo[ 0 ]} ) ) {
+ $value = ${@$pinfo[ 0 ]};
+ print( "$param=$value\n" );
+ } else {
+ print( "#${param}=\n" );
+ }
+ } elsif (2==$cfg_type) {
+ $value = @{$pinfo}[ 1 ];
+ if( defined( @$pinfo[ 1 ] ) ) {
+ $value = @{$pinfo}[ 1 ];
+ print( "$param=$value\n" );
+ } else {
+ print( "#${param}=\n" );
+ }
+ } elsif (3==$cfg_type) {
+ if( defined( ${@$pinfo[ 0 ]} ) ) {
+ $value = ${@$pinfo[ 0 ]};
+ daemon_log( " $param=$value\n", 3 )
+ }
+ }
+ }
+ }
- # create a syslog msg if it is not to possible to open PID file
- if (not sysopen(LOCK_FILE, $pid_file, O_WRONLY|O_CREAT|O_EXCL, 0644)) {
- my($msg) = "Couldn't obtain lockfile '$pid_file' ";
- if (open(LOCK_FILE, '<', $pid_file)
- && ($pid = <LOCK_FILE>))
- {
- chomp($pid);
- $msg .= "(PID $pid)\n";
- } else {
- $msg .= "(unable to read PID)\n";
- }
- if( ! ($foreground) ) {
- openlog( $0, "cons,pid", "daemon" );
- syslog( "warning", $msg );
- closelog();
- }
- else {
- print( STDERR " $msg " );
- }
- exit( -1 );
- }
-}
+# We just exit at stdout dump
+ if( 3 == $cfg_type ) {
+ daemon_log( "\n", 3 );
+ } else {
+ exit( 0 );
+ }
+}
+#############################
+#
+# @brief When caching an interrupt remove file pid and stopping gosa-si
+#
sub sig_int_handler {
- my ($signal) = @_;
-
- daemon_log("shutting down gosa-si-client", 1);
- system("kill `ps -C gosa-si-client -o pid=`");
+ my ($signal) = @_;
+
+ daemon_log("shutting down gosa-si-client", 1);
+
+ # shtudown the client by telling the poe kernel
+ $global_kernel->yield('shutdown');
+
+ #removing the opts file
+ unlink ('/var/run/gosa-si/gosa-si-client.opts');
+
+ #removing the fifo for communication
+ unlink ($fai_com_fifo);
+
+ #removing the pid
+ $pid->remove or warn "Could not remove $pid_file\n";
+
+ exit(0);
}
$SIG{INT} = \&sig_int_handler;
-
#=== FUNCTION ================================================================
# NAME: logging
# PARAMETERS: level - string - default 'info'
$microSeconds =~ s/^\d*(.\d\d)$/$1/;
- my $log_msg = "$month $monthday $hours:$minutes:$seconds$microSeconds $prg $msg\n";
+ my $log_msg = "$month $monthday $hours:$minutes:$seconds$microSeconds gosa-si-client $msg\n";
print LOG_HANDLE $log_msg;
if( $foreground ) {
print STDERR $log_msg;
$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 ($client_mac_address and length($client_mac_address) > 0 and not($client_mac_address eq "00:00:00:00:00:00")) {
$result= $client_mac_address;
}
else {
- socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
- or die "socket: $!";
-
- 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;
- }
- }
+ $result = Net::ARP::get_mac($ifreq);
}
}
}
if($server_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
my $PROC_NET_ROUTE= ('/proc/net/route');
- open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
+ open(my $PROC_NET, "<","$PROC_NET_ROUTE")
or die "Could not open $PROC_NET_ROUTE";
- my @ifs = <PROC_NET_ROUTE>;
+ my @ifs = <$PROC_NET>;
- close(PROC_NET_ROUTE);
+ close($PROC_NET);
# Eat header line
shift @ifs;
if ($REGISTERED == 1) {
&_setREGISTERED(0); # if server is not available, cause reregistering
daemon_log("INFO: cause reregistering at gosa-si-server", 5);
- $global_kernel->yield('register_at_gosa_si_server');
+ $global_kernel->post('client_session', 'register_at_gosa_si_server');
}
$error++;
my $error = 0;
if( not defined $file || not -f $file ) {
- &main::daemon_log("ERROR: $prg: check '-f file' failed: $file", 1);
+ &main::daemon_log("ERROR: gosa-si-client : 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);
+ &main::daemon_log("ERROR: gosa-si-client : empty string to write to file '$file'", 1);
$error++;
}
chomp($string);
- if (open(FILE, ">> $file")){
- print FILE $string."\n";
- close(FILE);
+ if (open(my $FILE, ">>", "$file")){
+ print $FILE $string."\n";
+ close($FILE);
}
}
- return;
+ return;
}
@logged_in_user_list = split(/\s/, $result);
}
- system("echo 'CURRENTLY_LOGGED_IN ".join(" ", @logged_in_user_list)."' > /var/run/gosa-si-client.socket");
+ system("echo 'CURRENTLY_LOGGED_IN ".join(" ", @logged_in_user_list)."' > /var/run/gosa-si/gosa-si-client.socket");
$kernel->delay_set('trigger_logged_in_users_report', $trigger_logged_in_users_report_delay);
} else {
# try it in 10 sec again
# Check if file has 'seen' tag
foreach my $goto_file (@goto_files) {
- open(FILE, "$goto_dir/$goto_file");
- my @lines = <FILE>;
- close FILE;
+ open(my $FILE, "$goto_dir/$goto_file");
+ my @lines = <$FILE>;
+ close($FILE);
my $source;
my $target;
next;
}
- open(FILE, "<$log_file");
- my @lines = <FILE> ;
- close (FILE);
+ open(my $FILE, "<","$log_file");
+ my @lines = <$FILE> ;
+ close ($FILE);
my $log_string = join("", @lines);
$log .= &encode_base64($log_string);
push(@log_list, $log);
return;
}
+sub find_servers {
+ # add gosa-si-server address from config file at first position of server list
+ my $server_check_cfg = Config::IniFiles->new( -file => $config );
-#==== MAIN = main ==============================================================
-# parse commandline options
-Getopt::Long::Configure( "bundling" );
-GetOptions("h|help" => \&usage,
- "c|config=s" => \$cfg_file,
- "f|foreground" => \$foreground,
- "v|verbose+" => \$verbose,
- );
+ # Parse servers string
+ my @conf_servers = split(',', $servers_string);
-# read and set config parameters
-&check_cmdline_param ;
-&read_configfile($cfg_file, %cfg_defaults);
-&check_pid;
+ # Now search for fallback servers in the configuration
+ foreach my $cur_server (@conf_servers) {
+ # Remove spaces from the IP
+ $cur_server =~ s/\s//g;
+ my $ip = $cur_server;
+ if(not $cur_server =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
+ my $ip_address = inet_ntoa(scalar gethostbyname($ip));
+ if(defined($ip_address) && $ip_address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
+ # Write ip address to $server_ip variable
+ $ip = $ip_address;
+ }
+ }
-# forward error messages to logfile
-if ( ! $foreground ) {
- open( STDIN, '+>/dev/null' );
- open( STDOUT, '+>&STDIN' );
- open( STDERR, '+>&STDIN' );
-}
+ my $server_addr = sprintf("%s:%s", $ip, $server_port);
+ if (not grep { $_ eq $server_addr } @servers) {
+ push(@servers, $server_addr);
+ }
+ }
+
+ my $servers_string = join(", ", @servers);
+ daemon_log("INFO: found servers in configuration file: $servers_string", 1);
+
+ # Last but not least search for fallback servers in the DNS
+ if (defined($opts_dnslookup) and $opts_dnslookup eq "true") {
+ my @tmp_servers;
+ if ( !$server_domain) {
+ # Try our DNS Searchlist
+ my @domain_list = &get_dns_domains();
+ my $tmp_domains;
+ my $error_string;
+ for my $domain (@domain_list) {
+ chomp($domain);
+ ($tmp_domains, $error_string) = &get_server_addresses($domain);
+ if(@$tmp_domains) {
+ for my $tmp_server(@$tmp_domains) {
+ push @tmp_servers, $tmp_server;
+ }
+ }
+ }
+
+ if (0 == @tmp_servers) {
+ daemon_log("INFO: No servers found in DNS.", 1);
+ }
+ else {
+ my $servers_string = join(", ", @tmp_servers);
+ daemon_log("INFO: found servers in DNS: $servers_string", 1);
+ }
+ } else {
+ @tmp_servers = &get_server_addresses($server_domain);
+ if( 0 == @tmp_servers ) {
+ daemon_log("INFO: No servers found in DNS for domain '$server_domain'",1);
+ }
+ }
-# Just fork, if we are not in foreground mode
-if( ! $foreground ) {
- chdir '/' or die "Can't chdir to /: $!";
- $pid = fork;
- setsid or die "Can't start a new session: $!";
- umask 0;
-} else {
- $pid = $$;
+ if ( 0 != @tmp_servers ) {
+ foreach my $server_addr (@tmp_servers) {
+ if (not grep { $_ eq $server_addr } @servers) {
+ push(@servers, $server_addr);
+ }
+ }
+ }
+ }
+
+ if (0 == scalar(@servers)) {
+ daemon_log("ERROR: No servers found in the configuration or DNS.", 1);
+ exit(1);
+ }
+
+ # Define first server as server_ip
+ $server_ip = $servers[0];
+
+ # prepare variables
+ if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); }
+ if (defined $server_ip && defined $server_port) {
+ $server_address = $server_ip.":".$server_port;
+ }
}
-# 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 )
- };
+
+sub start_daemon {
+
+ if( ! $foreground ) {
+ chdir '/' or die "Can't chdir to /: $!";
+ umask 0;
+ open STDIN, '+>/dev/null' or die "Can't read /dev/null: $!";
+ open STDOUT, '+>&STDIN' or die "Can't write to /dev/null: $!";
+ open STDERR, '+>&STDIN' or die "Can't write to /dev/null: $!";
+ defined($pid = fork) or die "Can't fork: $!";
+ exit if $pid;
+ setsid or die "Can't start a new session: $!";
+ }
+ return;
}
-# parse head url and revision from svn
-my $client_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};
-$client_version =~ /^\$HeadURL: (\S+) \$:\$Rev: (\d+) \$$/;
-$client_headURL = defined $1 ? $1 : 'unknown' ;
-$client_revision = defined $2 ? $2 : 'unknown' ;
-if ($client_headURL =~ /\/tag\// ||
+sub put_version {
+
+ # parse head url and revision from svn
+ $client_version =~ /^\$HeadURL: (\S+) \$:\$Rev: (\d+) \$$/;
+ $client_headURL = defined $1 ? $1 : 'unknown' ;
+ $client_revision = defined $2 ? $2 : 'unknown' ;
+ if ($client_headURL =~ /\/tag\// ||
$client_headURL =~ /\/branches\// ) {
$client_status = "stable";
-} else {
+ } else {
$client_status = "developmental" ;
+ }
+ return;
}
-# Determine root uid and adm gid, used for creating log files
-$root_uid = getpwnam('root');
-$adm_gid = getgrnam('adm');
-if(not defined $adm_gid){
- $adm_gid = getgrnam('root');
+sub get_perms_admin {
+ # Determine root uid and adm gid, used for creating log files
+ $root_uid = getpwnam('root');
+ $adm_gid = getgrnam('adm');
+ if(not defined $adm_gid){
+ $adm_gid = getgrnam('root');
+ }
+ return;
+}
+
+sub create_pid {
+ # Create the PID object
+ $pid = File::Pid->new({ file => $pid_file });
+
+ # Write the PID file
+ $pid->write;
+
+ return;
}
+#
+#==== MAIN = main ==============================================================
+#
+# Parse options and allow '-vvv'
+Getopt::Long::Configure( 'bundling' );
+GetOptions( 'v|verbose+' => \$verbose,
+ 'h|help' => \&usage,
+ 'c|config=s' => \$config,
+ 'x|dump-config=i' => \$dump_config,
+ 'f|foreground' => \$foreground)
+ or usage( '', 1 );
+
+# We may want to dump the default configuration
+if( defined $dump_config ) {
+ if($dump_config==1) {
+ } elsif ($dump_config==2) {
+ dump_configuration( $dump_config );
+ } else {
+ usage( "Dump configuration value has to be 1 or 2" );
+ }
+}
+
+# read and set config parameters
+&read_configfile($config, %cfg_defaults);
+
+# daemonize the program
+&start_daemon($foreground);
+
+# create pid file
+&create_pid($pid, $pid_file);
+
+# Determine root uid and adm gid, used for creating log files
+&get_perms_admin($root_uid, $adm_gid);
+
+# put version
+&put_version($client_status_hash, $client_version, $client_version, $client_headURL, $client_status);
+
daemon_log(" ", 1);
-daemon_log("$prg started!", 1);
+daemon_log("$0 started!", 1);
daemon_log("INFO: status: $client_status", 1);
daemon_log("INFO: ".$client_status_hash->{$client_status}.": $client_revision", 1);
-# delete old DBsqlite lock files
-system('rm -f /tmp/gosa_si_lock*gosa-si-client*');
+# to be changed maybe not trace of it when running
+#system('rm -f /tmp/gosa_si_lock*gosa-si-client*');
# detect ip and mac address and complete host address
$client_address = $client_ip.":".$client_port;
my $network_interface= &get_interface_for_ip($client_ip);
$client_mac_address= &get_mac($network_interface);
+
daemon_log("INFO: ip address detected: $client_ip", 1);
-daemon_log("INFO: gosa-si-client mac address detected: $client_mac_address", 1);
+daemon_log("INFO: $0 mac address detected: $client_mac_address", 1);
# import events
$gotoHardwareChecksum= &generate_hw_digest();
daemon_log("INFO: gotoHardwareChecksum detected: $gotoHardwareChecksum", 1);
-
# create socket for incoming xml messages
POE::Component::Server::TCP->new(
Alias => 'gosa-si-client',
);
daemon_log("INFO: start socket for incoming xml messages at port '$client_port' ", 1);
-
-# prepare variables
-if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); }
-if (defined $server_ip && defined $server_port) {
- $server_address = $server_ip.":".$server_port;
-}
$xml = new XML::Simple();
$default_server_key = $server_key;
-# add gosa-si-server address from config file at first position of server list
-my $server_check_cfg = Config::IniFiles->new( -file => $cfg_file );
-my $server_check = (defined($server_check_cfg))?$server_check_cfg->val( "server", "ip"):undef;
-if( defined $server_check ) {
- unshift(@servers, $server_address);
- my $servers_string = join(", ", @servers);
- daemon_log("INFO: found servers in configuration file: $servers_string", 1);
-} else {
- my @tmp_servers;
- if ( !$server_domain) {
- # Try our DNS Searchlist
- my @domain_list = &get_dns_domains();
- my $tmp_domains;
- my $error_string;
- for my $domain (@domain_list) {
- chomp($domain);
- ($tmp_domains, $error_string) = &get_server_addresses($domain);
- if(@$tmp_domains) {
- for my $tmp_server(@$tmp_domains) {
- push @tmp_servers, $tmp_server;
- }
- }
- }
- if (0 == @tmp_servers) {
- my $log_string = "no gosa-si-server found in DNS for domain: ".join(", ", @domain_list) if (@domain_list);
- my $log_string2 = "server addresses in domain: ".join(", ",@$tmp_domains) if (defined($tmp_domains));
- daemon_log("ERROR: $log_string", 1) if (defined($log_string));
- daemon_log("ERROR: $log_string2", 1) if (defined($log_string2));
- daemon_log("ERROR: $error_string", 1) if (defined($error_string));
- daemon_log("ERROR: please specify a gosa-si-server address or a domain in config file", 1);
- kill 2, $$;
- }
- } else {
- @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);
- }
- my $servers_string = join(", ", @servers);
- daemon_log("INFO: found servers in DNS: $servers_string", 1);
-}
-
-
# Open a new fifo for FAI messages to gosa-si-server
if (-p $fai_com_fifo) { unlink $fai_com_fifo }
POSIX::mkfifo("$fai_com_fifo", 0600);
+# Find servers from config and DNS
+&find_servers;
+
# Open a new fifo for system communication,
if (-p $system_com_fifo) { unlink $system_com_fifo }
if ($system_com eq "enabled")
POE::Session->create(
inline_states => {
- _start => \&_start,
- _default => \&_default,
- sig_handler => \&sig_handler,
- register_at_gosa_si_server => \®ister_at_gosa_si_server,
+ _start => \&_start,
+ _default => \&_default,
+ sig_handler => \&sig_handler,
+ register_at_gosa_si_server => \®ister_at_gosa_si_server,
- # trigger periodical tasks
- trigger_new_key => \&trigger_new_key,
- trigger_logged_in_users_report => \&trigger_logged_in_users_report,
- trigger_seen_messages => \&trigger_seen_messages,
+ # trigger periodical tasks
+ trigger_new_key => \&trigger_new_key,
+ trigger_logged_in_users_report => \&trigger_logged_in_users_report,
+ trigger_seen_messages => \&trigger_seen_messages,
# trigger non periodical tasks
trigger_set_terminal_server => \&trigger_set_terminal_server,
-
- # handle records from each defined file differently
- fai_fifo_record => \&fai_fifo_got_record,
+
+ # handle records from each defined file differently
+ fai_fifo_record => \&fai_fifo_got_record,
system_fifo_record => \&system_fifo_got_record,
- # handle file resets and errors the same way for each file
- file_reset => \&generic_file_reset,
- file_error => \&generic_file_error,
+ # handle file resets and errors the same way for each file
+ file_reset => \&generic_file_reset,
+ file_error => \&generic_file_error,
}
);
index c1a51b9c265dc83db3d2004f89e623635332792f..6d2a205f8edd9f3a9e2352321b1e4a0a73bb7f01 100644 (file)
--- a/gosa-si/gosa-si-client.1
+++ b/gosa-si/gosa-si-client.1
-.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.\" ========================================================================
.\"
.IX Title "GOSA-SI-CLIENT 1"
-.TH GOSA-SI-CLIENT 1 "2009-09-04" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH GOSA-SI-CLIENT 1 "2010-05-17" "perl v5.10.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.PP
\&\fB\-c\fR \fIfile\fR, \fB\-\-config=\fR\fIfile\fR
configuration file, default \fI/etc/gosa\-si/client.conf\fR
+.PP
+\&\fB\-x\fR <dump>
+ dump configuration to stdout
+ ( 1 = current, 2 = default )
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBgosa-si-client\fR belongs to the support infrastructure of GOsa.
@@ -165,7 +169,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa\
.IX Header "LICENCE AND COPYRIGHT"
This code is part of GOsa (<http://www.gosa\-project.org>)
.PP
-Copyright (C) 2003\-2009 \s-1GONICUS\s0 GmbH
+Copyright (C) 2003\-2010 \s-1GONICUS\s0 GmbH
.PP
This program is distributed in the hope that it will be useful,
but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
index b87dc2113969ec18b507029f560962f4370539ba..41bab58d37eb5c350f9edca221493fe203e2a4e7 100644 (file)
-.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.\" ========================================================================
.\"
.IX Title "CLIENT.CONF 1"
-.TH CLIENT.CONF 1 "2009-12-09" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH CLIENT.CONF 1 "2010-05-17" "perl v5.10.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
The gosa\-si\-client.conf file defines all parameter GOsa-SI-client needs for running and communication with GOsa-SI-server. It is normally located in the \fI/etc/gosa\-si/\fR directory and is generated automatically by the \fIgosa\-si\-client\fR\|(1) program during installation.
.SH "DIRECTIVES"
.IX Header "DIRECTIVES"
-.SS "[general]"
-.IX Subsection "[general]"
-.IP "log-file = /var/run/gosa\-si\-client.log" 4
-.IX Item "log-file = /var/run/gosa-si-client.log"
+.SS "[General]"
+.IX Subsection "[General]"
+.IP "log-file = /var/log/gosa\-si/gosa\-si\-client.log" 4
+.IX Item "log-file = /var/log/gosa-si/gosa-si-client.log"
Defines the location for the log file.
-.IP "pid-file = /var/run/gosa\-si\-client.pid" 4
-.IX Item "pid-file = /var/run/gosa-si-client.pid"
+.IP "pid-file = /var/run/gosa\-si/gosa\-si\-client.pid" 4
+.IX Item "pid-file = /var/run/gosa-si/gosa-si-client.pid"
Defines the location for the pid file.
-.IP "opts-file = var/run/gosa\-si\-client.opts" 4
-.IX Item "opts-file = var/run/gosa-si-client.opts"
+.IP "opts-file = var/run/gosa\-si/gosa\-si\-client.opts" 4
+.IX Item "opts-file = var/run/gosa-si/gosa-si-client.opts"
Defines the location for the opts file.
-.SS "[client]"
-.IX Subsection "[client]"
+.SS "[Client]"
+.IX Subsection "[Client]"
.IP "port = 20083" 4
.IX Item "port = 20083"
Defines the port GOsa-SI-client is listening for incoming messages.
@@ -182,8 +182,8 @@ If set to true, client will try to get the hostname for registration from \f(CW$
.IP "system-com = disabled | enabled" 4
.IX Item "system-com = disabled | enabled"
Open a different fifo for system communication
-.SS "[server]"
-.IX Subsection "[server]"
+.SS "[Server]"
+.IX Subsection "[Server]"
.IP "ip = 127.0.0.1" 4
.IX Item "ip = 127.0.0.1"
If set GOsa-SI-client is forced to register at specified GOsa-SI-Server. If it is not set, GOsa-SI tries to register at GOsa-SI-servers found in \s-1DNS\s0.
@@ -214,7 +214,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa\
.IX Header "LICENCE AND COPYRIGHT"
This code is part of GOsa (<http://www.gosa\-project.org>)
.PP
-Copyright (C) 2003\-2009 \s-1GONICUS\s0 GmbH
+Copyright (C) 2003\-2010 \s-1GONICUS\s0 GmbH
.PP
This program is distributed in the hope that it will be useful,
but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
diff --git a/gosa-si/gosa-si-client.pod b/gosa-si/gosa-si-client.pod
+++ /dev/null
@@ -1,56 +0,0 @@
-
-=head1 NAME
-
-gosa-si-client - Client for GOsa support infrastructure
-
-=head1 SYNOPSIS
-
-gosa-si-client [-hvf] [-c config]
-
-=head1 OPTIONS
-
-B<-h>, B<--help>
- print out this help message
-
-B<-v>, B<--verbose>
- be verbose (multiple v's will increase verbosity)
- -v ERROR level
- -vvv WARNING + ERROR level
- -vvvvv INFO + WARNING level
- -vvvvvvv DEBUG + INFO level
- -vvvvvvvvv in and out going xml messages will be displayed
-
-B<-f>, B<--foreground>
- foregroud, process will not be forked to background
-
-B<-c> I<file>, B<--config=>I<file>
- configuration file, default F</etc/gosa-si/client.conf>
-
-
-=head1 DESCRIPTION
-
-B<gosa-si-client> belongs to the support infrastructure of GOsa.
-The client registrates at a GOsa-SI-server and accepts messages from it.
-Each message is related to a working instruction which will be executed on the client.
-Depending on the message an answer can be send back to the server.
-
-=head1 BUGS
-
-Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-devel@oss.gonicus.de> or to <https://oss.gonicus.de/labs/gosa>
-
-
-=head1 LICENCE AND COPYRIGHT
-
-This code is part of GOsa (L<http://www.gosa-project.org>)
-
-Copyright (C) 2003-2009 GONICUS GmbH
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-=cut
-
-
-
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 94f568e9ec170ab4fbaae37cf805217e4fd44234..9d92dc9971e4d9fe7c5f66a4cce57c8c4eca45d4 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
#!/usr/bin/perl
-#===============================================================================
-#
-# FILE: gosa-si-server
+#*********************************************************************
#
-# USAGE: ./gosa-si-server
+# gosa-si-client -- client for the gosa-si-server
#
-# DESCRIPTION:
+# (c) 2007-2009 by Andreas Rettenberger <rettenberger@gonicus.de>
+# (c) 2008-2010 by Cajus Pollmeier <pollmeier@gonicus.de>
+# (c) 2008-2009 by Jan Wenzel <wenzel@gonicus.de>
+# (c) 2010 by Benoit Mortier <benoit.mortier@opensides.be>
#
-# OPTIONS: ---
-# REQUIREMENTS: libconfig-inifiles-perl libcrypt-rijndael-perl libxml-simple-perl
-# libdata-dumper-simple-perl libdbd-sqlite3-perl libnet-ldap-perl
-# libpoe-perl
-# BUGS: ---
-# NOTES:
-# AUTHOR: (Andreas Rettenberger), <rettenberger@gonicus.de>
-# COMPANY:
-# VERSION: 1.0
-# CREATED: 12.09.2007 08:54:41 CEST
-# REVISION: ---
-#===============================================================================
+#*********************************************************************
-my $server_version = '$HeadURL: https://oss.gonicus.de/repositories/gosa/trunk/gosa-si/gosa-si-server $:$Rev$';
+
+=head1 NAME
+
+gosa-si-server -Support infrastructure for GOsa
+
+=head1 SYNOPSIS
+
+gosa-si-server [-hvf] [-c config] [-x dump ]
+
+=head1 OPTIONS
+
+B<-h>, B<--help>
+ print out this help message
+
+B<-v>, B<--verbose>
+ be verbose (multiple v's will increase verbosity)
+ -v ERROR level
+ -vvv WARNING + ERROR level
+ -vvvvv INFO + WARNING level
+ -vvvvvvv DEBUG + INFO level
+ -vvvvvvvvv in and out going xml messages will be displayed
+
+B<-f>, B<--foreground>
+ foregroud, process will not be forked to background
+
+B<-c> I<file>, B<--config=>I<file>
+ configuration file, default F</etc/gosa-si/server.conf>
+
+B<--no-arp>
+ starts script without connection to arp module
+
+B<-d> <int>
+ if verbose level is higher than 7 'v' specified parts can be debugged
+
+ 1 : receiving messages
+ 2 : sending messages
+ 4 : encrypting/decrypting messages
+ 8 : verification if a message complies gosa-si requirements
+ 16 : message processing
+ 32 : ldap connectivity
+ 64 : database status and connectivity
+ 128 : main process
+ 256 : creation of packages_list_db
+ 512 : ARP debug information
+
+B<-x> <dump>
+ dump configuration to stdout
+ ( 1 = current, 2 = default )
+
+=head1 DESCRIPTION
+
+gosa-si-server belongs to the support infrastructure of GOsa. Several gosa-si-clients can connect to one gosa-si-server. The server take care of the message forwarding from GOsa to si-clients. At the client site each message is related to a working instruction which will be executed there. Depending of the message an answer from the client to GOsa via the server is possible. Additional to answers clients reporting events or information to the server. The server registers himself at other servers in network and shares his knowledge with them. So messages to clients which are no registrated locally will be forward to the client corresponding server. The communication within the complete SI nework is realised by XML messages.
+
+
+=head1 BUGS
+
+Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-devel@oss.gonicus.de> or to <https://oss.gonicus.de/labs/gosa>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+This code is part of GOsa (L<http://www.gosa-project.org>)
+
+Copyright (C) 2003-2010 GONICUS GmbH
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+=cut
use strict;
use warnings;
+
use Getopt::Long;
use Config::IniFiles;
-use POSIX;
-
-use Fcntl qw/:flock/;
use IO::Socket::INET;
use IO::Handle;
use IO::Select;
-use Symbol qw(qualify_to_ref);
use Crypt::Rijndael;
use MIME::Base64;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use Data::Dumper;
use Sys::Syslog qw( :DEFAULT setlogsock);
use Time::HiRes qw( usleep clock_gettime );
-use Cwd;
use File::Spec;
use File::Basename;
use File::Find;
use File::Copy;
use File::Path;
-use GOSA::GosaSupportDaemon;
-use POE qw(Component::Server::TCP Wheel::Run Filter::Reference);
use Net::LDAP;
use Net::LDAP::Util qw(:escape);
+use File::Pid;
+use GOsaSI::GosaSupportDaemon;
+use POE qw(Component::Server::TCP Wheel::Run Filter::Reference);
+use Symbol qw(qualify_to_ref);
+use Fcntl qw/:flock/;
+use POSIX;
+
+my $server_version = '$HeadURL: https://oss.gonicus.de/repositories/gosa/trunk/gosa-si/gosa-si-server $:$Rev$';
# revision number of server and program name
my $server_headURL;
my $server_revision;
my $server_status;
-our $prg= basename($0);
-our $verbose= 0;
my $db_module = "DBsqlite";
{
no strict "refs";
-require ("GOSA/".$db_module.".pm");
-("GOSA/".$db_module)->import;
+require ("GOsaSI/".$db_module.".pm");
+("GOsaSI/".$db_module)->import;
}
my $modules_path = "/usr/lib/gosa-si/modules";
use lib "/usr/lib/gosa-si/modules";
-our $global_kernel;
my ($foreground, $ping_timeout);
my ($server);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
my ($messaging_db_loop_delay);
-my ($procid, $pid);
+my $procid;
my $arp_fifo;
my $debug_parts = 0;
my $debug_parts_bitstring;
my $repo_path;
my %repo_dirs=();
+my $server_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};
+
# Variables declared in config file are always set to 'our'
-our (%cfg_defaults, $log_file, $pid_file,
+our (%cfg_defaults, $log_file, $pid_file, $pid,
$server_ip, $server_port, $ClientPackages_key, $dns_lookup,
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_timeout,
our $known_functions;
our $root_uid;
our $adm_gid;
+our $verbose= 0;
+our $global_kernel;
+
+# where is the config stored by default and his name
+our $config = '/etc/gosa-si/server.conf';
+
+# by default dumping of config is undefined
+our $dump_config = undef;
# if foreground is not null, script will be not forked to background
$foreground = 0 ;
our $client_fai_log_dir = "/var/log/fai";
# queue which stores taskes until one of the $max_children children are ready to process the task
-#my @tasks = qw();
my @msgs_to_decrypt = qw();
my $max_children = 2;
@@ -231,11 +299,11 @@ our $check_periodic = {"months"=>'', "weeks"=>'', "days"=>'', "hours"=>'', "minu
%cfg_defaults = (
-"general" => {
- "log-file" => [\$log_file, "/var/run/".$prg.".log"],
- "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"],
+"General" => {
+ "log-file" => [\$log_file, "/var/log/gosa-si/gosa-si-server.log"],
+ "pid-file" => [\$pid_file, "/var/run/gosa-si/gosa-si-server.pid"],
},
-"server" => {
+"Server" => {
"ip" => [\$server_ip, "0.0.0.0"],
"port" => [\$server_port, "20081"],
"known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
@@ -248,7 +316,7 @@ our $check_periodic = {"months"=>'', "weeks"=>'', "days"=>'', "hours"=>'', "minu
"messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
"foreign-clients" => [\$foreign_clients_file_name, '/var/lib/gosa-si/foreign_clients.db'],
"source-list" => [\$sources_list, '/etc/apt/sources.list'],
- "repo-path" => [\$repo_path, '/srv/www/repository'],
+ "repo-path" => [\$repo_path, '/srv/www/debian'],
"debian-arch" => [\$arch, 'i386'],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
@@ -298,26 +366,40 @@ our $check_periodic = {"months"=>'', "weeks"=>'', "days"=>'', "hours"=>'', "minu
);
+#############################
+#
+# @brief Display error message and/or help text.
+#
+# In correspondence to previous GetOptions
+#
+# @param $text - string to print as error message
+# @param $help - set true, if you want to show usage help
+#
+sub usage
+{
+ my( $text, $help ) = @_;
+
+ $text = undef if( 'h' eq $text );
+ (defined $text) && print STDERR "\n$text\n";
-#=== FUNCTION ================================================================
-# NAME: usage
-# PARAMETERS: nothing
-# RETURNS: nothing
-# DESCRIPTION: print out usage text to STDERR
-#===============================================================================
-sub usage {
- print STDERR << "EOF" ;
-usage: $prg [-hvf] [-c config] [-d number]
+ if( (defined $help && $help)
+ || (!defined $help && !defined $text) )
+{
+ print STDERR << "EOF";
- -h : this (help) message
- -c <file> : config file
- -f : foreground, process will not be forked to background
+ usage: $0 [-hvf] [-c config] [-d number]
+
+ -h : this (help) message
+ -c <file> : config file (default: ${config})
+ -x <cfg> : dump configuration to stdout
+ ( 1 = current, 2 = default )
+ -f : foreground (don't fork)
-v : be verbose (multiple to increase verbosity)
'v': error logs
'vvv': warning plus error logs
'vvvvv': info plus warning logs
'vvvvvvv': debug plus info logs
- -no-arp : starts $prg without connection to arp module
+ -no-arp : starts gosa-si-server without connection to arp module
-d <int> : if verbose level is higher than 7x 'v' specified parts can be debugged
1 : report incoming messages
2 : report unencrypted outgoing messages
256 : creation of packages_list_db
512 : ARP debug information
EOF
- exit(0);
+}
+ print( "\n" );
+
+ exit( -1 );
+}
+
+#############################
+#
+# @brief Manage gosa-si-client configuration.
+#
+# Will exit after successfull dump to stdout (type = 1 | 2)
+#
+# Dump type can be:
+# 1: Current gosa-si-client configuration in config file (exit)
+# 2: Default gosa-si-client configuration (exit)
+# 3: Dump to logfile (no exit)
+#
+# @param int config type
+#
+sub dump_configuration {
+
+ my( $cfg_type ) = @_;
+
+ return if( ! defined $cfg_type );
+
+ if(1==$cfg_type ) {
+ print( "# Current gosa-si-server configuration\n" );
+ } elsif (2==$cfg_type) {
+ print( "# Default gosa-si-server configuration\n" );
+ } elsif (3==$cfg_type) {
+ daemon_log( "Dumping gosa-si-server configuration\n", 2 );
+ } else {
+ return;
+ }
+
+ foreach my $section (keys %cfg_defaults) {
+ if( 3 != $cfg_type ) {
+ print( "\n[${section}]\n" );
+ } else {
+ daemon_log( "\n [${section}]\n", 3 );
+ }
+
+ foreach my $param (sort( keys %{$cfg_defaults{ $section }})) {
+ my $pinfo = $cfg_defaults{ $section }{ $param };
+ my $value;
+ if (1==$cfg_type) {
+ if( defined( ${@$pinfo[ 0 ]} ) ) {
+ $value = ${@$pinfo[ 0 ]};
+ print( "$param=$value\n" );
+ } else {
+ print( "#${param}=\n" );
+ }
+ } elsif (2==$cfg_type) {
+ $value = @{$pinfo}[ 1 ];
+ if( defined( @$pinfo[ 1 ] ) ) {
+ $value = @{$pinfo}[ 1 ];
+ print( "$param=$value\n" );
+ } else {
+ print( "#${param}=\n" );
+ }
+ } elsif (3==$cfg_type) {
+ if( defined( ${@$pinfo[ 0 ]} ) ) {
+ $value = ${@$pinfo[ 0 ]};
+ daemon_log( " $param=$value\n", 3 )
+ }
+ }
+ }
+ }
+
+
+# We just exit at stdout dump
+ if( 3 == $cfg_type ) {
+ daemon_log( "\n", 3 );
+ } else {
+ exit( 0 );
+ }
}
# Build log message and write it to log file and commandline
chomp($msg);
- my $log_msg = "$month $monthday $hours:$minutes:$seconds$microSeconds $prg $msg\n";
+ my $log_msg = "$month $monthday $hours:$minutes:$seconds$microSeconds $0 $msg\n";
flock(LOG_HANDLE, LOCK_EX);
seek(LOG_HANDLE, 0, 2);
print LOG_HANDLE $log_msg;
}
}
-
-#=== FUNCTION ================================================================
-# NAME: check_cmdline_param
-# PARAMETERS: nothing
-# RETURNS: nothing
-# DESCRIPTION: validates commandline parameter
-#===============================================================================
-sub check_cmdline_param () {
- my $err_counter = 0;
-
- # Check configuration file
- if(not defined($cfg_file)) {
- $cfg_file = "/etc/gosa-si/server.conf";
- if(! -r $cfg_file) {
- print STDERR "Please specify a config file.\n";
- $err_counter++;
- }
- }
-
- # Prepare identification which gosa-si parts should be debugged and which not
- if (defined $debug_parts)
- {
- if ($debug_parts =~ /^\d+$/)
- {
- $debug_parts_bitstring = unpack("B32", pack("N", $debug_parts));
- }
- else
- {
- print STDERR "Value '$debug_parts' invalid for option d (number expected)\n";
- $err_counter++;
- }
- }
-
- # Exit if an error occour
- if( $err_counter > 0 ) { &usage( "", 1 ); }
-}
-
-
-#=== FUNCTION ================================================================
-# NAME: check_pid
-# PARAMETERS: nothing
-# RETURNS: nothing
-# DESCRIPTION: handels pid processing
-#===============================================================================
-sub check_pid {
- $pid = -1;
- # Check, if we are already running
- if( open(LOCK_FILE, "<$pid_file") ) {
- $pid = <LOCK_FILE>;
- if( defined $pid ) {
- chomp( $pid );
- if( -f "/proc/$pid/stat" ) {
- my($stat) = `cat /proc/$pid/stat` =~ m/$pid \((.+)\).*/;
- if( $stat ) {
- print STDERR "\nERROR: Already running!\n";
- close( LOCK_FILE );
- exit -1;
- }
- }
- }
- close( LOCK_FILE );
- unlink( $pid_file );
- }
-
- # create a syslog msg if it is not to possible to open PID file
- if (not sysopen(LOCK_FILE, $pid_file, O_WRONLY|O_CREAT|O_EXCL, 0644)) {
- my($msg) = "Couldn't obtain lockfile '$pid_file' ";
- if (open(LOCK_FILE, '<', $pid_file)
- && ($pid = <LOCK_FILE>))
- {
- chomp($pid);
- $msg .= "(PID $pid)\n";
- } else {
- $msg .= "(unable to read PID)\n";
- }
- if( ! ($foreground) ) {
- openlog( $0, "cons,pid", "daemon" );
- syslog( "warning", $msg );
- closelog();
- }
- else {
- print( STDERR " $msg " );
- }
- exit( -1 );
- }
-}
-
#=== FUNCTION ================================================================
# NAME: import_modules
# PARAMETERS: module_path - string - abs. path to the directory the modules
#=== FUNCTION ================================================================
# NAME: sig_int_handler
-# PARAMETERS: signal - string - signal arose from system
+# PARAMETERS: signal - string - signal came from system
# RETURNS: nothing
-# DESCRIPTION: handels tasks to be done befor signal becomes active
+# DESCRIPTION: handle tasks to be done before signal becomes active
#===============================================================================
sub sig_int_handler {
- my ($signal) = @_;
+ my ($signal) = @_;
# if (defined($ldap_handle)) {
# $ldap_handle->disconnect;
# }
- # TODO alle verbliebenden ldap verbindungen aus allen heaps beenden
+# TODO all ldap connections shoudl be closed
+ daemon_log("shutting down gosa-si-server", 1);
+
+ # asking the poe kernel to shutdown the server
+ $global_kernel->yield(TCP_SERVER => 'shutdown');
+
+ # removing the pidfile
+ $pid->remove or warn "Could not remove $pid_file\n";
- daemon_log("shutting down gosa-si-server", 1);
- system("kill `ps -C gosa-si-server -o pid=`");
+ exit(0);
}
$SIG{INT} = \&sig_int_handler;
}
sub session_start {
- my ($kernel) = $_[KERNEL];
- $global_kernel = $kernel;
- $kernel->yield('register_at_foreign_servers');
+ my ($kernel) = $_[KERNEL];
+ $global_kernel = $kernel;
+ $kernel->yield('register_at_foreign_servers');
$kernel->yield('create_fai_server_db', $fai_server_tn );
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
$kernel->sig(USR2 => "recreate_packages_db");
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
- $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
$kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
- $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
+ $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
- $kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay);
- # Start opsi check
- if ($opsi_enabled eq "true") {
- $kernel->delay_set('watch_for_opsi_jobs', $job_queue_opsi_delay);
- }
+ # Start opsi check
+ if ($opsi_enabled eq "true") {
+ $kernel->delay_set('watch_for_opsi_jobs', $job_queue_opsi_delay);
+ }
}
&main::daemon_log("$session_id DEBUG: remove an old version of '$result'", 7);
}
- my $fh;
- open($fh, ">$result");
+ open(my $fh, ">", "$result");
if (not defined $fh) {
&main::daemon_log("$session_id DEBUG: cannot open '$result' for writing", 7);
return undef;
my $line;
- open(CONFIG, "<$sources_file") or do {
+ open(my $CONFIG, "<", "$sources_file") or do {
daemon_log( "$session_id ERROR: create_packages_list_db: Failed to open '$sources_file'", 1);
unlink($packages_list_under_construction);
return;
};
# Read lines
- while ($line = <CONFIG>){
+ while ($line = <$CONFIG>){
# Unify
chop($line);
$line =~ s/^\s+//;
&parse_package_info( $baseurl, $dist, $section, $session_id );
}
}
+ else {
+ daemon_log("$session_id ERROR: cannot parse line '$line'", 1);
+ }
}
- close (CONFIG);
+ close ($CONFIG);
if(keys(%repo_dirs)) {
find(\&cleanup_and_extract, keys( %repo_dirs ));
my ($path, $dist, $srv_path, $session_id)= @_;
if (not defined $session_id) { $session_id = 0;}
my ($package, $version, $section, $description);
- my $PACKAGES;
my $timestamp = &get_time();
if(not stat("$path.in")) {
return;
}
- open($PACKAGES, "<$path.in");
+ open(my $PACKAGES, "<", "$path.in");
if(not defined($PACKAGES)) {
daemon_log("$session_id ERROR: create_packages_list_db: parse_package: cannot open '$path.in'",1);
return;
my $tmpl= ""; {
local $/=undef;
- open FILE, "$dir/DEBIAN/templates";
- $tmpl = &encode_base64(<FILE>);
- close FILE;
+ open(my $FILE, "$dir/DEBIAN/templates");
+ $tmpl = &encode_base64(<$FILE>);
+ close($FILE);
}
rmtree("$dir/DEBIAN/templates");
return;
}
+sub start_daemon {
-#==== MAIN = main ==============================================================
-# parse commandline options
-Getopt::Long::Configure( "bundling" );
-GetOptions("h|help" => \&usage,
- "c|config=s" => \$cfg_file,
- "f|foreground" => \$foreground,
- "v|verbose+" => \$verbose,
- "no-arp+" => \$no_arp,
- "d=s" => \$debug_parts,
- ) or &usage("", 1);
+ #to prevent zombie child
+ $SIG{CHLD} = 'IGNORE';
-# read and set config parameters
-&check_cmdline_param ;
-&read_configfile($cfg_file, %cfg_defaults);
-&check_pid;
-
-#to prevent sombie child
-$SIG{CHLD} = 'IGNORE';
-
-# forward error messages to logfile
-if( ! $foreground ) {
- open( STDIN, '+>/dev/null' );
- open( STDOUT, '+>&STDIN' );
- open( STDERR, '+>&STDIN' );
-}
-
-# Just fork, if we are not in foreground mode
-if( ! $foreground ) {
- chdir '/' or die "Can't chdir to /: $!";
- $pid = fork;
- setsid or die "Can't start a new session: $!";
- umask 0;
-#} 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 );
- if( !$foreground ) {
- exit( 0 )
- };
+ if( ! $foreground ) {
+ chdir '/' or die "Can't chdir to /: $!";
+ umask 0;
+ open STDIN, '+>/dev/null' or die "Can't read /dev/null: $!";
+ open STDOUT, '+>&STDIN' or die "Can't write to /dev/null: $!";
+ open STDERR, '+>&STDIN' or die "Can't write to /dev/null: $!";
+ defined($pid = fork) or die "Can't fork: $!";
+ exit if $pid;
+ setsid or die "Can't start a new session: $!";
+ }
+ return;
}
-# parse head url and revision from svn
-my $server_status_hash = { 'developmental'=>'revision', 'stable'=>'release'};
-$server_version =~ /^\$HeadURL: (\S+) \$:\$Rev: (\d+) \$$/;
-$server_headURL = defined $1 ? $1 : 'unknown' ;
-$server_revision = defined $2 ? $2 : 'unknown' ;
-if ($server_headURL =~ /\/tag\// ||
+sub put_version {
+
+ # parse head url and revision from svn
+ $server_version =~ /^\$HeadURL: (\S+) \$:\$Rev: (\d+) \$$/;
+ $server_headURL = defined $1 ? $1 : 'unknown' ;
+ $server_revision = defined $2 ? $2 : 'unknown' ;
+ if ($server_headURL =~ /\/tag\// ||
$server_headURL =~ /\/branches\// ) {
- $server_status = "stable";
-} else {
+ $server_status = "stable";
+ } else {
$server_status = "developmental" ;
+ }
+ return;
+}
+
+sub get_perms_admin {
+# Determine root uid and adm gid, used for creating log files
+ $root_uid = getpwnam('root');
+ $adm_gid = getgrnam('adm');
+ if(not defined $adm_gid){
+ $adm_gid = getgrnam('root');
+ }
+ return;
+}
+
+sub open_log {
+ # Prepare log file and set permissions
+ open(my $log, ">>", "$log_file");
+ close($log);
+ chmod(0440, $log_file);
+ chown($root_uid, $adm_gid, $log_file);
+
+ return;
+}
+
+sub create_pid {
+ # Create the PID object
+ $pid = File::Pid->new({ file => $pid_file });
+
+ # Write the PID file
+ $pid->write;
+
+ return;
}
-# Prepare log file and set permissions
-$root_uid = getpwnam('root');
-$adm_gid = getgrnam('adm');
-open(FH, ">>$log_file");
-close FH;
-chmod(0440, $log_file);
-chown($root_uid, $adm_gid, $log_file);
-chown($root_uid, $adm_gid, "/var/lib/gosa-si");
+
+#
+#==== MAIN = main ==============================================================
+#
+# Parse options and allow '-vvv'
+Getopt::Long::Configure( 'bundling' );
+GetOptions( 'v|verbose+' => \$verbose,
+ 'h|help' => \&usage,
+ 'c|config=s' => \$config,
+ 'x|dump-config=i' => \$dump_config,
+ 'f|foreground' => \$foreground,
+ 'd=s' => \$debug_parts)
+ or usage( '', 1 );
+
+# We may want to dump the default configuration
+if( defined $dump_config ) {
+ if($dump_config==1) {
+ } elsif ($dump_config==2) {
+ dump_configuration( $dump_config );
+ } else {
+ usage( "Dump configuration value has to be 1 or 2" );
+ }
+}
+
+# read and set config parameters
+&read_configfile($config, %cfg_defaults);
+
+# daemonize the program
+&start_daemon($pid, $foreground);
+
+# create pid file
+&create_pid($pid, $pid_file);
+
+# Determine root uid and adm gid, used for creating log files
+&get_perms_admin($root_uid, $adm_gid);
+
+# put version
+&put_version($server_status_hash, $server_version, $server_headURL, $server_revision, $server_status);
+
+#open log file
+&open_log($root_uid, $adm_gid, $log_file);
+
+# prepare directory for databases
+mkpath('/var/lib/gosa-si', 0, {owner=>'root', group=>'root', mode=> '0755'});
+
+# remove leftover files in tmp for packaged.db populate
+rmtree( '/tmp/packages_list_db',0,1);
+
+# remove list of sources from apt.sources.list
+unlink '/tmp/gosa_si_tmp_sources_list';
+
+# remove marker that the list creation is in progress
+unlink '/tmp/packages_list_creation_in_progress';
daemon_log(" ", 1);
daemon_log("$0 started!", 1);
{
no strict "refs";
- if ($db_module eq "DBmysql") {
-
- daemon_log("0 INFO: importing database module '$db_module'", 1);
+ daemon_log("0 INFO: importing database module '$db_module'", 1);
+ if ($db_module eq "DBmysql") {
+
# connect to incoming_db
- $incoming_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $incoming_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to gosa-si job queue
- $job_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $job_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to known_clients_db
- $known_clients_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $known_clients_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to foreign_clients_db
- $foreign_clients_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $foreign_clients_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to known_server_db
- $known_server_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $known_server_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to login_usr_db
- $login_users_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $login_users_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to fai_server_db
- $fai_server_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $fai_server_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to fai_release_db
- $fai_release_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $fai_release_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to packages_list_db
- $packages_list_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $packages_list_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
# connect to messaging_db
- $messaging_db = ("GOSA::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
+ $messaging_db = ("GOsaSI::".$db_module)->new($main::mysql_database, $main::mysql_host, $main::mysql_username, $main::mysql_password);
} elsif ($db_module eq "DBsqlite") {
- daemon_log("0 INFO: importing database module '$db_module'", 1);
+ daemon_log("0 INFO: Removing SQLlite lock files", 1);
+
+ # delete old DBsqlite lock files to be replace by rmtree !!
+ system('rm -f /var/lib/gosa-si/*.si.lock*');
+ #rmtree( '/var/lib/gosa-si/',0,1);
# connect to incoming_db
unlink($incoming_file_name);
- $incoming_db = GOSA::DBsqlite->new($incoming_file_name);
- chmod(0640, $incoming_file_name);
- chown($root_uid, $adm_gid, $incoming_file_name);
-
+ $incoming_db = ("GOsaSI::".$db_module)->new($incoming_file_name);
+
# connect to gosa-si job queue
- $job_db = GOSA::DBsqlite->new($job_queue_file_name);
- chmod(0640, $job_queue_file_name);
- chown($root_uid, $adm_gid, $job_queue_file_name);
+ $job_db = ("GOsaSI::".$db_module)->new($job_queue_file_name);
# connect to known_clients_db
- #unlink($known_clients_file_name);
- $known_clients_db = GOSA::DBsqlite->new($known_clients_file_name);
- chmod(0640, $known_clients_file_name);
- chown($root_uid, $adm_gid, $known_clients_file_name);
+ $known_clients_db = ("GOsaSI::".$db_module)->new($known_clients_file_name);
# connect to foreign_clients_db
- #unlink($foreign_clients_file_name);
- $foreign_clients_db = GOSA::DBsqlite->new($foreign_clients_file_name);
- chmod(0640, $foreign_clients_file_name);
- chown($root_uid, $adm_gid, $foreign_clients_file_name);
+ $foreign_clients_db = ("GOsaSI::".$db_module)->new($foreign_clients_file_name);
# connect to known_server_db
- unlink($known_server_file_name); # do not delete, gosa-si-server should be forced to check config file and dns at each start
- $known_server_db = GOSA::DBsqlite->new($known_server_file_name);
- chmod(0640, $known_server_file_name);
- chown($root_uid, $adm_gid, $known_server_file_name);
+ $known_server_db = ("GOsaSI::".$db_module)->new($known_server_file_name);
# connect to login_usr_db
- #unlink($login_users_file_name);
- $login_users_db = GOSA::DBsqlite->new($login_users_file_name);
- chmod(0640, $login_users_file_name);
- chown($root_uid, $adm_gid, $login_users_file_name);
+ $login_users_db = ("GOsaSI::".$db_module)->new($login_users_file_name);
# connect to fai_server_db
- unlink($fai_server_file_name);
- $fai_server_db = GOSA::DBsqlite->new($fai_server_file_name);
- chmod(0640, $fai_server_file_name);
- chown($root_uid, $adm_gid, $fai_server_file_name);
+ $fai_server_db = ("GOsaSI::".$db_module)->new($fai_server_file_name);
# connect to fai_release_db
- unlink($fai_release_file_name);
- $fai_release_db = GOSA::DBsqlite->new($fai_release_file_name);
- chmod(0640, $fai_release_file_name);
- chown($root_uid, $adm_gid, $fai_release_file_name);
+ $fai_release_db = ("GOsaSI::".$db_module)->new($fai_release_file_name);
# connect to packages_list_db
- unlink($packages_list_under_construction);
- $packages_list_db = GOSA::DBsqlite->new($packages_list_file_name);
- chmod(0640, $packages_list_file_name);
- chown($root_uid, $adm_gid, $packages_list_file_name);
+ $packages_list_db = ("GOsaSI::".$db_module)->new($packages_list_file_name);
# connect to messaging_db
- #unlink($messaging_file_name);
- $messaging_db = GOSA::DBsqlite->new($messaging_file_name);
- chmod(0640, $messaging_file_name);
- chown($root_uid, $adm_gid, $messaging_file_name);
+ $messaging_db = ("GOsaSI::".$db_module)->new($messaging_file_name);
}
}
$opsi_client = new JSON::RPC::Client;
}
+daemon_log("0 INFO: start socket for incoming xml messages at port '$server_port' ", 1);
POE::Component::Server::TCP->new(
Alias => "TCP_SERVER",
}
);
-daemon_log("0 INFO: start socket for incoming xml messages at port '$server_port' ", 1);
-
# create session for repeatedly checking the job queue for jobs
POE::Session->create(
inline_states => {
- _start => \&session_start,
+ _start => \&session_start,
register_at_foreign_servers => \®ister_at_foreign_servers,
- control_server_registration => \&control_server_registration,
+ control_server_registration => \&control_server_registration,
sig_handler => \&sig_handler,
next_task => \&next_task,
task_result => \&handle_task_result,
watch_for_new_messages => \&watch_for_new_messages,
watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
- watch_for_new_jobs => \&watch_for_new_jobs,
+ watch_for_new_jobs => \&watch_for_new_jobs,
watch_for_modified_jobs => \&watch_for_modified_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
watch_for_opsi_jobs => \&watch_for_opsi_jobs,
create_packages_list_db => \&run_create_packages_list_db,
create_fai_server_db => \&run_create_fai_server_db,
create_fai_release_db => \&run_create_fai_release_db,
- recreate_packages_db => \&run_recreate_packages_db,
+ recreate_packages_db => \&run_recreate_packages_db,
session_run_result => \&session_run_result,
session_run_debug => \&session_run_debug,
session_run_done => \&session_run_done,
index a097799b14c764cc30742f0445f8dafa640cddd0..78e90100e0cf78ae20618adeab04ffa4c3c4ebfd 100644 (file)
--- a/gosa-si/gosa-si-server.1
+++ b/gosa-si/gosa-si-server.1
-.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.\" ========================================================================
.\"
.IX Title "GOSA-SI-SERVER 1"
-.TH GOSA-SI-SERVER 1 "2009-09-23" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH GOSA-SI-SERVER 1 "2010-05-17" "perl v5.10.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
gosa\-si\-server \-Support infrastructure for GOsa
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
-gosa-si-server [\-hvf] [\-c config]
+gosa-si-server [\-hvf] [\-c config] [\-x dump ]
.SH "OPTIONS"
.IX Header "OPTIONS"
\&\fB\-h\fR, \fB\-\-help\fR
\& 256 : creation of packages_list_db
\& 512 : ARP debug information
.Ve
+.PP
+\&\fB\-x\fR <dump>
+ dump configuration to stdout
+ ( 1 = current, 2 = default )
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
gosa-si-server belongs to the support infrastructure of GOsa. Several gosa-si-clients can connect to one gosa-si-server. The server take care of the message forwarding from GOsa to si-clients. At the client site each message is related to a working instruction which will be executed there. Depending of the message an answer from the client to GOsa via the server is possible. Additional to answers clients reporting events or information to the server. The server registers himself at other servers in network and shares his knowledge with them. So messages to clients which are no registrated locally will be forward to the client corresponding server. The communication within the complete \s-1SI\s0 nework is realised by \s-1XML\s0 messages.
@@ -181,7 +185,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa\
.IX Header "LICENCE AND COPYRIGHT"
This code is part of GOsa (<http://www.gosa\-project.org>)
.PP
-Copyright (C) 2003\-2009 \s-1GONICUS\s0 GmbH
+Copyright (C) 2003\-2010 \s-1GONICUS\s0 GmbH
.PP
This program is distributed in the hope that it will be useful,
but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
index 2d601f5787a4b7d536c9821dd93f327dccea31fb..2c8d0c66024eef3daa5e69209f025c4a07d78cef 100644 (file)
-.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05)
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.\" ========================================================================
.\"
.IX Title "SERVER.CONF 1"
-.TH SERVER.CONF 1 "2009-10-02" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH SERVER.CONF 1 "2010-05-17" "perl v5.10.0" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
The gosa\-si\-server.conf file defines all parameter GOsa-SI-server needs for running. It is normally located in the /etc/gosa\-si/ directory and is generated automatically by the \fIgosa\-si\-server\fR\|(1) program during installation.
.SH "DIRECTIVES"
.IX Header "DIRECTIVES"
-.SS "[general]"
-.IX Subsection "[general]"
-.IP "logfile = /var/log/gosa\-si\-server.log" 4
-.IX Item "logfile = /var/log/gosa-si-server.log"
+.SS "[General]"
+.IX Subsection "[General]"
+.IP "logfile = /var/log/gosa\-si/gosa\-si\-server.log" 4
+.IX Item "logfile = /var/log/gosa-si/gosa-si-server.log"
Defines the location for the log file.
-.IP "pid-file = /var/run/gosa\-si\-server.pid Defines the location for the pid file." 4
-.IX Item "pid-file = /var/run/gosa-si-server.pid Defines the location for the pid file."
-.SS "[server]"
-.IX Subsection "[server]"
+.IP "pid-file = /var/run/gosa\-si/gosa\-si\-server.pid Defines the location for the pid file." 4
+.IX Item "pid-file = /var/run/gosa-si/gosa-si-server.pid Defines the location for the pid file."
+.SS "[Server]"
+.IX Subsection "[Server]"
.PD 0
.IP "ip = 1.2.3.4" 4
.IX Item "ip = 1.2.3.4"
.IP "source-list = /etc/apt/sources.list" 4
.IX Item "source-list = /etc/apt/sources.list"
Defines the location for the sources file.
-.IP "repo-path = /srv/www/repository" 4
-.IX Item "repo-path = /srv/www/repository"
+.IP "repo-path = /srv/www/" 4
+.IX Item "repo-path = /srv/www/"
Defines the location of the dak Archive or local Debian Mirror and is scanned for Debian Packages.
.IP "debian-arch = i386" 4
.IX Item "debian-arch = i386"
.IX Subsection "[ServerPackages]"
.IP "address =" 4
.IX Item "address ="
-Comma seperated list of GOsa-si-servers (1.2.3.4:20081,9.8.7.6:123) in network where this SI-server should register. These given SI-servers extend the list of SI-servers found in \s-1DNS\s0.
+Comma separated list of GOsa-si-servers (1.2.3.4:20081,9.8.7.6:123) in network where this SI-server should register. These given SI-servers extend the list of SI-servers found in \s-1DNS\s0.
.IP "dns-lookup = true" 4
.IX Item "dns-lookup = true"
Perform a \s-1DNS\s0 lookup for server registration
Defines the lifetime in seconds of a GOsa-SI-server key. After expiring the key will be automatically renewed.
.IP "job-synchronization-enabled = true" 4
.IX Item "job-synchronization-enabled = true"
-Defines whether job queue informations are be shared with other GOsa-SI-server in network.
+Defines whether job queue information are be shared with other GOsa-SI-server in network.
.IP "synchronization-loog = 5" 4
.IX Item "synchronization-loog = 5"
Defines in seconds after which time the job queue synchronization is being done.
@@ -289,7 +289,7 @@ Space\- or comma-separated list of interfaces on which to start an ARP-Daemon. E
.IX Subsection "[Opsi]"
.IP "enabled = false" 4
.IX Item "enabled = false"
-Defines wheter Opsi integration is being enabled or not.
+Defines whether Opsi integration is being enabled or not.
.IP "server = localhost" 4
.IX Item "server = localhost"
Define the hostname of the Opsi server
@@ -306,7 +306,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa\
.IX Header "LICENCE AND COPYRIGHT"
This code is part of GOsa (<http://www.gosa\-project.org>)
.PP
-Copyright (C) 2003\-2009 \s-1GONICUS\s0 GmbH
+Copyright (C) 2003\-2010 \s-1GONICUS\s0 GmbH
.PP
This program is distributed in the hope that it will be useful,
but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
diff --git a/gosa-si/gosa-si-server.pod b/gosa-si/gosa-si-server.pod
+++ /dev/null
@@ -1,71 +0,0 @@
-
-=head1 NAME
-
-gosa-si-server -Support infrastructure for GOsa
-
-=head1 SYNOPSIS
-
-gosa-si-server [-hvf] [-c config]
-
-=head1 OPTIONS
-
-B<-h>, B<--help>
- print out this help message
-
-B<-v>, B<--verbose>
- be verbose (multiple v's will increase verbosity)
- -v ERROR level
- -vvv WARNING + ERROR level
- -vvvvv INFO + WARNING level
- -vvvvvvv DEBUG + INFO level
- -vvvvvvvvv in and out going xml messages will be displayed
-
-B<-f>, B<--foreground>
- foregroud, process will not be forked to background
-
-B<-c> I<file>, B<--config=>I<file>
- configuration file, default F</etc/gosa-si/server.conf>
-
-B<--no-arp>
- starts script without connection to arp module
-
-B<-d> <int>
- if verbose level is higher than 7 'v' specified parts can be debugged
-
- 1 : receiving messages
- 2 : sending messages
- 4 : encrypting/decrypting messages
- 8 : verification if a message complies gosa-si requirements
- 16 : message processing
- 32 : ldap connectivity
- 64 : database status and connectivity
- 128 : main process
- 256 : creation of packages_list_db
- 512 : ARP debug information
-
-
-=head1 DESCRIPTION
-
-gosa-si-server belongs to the support infrastructure of GOsa. Several gosa-si-clients can connect to one gosa-si-server. The server take care of the message forwarding from GOsa to si-clients. At the client site each message is related to a working instruction which will be executed there. Depending of the message an answer from the client to GOsa via the server is possible. Additional to answers clients reporting events or information to the server. The server registers himself at other servers in network and shares his knowledge with them. So messages to clients which are no registrated locally will be forward to the client corresponding server. The communication within the complete SI nework is realised by XML messages.
-
-
-=head1 BUGS
-
-Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-devel@oss.gonicus.de> or to <https://oss.gonicus.de/labs/gosa>
-
-
-=head1 LICENCE AND COPYRIGHT
-
-This code is part of GOsa (L<http://www.gosa-project.org>)
-
-Copyright (C) 2003-2009 GONICUS GmbH
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-=cut
-
-
-
index 210e95654f4e0231a4f6888c3a3f46d351925232..408d80ac667963633d09b2bad95ee6182e84634f 100644 (file)
package ArpHandler;
-use Exporter;
-@ISA = ("Exporter");
-
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
-use POSIX;
-use Fcntl;
+
use Net::LDAP;
use Net::LDAP::LDIF;
use Net::LDAP::Entry;
use Net::DNS;
use Switch;
use Data::Dumper;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
+use POSIX;
+use Fcntl;
use Socket;
+our @ISA = ("Exporter");
+
# Don't start if some of the modules are missing
my $start_service=1;
my $lookup_vendor=1;
},
);
+# to be removed use only main::read_configfile
#=== FUNCTION ================================================================
# NAME: read_configfile
# PARAMETERS: cfg_file - string -
# Don't start if some of the modules are missing
if(($arp_enabled eq 'true') && $start_service) {
if($lookup_vendor) {
+ # put the file in /etc/gosa/oui.txt or use the native oui.txt from snmp
eval("Net::MAC::Vendor::load_cache('file:///usr/lib/gosa-si/modules/oui.txt')");
if($@) {
&main::daemon_log("Loading OUI cache file failed! MAC Vendor lookup disabled", 1);
my $mac=shift;
my $result={};
- my $ldap_handle = &main::get_ldap_handle();
+ my $ldap_handle = &main::get_ldap_handle();
if(defined($ldap_handle)) {
my $ldap_result= &search_ldap_entry(
$ldap_handle,
index fb8aab830dd33adcc62e5226f235e304b16f934c..ad94ee2f0e3d45918a1dd7a4b844efde95bc0adf 100644 (file)
package ClientPackages;
-use Exporter;
-@ISA = ("Exporter");
-
# Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and receives the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it.
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
+
use IO::Socket::INET;
use XML::Simple;
use Data::Dumper;
use Net::LDAP::Util;
use Socket;
use Net::hostent;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
+
+our @ISA = ("Exporter");
my $event_dir = "/usr/lib/gosa-si/server/ClientPackages";
use lib "/usr/lib/gosa-si/server/ClientPackages";
my $mesg;
my %cfg_defaults = (
-"server" => {
+"Server" => {
"ip" => [\$server_ip, "0.0.0.0"],
"mac-address" => [\$main::server_mac_address, "00:00:00:00:00"],
"port" => [\$server_port, "20081"],
### START #####################################################################
# read configfile and import variables
+#why not using the main::read_configfile !!
&local_read_configfile();
if ( defined($msg_hash->{'force-hostname'}[0]) &&
length($msg_hash->{'force-hostname'}[0]) > 0){
# $heap->{force-hostname}->{$mac_address}= $msg_hash->{'force-hostname'}[0];
- open (TFILE, ">/var/tmp/$mac_address");
- print TFILE $msg_hash->{'force-hostname'}[0];
- close (TFILE);
+ open (my $TFILE, ">", "/var/tmp/$mac_address");
+ print $TFILE $msg_hash->{'force-hostname'}[0];
+ close ($TFILE);
} else {
# $heap->{force-hostname}->{$mac_address}= undef;
if ( -e "/var/tmp/$mac_address") {
if($ldap_res->code) {
&main::daemon_log("$session_id ERROR: LDAP Entry for client with mac address $mac_address not found: ".$ldap_res->error, 1);
} elsif ($ldap_res->count != 1) {
- &main::daemon_log("$session_id ERROR: client with mac address $mac_address not found/unique/active - not updating ldap entry".
+ &main::daemon_log("$session_id WARNING: client with mac address $mac_address not found/unique/active - not updating ldap entry".
"\n\tbase: $ldap_base".
"\n\tscope: sub".
"\n\tattrs: ipHostNumber".
# Sanity check
if ($ldap_res->count != 1) {
- &main::daemon_log("$session_id ERROR: client with mac address $mac_address not found/unique/active - not sending syslog config".
+ &main::daemon_log("$session_id WARNING: client with mac address $mac_address not found/unique/active - not sending syslog config".
"\n\tbase: $ldap_base".
"\n\tscope: sub".
"\n\tattrs: gotoSyslogServer".
# Sanity check
if ($mesg->count != 1) {
- &main::daemon_log("$session_id ERROR: new_ldap_config: client with mac address $macaddress not found/unique/active - not sending ldap config".
+ &main::daemon_log("$session_id WARNING: new_ldap_config: client with mac address $macaddress not found/unique/active - not sending ldap config".
"\n\tbase: $ldap_base".
"\n\tscope: sub".
"\n\tattrs: dn, gotoLdapServer, FAIclass".
} else {
my $PROC_NET_ROUTE= ('/proc/net/route');
- open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
+ open(my $FD_PROC_NET_ROUTE, "<", "$PROC_NET_ROUTE")
or die "Could not open $PROC_NET_ROUTE";
- my @ifs = <PROC_NET_ROUTE>;
+ my @ifs = <$FD_PROC_NET_ROUTE>;
- close(PROC_NET_ROUTE);
+ close($FD_PROC_NET_ROUTE);
# Eat header line
shift @ifs;
index 9f0b12b4ae921313b7c259dee11163394d5fcbf9..8e3784df7cab92b024fe4cc5d4aaaf34f1298db9 100644 (file)
-package GOSA::DBsqlite;
+package GOsaSI::DBsqlite;
use strict;
use warnings;
-use Carp;
-use DBI;
-use GOSA::GosaSupportDaemon;
+
+
use Time::HiRes qw(usleep);
use Data::Dumper;
+use GOsaSI::GosaSupportDaemon;
+
use Fcntl qw/:DEFAULT :flock/; # import LOCK_* constants
+use Carp;
+use DBI;
our $col_names = {};
sub connect {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::connect was called static! Argument was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::connect was called static! Argument was '$self'!", 1);
return;
}
sub disconnect {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::disconnect was called static! Argument was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::disconnect was called static! Argument was '$self'!", 1);
return;
}
sub lock {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::lock was called static! Argument was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::lock was called static! Argument was '$self'!", 1);
return;
}
sub unlock {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::unlock was called static! Argument was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::unlock was called static! Argument was '$self'!", 1);
return;
}
if(not ref $self->{db_lock_handle}) {
sub create_table {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::create_table was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::create_table was called static! Statement was '$self'!", 1);
return;
}
my $table_name = shift;
sub update_dbentry {
my ($self, $sql)= @_;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::update_dbentry was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::update_dbentry was called static! Statement was '$self'!", 1);
return;
}
my $db_answer= $self->exec_statement($sql);
sub del_dbentry {
my ($self, $sql)= @_;;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::del_dbentry was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::del_dbentry was called static! Statement was '$self'!", 1);
return;
}
my $db_res= $self->exec_statement($sql);
sub get_table_columns {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::get_table_columns was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::get_table_columns was called static! Statement was '$self'!", 1);
return;
}
my $table = shift;
sub select_dbentry {
my ($self, $sql)= @_;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::select_dbentry was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::select_dbentry was called static! Statement was '$self'!", 1);
return;
}
my $error= 0;
sub show_table {
my $self = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::show_table was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::show_table was called static! Statement was '$self'!", 1);
return;
}
my $table_name = shift;
sub exec_statement {
my $self = shift;
my $sql_statement = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::exec_statement was called static! Statement was '$self'!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::exec_statement was called static! Statement was '$self'!", 1);
return;
}
if(not defined($sql_statement) or length($sql_statement) == 0) {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::exec_statement was called with empty statement!", 1);
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::exec_statement was called with empty statement!", 1);
return;
}
sub exec_statementlist {
my $self = shift;
my $sql_list = shift;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::exec_statementlist was called static!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::exec_statementlist was called static!", 1);
return;
}
my @db_answer;
sub count_dbentries {
my ($self, $table)= @_;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::count_dbentries was called static!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::count_dbentries was called static!", 1);
return;
}
my $error= 0;
sub move_table {
my ($self, $from, $to) = @_;
- if(not defined($self) or ref($self) ne 'GOSA::DBsqlite') {
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::move_table was called static!", 1);
+ if(not defined($self) or ref($self) ne 'GOsaSI::DBsqlite') {
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::move_table was called static!", 1);
return;
}
};
if($@) {
$self->{dbh}->rollback();
- &main::daemon_log("0 ERROR: GOSA::DBsqlite::move_table crashed! Operation failed with $@", 1);
+ &main::daemon_log("0 ERROR: GOsaSI::DBsqlite::move_table crashed! Operation failed with $@", 1);
}
}
- &main::daemon_log("0 INFO: GOSA::DBsqlite::move_table: Operation successful!", 7);
+ &main::daemon_log("0 INFO: GOsaSI::DBsqlite::move_table: Operation successful!", 7);
$self->unlock();
return;
index 835eaa520108a5015b9238290436f1cf3b3df8e4..c18472eb8047e04df3cc361435786aa55616901c 100644 (file)
package GosaPackages;
-use Exporter;
-@ISA = ("Exporter");
-
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
+
+use Exporter;
+use GOsaSI::GosaSupportDaemon;
use IO::Socket::INET;
use Socket;
use XML::Simple;
use File::Spec;
use Data::Dumper;
use MIME::Base64;
+use Net::ARP;
+
+our @ISA = ("Exporter");
my $event_dir = "/usr/lib/gosa-si/server/GosaPackages";
use lib "/usr/lib/gosa-si/server/GosaPackages";
sub get_mac {
my $ifreq= shift;
my $result;
- if ($ifreq && length($ifreq) > 0) {
+ 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 ($gosa_mac_address and length($gosa_mac_address) > 0) {
$result= $gosa_mac_address;
}
- socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
- or die "socket: $!";
-
- 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;
- }
- }
+ $result = Net::ARP::get_mac($ifreq);
}
}
return $result;
index 7d769c08ad6ff4e302a900203e214f955cb2b16c..651bd57d7a1d914fec06b226d69cbdfd08d60014 100644 (file)
-package GOSA::GosaSupportDaemon;
+package GOsaSI::GosaSupportDaemon;
+use strict;
+use warnings;
+
+use IO::Socket::INET;
+use Crypt::Rijndael;
+use Digest::MD5 qw(md5 md5_hex md5_base64);
+use MIME::Base64;
+use XML::Quote qw(:all);
+use XML::Simple;
+use Data::Dumper;
+use Net::DNS;
+use Net::ARP;
+
+use DateTime;
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @functions = (
"create_passwd",
"create_xml_hash",
- "createXmlHash",
- "myXmlHashToString",
+ "createXmlHash",
+ "myXmlHashToString",
"get_content_from_xml_hash",
"add_content2xml_hash",
"create_xml_string",
"check_opsi_res",
"calc_timestamp",
"opsi_callobj2string",
- );
-@EXPORT = @functions;
-use strict;
-use warnings;
-use IO::Socket::INET;
-use Crypt::Rijndael;
-use Digest::MD5 qw(md5 md5_hex md5_base64);
-use MIME::Base64;
-use XML::Quote qw(:all);
-use XML::Simple;
-use Data::Dumper;
-use Net::DNS;
-use DateTime;
+ );
+
+our @EXPORT = @functions;
my $op_hash = {
'eq' => '=',
sub get_dns_domains() {
my $line;
my @searches;
- open(RESOLV, "</etc/resolv.conf") or return @searches;
- while(<RESOLV>){
+ open(my $RESOLV, "<", "/etc/resolv.conf") or return @searches;
+ while(<$RESOLV>){
$line= $_;
chomp $line;
$line =~ s/^\s+//;
push(@searches, split(/ /, $1));
}
}
- close(RESOLV);
+ close($RESOLV);
my %tmp = map { $_ => 1 } @searches;
@searches = sort keys %tmp;
my @result;
my $PROC_NET_DEV= ('/proc/net/dev');
- open(PROC_NET_DEV, "<$PROC_NET_DEV")
+ open(my $FD_PROC_NET_DEV, "<", "$PROC_NET_DEV")
or die "Could not open $PROC_NET_DEV";
- my @ifs = <PROC_NET_DEV>;
+ my @ifs = <$FD_PROC_NET_DEV>;
- close(PROC_NET_DEV);
+ close($FD_PROC_NET_DEV);
# Eat first two line
shift @ifs;
if($remote_ip =~ /^(\d\d?\d?\.){3}\d\d?\d?$/) {
my $PROC_NET_ROUTE= ('/proc/net/route');
- open(PROC_NET_ROUTE, "<$PROC_NET_ROUTE")
+ open(my $FD_PROC_NET_ROUTE, "<", "$PROC_NET_ROUTE")
or die "Could not open $PROC_NET_ROUTE";
- my @ifs = <PROC_NET_ROUTE>;
+ my @ifs = <$FD_PROC_NET_ROUTE>;
- close(PROC_NET_ROUTE);
+ close($FD_PROC_NET_ROUTE);
# Eat header line
shift @ifs;
sub get_mac_for_interface {
my $ifreq= shift;
my $result;
- if ($ifreq && length($ifreq) > 0) {
+ 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 ($main::server_mac_address and length($main::server_mac_address) > 0) {
- $result= $main::server_mac_address;
- }
-
- socket SOCKET, PF_INET, SOCK_DGRAM, getprotobyname('ip')
- or die "socket: $!";
-
- 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;
- }
- }
+ $result = Net::ARP::get_mac($ifreq);
}
}
return $result;
&main::daemon_log("ERROR: The sudo utility is not available! Please fix this!");
}
my $cmd_line= "$sudo_cmd su - $uid -c '$command'";
- open(PIPE, "$cmd_line |");
+ open(my $PIPE, "$cmd_line |");
my $result = {'command' => $cmd_line};
- push @{$result->{'output'}}, <PIPE>;
- close(PIPE);
+ push @{$result->{'output'}}, <$PIPE>;
+ close($PIPE);
my $exit_value = $? >> 8;
$result->{'resultCode'} = $exit_value;
return $result;
index b008d01a9fc5b8549cf70f7113da2fc13eb42779..bf4ac091b12ef38025b4a79eb89017d5567254b1 100644 (file)
package ServerPackages;
-use Exporter;
-@ISA = ("Exporter");
+
# Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and receives the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it.
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
+
use Data::Dumper;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
+
+our @ISA = ("Exporter");
my $event_dir = "/usr/lib/gosa-si/server/ServerPackages";
use lib "/usr/lib/gosa-si/server/ServerPackages";
index 90c8d6abb8e274628e17a0374bb5d9a93903e9ae..c920d413dda8ba1ac60923a9bb659a7ac42842a6 100644 (file)
package TestModule;
-use Exporter;
-@ISA = ("Exporter");
use strict;
use warnings;
-use GosaSupportDaemon;
+
+use GOsaSI::GOsaSupportDaemon;
+
+use Exporter;
+
+our @ISA = ("Exporter");
BEGIN{
}
diff --git a/gosa-si/server.conf b/gosa-si/server.conf
index c4c0a37122f82245db719a739c8245e95e851ade..554ac444c98a5f6a501c7784e2dbd4cb628c525b 100644 (file)
--- a/gosa-si/server.conf
+++ b/gosa-si/server.conf
-[general]
-log-file = /var/log/gosa-si-server.log
-pid-file = /var/run/gosa-si-server.pid
+[General]
+log-file = /var/log/gosa-si/gosa-si-server.log
+pid-file = /var/run/gosa-si/gosa-si-server.pid
-[server]
+[Server]
max-clients = 100
ldap-uri = ldap://127.0.0.1
ldap-base = dc=your,dc=domain
index 2ad848e68a85803abe44bd4b464cf997eb5905c2..a708d94b4f21d379fce0bd13cdf615b1aa1b1665 100644 (file)
--- a/gosa-si/server.conf.pod
+++ b/gosa-si/server.conf.pod
@@ -11,21 +11,21 @@ The gosa-si-server.conf file defines all parameter GOsa-SI-server needs for runn
=head1 DIRECTIVES
-=head2 [general]
+=head2 [General]
=over 4
-=item logfile = /var/log/gosa-si-server.log
+=item logfile = /var/log/gosa-si/gosa-si-server.log
Defines the location for the log file.
-=item pid-file = /var/run/gosa-si-server.pid
+=item pid-file = /var/run/gosa-si/gosa-si-server.pid
Defines the location for the pid file.
=back
-=head2 [server]
+=head2 [Server]
=over 4
Defines the location for the sources file.
-=item repo-path = /srv/www/repository
+=item repo-path = /srv/www/
Defines the location of the dak Archive or local Debian Mirror and is scanned for Debian Packages.
=item address =
-Comma seperated list of GOsa-si-servers (1.2.3.4:20081,9.8.7.6:123) in network where this SI-server should register. These given SI-servers extend the list of SI-servers found in DNS.
+Comma separated list of GOsa-si-servers (1.2.3.4:20081,9.8.7.6:123) in network where this SI-server should register. These given SI-servers extend the list of SI-servers found in DNS.
=item dns-lookup = true
=item job-synchronization-enabled = true
-Defines whether job queue informations are be shared with other GOsa-SI-server in network.
+Defines whether job queue information are be shared with other GOsa-SI-server in network.
=item synchronization-loog = 5
@@ -237,7 +237,7 @@ Space- or comma-separated list of interfaces on which to start an ARP-Daemon. En
=item enabled = false
-Defines wheter Opsi integration is being enabled or not.
+Defines whether Opsi integration is being enabled or not.
=item server = localhost
@@ -262,7 +262,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list <gosa-
This code is part of GOsa (L<http://www.gosa-project.org>)
-Copyright (C) 2003-2009 GONICUS GmbH
+Copyright (C) 2003-2010 GONICUS GmbH
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
index 6c1e0546003c00552f7cacaeac071b4fece9f073..dc57144ea224d54567b16b71df731c1bb30bf5d5 100644 (file)
# @details A GOsa-SI event module containing all functions to handle incoming messages from clients.
package clMessages;
+
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use MIME::Base64;
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"confirm_usr_msg",
"PROGRESS",
"CURRENTLY_LOGGED_IN",
"save_fai_log",
);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use Data::Dumper;
-use GOSA::GosaSupportDaemon;
-use MIME::Base64;
-
+our @EXPORT = @events;
BEGIN {}
my ($log_file, $log_string) = split(":", $log);
my $client_fai_log_file = File::Spec->catfile( $client_fai_log_dir, $log_file);
- open(my $LOG_FILE, ">$client_fai_log_file");
+ open(my $LOG_FILE, ">", "$client_fai_log_file");
print $LOG_FILE &decode_base64($log_string);
close($LOG_FILE);
chown($main::root_uid, $main::adm_gid, $client_fai_log_file);
);
# Sanity check of user search
if ($ldap_mesg->count == 0) {
- &main::daemon_log("$session_id ERROR: no user with uid='$user' was found in base '".
+ &main::daemon_log("$session_id WARNING: no user with uid='$user' was found in base '".
$main::ldap_base."', setting of 'gotoLastSystem' and 'gotoLastSystemLogin' stopped!", 1);
# Set gotoLastSystem and gotoLastSystemLogin
index 881ebb8209468c36b0a6d064f226fec7d8142c1e..796e97f3de3dbc1f86e40a44e2af8cea5637199b 100644 (file)
package databases;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"query_jobdb",
"query_fai_release",
"count_fai_release",
);
-@EXPORT = @events;
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use Data::Dumper;
+our @EXPORT = @events;
BEGIN {}
### Start ######################################################################
-#&main::read_configfile($main::cfg_file, %cfg_defaults);
-
sub get_events {
return \@events;
}
index 2a54b86e0148cc563cf62983582c4b7efda23a6f..f014ad12421b2864800558f580394c5ad8a1de52 100644 (file)
# @brief Implementation of a GOsa-SI event module.
package gosaTriggered;
+
+use strict;
+use warnings;
+
+use Crypt::SmbHash;
+use Net::ARP;
+use Net::Ping;
+use Time::HiRes qw( usleep);
+use MIME::Base64;
+use Data::Dumper;
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+use Socket;
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"get_login_usr_for_client",
"recreate_packages_list_db",
"send_user_msg",
"get_available_kernel",
- "trigger_activate_new",
+ "trigger_activate_new",
"get_hosts_with_module",
);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use Crypt::SmbHash;
-use Net::ARP;
-use Net::Ping;
-use Socket;
-use Time::HiRes qw( usleep);
-use MIME::Base64;
-use Data::Dumper;
+
+our @EXPORT = @events;
BEGIN {}
index 9fdce81d0e9d4fed943963a002573263cc891ac4..9e1f38cd999c7d774973743ecc06d7f5fd4dd7ee 100644 (file)
package logHandling;
+
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use File::Spec;
+use MIME::Base64;
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"show_log_by_mac",
"get_recent_log_by_mac",
"delete_log_by_date_and_mac",
);
-@EXPORT = @events;
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use Data::Dumper;
-use File::Spec;
-use MIME::Base64;
+our @EXPORT = @events;
BEGIN {}
# read log file
my $log_content;
- open(FILE, "<$act_log_file");
- my @log_lines = <FILE>;
- close(FILE);
+ open(my $FILE, "<$act_log_file");
+ my @log_lines = <$FILE>;
+ close($FILE);
# prepare content for xml sending
$log_content = join("", @log_lines);
index 87642ebd0248f9d533b15c510736099e71a84051..63d8d0c938fef155b0a0dcf62989de37c84e7a37 100644 (file)
@@ -21,22 +21,26 @@ be automatically imported by GOsa-SI if it is under F</usr/lib/gosa-si/server/E<
=cut
package mailqueue_com;
-use Exporter;
-@ISA = qw(Exporter);
-my @events = (
- "get_events",
- "mailqueue_query",
- "mailqueue_header",
-);
-@EXPORT = @events;
use strict;
use warnings;
-use GOSA::GosaSupportDaemon;
+
use Data::Dumper;
use Time::HiRes qw( usleep);
use MIME::Base64;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
+
+our @ISA = qw(Exporter);
+
+my @events = (
+ "get_events",
+ "mailqueue_query",
+ "mailqueue_header",
+);
+our @EXPORT = @events;
BEGIN {}
my ($sql, $res);
if( defined $jobdb_id) {
- my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=$jobdb_id";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->exec_statement($sql_statement);
}
my ($sql, $res);
if( defined $jobdb_id) {
- my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=$jobdb_id";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->exec_statement($sql_statement);
}
index 1c67f577ebc560c2431e0fa66769340aff23278f..2c3698147588087b7f8591dac1707a0650dcbe41 100644 (file)
package opsi_com;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use XML::Quote qw(:all);
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
use UNIVERSAL 'isa';
-@ISA = qw(Exporter);
+our @ISA = qw(Exporter);
+
my @events = (
"get_events",
"opsi_install_client",
"opsi_unboundHostFromLicense",
"opsi_test",
);
-@EXPORT = @events;
-use strict;
-use warnings;
-use GOSA::GosaSupportDaemon;
-use Data::Dumper;
-use XML::Quote qw(:all);
+our @EXPORT = @events;
+
BEGIN {}
"password" => [\$opsi_password, "secret"],
},
);
+
&read_configfile($main::cfg_file, %cfg_defaults);
+
if ($opsi_enabled eq "true") {
use JSON::RPC::Client;
use XML::Quote qw(:all);
diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm
index b13762622b03e620a5d5c24c0b1bb3c38f7784f7..5fbc4cc0654827754f1817bf36409758277c9e42 100644 (file)
package server_server_com;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+use Time::HiRes qw( usleep);
+use GOsaSI::GosaSupportDaemon;
+
use Exporter;
-@ISA = qw(Exporter);
+use Socket;
+
+our @ISA = qw(Exporter);
+
my @events = (
'information_sharing',
'new_server',
'foreign_job_updates',
'confirm_usr_msg',
);
-@EXPORT = @events;
-
-use strict;
-use warnings;
-use Data::Dumper;
-use GOSA::GosaSupportDaemon;
-use Time::HiRes qw( usleep);
-use Socket;
-
+
+our @EXPORT = @events;
BEGIN {}
index 530da9292f03c13183057b39a190b805a7a7f803..4ef51a5bc91cb6e58617ee78712169aaf90f88cd 100644 (file)
package siTriggered;
-use Exporter;
-@ISA = qw(Exporter);
-my @events = (
- "got_ping",
- "detected_hardware",
- "trigger_wake",
- "reload_ldap_config",
- "get_terminal_server",
- );
-@EXPORT = @events;
use strict;
use warnings;
+
use Data::Dumper;
-use GOSA::GosaSupportDaemon;
+use GOsaSI::GosaSupportDaemon;
+
+use Exporter;
use Socket;
+our @ISA = qw(Exporter);
+my @events = (
+ "got_ping",
+ "detected_hardware",
+ "trigger_wake",
+ "reload_ldap_config",
+ "get_terminal_server",
+ );
+
+our @EXPORT = @events;
BEGIN {}
my $mesg;
my %cfg_defaults = (
- "server" => {
+ "Server" => {
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
"ldap-admin-dn" => [\$ldap_admin_dn, ""],
"ldap-admin-password" => [\$ldap_admin_password, ""],
},
);
-&GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults);
+# why not using it from main::read_configfile
+&GOsaSI::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults);
sub get_terminal_server
# $dnsname= $heap->{force-hostname}->{$macaddress};
# &main::daemon_log("INFO: Using forced hostname $dnsname for client $address", 4);
if (-e "/var/tmp/$macaddress" ){
- open(TFILE, "< /var/tmp/$macaddress");
- $dnsname= <TFILE>;
- close(TFILE);
+ open(my $TFILE, "<", "/var/tmp/$macaddress");
+ $dnsname= <$TFILE>;
+ close($TFILE);
} else {
$dnsname= gethostbyaddr(inet_aton($ipaddress), AF_INET) || $ipaddress;
}