Bug 1076172 - Fix the case where we don't have .mozilla created and file permissions. r=armenzg
authorKartik Gupta <kartikgupta0909@gmail.com>
Wed, 10 Dec 2014 14:29:06 -0500 (2014-12-10)
changeset 3455 30247a28bfd509ed059977363c0ea1cc15f3112e
parent 3454 0a33dcc7043deb37b368b1578002b781c0569166
child 3456 974ed06d29fb65e98def60de297e6ab5ad02842a
push id2678
push userarmenzg@mozilla.com
push dateWed, 10 Dec 2014 19:29:29 +0000 (2014-12-10)
reviewersarmenzg
bugs1076172
Bug 1076172 - Fix the case where we don't have .mozilla created and file permissions. r=armenzg
mozharness/mozilla/testing/testbase.py
--- a/mozharness/mozilla/testing/testbase.py
+++ b/mozharness/mozilla/testing/testbase.py
@@ -160,22 +160,26 @@ class TestingMixin(VirtualenvMixin, Buil
 	    self.credential_path = os.path.expanduser("~/.mozilla/credentials.cfg")
 	    if (os.path.isfile(self.credential_path)):
 	        fp = open(self.credential_path,'r')
 		content = fp.read().splitlines()
 		fp.close()
 		self.https_username = content[0].strip()
 		self.https_password = content[1].strip()
 	    else:
+                if not os.path.exists(os.path.expanduser("~/.mozilla")):
+                    os.makedirs(os.path.expanduser("~/.mozilla"))
                 self.https_username = raw_input("Please enter your full LDAP email address: ")
                 self.https_password = getpass.getpass()
 	        fp = open(self.credential_path,"w+")
 	        fp.write("%s\n" % self.https_username)
 		fp.write("%s\n" % self.https_password)
 	        fp.close()
+		os.chmod(self.credential_path, 0600)
+
         return self.https_username, self.https_password
 
     def _pre_config_lock(self, rw_config):
         for i, (target_file, target_dict) in enumerate(rw_config.all_cfg_files_and_dicts):
             if 'developer_config' in target_file:
                 self._developer_mode_changes(rw_config)
 
     def _developer_mode_changes(self, rw_config):