Jeremy Katz
2009-Feb-06 20:26 UTC
[Ovirt-devel] [PATCH server] Require confirming of the passwords
(Warning: my ruby-fu is weak) If a password is entered incorrectly and not known, it can lead to problems so make sure that the password is confirmed by the user and matching what they originally entered. There's probably also value in check the passwords with libcrypt but that would have required finding a ruby libcrypt module --- installer/bin/ovirt-installer | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/installer/bin/ovirt-installer b/installer/bin/ovirt-installer index 99601d4..90176b6 100755 --- a/installer/bin/ovirt-installer +++ b/installer/bin/ovirt-installer @@ -50,6 +50,18 @@ def prompt_for_answer(prompt, options={}) return answer end +# prompt a user for a password, with confirmation +def prompt_for_password(prompt, confirm) + loop do + pass = prompt_for_answer(prompt, :password => true) + conf = prompt_for_answer(confirm, :password => true) + if pass == conf + return pass + end + @cli.say("Passwords do not match!") + end +end + # Allow a user to enter a Yes/No # And repeat the prompt until they do def prompt_yes_no(prompt, options={}) @@ -193,17 +205,17 @@ elsif cobbler_setup == "n" end cobbler_user_name= prompt_for_answer("Enter your cobbler username:") -cobbler_user_password = prompt_for_answer("Enter your cobbler user password:", :password => true) +cobbler_user_password = prompt_for_password("Enter your cobbler user password:", "Confirm your cobbler user password:") # Postgres Configuration db_username = "ovirt" -db_password = prompt_for_answer("Enter a password for the ovirt postgres account:", :password => true) +db_password = prompt_for_password("Enter a password for the ovirt postgres account:", "Confirm your ovirt postgres password") # FreeIPA Configuration realm_name = prompt_for_answer("Enter your realm name (example: example.com):", :regex => FQDN) -freeipa_password = prompt_for_answer("NOTE: The following pasword will also be your ovirtadmin password for the web management login\n\ -Enter an administrator password for FreeIPA:", :password => true) + at cli.say("NOTE: The following password will also be your ovirtadmin password for the web management login") +freeipa_password = prompt_for_password("Enter an administrator password for FreeIPA:", "Confirm your FreeIPA admin password:") ldap_dn = "cn=ipaConfig,cn=etc," ldap_dn_temp = realm_name.split(".") ldap_dn_temp.each do |i| -- 1.6.1
Joey Boggs
2009-Feb-09 14:52 UTC
[Ovirt-devel] [PATCH server] Require confirming of the passwords
Jeremy Katz wrote:> (Warning: my ruby-fu is weak) > > If a password is entered incorrectly and not known, it can lead to problems so make sure that the password > is confirmed by the user and matching what they originally entered. There's probably also value in check > the passwords with libcrypt but that would have required finding a ruby libcrypt module > > --- > installer/bin/ovirt-installer | 20 ++++++++++++++++---- > 1 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/installer/bin/ovirt-installer b/installer/bin/ovirt-installer > index 99601d4..90176b6 100755 > --- a/installer/bin/ovirt-installer > +++ b/installer/bin/ovirt-installer > @@ -50,6 +50,18 @@ def prompt_for_answer(prompt, options={}) > return answer > end > > +# prompt a user for a password, with confirmation > +def prompt_for_password(prompt, confirm) > + loop do > + pass = prompt_for_answer(prompt, :password => true) > + conf = prompt_for_answer(confirm, :password => true) > + if pass == conf > + return pass > + end > + @cli.say("Passwords do not match!") > + end > +end > + > # Allow a user to enter a Yes/No > # And repeat the prompt until they do > def prompt_yes_no(prompt, options={}) > @@ -193,17 +205,17 @@ elsif cobbler_setup == "n" > end > > cobbler_user_name= prompt_for_answer("Enter your cobbler username:") > -cobbler_user_password = prompt_for_answer("Enter your cobbler user password:", :password => true) > +cobbler_user_password = prompt_for_password("Enter your cobbler user password:", "Confirm your cobbler user password:") > > # Postgres Configuration > db_username = "ovirt" > -db_password = prompt_for_answer("Enter a password for the ovirt postgres account:", :password => true) > +db_password = prompt_for_password("Enter a password for the ovirt postgres account:", "Confirm your ovirt postgres password") > > # FreeIPA Configuration > realm_name = prompt_for_answer("Enter your realm name (example: example.com):", :regex => FQDN) > > -freeipa_password = prompt_for_answer("NOTE: The following pasword will also be your ovirtadmin password for the web management login\n\ > -Enter an administrator password for FreeIPA:", :password => true) > + at cli.say("NOTE: The following password will also be your ovirtadmin password for the web management login") > +freeipa_password = prompt_for_password("Enter an administrator password for FreeIPA:", "Confirm your FreeIPA admin password:") > ldap_dn = "cn=ipaConfig,cn=etc," > ldap_dn_temp = realm_name.split(".") > ldap_dn_temp.each do |i| >ACK