summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-01-18 12:31:16 +0100
committerSimo Sorce <ssorce@redhat.com>2011-01-18 10:03:55 -0500
commite73efb9a9000c2efb73297340c6268d59a11b6fc (patch)
tree7ea1a3543c2d39d3598fa78d1a8312f5a0bca3e9 /ipapython
parent38bce669da7887df5f2d518b675299167b440f8e (diff)
downloadfreeipa-e73efb9a9000c2efb73297340c6268d59a11b6fc.tar.gz
freeipa-e73efb9a9000c2efb73297340c6268d59a11b6fc.tar.xz
freeipa-e73efb9a9000c2efb73297340c6268d59a11b6fc.zip
Password generation and logging in ipa-server-install
When a randomly generated password contains a space character as the first or the last character, installation fails on kdb5_ldap_util calling, which does not accept that. This patch fixes the generator to generate space only on allowed position. This patch also ensures that no password is printed to server install log. https://fedorahosted.org/freeipa/ticket/731
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/ipautil.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py
index 77c838e80..8ce8bb970 100644
--- a/ipapython/ipautil.py
+++ b/ipapython/ipautil.py
@@ -20,6 +20,8 @@
SHARE_DIR = "/usr/share/ipa/"
PLUGINS_SHARE_DIR = "/usr/share/ipa/plugins"
+GEN_PWD_LEN = 12
+
import string
import tempfile
import logging
@@ -422,8 +424,15 @@ def parse_generalized_time(timestr):
def ipa_generate_password():
rndpwd = ''
r = random.SystemRandom()
- for x in range(12):
- rndpwd += chr(r.randint(32,126))
+ for x in range(GEN_PWD_LEN):
+ # do not generate space (chr(32)) as the first or last character
+ if x == 0 or x == (GEN_PWD_LEN-1):
+ rndchar = chr(r.randint(33,126))
+ else:
+ rndchar = chr(r.randint(32,126))
+
+ rndpwd += rndchar
+
return rndpwd