VMM/cli/handler: Added support for random passwords in user_add().
--- a/VirtualMailManager/cli/handler.py Mon Aug 09 19:39:55 2010 +0000
+++ b/VirtualMailManager/cli/handler.py Tue Aug 10 01:02:21 2010 +0000
@@ -16,6 +16,7 @@
from VirtualMailManager.cli.config import CliConfig as Cfg
from VirtualMailManager.constants import ACCOUNT_EXISTS, INVALID_SECTION, \
NO_SUCH_ACCOUNT
+from VirtualMailManager.password import randompw
_ = lambda msg: msg
@@ -67,16 +68,21 @@
def user_add(self, emailaddress, password=None):
"""Override the parent user_add() - add the interactive password
- dialog."""
+ dialog.
+
+ Returns the generated password, if account.random_password == True.
+ """
acc = self._get_account(emailaddress)
if acc:
raise VMMError(_(u"The account '%s' already exists.") %
acc.address, ACCOUNT_EXISTS)
+ rand_pass = self._cfg.dget('account.random_password')
if password is None:
- password = read_pass()
+ password = (read_pass, randompw)[rand_pass]()
acc.set_password(password)
acc.save()
self._make_account_dirs(acc)
+ return (None, password)[rand_pass]
def user_password(self, emailaddress, password=None):
"""Override the parent user_password() - add the interactive
--- a/VirtualMailManager/cli/subcommands.py Mon Aug 09 19:39:55 2010 +0000
+++ b/VirtualMailManager/cli/subcommands.py Tue Aug 10 01:02:21 2010 +0000
@@ -380,7 +380,9 @@
password = None
else:
password = ctx.args[3]
- ctx.hdlr.user_add(ctx.args[2].lower(), password)
+ gen_pass = ctx.hdlr.user_add(ctx.args[2].lower(), password)
+ if gen_pass:
+ w_std(_(u"Generated password: %s") % gen_pass)
def user_delete(ctx):
--- a/man/de/man1/vmm.1.rst Mon Aug 09 19:39:55 2010 +0000
+++ b/man/de/man1/vmm.1.rst Tue Aug 10 01:02:21 2010 +0000
@@ -7,7 +7,7 @@
-----------------------------------------------------------------------------
:Author: Pascal Volk <neverseen@users.sourceforge.net>
-:Date: 2010-08-01
+:Date: |today|
:Version: vmm-0.6.0
:Manual group: vmm Manual
:Manual section: 1
@@ -288,7 +288,10 @@
angelegt.
Wurde kein *Passwort* angegeben wird **vmm** dieses im interaktiven Modus
- erfragen.
+ erfragen. Falls kein *Passwort* angegeben wurde und
+ |account.random_password|_ den Wert **true** hat, wird **vmm** ein
+ zufälliges Passwort generieren und auf stdout ausgeben, nachdem das Konto
+ angelegt wurde.
Beispiele::
--- a/man/man1/vmm.1.rst Mon Aug 09 19:39:55 2010 +0000
+++ b/man/man1/vmm.1.rst Tue Aug 10 01:02:21 2010 +0000
@@ -7,7 +7,7 @@
----------------------------------------------------------
:Author: Pascal Volk <neverseen@users.sourceforge.net>
-:Date: 2010-08-01
+:Date: |today|
:Version: vmm-0.6.0
:Manual group: vmm Manual
:Manual section: 1
@@ -270,7 +270,9 @@
Use this subcommand to create a new email account for the given *address*.
If the *password* is not provided, **vmm** will prompt for it
- interactively.
+ interactively. When no *password* is provided and |account.random_password|_
+ is set to **true**, **vmm** will generate a random password and print it to
+ stdout after the account has been created.
Examples::
--- a/man/substitute_links_1.rst Mon Aug 09 19:39:55 2010 +0000
+++ b/man/substitute_links_1.rst Tue Aug 10 01:02:21 2010 +0000
@@ -2,6 +2,8 @@
.. |account.disk_usage| replace:: `account.disk_usage`
.. _account.disk_usage: vmm.cfg.5#account-disk-usage
+.. |account.random_password| replace:: `account.random_password`
+.. _account.random_password: vmm.cfg.5#account-random-password
.. |domain.force_deletion| replace:: `domain.force_deletion`
.. _domain.force_deletion: vmm.cfg.5#domain-force-deletion