summaryrefslogtreecommitdiffstats
path: root/py-bin
diff options
context:
space:
mode:
authorbanah <banah@2b6ed08e-c90c-0410-9317-ae88bde05ade>2007-03-16 16:06:25 +0000
committerbanah <banah@2b6ed08e-c90c-0410-9317-ae88bde05ade>2007-03-16 16:06:25 +0000
commit635ce401d116cd8e11333a5565664cf4dcbaa4b5 (patch)
treefcef2cc9ce46bfba1c5be3da161536d8e87635b7 /py-bin
parent41293e1939e18a82f763bc16ac3cf6c42173c58e (diff)
suppress logging of passwords in case of ejabberdctl failure
git-svn-id: https://rfd.cronopios.org/immerda/jabber@60 2b6ed08e-c90c-0410-9317-ae88bde05ade
Diffstat (limited to 'py-bin')
-rw-r--r--py-bin/ejabberdctl.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/py-bin/ejabberdctl.py b/py-bin/ejabberdctl.py
index 876261c..7e2360b 100644
--- a/py-bin/ejabberdctl.py
+++ b/py-bin/ejabberdctl.py
@@ -3,9 +3,20 @@
import subprocess, logging
import config
+class SensitiveString:
+ def __init__(self, strn):
+ self.strn = strn
+
+ def __str__(self):
+ return "*"
+
+ def get_sensitive_value(self):
+ return self.strn
+
+
class EJabberdCtl:
def create_account(self, user, server, password):
- if self.__ejabberdctl(["register", user, server, password]):
+ if self.__ejabberdctl(["register", user, server, SensitiveString(password)]):
logging.info("Created account %s@%s." % (user, server))
return True
return False
@@ -17,7 +28,7 @@ class EJabberdCtl:
return False
def change_password(self, user, server, password):
- if self.__ejabberdctl(["set-password", user, server, password]):
+ if self.__ejabberdctl(["set-password", user, server, SensitiveString(password)]):
logging.info("Changed Password for %s@%s." % (user, server))
return True
return False
@@ -25,24 +36,18 @@ class EJabberdCtl:
def __ejabberdctl(self, params):
return self.__run([config.ejabberdctl_path] + params, config.ejabberdctl_environ)
-# def __run(self, path_and_params, environ={}):
-# try:
-# result = subprocess.call(path_and_params, env=environ)
-# if result != 0:
-# logging.error("Error invoking '%s': Result = %s." %
-# (str(path_and_params), str(result)))
-# return (result == 0)
-# except Exception, e:
-# logging.error("Error invoking '%s': %s." % (str(path_and_params), str(e)))
-# return False
-
def __run(self, path_and_params, environ={}):
- p = subprocess.Popen(path_and_params, stdin=subprocess.PIPE,
+ real_params = map(self.__get_sensitive_value, path_and_params)
+ p = subprocess.Popen(real_params, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environ)
result = p.wait()
if result != 0:
logging.error("Error invoking '%s': Result = %s." %
- (str(path_and_params), str(result)))
+ (str(map(str,path_and_params)), str(result)))
return False
return True
-
+
+ def __get_sensitive_value(self, s):
+ if isinstance(s, SensitiveString):
+ return s.get_sensitive_value()
+ return s