From: rettenbe Date: Mon, 4 Aug 2008 12:19:33 +0000 (+0000) Subject: only one single function read_configfile X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5993c371fd3cfc73eada2207230c0841cebd08d7;p=gosa.git only one single function read_configfile git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12135 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client/events/dak.pm b/gosa-si/client/events/dak.pm index f5be2bf02..2b7c27d68 100644 --- a/gosa-si/client/events/dak.pm +++ b/gosa-si/client/events/dak.pm @@ -36,6 +36,7 @@ my %cfg_defaults = ( ); &GOSA::GosaSupportDaemon::read_configfile($main::config_file, %cfg_defaults); + ## @method get_events() # A brief function returning a list of functions which are exported by importing the module. # @return List of all provided functions diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index aaf2b5e00..2f224016e 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -283,24 +283,24 @@ EOF # RETURNS: nothing # DESCRIPTION: read cfg_file and set variables #=============================================================================== -sub read_configfile { - my $cfg; - if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { - if( -r $cfg_file ) { - $cfg = Config::IniFiles->new( -file => $cfg_file ); - } else { - print STDERR "Couldn't read config file!\n"; - } - } else { - $cfg = Config::IniFiles->new() ; - } - foreach my $section (keys %cfg_defaults) { - foreach my $param (keys %{$cfg_defaults{ $section }}) { - my $pinfo = $cfg_defaults{ $section }{ $param }; - ${@$pinfo[ 0 ]} = $cfg->val( $section, $param, @$pinfo[ 1 ] ); - } - } -} +#sub read_configfile { +# my $cfg; +# if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { +# if( -r $cfg_file ) { +# $cfg = Config::IniFiles->new( -file => $cfg_file ); +# } else { +# print STDERR "Couldn't read config file!\n"; +# } +# } else { +# $cfg = Config::IniFiles->new() ; +# } +# foreach my $section (keys %cfg_defaults) { +# foreach my $param (keys %{$cfg_defaults{ $section }}) { +# my $pinfo = $cfg_defaults{ $section }{ $param }; +# ${@$pinfo[ 0 ]} = $cfg->val( $section, $param, @$pinfo[ 1 ] ); +# } +# } +#} #=== FUNCTION ================================================================ @@ -2873,7 +2873,7 @@ GetOptions("h|help" => \&usage, # read and set config parameters &check_cmdline_param ; -&read_configfile; +&read_configfile($cfg_file, %cfg_defaults); &check_pid; $SIG{CHLD} = 'IGNORE'; diff --git a/gosa-si/modules/ClientPackages.pm b/gosa-si/modules/ClientPackages.pm index a0a173a0b..c64264a1b 100644 --- a/gosa-si/modules/ClientPackages.pm +++ b/gosa-si/modules/ClientPackages.pm @@ -50,7 +50,7 @@ my %cfg_defaults = ( ### START ##################################################################### # read configfile and import variables -&read_configfile(); +&local_read_configfile(); # if server_ip is not an ip address but a name @@ -158,12 +158,12 @@ sub get_module_info { #=== FUNCTION ================================================================ -# NAME: read_configfile +# NAME: local_read_configfile # PARAMETERS: cfg_file - string - # RETURNS: nothing # DESCRIPTION: read cfg_file and set variables #=============================================================================== -sub read_configfile { +sub local_read_configfile { my $cfg; if( defined( $main::cfg_file) && ( (-s $main::cfg_file) > 0 )) { if( -r $main::cfg_file ) { diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index ae9422552..2427c8b7b 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -29,6 +29,7 @@ my @functions = ( "is_local", "run_as", "inform_all_other_si_server", + "read_configfile", ); @EXPORT = @functions; use strict; @@ -706,4 +707,26 @@ sub inform_all_other_si_server { return; } + +sub read_configfile { + my ($cfg_file, %cfg_defaults) = @_ ; + my $cfg; + if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { + if( -r $cfg_file ) { + $cfg = Config::IniFiles->new( -file => $cfg_file ); + } else { + print STDERR "Couldn't read config file!"; + } + } else { + $cfg = Config::IniFiles->new() ; + } + foreach my $section (keys %cfg_defaults) { + foreach my $param (keys %{$cfg_defaults{ $section }}) { + my $pinfo = $cfg_defaults{ $section }{ $param }; + ${@$pinfo[ 0 ]} = $cfg->val( $section, $param, @$pinfo[ 1 ] ); + } + } +} + + 1; diff --git a/gosa-si/server/events/siTriggered.pm b/gosa-si/server/events/siTriggered.pm index ef0eb4398..7de3c5a7c 100644 --- a/gosa-si/server/events/siTriggered.pm +++ b/gosa-si/server/events/siTriggered.pm @@ -28,14 +28,14 @@ my $ldap_admin_password; my $mesg; my %cfg_defaults = ( -"server" => { - "ldap-uri" => [\$ldap_uri, ""], - "ldap-base" => [\$ldap_base, ""], - "ldap-admin-dn" => [\$ldap_admin_dn, ""], - "ldap-admin-password" => [\$ldap_admin_password, ""], + "server" => { + "ldap-uri" => [\$ldap_uri, ""], + "ldap-base" => [\$ldap_base, ""], + "ldap-admin-dn" => [\$ldap_admin_dn, ""], + "ldap-admin-password" => [\$ldap_admin_password, ""], }, ); -&read_configfile($main::cfg_file, %cfg_defaults); +&GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults); sub get_events { @@ -43,26 +43,26 @@ sub get_events { } -sub read_configfile { - my ($cfg_file, %cfg_defaults) = @_; - my $cfg; - - if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { - if( -r $cfg_file ) { - $cfg = Config::IniFiles->new( -file => $cfg_file ); - } else { - &main::daemon_log("ERROR: siTriggered.pm couldn't read config file!", 1); - } - } else { - $cfg = Config::IniFiles->new() ; - } - foreach my $section (keys %cfg_defaults) { - foreach my $param (keys %{$cfg_defaults{ $section }}) { - my $pinfo = $cfg_defaults{ $section }{ $param }; - ${@$pinfo[0]} = $cfg->val( $section, $param, @$pinfo[1] ); - } - } -} +#sub read_configfile { +# my ($cfg_file, %cfg_defaults) = @_; +# my $cfg; +# +# if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) { +# if( -r $cfg_file ) { +# $cfg = Config::IniFiles->new( -file => $cfg_file ); +# } else { +# &main::daemon_log("ERROR: siTriggered.pm couldn't read config file!", 1); +# } +# } else { +# $cfg = Config::IniFiles->new() ; +# } +# foreach my $section (keys %cfg_defaults) { +# foreach my $param (keys %{$cfg_defaults{ $section }}) { +# my $pinfo = $cfg_defaults{ $section }{ $param }; +# ${@$pinfo[0]} = $cfg->val( $section, $param, @$pinfo[1] ); +# } +# } +#} sub reload_ldap_config { diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index ff516f48c..c97a879f9 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -169,9 +169,9 @@ for($count = 1; $count <= $zahl; $count++) ######################## # DAK Debian Archive Kit - #$data = "
gosa_get_dak_keyring
GOSA 00:01:6c:9d:b9:fa
"; + $data = "
gosa_get_dak_keyring
GOSA 00:01:6c:9d:b9:fa
"; #$data = "
gosa_import_dak_key
GOSA 00:01:6c:9d:b9:fa
"; - $data = "
gosa_remove_dak_key
GOSA 00:01:6c:9d:b9:fa
"; + #$data = "
gosa_remove_dak_key
GOSA 00:01:6c:9d:b9:fa
"; $sock->write($data); $answer = "nothing";