From ce96f4e21ef9d3081decd3e7bc9be41827c2dd4c Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Wed, 18 Jul 2007 18:51:43 +0000 Subject: * fixed use of an uninitialized value * added support for automatically dropping 'name=""' constructs whenever only the name is expected (as a special gift to Dirk ;-P) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1253 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/slxconfig | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'config-db/slxconfig') diff --git a/config-db/slxconfig b/config-db/slxconfig index 50c8d8cd..88eb2769 100755 --- a/config-db/slxconfig +++ b/config-db/slxconfig @@ -178,7 +178,7 @@ sub dumpElements sub listClients { - my $name = shift; + my $name = _cleanName(shift); my %nameSpec; # set verbose mode if any params have been passed in: @@ -206,7 +206,7 @@ sub listClients sub listExports { - my $name = shift; + my $name = _cleanName(shift); my %nameSpec; # set verbose mode if any params have been passed in: @@ -236,7 +236,7 @@ sub listExports sub listSystems { - my $name = shift; + my $name = _cleanName(shift); my %nameSpec; # set verbose mode if any params have been passed in: @@ -268,7 +268,7 @@ sub listSystems sub listVendorOSes { - my $name = shift; + my $name = _cleanName(shift); my %nameSpec; # set verbose mode if any params have been passed in: @@ -390,7 +390,7 @@ sub searchVendorOSes sub addClientToConfigDB { - my $clientName = shift; + my $clientName = _cleanName(shift || ''); if (!length($clientName)) { die _tr("you have to specify the name for the new client\n"); @@ -418,7 +418,7 @@ sub addClientToConfigDB delete $clientData->{systems}; } - if (!length($clientData->{mac})) { + if (!$clientData->{mac}) { die _tr("you have to specify the MAC for the new client\n"); } if ($clientData->{mac} !~ m[^(?:[[:xdigit:]][[:xdigit:]]:){5}?[[:xdigit:]][[:xdigit:]]$]) { @@ -447,7 +447,7 @@ sub addClientToConfigDB sub addSystemToConfigDB { - my $systemName = shift; + my $systemName = _cleanName(shift || ''); if (!length($systemName)) { die _tr("you have to specify the name of the new system!\n"); @@ -534,7 +534,7 @@ sub addSystemToConfigDB sub changeClientInConfigDB { - my $clientName = shift; + my $clientName = _cleanName(shift || ''); if (!length($clientName)) { die _tr("you have to specify the name for the client you'd like to change!\n"); @@ -611,7 +611,7 @@ sub changeClientInConfigDB sub changeSystemInConfigDB { - my $systemName = shift; + my $systemName = _cleanName(shift || ''); if (!length($systemName)) { die _tr("you have to specify the name of the system you'd like to change!\n"); @@ -682,7 +682,7 @@ sub changeSystemInConfigDB sub removeClientFromConfigDB { - my $clientName = shift; + my $clientName = _cleanName(shift || ''); if (!length($clientName)) { die _tr("you have to specify the name of the client you'd like to remove!\n"); @@ -706,7 +706,7 @@ sub removeClientFromConfigDB sub removeSystemFromConfigDB { - my $systemName = shift; + my $systemName = _cleanName(shift || ''); if (!length($systemName)) { die _tr("you have to specify the name of the system you'd like to remove!\n"); @@ -728,6 +728,19 @@ sub removeSystemFromConfigDB return; } +sub _cleanName +{ # removes 'name=""' constructs from the name, as it is rather tempting + # for the user to type that ... (and we'd like to play along with DWIM) + my $name = shift; + + return unless defined $name; + + if ($name =~ m[^name=(.+)$]) { + return $1; + } + return $name; +} + =head1 NAME slxconfig - OpenSLX-script to view & change the configurational database -- cgit v1.2.3-55-g7522