summaryrefslogtreecommitdiffstats
path: root/base/deploy/src/scriptlets/pkiparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'base/deploy/src/scriptlets/pkiparser.py')
-rw-r--r--base/deploy/src/scriptlets/pkiparser.py56
1 files changed, 48 insertions, 8 deletions
diff --git a/base/deploy/src/scriptlets/pkiparser.py b/base/deploy/src/scriptlets/pkiparser.py
index aec125016..19f7210e8 100644
--- a/base/deploy/src/scriptlets/pkiparser.py
+++ b/base/deploy/src/scriptlets/pkiparser.py
@@ -23,6 +23,7 @@
import ConfigParser
import argparse
import getpass
+import ldap
import logging
import os
import random
@@ -241,6 +242,9 @@ class PKIConfigParser:
config.user_config.set(section, property, value)
+ def print_text(self, message):
+ print ' ' * self.indent + message
+
def read_text(self, message,
section=None, property=None, default=None,
options=None, sign=':', allowEmpty=True, caseSensitive=True):
@@ -286,20 +290,24 @@ class PKIConfigParser:
def read_password(self, message, section=None, property=None,
verifyMessage=None):
message = ' ' * self.indent + message + ': '
- verifyMessage = ' ' * self.indent + verifyMessage + ': '
+ if verifyMessage is not None:
+ verifyMessage = ' ' * self.indent + verifyMessage + ': '
+
while True:
password = ''
while len(password) == 0:
password = getpass.getpass(prompt=message)
- verification = ''
- while len(verification) == 0:
- verification = getpass.getpass(prompt=verifyMessage)
+ if verifyMessage is not None:
+ verification = ''
+ while len(verification) == 0:
+ verification = getpass.getpass(prompt=verifyMessage)
- if password == verification:
- break
- else:
- print ' ' * self.indent + 'Passwords do not match.'
+ if password != verification:
+ self.print_text('Passwords do not match.')
+ continue
+
+ break
if section:
self.set_property(section, property, password)
@@ -345,6 +353,38 @@ class PKIConfigParser:
config.pki_master_dict.update(subsystem_dict)
+ def ds_connect(self):
+ uri = 'ldap://' + config.pki_master_dict['pki_ds_hostname'] +\
+ ':' + config.pki_master_dict['pki_ds_ldap_port']
+ self.ds_connection = ldap.initialize(uri)
+ self.ds_connection.search_s('', ldap.SCOPE_BASE)
+
+ def ds_bind(self):
+ self.ds_connection.simple_bind_s(
+ config.pki_master_dict['pki_ds_bind_dn'],
+ config.pki_master_dict['pki_ds_password'])
+
+ def ds_base_dn_exists(self):
+ try:
+ results = self.ds_connection.search_s(
+ config.pki_master_dict['pki_ds_base_dn'],
+ ldap.SCOPE_BASE)
+
+ if results is None or len(results) == 0:
+ return False
+
+ return True
+
+ except ldap.NO_SUCH_OBJECT as e:
+ return False
+
+ except ldap.LDAPError as e:
+ print 'ERROR: ' + e.message['desc']
+ sys.exit(1)
+
+ def ds_close(self):
+ self.ds_connection.unbind_s()
+
def compose_pki_master_dictionary(self):
"Create a single master PKI dictionary from the sectional dictionaries"
try: