mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Raise error on malformed SSOwat persistent conf.
This commit is contained in:
parent
431e6ffb78
commit
937f26bdaa
4 changed files with 16 additions and 6 deletions
|
@ -209,6 +209,7 @@
|
|||
"service_unknown": "Unknown service '{service:s}'",
|
||||
"ssowat_conf_generated": "The SSOwat configuration has been generated",
|
||||
"ssowat_conf_updated": "The SSOwat configuration has been updated",
|
||||
"ssowat_persistent_conf_error": "Erro while reading SSOwat persistent configuration",
|
||||
"system_upgraded": "The system has been upgraded",
|
||||
"system_username_exists": "Username already exists in the system users",
|
||||
"unbackup_app": "App '{app:s}' will not be saved",
|
||||
|
|
|
@ -806,6 +806,9 @@ def app_makedefault(auth, app, domain=None):
|
|||
try:
|
||||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||
ssowat_conf = json.loads(str(json_conf.read()))
|
||||
except ValueError:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_error'))
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
|
|
|
@ -226,6 +226,9 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
|
|||
try:
|
||||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||
ssowat_conf = json.loads(str(json_conf.read()))
|
||||
except ValueError:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_error'))
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
|
|
|
@ -177,14 +177,17 @@ def user_create(auth, username, firstname, lastname, mail, password,
|
|||
try:
|
||||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||
ssowat_conf = json.loads(str(json_conf.read()))
|
||||
except ValueError:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_error'))
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
if 'redirected_urls' in ssowat_conf and '/' in ssowat_conf['redirected_urls']:
|
||||
del ssowat_conf['redirected_urls']['/']
|
||||
if 'redirected_urls' in ssowat_conf and '/' in ssowat_conf['redirected_urls']:
|
||||
del ssowat_conf['redirected_urls']['/']
|
||||
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
|
||||
except IOError: pass
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
|
||||
|
||||
if auth.add(rdn, attr_dict):
|
||||
|
|
Loading…
Add table
Reference in a new issue