core: added the security_limit to setParam
- params with a security greater than security_limit can not be modified - special value: security_limit < 0 disable the check (all params can be modified)
This commit is contained in:
parent
5366490603
commit
2bf3694fd0
13 changed files with 56 additions and 37 deletions
|
|
@ -199,8 +199,8 @@ class DBusBridgeFrontend(BridgeFrontend):
|
||||||
def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"):
|
def sendMessage(self, to_jid, message, subject='', mess_type="auto", options={}, profile_key="@NONE@"):
|
||||||
return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, options, profile_key)
|
return self.db_core_iface.sendMessage(to_jid, message, subject, mess_type, options, profile_key)
|
||||||
|
|
||||||
def setParam(self, name, value, category, profile_key="@DEFAULT@"):
|
def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"):
|
||||||
return self.db_core_iface.setParam(name, value, category, profile_key)
|
return self.db_core_iface.setParam(name, value, category, security_limit, profile_key)
|
||||||
|
|
||||||
def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
|
def setPresence(self, to_jid='', show='', priority=0, statuses={}, profile_key="@DEFAULT@"):
|
||||||
return self.db_core_iface.setPresence(to_jid, show, priority, statuses, profile_key)
|
return self.db_core_iface.setPresence(to_jid, show, priority, statuses, profile_key)
|
||||||
|
|
|
||||||
|
|
@ -525,8 +525,7 @@ class PrimitivusApp(QuickApp):
|
||||||
self.addWindow(XMLUI(self,xml_data=params))
|
self.addWindow(XMLUI(self,xml_data=params))
|
||||||
def failure(error):
|
def failure(error):
|
||||||
self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get parameters"), ok_cb=self.removePopUp))
|
self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get parameters"), ok_cb=self.removePopUp))
|
||||||
security_limit = -1
|
self.bridge.getParamsUI(profile_key=self.profile, callback=success, errback=failure)
|
||||||
self.bridge.getParamsUI(security_limit, self.profile, callback=success, errback=failure)
|
|
||||||
|
|
||||||
|
|
||||||
def onExitRequest(self, menu):
|
def onExitRequest(self, menu):
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,10 @@ class ProfileManager(urwid.WidgetWrap):
|
||||||
new_pass = self.pass_wid.get_edit_text()
|
new_pass = self.pass_wid.get_edit_text()
|
||||||
|
|
||||||
if old_jid != new_jid:
|
if old_jid != new_jid:
|
||||||
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile)
|
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile_key=profile)
|
||||||
self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile)
|
self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile_key=profile)
|
||||||
if old_pass != new_pass:
|
if old_pass != new_pass:
|
||||||
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
|
self.host.bridge.setParam("Password", new_pass, "Connection", profile_key=profile)
|
||||||
self.host.plug_profile(profile)
|
self.host.plug_profile(profile)
|
||||||
|
|
||||||
def getParamError(self, ignore):
|
def getParamError(self, ignore):
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ def getText(node):
|
||||||
data.append(child.wholeText)
|
data.append(child.wholeText)
|
||||||
return u"".join(data)
|
return u"".join(data)
|
||||||
|
|
||||||
|
|
||||||
class Pairs(urwid.WidgetWrap):
|
class Pairs(urwid.WidgetWrap):
|
||||||
|
|
||||||
def __init__(self, weight_0='1', weight_1='1'):
|
def __init__(self, weight_0='1', weight_1='1'):
|
||||||
|
|
@ -274,5 +275,6 @@ class XMLUI(urwid.WidgetWrap):
|
||||||
value = "true" if ctrl.get_state() else "false"
|
value = "true" if ctrl.get_state() else "false"
|
||||||
else:
|
else:
|
||||||
value = ctrl.get_edit_text()
|
value = ctrl.get_edit_text()
|
||||||
self.host.bridge.setParam(ctrl._param_name, value, ctrl._param_category, profile_key = self.host.profile)
|
self.host.bridge.setParam(ctrl._param_name, value, ctrl._param_category,
|
||||||
|
profile_key=self.host.profile)
|
||||||
self.host.removeWindow()
|
self.host.removeWindow()
|
||||||
|
|
|
||||||
|
|
@ -363,8 +363,7 @@ class MainWindow(wx.Frame, QuickApp):
|
||||||
|
|
||||||
def onParam(self, e):
|
def onParam(self, e):
|
||||||
debug(_("Param request"))
|
debug(_("Param request"))
|
||||||
#security_limit = -1
|
#xmlui = self.bridge.getParamsUI(profile_key=self.profile)
|
||||||
#xmlui = self.bridge.getParamsUI(security_limit, profile_key=self.profile)
|
|
||||||
#XMLUI(self, xml_data = xmlui)
|
#XMLUI(self, xml_data = xmlui)
|
||||||
param=Param(self)
|
param=Param(self)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,6 @@ class Param(wx.Frame):
|
||||||
cat_dom.unlink()
|
cat_dom.unlink()
|
||||||
|
|
||||||
self.host.bridge.getParamsForCategory(category,
|
self.host.bridge.getParamsForCategory(category,
|
||||||
security_limit=-1,
|
|
||||||
profile_key=self.host.profile,
|
profile_key=self.host.profile,
|
||||||
callback=gotParams,
|
callback=gotParams,
|
||||||
errback=errorGettingParams)
|
errback=errorGettingParams)
|
||||||
|
|
@ -137,7 +136,8 @@ class Param(wx.Frame):
|
||||||
|
|
||||||
def __save_parameters(self):
|
def __save_parameters(self):
|
||||||
for param in self.modified:
|
for param in self.modified:
|
||||||
self.host.bridge.setParam(param[0], self.modified[param], param[1], profile_key = self.host.profile)
|
self.host.bridge.setParam(param[0], self.modified[param], param[1],
|
||||||
|
profile_key=self.host.profile)
|
||||||
self.modified.clear()
|
self.modified.clear()
|
||||||
|
|
||||||
def onClose(self, event):
|
def onClose(self, event):
|
||||||
|
|
|
||||||
|
|
@ -145,11 +145,11 @@ class ProfileManager(wx.Panel):
|
||||||
new_pass = self.login_pass.GetValue()
|
new_pass = self.login_pass.GetValue()
|
||||||
if old_jid != new_jid:
|
if old_jid != new_jid:
|
||||||
debug(_('Saving new JID and server'))
|
debug(_('Saving new JID and server'))
|
||||||
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile)
|
self.host.bridge.setParam("JabberID", new_jid, "Connection", profile_key=profile)
|
||||||
self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile)
|
self.host.bridge.setParam("Server", JID(new_jid).domain, "Connection", profile_key=profile)
|
||||||
if old_pass != new_pass:
|
if old_pass != new_pass:
|
||||||
debug(_('Saving new password'))
|
debug(_('Saving new password'))
|
||||||
self.host.bridge.setParam("Password", new_pass, "Connection", profile)
|
self.host.bridge.setParam("Password", new_pass, "Connection", profile_key=profile)
|
||||||
self.host.plug_profile(profile)
|
self.host.plug_profile(profile)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -391,10 +391,10 @@ class DbusObject(dbus.service.Object):
|
||||||
return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), options, unicode(profile_key))
|
return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), options, unicode(profile_key))
|
||||||
|
|
||||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||||
in_signature='ssss', out_signature='',
|
in_signature='sssis', out_signature='',
|
||||||
async_callbacks=None)
|
async_callbacks=None)
|
||||||
def setParam(self, name, value, category, profile_key="@DEFAULT@"):
|
def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"):
|
||||||
return self._callback("setParam", unicode(name), unicode(value), unicode(category), unicode(profile_key))
|
return self._callback("setParam", unicode(name), unicode(value), unicode(category), security_limit, unicode(profile_key))
|
||||||
|
|
||||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||||
in_signature='ssia{ss}s', out_signature='',
|
in_signature='ssia{ss}s', out_signature='',
|
||||||
|
|
|
||||||
|
|
@ -398,14 +398,16 @@ doc_param_1=name: name of the option
|
||||||
[setParam]
|
[setParam]
|
||||||
type=method
|
type=method
|
||||||
category=core
|
category=core
|
||||||
sig_in=ssss
|
sig_in=sssis
|
||||||
sig_out=
|
sig_out=
|
||||||
param_3_default="@DEFAULT@"
|
param_3_default=-1
|
||||||
|
param_4_default="@DEFAULT@"
|
||||||
doc=Change a parameter
|
doc=Change a parameter
|
||||||
doc_param_0=name: Name of the parameter to change
|
doc_param_0=name: Name of the parameter to change
|
||||||
doc_param_1=value: New Value of the parameter
|
doc_param_1=value: New Value of the parameter
|
||||||
doc_param_2=category: Category of the parameter to change
|
doc_param_2=category: Category of the parameter to change
|
||||||
doc_param_3=%(doc_profile_key)s
|
doc_param_3=security_limit: -1 means no security then the higher the most secure
|
||||||
|
doc_param_4=%(doc_profile_key)s
|
||||||
|
|
||||||
[getParamA]
|
[getParamA]
|
||||||
type=method
|
type=method
|
||||||
|
|
|
||||||
|
|
@ -414,10 +414,10 @@ class SAT(service.Service):
|
||||||
|
|
||||||
## Client management ##
|
## Client management ##
|
||||||
|
|
||||||
def setParam(self, name, value, category, profile_key):
|
def setParam(self, name, value, category, security_limit, profile_key):
|
||||||
"""set wanted paramater and notice observers"""
|
"""set wanted paramater and notice observers"""
|
||||||
info(_("setting param: %(name)s=%(value)s in category %(category)s") % {'name': name, 'value': value, 'category': category})
|
info(_("setting param: %(name)s=%(value)s in category %(category)s") % {'name': name, 'value': value, 'category': category})
|
||||||
self.memory.setParam(name, value, category, profile_key)
|
self.memory.setParam(name, value, category, security_limit, profile_key)
|
||||||
|
|
||||||
def isConnected(self, profile_key):
|
def isConnected(self, profile_key):
|
||||||
"""Return connection status of profile
|
"""Return connection status of profile
|
||||||
|
|
|
||||||
|
|
@ -392,12 +392,12 @@ class Params(object):
|
||||||
if security_limit < 0:
|
if security_limit < 0:
|
||||||
return False
|
return False
|
||||||
if not node.hasAttribute('security'):
|
if not node.hasAttribute('security'):
|
||||||
debug("filtered param: %s (no security set)"
|
#debug("filtered param: %s (no security set)"
|
||||||
% node.getAttribute("name"))
|
# % node.getAttribute("name"))
|
||||||
return True
|
return True
|
||||||
if int(node.getAttribute('security')) > security_limit:
|
if int(node.getAttribute('security')) > security_limit:
|
||||||
debug("filtered param: %s (security level > %i)"
|
#debug("filtered param: %s (security level > %i)"
|
||||||
% (node.getAttribute("name"), security_limit))
|
# % (node.getAttribute("name"), security_limit))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -545,7 +545,7 @@ class Params(object):
|
||||||
categories.append(cat.getAttribute("name"))
|
categories.append(cat.getAttribute("name"))
|
||||||
return categories
|
return categories
|
||||||
|
|
||||||
def setParam(self, name, value, category, profile_key='@NONE@'):
|
def setParam(self, name, value, category, security_limit=-1, profile_key='@NONE@'):
|
||||||
"""Set a parameter, return None if the parameter is not in param xml"""
|
"""Set a parameter, return None if the parameter is not in param xml"""
|
||||||
#TODO: use different behaviour depending of the data type (e.g. password encrypted)
|
#TODO: use different behaviour depending of the data type (e.g. password encrypted)
|
||||||
if profile_key != "@NONE@":
|
if profile_key != "@NONE@":
|
||||||
|
|
@ -556,9 +556,20 @@ class Params(object):
|
||||||
|
|
||||||
node = self.__getParamNode(name, category, '@ALL@')
|
node = self.__getParamNode(name, category, '@ALL@')
|
||||||
if not node:
|
if not node:
|
||||||
error(_('Requesting an unknown parameter (%(category)s/%(name)s)') % {'category': category, 'name': name})
|
error(_('Requesting an unknown parameter (%(category)s/%(name)s)')
|
||||||
|
% {'category': category, 'name': name})
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if security_limit >= 0:
|
||||||
|
abort = True
|
||||||
|
if node[1].hasAttribute("security"):
|
||||||
|
if int(node[1].getAttribute("security")) <= security_limit:
|
||||||
|
abort = False
|
||||||
|
if abort:
|
||||||
|
warning(_("Trying to set parameter '%s' in category '%s' without authorization!!!"
|
||||||
|
% (name, category)))
|
||||||
|
return
|
||||||
|
|
||||||
if node[0] == 'general':
|
if node[0] == 'general':
|
||||||
self.params_gen[(category, name)] = value
|
self.params_gen[(category, name)] = value
|
||||||
self.storage.setGenParam(category, name, value)
|
self.storage.setGenParam(category, name, value)
|
||||||
|
|
@ -921,8 +932,8 @@ class Memory(object):
|
||||||
def getParamsCategories(self):
|
def getParamsCategories(self):
|
||||||
return self.params.getParamsCategories()
|
return self.params.getParamsCategories()
|
||||||
|
|
||||||
def setParam(self, name, value, category, profile_key):
|
def setParam(self, name, value, category, security_limit, profile_key):
|
||||||
return self.params.setParam(name, value, category, profile_key)
|
return self.params.setParam(name, value, category, security_limit, profile_key)
|
||||||
|
|
||||||
def importParams(self, xml):
|
def importParams(self, xml):
|
||||||
return self.params.importParams(xml)
|
return self.params.importParams(xml)
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,12 @@ class MiscAccount(object):
|
||||||
def _profileRegistered(self, result, email, password, profile):
|
def _profileRegistered(self, result, email, password, profile):
|
||||||
|
|
||||||
#FIXME: values must be in a config file instead of hardcoded
|
#FIXME: values must be in a config file instead of hardcoded
|
||||||
self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, _NEW_ACCOUNT_DOMAIN, _NEW_ACCOUNT_RESOURCE), "Connection", profile)
|
self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, _NEW_ACCOUNT_DOMAIN, _NEW_ACCOUNT_RESOURCE),
|
||||||
self.host.memory.setParam("Server", _NEW_ACCOUNT_SERVER, "Connection", profile)
|
"Connection", profile_key=profile)
|
||||||
self.host.memory.setParam("Password", password, "Connection", profile)
|
self.host.memory.setParam("Server", _NEW_ACCOUNT_SERVER,
|
||||||
|
"Connection", profile_key=profile)
|
||||||
|
self.host.memory.setParam("Password", password,
|
||||||
|
"Connection", profile_key=profile)
|
||||||
#and the account
|
#and the account
|
||||||
|
|
||||||
#XXX: we use "prosodyctl adduser" because "register" doesn't check conflict
|
#XXX: we use "prosodyctl adduser" because "register" doesn't check conflict
|
||||||
|
|
|
||||||
|
|
@ -798,9 +798,12 @@ class XEP_0065_handler(XMPPHandler):
|
||||||
if len(streamhost_elts) != 1:
|
if len(streamhost_elts) != 1:
|
||||||
warning(_("Multiple streamhost elements in proxy not managed, keeping only the first one"))
|
warning(_("Multiple streamhost elements in proxy not managed, keeping only the first one"))
|
||||||
streamhost_elt = streamhost_elts[0]
|
streamhost_elt = streamhost_elts[0]
|
||||||
proxy = self.host.memory.setParam("Proxy", streamhost_elt.getAttribute("jid", ""), "File Transfer", self.parent.profile)
|
proxy = self.host.memory.setParam("Proxy", streamhost_elt.getAttribute("jid", ""),
|
||||||
proxy = self.host.memory.setParam("Proxy host", streamhost_elt.getAttribute("host", ""), "File Transfer", self.parent.profile)
|
"File Transfer", profile_key=self.parent.profile)
|
||||||
proxy = self.host.memory.setParam("Proxy port", streamhost_elt.getAttribute("port", ""), "File Transfer", self.parent.profile)
|
proxy = self.host.memory.setParam("Proxy host", streamhost_elt.getAttribute("host", ""),
|
||||||
|
"File Transfer", profile_key=self.parent.profile)
|
||||||
|
proxy = self.host.memory.setParam("Proxy port", streamhost_elt.getAttribute("port", ""),
|
||||||
|
"File Transfer", profile_key=self.parent.profile)
|
||||||
|
|
||||||
def connectionInitialized(self):
|
def connectionInitialized(self):
|
||||||
def after_init(ignore):
|
def after_init(ignore):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue