mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #170 from YunoHost/fix-ssowat-persistent-conf-error
[fix] Raise error on malformed SSOwat persistent conf.
This commit is contained in:
commit
27cc0aac29
4 changed files with 35 additions and 11 deletions
|
@ -209,6 +209,8 @@
|
|||
"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_read_error": "Error while reading SSOwat persistent configuration: {error:s}. Edit /etc/ssowat/conf.json.persistent file to fix the JSON syntax.",
|
||||
"ssowat_persistent_conf_write_error": "Error while saving SSOwat persistent configuration: {error:s}. Edit /etc/ssowat/conf.json.persistent file to fix the JSON syntax.",
|
||||
"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",
|
||||
|
|
|
@ -809,6 +809,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 as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_read_error', error=e.strerror))
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
|
@ -817,8 +820,13 @@ def app_makedefault(auth, app, domain=None):
|
|||
|
||||
ssowat_conf['redirected_urls'][domain +'/'] = app_domain + app_path
|
||||
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
try:
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
except IOError as e:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
|
||||
|
||||
|
||||
os.system('chmod 644 /etc/ssowat/conf.json.persistent')
|
||||
|
||||
|
|
|
@ -244,6 +244,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 as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_read_error', error=e.strerror))
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
|
@ -252,8 +255,13 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
|
|||
|
||||
ssowat_conf['redirected_urls']['/'] = domain +'/yunohost/admin'
|
||||
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
try:
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
except IOError as e:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
|
||||
|
||||
|
||||
os.system('chmod 644 /etc/ssowat/conf.json.persistent')
|
||||
|
||||
|
|
|
@ -176,14 +176,20 @@ 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 as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_read_error', error=e.strerror))
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
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
|
||||
if 'redirected_urls' in ssowat_conf and '/' in ssowat_conf['redirected_urls']:
|
||||
del ssowat_conf['redirected_urls']['/']
|
||||
try:
|
||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
except IOError as e:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
|
||||
|
||||
|
||||
if auth.add(rdn, attr_dict):
|
||||
|
|
Loading…
Add table
Reference in a new issue