diff --git a/locales/en.json b/locales/en.json index a91b0c525..3a3c8b0b2 100644 --- a/locales/en.json +++ b/locales/en.json @@ -209,7 +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_error": "Erro while reading SSOwat persistent configuration", + "ssowat_persistent_conf_read_error": "Error while reading SSOwat persistent configuration", + "ssowat_persistent_conf_write_error": "Error while saving 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", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 27046fd01..4f4a678d1 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -808,7 +808,7 @@ def app_makedefault(auth, app, domain=None): ssowat_conf = json.loads(str(json_conf.read())) except ValueError: raise MoulinetteError(errno.EINVAL, - m18n.n('ssowat_persistent_conf_error')) + m18n.n('ssowat_persistent_conf_read_error')) except IOError: ssowat_conf = {} diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index 1898e7023..7af818a30 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -228,7 +228,7 @@ def tools_postinstall(domain, password, ignore_dyndns=False): ssowat_conf = json.loads(str(json_conf.read())) except ValueError: raise MoulinetteError(errno.EINVAL, - m18n.n('ssowat_persistent_conf_error')) + m18n.n('ssowat_persistent_conf_read_error')) except IOError: ssowat_conf = {} diff --git a/src/yunohost/user.py b/src/yunohost/user.py index e04ba9883..4cef87429 100644 --- a/src/yunohost/user.py +++ b/src/yunohost/user.py @@ -179,15 +179,19 @@ def user_create(auth, username, firstname, lastname, mail, password, ssowat_conf = json.loads(str(json_conf.read())) except ValueError: raise MoulinetteError(errno.EINVAL, - m18n.n('ssowat_persistent_conf_error')) + m18n.n('ssowat_persistent_conf_read_error')) 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) + try: + with open('/etc/ssowat/conf.json.persistent', 'w+') as f: + json.dump(ssowat_conf, f, sort_keys=True, indent=4) + except IOError: + raise MoulinetteError(errno.EINVAL, + m18n.n('ssowat_persistent_conf_write_error')) if auth.add(rdn, attr_dict):