From 7a45ad19414f0b8fa433ffd5f65f05e7c0ca6293 Mon Sep 17 00:00:00 2001 From: opensides Date: Sun, 16 May 2010 22:02:38 +0000 Subject: [PATCH] - Debian Packaging fixes - Cleanup of some fonctions - Added dump configuration to gosa-si-client - Cleaned usage to give better explanations - added new options to manpages - Renomed GOSA::GOSa to GOsa::SI to be more perl compliant and more clean git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18483 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client.conf | 4 +- gosa-si/client/events/corefunctions.pm | 27 +-- gosa-si/client/events/dak.pm | 5 +- gosa-si/client/events/gosaTriggered.pm | 6 +- gosa-si/client/events/installation.pm | 2 +- gosa-si/client/events/krb5.pm | 6 +- gosa-si/client/events/load_reporter.pm | 15 +- gosa-si/client/events/mailqueue.pm | 5 +- gosa-si/debian/gosa-si-common.default | 2 +- gosa-si/debian/gosa-si-common.dirs | 4 +- gosa-si/debian/gosa-si-common.init | 4 +- gosa-si/debian/gosa-si-common.install | 4 +- gosa-si/debian/rules | 8 - gosa-si/gosa-si-client | 218 ++++++++++++++++----- gosa-si/gosa-si-client.pod | 6 +- gosa-si/gosa-si-server | 53 +++-- gosa-si/gosa-si-server.pod | 2 +- gosa-si/modules/ArpHandler.pm | 13 +- gosa-si/modules/ClientPackages.pm | 8 +- gosa-si/modules/DBmysql.pm | 8 +- gosa-si/modules/DBsqlite.pm | 2 +- gosa-si/modules/GosaPackages.pm | 2 +- gosa-si/modules/GosaSupportDaemon.pm | 5 +- gosa-si/modules/ServerPackages.pm | 5 +- gosa-si/modules/TestModule.pm | 3 +- gosa-si/server.conf | 4 +- gosa-si/server.conf.pod | 2 +- gosa-si/server/events/clMessages.pm | 5 +- gosa-si/server/events/databases.pm | 7 +- gosa-si/server/events/gosaTriggered.pm | 7 +- gosa-si/server/events/logHandling.pm | 5 +- gosa-si/server/events/mailqueue_com.pm | 5 +- gosa-si/server/events/opsi_com.pm | 9 +- gosa-si/server/events/server_server_com.pm | 5 +- gosa-si/server/events/siTriggered.pm | 8 +- 35 files changed, 306 insertions(+), 168 deletions(-) diff --git a/gosa-si/client.conf b/gosa-si/client.conf index 7859d5e86..88008aee5 100644 --- a/gosa-si/client.conf +++ b/gosa-si/client.conf @@ -1,6 +1,6 @@ [General] -log-file = /var/log/gosa-si-client.log -pid-file = /var/run/gosa-si-client.pid +log-file = /var/log/gosa-si/gosa-si-client.log +pid-file = /var/run/gosa-si/gosa-si-client.pid [Client] fai-logpath = /var/log/fai/fai.log diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index ffb00f3d7..c15700354 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -2,10 +2,13 @@ package corefunctions; use strict; use warnings; + +use File::Basename; +use GOsaSI::GosaSupportDaemon; + use Exporter; use Fcntl; -use GOSA::GosaSupportDaemon; -use File::Basename; + our @ISA = qw(Exporter); @@ -30,6 +33,7 @@ my ($ldap_enabled, $offline_enabled, $ldap_config, $pam_config, $nss_config, $fa 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], @@ -48,6 +52,7 @@ END {} ### Start ###################################################################### +# why not using the config read in the main ?? !! &main::read_configfile($main::cfg_file, %cfg_defaults); @@ -81,10 +86,10 @@ sub write_to_file { close($FD_FILE); } - return; + return; } - +# should be the first function of each module of gosa-si !! sub get_events { return \@events; } @@ -155,7 +160,7 @@ sub server_leaving { # registrated at new daemon &main::register_at_server(); - return; + return; } @@ -477,7 +482,7 @@ sub new_key { $main::server_key = $new_server_key; } - return; + return; } @@ -602,11 +607,11 @@ sub detect_hardware { &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; diff --git a/gosa-si/client/events/dak.pm b/gosa-si/client/events/dak.pm index 8070221a4..d0846f615 100644 --- a/gosa-si/client/events/dak.pm +++ b/gosa-si/client/events/dak.pm @@ -6,11 +6,12 @@ package dak; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; +use GOsaSI::GosaSupportDaemon; use MIME::Base64; +use Exporter; + our @ISA = qw(Exporter); my @events = ( diff --git a/gosa-si/client/events/gosaTriggered.pm b/gosa-si/client/events/gosaTriggered.pm index 3afc78386..4a304eb93 100644 --- a/gosa-si/client/events/gosaTriggered.pm +++ b/gosa-si/client/events/gosaTriggered.pm @@ -25,16 +25,16 @@ Andreas Rettenberger =cut - package gosaTriggered; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use MIME::Base64; use File::Temp qw/ tempfile/; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); diff --git a/gosa-si/client/events/installation.pm b/gosa-si/client/events/installation.pm index 62420fe18..a335948dd 100644 --- a/gosa-si/client/events/installation.pm +++ b/gosa-si/client/events/installation.pm @@ -29,7 +29,7 @@ sub set_activated_for_installation { my $target = @{$msg_hash->{'target'}}[0]; my $source = @{$msg_hash->{'source'}}[0]; - my $Datei = "/var/run/gosa-si-client.activated"; + my $Datei = "/var/run/gosa-si/gosa-si-client.activated"; open(my $FILE, ">", "$Datei"); print $FILE "$msg\n"; close($FILE); diff --git a/gosa-si/client/events/krb5.pm b/gosa-si/client/events/krb5.pm index 39cf3f476..a4ccd33bc 100644 --- a/gosa-si/client/events/krb5.pm +++ b/gosa-si/client/events/krb5.pm @@ -4,10 +4,11 @@ package krb5; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use Authen::Krb5; use Authen::Krb5::Admin qw(:constants); +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); @@ -46,6 +47,7 @@ my %cfg_defaults = ( "password" => [\$krb_password, ""], }, ); +# why not using the main::read_configfile, the code seems exactly the same &krb5_read_configfile($main::cfg_file, %cfg_defaults); diff --git a/gosa-si/client/events/load_reporter.pm b/gosa-si/client/events/load_reporter.pm index b823237d9..241dc07b6 100644 --- a/gosa-si/client/events/load_reporter.pm +++ b/gosa-si/client/events/load_reporter.pm @@ -3,9 +3,10 @@ package load_reporter; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; +use GOsaSI::GosaSupportDaemon; + +use Exporter; BEGIN {} END {} @@ -25,11 +26,13 @@ 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], + }, ); + +# to be removed ugly !! why not using main::_read_configfile &GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults); diff --git a/gosa-si/client/events/mailqueue.pm b/gosa-si/client/events/mailqueue.pm index c5ee3dd4c..43552af74 100644 --- a/gosa-si/client/events/mailqueue.pm +++ b/gosa-si/client/events/mailqueue.pm @@ -30,9 +30,10 @@ package mailqueue; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use MIME::Base64; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); diff --git a/gosa-si/debian/gosa-si-common.default b/gosa-si/debian/gosa-si-common.default index fede17e5f..5f3241a57 100644 --- a/gosa-si/debian/gosa-si-common.default +++ b/gosa-si/debian/gosa-si-common.default @@ -1,3 +1,3 @@ # /etc/default/gosa-si - configure the init script START_CLIENT=1 -DEBUG=-vvv +DEBUG=-vvvvvvv diff --git a/gosa-si/debian/gosa-si-common.dirs b/gosa-si/debian/gosa-si-common.dirs index 2d13e8f10..0cab98e29 100644 --- a/gosa-si/debian/gosa-si-common.dirs +++ b/gosa-si/debian/gosa-si-common.dirs @@ -1,2 +1,4 @@ /etc/default -/usr/share/perl5/GOSA +/usr/share/perl5/GOsaSI +/var/run/gosa-si +/var/log/gosa-si diff --git a/gosa-si/debian/gosa-si-common.init b/gosa-si/debian/gosa-si-common.init index 9a9cb9268..69e74e4e9 100755 --- a/gosa-si/debian/gosa-si-common.init +++ b/gosa-si/debian/gosa-si-common.init @@ -18,8 +18,8 @@ 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" +PIDFILE_SERVER="/var/run/gosa-si/${SERVER}.pid" +PIDFILE_CLIENT="/var/run/gosa-si/${CLIENT}.pid" PATH="/sbin:/usr/sbin:/bin:/usr/bin" diff --git a/gosa-si/debian/gosa-si-common.install b/gosa-si/debian/gosa-si-common.install index 4fede15d3..1e14d1848 100644 --- a/gosa-si/debian/gosa-si-common.install +++ b/gosa-si/debian/gosa-si-common.install @@ -1,3 +1,3 @@ -modules/GosaSupportDaemon.pm usr/share/perl5/GOSA -modules/DBsqlite.pm usr/share/perl5/GOSA +modules/GosaSupportDaemon.pm usr/share/perl5/GOsaSI +modules/DBsqlite.pm usr/share/perl5/GOsaSI modules/ArpWatch.pm usr/share/perl5/POE/Component diff --git a/gosa-si/debian/rules b/gosa-si/debian/rules index 1ad15fefa..e62500e47 100755 --- a/gosa-si/debian/rules +++ b/gosa-si/debian/rules @@ -35,13 +35,6 @@ install-stamp: -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 @@ -62,7 +55,6 @@ binary-indep: install dh_installchangelogs dh_installman dh_installlogrotate - #dh_installdebconf dh_installinit --init-script=gosa-si -- start 00 2 3 4 5 . stop 29 1 . chmod 640 debian/gosa-si-server/etc/gosa-si/server.conf debian/gosa-si-client/etc/gosa-si/client.conf diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index d9c62845c..f048269b9 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -1,42 +1,35 @@ #!/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 +# (c) 2008-2010 by Cajus Pollmeier +# (c) 2008-2009 by Jan Wenzel +# (c) 2010 by Benoit Mortier # -# OPTIONS: --- -# REQUIREMENTS: libnetaddr-ip-perl -# BUGS: --- -# NOTES: -# AUTHOR: (Andreas Rettenberger), -# COMPANY: -# VERSION: 1.0 -# CREATED: 12.09.2007 08:54:41 CEST -# REVISION: --- -#=============================================================================== +#********************************************************************* 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 GOsaSI::GosaSupportDaemon; use Digest::MD5 qw(md5_hex md5 md5_base64); use MIME::Base64; use XML::Simple; use File::Basename; use File::Spec; use Net::ARP; + +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"; @@ -76,6 +69,12 @@ our $server_key; our $terminal_server_hash; our $opts_dnslookup; +# where is the config stored by default and his name +our $config = '/etc/fts/fts.conf'; + +# by default dumping of config is undefined +our $dump_config = undef; + # default variables my $REGISTERED = 0; @@ -85,10 +84,9 @@ my $fai_com_fifo = "/var/run/gosa-si-client.socket"; my $system_com_fifo = "/var/run/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; @@ -101,9 +99,9 @@ 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"], + {"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" => {"port" => [\$client_port, "20083"], @@ -132,19 +130,115 @@ my $fai_log_dir = "/var/log/fai"; #=== 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 ) = @_; + + $text = undef if( 'h' eq $text ); + (defined $text) && print STDERR "\n$text\n"; - -h : this (help) message - -c : config file - -f : foreground, process will not be forked to background - -v : be verbose (multiple to increase verbosity) - + if( (defined $help && $help) + || (!defined $help && !defined $text) ) +{ + print STDERR << "EOF"; + + usage: $0 [-hvf] [-c config] + + -h : this (help) message + -c : config file (default: ${config}) + -x : 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" ); + + 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-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 ) + } + } + } + } + + +# We just exit at stdout dump + if( 3 == $cfg_type ) { + daemon_log( "\n", 3 ); + } else { + exit( 0 ); + } +} + + #=== FUNCTION ================================================================ # NAME: check_cmdline_param # PARAMETERS: @@ -218,16 +312,25 @@ sub check_pid { } } - +############################# +# +# @brief When caching an interrupt remove file pid and stopping gosa-si +# sub sig_int_handler { - my ($signal) = @_; + my ($signal) = @_; + + daemon_log("shutting down gosa-si-client", 1); + +# to be changed crude !! +# system("kill `ps -C gosa-si-server -o pid=`"); + $global_kernel->yield('shutdown'); - daemon_log("shutting down gosa-si-client", 1); - system("kill `ps -C gosa-si-client -o pid=`"); +# $pid->remove or warn "Could not remove $pidfile\n"; + + exit(0); } $SIG{INT} = \&sig_int_handler; - #=== FUNCTION ================================================================ # NAME: logging # PARAMETERS: level - string - default 'info' @@ -270,7 +373,7 @@ sub daemon_log { $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; @@ -497,11 +600,11 @@ sub write_to_file { 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++; } @@ -1216,17 +1319,30 @@ sub find_servers { } } +# #==== 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 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 -&check_cmdline_param ; +#&check_cmdline_param ; &read_configfile($cfg_file, %cfg_defaults); &check_pid; @@ -1278,7 +1394,7 @@ if(not defined $adm_gid){ } daemon_log(" ", 1); -daemon_log("$prg started!", 1); +daemon_log("gosa-si-client started!", 1); daemon_log("INFO: status: $client_status", 1); daemon_log("INFO: ".$client_status_hash->{$client_status}.": $client_revision", 1); diff --git a/gosa-si/gosa-si-client.pod b/gosa-si/gosa-si-client.pod index 7a2f84a0d..507bf966e 100644 --- a/gosa-si/gosa-si-client.pod +++ b/gosa-si/gosa-si-client.pod @@ -26,6 +26,10 @@ B<-f>, B<--foreground> B<-c> I, B<--config=>I configuration file, default F +B<-x>, B<--dump> + Dump configuration + -1 Current configuration + -2 Default Configuration =head1 DESCRIPTION @@ -43,7 +47,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list ) -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 diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 83ac36dfb..489202349 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -1,36 +1,22 @@ #!/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 +# (c) 2008-2010 by Cajus Pollmeier +# (c) 2008-2009 by Jan Wenzel +# (c) 2010 by Benoit Mortier # -# 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), -# COMPANY: -# VERSION: 1.0 -# CREATED: 12.09.2007 08:54:41 CEST -# REVISION: --- -#=============================================================================== - +#********************************************************************* 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); @@ -38,16 +24,19 @@ use XML::Simple; 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 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$'; @@ -61,8 +50,8 @@ 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"; @@ -231,8 +220,8 @@ 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"], + "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" => { "ip" => [\$server_ip, "0.0.0.0"], @@ -585,9 +574,13 @@ sub sig_int_handler { # } # TODO alle verbliebenden ldap verbindungen aus allen heaps beenden - daemon_log("shutting down gosa-si-server", 1); + + #$global_kernel->yield('shutdown'); + system("kill `ps -C gosa-si-server -o pid=`"); + + exit(0); } $SIG{INT} = \&sig_int_handler; diff --git a/gosa-si/gosa-si-server.pod b/gosa-si/gosa-si-server.pod index e4ceb6777..50772cd1c 100644 --- a/gosa-si/gosa-si-server.pod +++ b/gosa-si/gosa-si-server.pod @@ -58,7 +58,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list ) -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 diff --git a/gosa-si/modules/ArpHandler.pm b/gosa-si/modules/ArpHandler.pm index 4dc4f57e7..408d80ac6 100644 --- a/gosa-si/modules/ArpHandler.pm +++ b/gosa-si/modules/ArpHandler.pm @@ -3,16 +3,17 @@ package ArpHandler; use strict; use warnings; -use Exporter; -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"); @@ -54,6 +55,7 @@ my %cfg_defaults = }, ); +# to be removed use only main::read_configfile #=== FUNCTION ================================================================ # NAME: read_configfile # PARAMETERS: cfg_file - string - @@ -86,6 +88,7 @@ sub get_module_info { # 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); @@ -235,7 +238,7 @@ sub get_host_from_ldap { 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, diff --git a/gosa-si/modules/ClientPackages.pm b/gosa-si/modules/ClientPackages.pm index f714cd466..1f91d053b 100644 --- a/gosa-si/modules/ClientPackages.pm +++ b/gosa-si/modules/ClientPackages.pm @@ -5,8 +5,6 @@ package ClientPackages; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use IO::Socket::INET; use XML::Simple; use Data::Dumper; @@ -15,6 +13,9 @@ use Net::LDAP; use Net::LDAP::Util; use Socket; use Net::hostent; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = ("Exporter"); @@ -31,7 +32,7 @@ my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret); 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"], @@ -49,6 +50,7 @@ my %cfg_defaults = ( ### START ##################################################################### # read configfile and import variables +#why not using the main::read_configfile !! &local_read_configfile(); diff --git a/gosa-si/modules/DBmysql.pm b/gosa-si/modules/DBmysql.pm index 7a7f67f7e..da87a38e1 100644 --- a/gosa-si/modules/DBmysql.pm +++ b/gosa-si/modules/DBmysql.pm @@ -1,11 +1,13 @@ -package GOSA::DBmysql; +package GOsaSI::DBmysql; use strict; use warnings; -use DBI; + use Data::Dumper; -use GOSA::GosaSupportDaemon; use Time::HiRes qw(usleep); +use GOsaSI::GosaSupportDaemon; + +use DBI; my $col_names = {}; diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 0a2e7f7a1..31f2c395d 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -1,4 +1,4 @@ -package GOSA::DBsqlite; +package GOsaSI::DBsqlite; use strict; use warnings; diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index 6c7159dd8..c18472eb8 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -4,7 +4,7 @@ use strict; use warnings; use Exporter; -use GOSA::GosaSupportDaemon; +use GOsaSI::GosaSupportDaemon; use IO::Socket::INET; use Socket; use XML::Simple; diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index 9c33df325..651bd57d7 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -1,9 +1,8 @@ -package GOSA::GosaSupportDaemon; +package GOsaSI::GosaSupportDaemon; use strict; use warnings; -use Exporter; use IO::Socket::INET; use Crypt::Rijndael; use Digest::MD5 qw(md5 md5_hex md5_base64); @@ -13,7 +12,9 @@ use XML::Simple; use Data::Dumper; use Net::DNS; use Net::ARP; + use DateTime; +use Exporter; our @ISA = qw(Exporter); diff --git a/gosa-si/modules/ServerPackages.pm b/gosa-si/modules/ServerPackages.pm index d1583017c..bf4ac091b 100644 --- a/gosa-si/modules/ServerPackages.pm +++ b/gosa-si/modules/ServerPackages.pm @@ -7,9 +7,10 @@ package ServerPackages; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use Data::Dumper; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = ("Exporter"); diff --git a/gosa-si/modules/TestModule.pm b/gosa-si/modules/TestModule.pm index 9b0d828b5..c920d413d 100644 --- a/gosa-si/modules/TestModule.pm +++ b/gosa-si/modules/TestModule.pm @@ -4,8 +4,9 @@ package TestModule; use strict; use warnings; +use GOsaSI::GOsaSupportDaemon; + use Exporter; -use GosaSupportDaemon; our @ISA = ("Exporter"); diff --git a/gosa-si/server.conf b/gosa-si/server.conf index b8da24124..554ac444c 100644 --- a/gosa-si/server.conf +++ b/gosa-si/server.conf @@ -1,6 +1,6 @@ [General] -log-file = /var/log/gosa-si-server.log -pid-file = /var/run/gosa-si-server.pid +log-file = /var/log/gosa-si/gosa-si-server.log +pid-file = /var/run/gosa-si/gosa-si-server.pid [Server] max-clients = 100 diff --git a/gosa-si/server.conf.pod b/gosa-si/server.conf.pod index a4159808e..a0b923fdd 100644 --- a/gosa-si/server.conf.pod +++ b/gosa-si/server.conf.pod @@ -262,7 +262,7 @@ Please report any bugs, or post any suggestions, to the GOsa mailing list ) -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 diff --git a/gosa-si/server/events/clMessages.pm b/gosa-si/server/events/clMessages.pm index 3492e4194..89ab1f785 100644 --- a/gosa-si/server/events/clMessages.pm +++ b/gosa-si/server/events/clMessages.pm @@ -8,10 +8,11 @@ package clMessages; use strict; use warnings; -use Exporter; use Data::Dumper; -use GOSA::GosaSupportDaemon; use MIME::Base64; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); diff --git a/gosa-si/server/events/databases.pm b/gosa-si/server/events/databases.pm index 9a6a89880..796e97f3d 100644 --- a/gosa-si/server/events/databases.pm +++ b/gosa-si/server/events/databases.pm @@ -3,9 +3,10 @@ package databases; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use Data::Dumper; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); @@ -32,8 +33,6 @@ END {} ### Start ###################################################################### -#&main::read_configfile($main::cfg_file, %cfg_defaults); - sub get_events { return \@events; } diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 4eb74cee3..f014ad124 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -7,15 +7,16 @@ package gosaTriggered; use strict; use warnings; -use Exporter; -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; +use GOsaSI::GosaSupportDaemon; + +use Exporter; +use Socket; our @ISA = qw(Exporter); diff --git a/gosa-si/server/events/logHandling.pm b/gosa-si/server/events/logHandling.pm index c5b9976e2..23c60b322 100644 --- a/gosa-si/server/events/logHandling.pm +++ b/gosa-si/server/events/logHandling.pm @@ -4,11 +4,12 @@ package logHandling; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use Data::Dumper; use File::Spec; use MIME::Base64; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); diff --git a/gosa-si/server/events/mailqueue_com.pm b/gosa-si/server/events/mailqueue_com.pm index 0107493fa..63d8d0c93 100644 --- a/gosa-si/server/events/mailqueue_com.pm +++ b/gosa-si/server/events/mailqueue_com.pm @@ -25,11 +25,12 @@ package mailqueue_com; use strict; use warnings; -use Exporter; -use GOSA::GosaSupportDaemon; use Data::Dumper; use Time::HiRes qw( usleep); use MIME::Base64; +use GOsaSI::GosaSupportDaemon; + +use Exporter; our @ISA = qw(Exporter); diff --git a/gosa-si/server/events/opsi_com.pm b/gosa-si/server/events/opsi_com.pm index c6fee306a..2c3698147 100644 --- a/gosa-si/server/events/opsi_com.pm +++ b/gosa-si/server/events/opsi_com.pm @@ -8,11 +8,12 @@ package opsi_com; use strict; use warnings; -use Exporter; -use UNIVERSAL 'isa'; -use GOSA::GosaSupportDaemon; use Data::Dumper; use XML::Quote qw(:all); +use GOsaSI::GosaSupportDaemon; + +use Exporter; +use UNIVERSAL 'isa'; our @ISA = qw(Exporter); @@ -74,7 +75,9 @@ my %cfg_defaults = ( "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 98f11a567..5fbc4cc06 100644 --- a/gosa-si/server/events/server_server_com.pm +++ b/gosa-si/server/events/server_server_com.pm @@ -3,10 +3,11 @@ package server_server_com; use strict; use warnings; -use Exporter; use Data::Dumper; -use GOSA::GosaSupportDaemon; use Time::HiRes qw( usleep); +use GOsaSI::GosaSupportDaemon; + +use Exporter; use Socket; our @ISA = qw(Exporter); diff --git a/gosa-si/server/events/siTriggered.pm b/gosa-si/server/events/siTriggered.pm index f190e15fe..810bd0209 100644 --- a/gosa-si/server/events/siTriggered.pm +++ b/gosa-si/server/events/siTriggered.pm @@ -3,9 +3,10 @@ package siTriggered; use strict; use warnings; -use Exporter; use Data::Dumper; -use GOSA::GosaSupportDaemon; +use GOsaSI::GosaSupportDaemon; + +use Exporter; use Socket; our @ISA = qw(Exporter); @@ -33,13 +34,14 @@ my $ldap_admin_password; 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, ""], }, ); +# why not using it from main::read_configfile &GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults); -- 2.30.2