You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/06/26 07:36:36 UTC

svn commit: r1496738 - in /incubator/ambari/branches/branch-1.2.5/ambari-server/src: main/python/ambari-server.py test/python/TestAmbaryServer.py

Author: swagle
Date: Wed Jun 26 05:36:36 2013
New Revision: 1496738

URL: http://svn.apache.org/r1496738
Log:
AMBARI-2488. LDAP: Error when executing resetmasterkey. (swagle)

Modified:
    incubator/ambari/branches/branch-1.2.5/ambari-server/src/main/python/ambari-server.py
    incubator/ambari/branches/branch-1.2.5/ambari-server/src/test/python/TestAmbaryServer.py

Modified: incubator/ambari/branches/branch-1.2.5/ambari-server/src/main/python/ambari-server.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.5/ambari-server/src/main/python/ambari-server.py?rev=1496738&r1=1496737&r2=1496738&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.5/ambari-server/src/main/python/ambari-server.py (original)
+++ incubator/ambari/branches/branch-1.2.5/ambari-server/src/main/python/ambari-server.py Wed Jun 26 05:36:36 2013
@@ -2390,7 +2390,7 @@ def setup_master_key(resetKey=False):
       return None, True, True       # setup is secure and key persisted
     elif not persist and not resetKey:
       masterKey = get_validated_string_input("Please provide master key " +\
-                    "for unlocking credential store: ", "", ".*", "", False)
+                    "for unlocking credential store: ", "", ".*", "", False, False)
       return masterKey, True, False # return master key for saving passwords
   else:
     if masterKeyFile is not None:
@@ -2409,14 +2409,14 @@ def setup_master_key(resetKey=False):
   if masterKeyFile is None or resetKey:
     key = get_validated_string_input(
       "Please provide master key for the credential store: ",
-      passwordDefault, passwordPattern, passwordDescr, True)
+      passwordDefault, passwordPattern, passwordDescr, True, False)
     if key != passwordDefault:
       key = get_validated_string_input("Please re-enter master key: ",
-        passwordDefault, passwordPattern, passwordDescr, True)
+        passwordDefault, passwordPattern, passwordDescr, True, False)
 
     persist = get_YN_input("Do you want to persist master key. If you choose "\
                            "not to persist, you need to provide the master "\
-                           "key while starting the ambari server as a env "\
+                           "key while starting the ambari server as an env "\
                            "variable named " + SECURITY_KEY_ENV_VAR_NAME +\
                            " or the start will prompt for the master key."
                            " Persist [y/n] (y)? ", True)
@@ -2441,6 +2441,8 @@ def setup_master_key(resetKey=False):
       os.remove(store_file)
 
     # Encrypt the passwords with new key
+    db_password_alias = None
+    ldap_password_alias = None
     try:
       db_password_alias = properties[JDBC_PASSWORD_PROPERTY]
       ldap_password_alias = properties[LDAP_MGR_PASSWORD_PROPERTY]
@@ -2451,7 +2453,10 @@ def setup_master_key(resetKey=False):
       configure_database_password(True, key, True)
 
     if ldap_password_alias is not None and is_alias_string(ldap_password_alias):
-      configure_ldap_password(True)
+      password = configure_ldap_password()
+      retCode = save_passwd_for_alias(LDAP_MGR_PASSWORD_ALIAS, password, key)
+      if retCode != 0:
+        print 'Saving secure ldap password failed. Exiting.'
 
   return key, True, persist
 

Modified: incubator/ambari/branches/branch-1.2.5/ambari-server/src/test/python/TestAmbaryServer.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.5/ambari-server/src/test/python/TestAmbaryServer.py?rev=1496738&r1=1496737&r2=1496738&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.5/ambari-server/src/test/python/TestAmbaryServer.py (original)
+++ incubator/ambari/branches/branch-1.2.5/ambari-server/src/test/python/TestAmbaryServer.py Wed Jun 26 05:36:36 2013
@@ -2805,7 +2805,7 @@ class TestAmbariServer(TestCase):
     sys.stdout = sys.__stdout__
 
 
-
+  @patch.object(ambari_server, 'save_passwd_for_alias')
   @patch.object(ambari_server, 'configure_ldap_password')
   @patch.object(ambari_server, 'configure_database_password')
   @patch.object(ambari_server, 'is_alias_string')
@@ -2821,7 +2821,7 @@ class TestAmbariServer(TestCase):
               get_validated_string_input_method, save_master_key_method,
               update_properties_method, get_master_key_ispersisted_method,
               is_alias_string_method, configure_database_password_method,
-              configure_ldap_password_method):
+              configure_ldap_password_method, save_passwd_for_alias_method):
 
     out = StringIO.StringIO()
     sys.stdout = out
@@ -2846,11 +2846,12 @@ class TestAmbariServer(TestCase):
     self.assertTrue(update_properties_method.called)
     self.assertTrue(configure_database_password_method.called)
     self.assertTrue(configure_ldap_password_method.called)
+    self.assertTrue(save_passwd_for_alias_method.called)
 
     sys.stdout = sys.__stdout__
 
 
-
+  @patch.object(ambari_server, 'save_passwd_for_alias')
   @patch.object(ambari_server, 'configure_ldap_password')
   @patch.object(ambari_server, 'configure_database_password')
   @patch.object(ambari_server, 'is_alias_string')
@@ -2866,7 +2867,7 @@ class TestAmbariServer(TestCase):
               get_validated_string_input_method, save_master_key_method,
               update_properties_method, get_master_key_ispersisted_method,
               is_alias_string_method, configure_database_password_method,
-              configure_ldap_password_method):
+              configure_ldap_password_method, save_passwd_for_alias_method):
 
     out = StringIO.StringIO()
     sys.stdout = out
@@ -2891,6 +2892,7 @@ class TestAmbariServer(TestCase):
     self.assertTrue(update_properties_method.called)
     self.assertTrue(configure_database_password_method.called)
     self.assertTrue(configure_ldap_password_method.called)
+    self.assertFalse(save_master_key_method.called)
 
     sys.stdout = sys.__stdout__