diff options
author | Rich Megginson <rmeggins@redhat.com> | 2007-06-12 21:08:20 +0000 |
---|---|---|
committer | Rich Megginson <rmeggins@redhat.com> | 2007-06-12 21:08:20 +0000 |
commit | b74967d111e7d6e73c5b8d90c8daae31a2d98522 (patch) | |
tree | d3885812a748db877a8aaefbc4ee95154e0bcebc /ldap/admin | |
parent | 3c6758091e1d5bd2eaec52981410d7a01cb2bfa5 (diff) | |
download | ds-b74967d111e7d6e73c5b8d90c8daae31a2d98522.tar.gz ds-b74967d111e7d6e73c5b8d90c8daae31a2d98522.tar.xz ds-b74967d111e7d6e73c5b8d90c8daae31a2d98522.zip |
Resolves: bug 237356
Description: Move DS Admin Code into Admin Server
Fix Description: 1) Need to have $SILENT be greater than $CUSTOM so that dialog hiding works properly.
2) Need to have the ability to hide or show individual prompts in a dialog e.g. if using TLS/SSL, need to ask for the CA certificate filename, otherwise, not.
3) Need the ability to call a function to get the default yes or no answer for DialogYesNo
4) DialogYesNo should match answer case insensitively
Diffstat (limited to 'ldap/admin')
-rw-r--r-- | ldap/admin/src/scripts/Dialog.pm | 22 | ||||
-rw-r--r-- | ldap/admin/src/scripts/Setup.pm.in | 2 |
2 files changed, 18 insertions, 6 deletions
diff --git a/ldap/admin/src/scripts/Dialog.pm b/ldap/admin/src/scripts/Dialog.pm index da82740c..31893e7b 100644 --- a/ldap/admin/src/scripts/Dialog.pm +++ b/ldap/admin/src/scripts/Dialog.pm @@ -107,12 +107,18 @@ sub isDisplayed { } # each prompt looks like this: -# [ 'resource key', is pwd ] +# [ 'resource key', is pwd, hide ] # The resource key is the string key of the resource # is pwd is optional - if present, the prompt is for a password # and should not echo the answer +# hide is optional - if present and true, the prompt will not be displayed - this +# is useful in cases where you may want to display or hide a subprompt depending +# on the response to a main prompt # e.g. # ['RESOURCE_USERNAME'], ['RESOURCE_PASSWORD', 1], ['RESOURCE_PASSWORD_AGAIN', 1] +# e.g. +# ['USE_SECURITY'], ['CA_CERTIFICATE', 0, 0] +# you can set the 0 to a 1 if the user has chosen to use security sub run { my $self = shift; my $resp = $DialogManager::SAME; @@ -129,7 +135,7 @@ sub run { my $prompt = $prompts[$index]; my $defaultans = $self->{defaultAns}($self, $index); my $ans; - if ($self->isDisplayed()) { + if ($self->isDisplayed() && !$promtpt->[2]) { $ans = $self->{manager}->showPrompt($prompt->[0], $defaultans, $prompt->[1]); } else { $ans = $defaultans; @@ -201,7 +207,13 @@ sub defaultAns { return $self->{ans}; } if (!exists($self->{default})) { - if ($self->{defaultIsYes}) { + my $isyes; + if (ref($self->{defaultIsYes}) eq 'CODE') { + $isyes = &{$self->{defaultIsYes}}($self); + } else { + $isyes = $self->{defaultIsYes}; + } + if ($isyes) { $self->{default} = $self->{"manager"}->getText("yes"); } else { $self->{default} = $self->{"manager"}->getText("no"); @@ -223,10 +235,10 @@ sub handleResponse { my $nno = $self->{"manager"}->getText("no"); # the regexp allows us to use y or ye or yes for "yes" - if ($nno =~ /^$ans/) { + if ($nno =~ /^$ans/i) { $resp = $DialogManager::NEXT; $self->{ans} = $nno; - } elsif ($yes =~ /^$ans/) { + } elsif ($yes =~ /^$ans/i) { $resp = $DialogManager::NEXT; $self->{ans} = $yes; } else { diff --git a/ldap/admin/src/scripts/Setup.pm.in b/ldap/admin/src/scripts/Setup.pm.in index d66fd7bb..67f6f21e 100644 --- a/ldap/admin/src/scripts/Setup.pm.in +++ b/ldap/admin/src/scripts/Setup.pm.in @@ -71,10 +71,10 @@ use File::Temp qw(tempfile tempdir); use SetupLog; # the setup types -$SILENT = 0; $EXPRESS = 1; $TYPICAL = 2; $CUSTOM = 3; +$SILENT = 4; # process command line options Getopt::Long::Configure(qw(bundling)); # bundling allows -ddddd |