# HG changeset patch
# User Pascal Volk <neverseen@users.sourceforge.net>
# Date 1272512299 0
# Node ID 45ec5c3cfef4160145f95b4d9ea6a139beb1aafb
# Parent  77fc7138ef6a4b22844f652bbf0f9e6203b533a6
VMM/password: added small output check on _dovecotpw().

diff -r 77fc7138ef6a -r 45ec5c3cfef4 VirtualMailManager/password.py
--- a/VirtualMailManager/password.py	Thu Apr 29 03:05:22 2010 +0000
+++ b/VirtualMailManager/password.py	Thu Apr 29 03:38:19 2010 +0000
@@ -52,7 +52,11 @@
     stdout, stderr = process.communicate()
     if process.returncode:
         raise VMMError(stderr.strip(), VMM_ERROR)
-    return stdout.strip()
+    hashed = stdout.strip()
+    if not hashed.startswith('{%s}' % scheme):
+        raise VMMError('Unexpected result from %s: %s' %
+                       (cfg_dget('bin.dovecotpw'), hashed), VMM_ERROR)
+    return hashed
 
 
 def _md4_new():