3 commits - pykolab/setup pykolab/utils.py share/templates

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Sat May 12 16:17:27 CEST 2012


 pykolab/setup/setup_ldap.py                    |   55 +++++++++++++++++++++++++
 pykolab/setup/setup_roundcube.py               |   12 +++++
 pykolab/utils.py                               |    2 
 share/templates/roundcubemail/main.inc.php.tpl |    2 
 4 files changed, 69 insertions(+), 2 deletions(-)

New commits:
commit 6ea8339291d8739c145144e6bee3d3873e6b91a2
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat May 12 14:50:42 2012 +0100

    The LDAP setup component should ask for confirmation and allow the alteration of the domain name space and root dn used (#716)

diff --git a/pykolab/setup/setup_ldap.py b/pykolab/setup/setup_ldap.py
index 9a9db2b..1f14a5e 100644
--- a/pykolab/setup/setup_ldap.py
+++ b/pykolab/setup/setup_ldap.py
@@ -120,6 +120,57 @@ def execute(*args, **kw):
 
     _input['rootdn'] = utils.standard_root_dn(_input['domain'])
 
+    if ask_questions:
+        print >> sys.stderr, utils.multiline_message(
+                _("""
+                        This setup procedure plans to set up Kolab Groupware for
+                        the following domain name space. This domain name is
+                        obtained from the reverse DNS entry on your network
+                        interface. Please confirm this is the appropriate domain
+                        name space.
+                    """)
+            )
+
+        answer = utils.ask_confirmation("%s" % (_input['domain']))
+
+        if not answer:
+            positive_answer = False
+            while not positive_answer:
+                _input['domain'] = utils.ask_question(_("Domain name to use"))
+                if not _input['domain'] == None and not _input['domain'] == "":
+                    positive_answer = True
+                else:
+                    print >> sys.stderr, utils.multiline_message(
+                            _("""
+                                    Invalid input. Please try again.
+                                """)
+                        )
+
+        _input['nodotdomain'] = _input['domain'].replace('.','_')
+        _input['rootdn'] = utils.standard_root_dn(_input['domain'])
+
+        print >> sys.stderr, utils.multiline_message(
+                _("""
+                        The standard root dn we composed for you follows. Please
+                        confirm this is the root dn you wish to use.
+                    """)
+            )
+
+        answer = utils.ask_confirmation("%s" % (_input['rootdn']))
+
+        if not answer:
+            positive_answer = False
+            while not positive_answer:
+                _input['rootdn'] = utils.ask_question(_("Root DN to use"))
+                if not _input['rootdn'] == None and not _input['rootdn'] == "":
+                    positive_answer = True
+                else:
+                    print >> sys.stderr, utils.multiline_message(
+                            _("""
+                                    Invalid input. Please try again.
+                                """)
+                        )
+
     data = """
 [General]
 FullMachineName = %(fqdn)s
@@ -175,6 +226,10 @@ ServerAdminPwd = %(admin_pass)s
     log.debug(_("Setup DS stderr:"), level=8)
     log.debug(stderrdata, level=8)
 
+    # TODO: Fails when ran a second time.
+
+    # TODO: When fail, fail gracefully.
+
     # Find the kolab schema. It's installed as %doc in the kolab-schema package.
     # TODO: Chown nobody, nobody, chmod 440
     schema_file = None


commit 9d1e262bc890ed664069332f6f6000d061ff571e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat May 12 14:39:25 2012 +0100

    Make utils.multiline_message() prepend and append a carrier return for clarity on the console

diff --git a/pykolab/utils.py b/pykolab/utils.py
index 325446f..ceb6f68 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -162,7 +162,7 @@ def multiline_message(message):
 
     lines.append(line)
 
-    return "\n".join(lines)
+    return "\n%s\n" % ("\n".join(lines))
 
 def normalize(_object):
     if type(_object) == list:


commit a31e53033bb2923e2743d3045c036b9e9df25f9e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Sat May 12 14:15:44 2012 +0100

    During setup, scratch the des_key setting for Roundcube (#715)

diff --git a/pykolab/setup/setup_roundcube.py b/pykolab/setup/setup_roundcube.py
index 0077a3d..30a2aa9 100644
--- a/pykolab/setup/setup_roundcube.py
+++ b/pykolab/setup/setup_roundcube.py
@@ -18,7 +18,10 @@
 #
 
 from Cheetah.Template import Template
+import hashlib
 import os
+import random
+import re
 import subprocess
 import sys
 
@@ -58,6 +61,15 @@ def execute(*args, **kw):
     conf.mysql_roundcube_password = mysql_roundcube_password
 
     rc_settings = {
+            'des_key': re.sub(
+                    r'[^a-zA-Z0-9]',
+                    "",
+                    "%s%s" % (
+                            hashlib.md5("%s" % random.random()).digest().encode("base64"),
+                            hashlib.md5("%s" % random.random()).digest().encode("base64")
+                        )
+                )[:25],
+
             'imap_admin_login': conf.get('cyrus-imapd', 'admin_login'),
             'imap_admin_password': conf.get('cyrus-imapd', 'admin_password'),
             'ldap_base_dn': conf.get('ldap', 'base_dn'),
diff --git a/share/templates/roundcubemail/main.inc.php.tpl b/share/templates/roundcubemail/main.inc.php.tpl
index 2828c9b..f8ceace 100644
--- a/share/templates/roundcubemail/main.inc.php.tpl
+++ b/share/templates/roundcubemail/main.inc.php.tpl
@@ -199,7 +199,7 @@
     \$rcmail_config['default_host'] = 'tls://localhost';
     \$rcmail_config['smtp_server'] = 'tls://localhost';
     \$rcmail_config['session_domain'] = '';
-    \$rcmail_config['des_key'] = 'aTMVSq6lNHg1YbcV6t59uGeZ';
+    \$rcmail_config['des_key'] = "$des_key";
     \$rcmail_config['username_domain'] = '';
 
     \$rcmail_config['mail_domain'] = '';





More information about the commits mailing list