Merge pull request #1131 from YunoHost/fix-legacy-persistent-migration

use read_yaml for json because lol
This commit is contained in:
Alexandre Aubin 2021-01-06 18:05:37 +01:00 committed by GitHub
commit 2f856cbe07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,7 @@ import os
from moulinette import m18n
from yunohost.utils.error import YunohostError
from moulinette.utils.log import getActionLogger
from moulinette.utils.filesystem import read_json, write_to_json, read_yaml
from moulinette.utils.filesystem import write_to_json, read_yaml
from yunohost.user import user_list, user_group_create, user_group_update
from yunohost.app import app_setting, _installed_apps, _get_app_settings, _set_app_settings
@ -211,10 +211,12 @@ def migrate_legacy_permission_settings(app=None):
def translate_legacy_rules_in_ssowant_conf_json_persistent():
if not os.path.exists("/etc/ssowat/conf.json.persistent"):
persistent_file_name = "/etc/ssowat/conf.json.persistent"
if not os.path.exists(persistent_file_name):
return
persistent = read_json("/etc/ssowat/conf.json.persistent")
# Ugly hack to try not to misarably fail migration
persistent = read_yaml(persistent_file_name)
legacy_rules = [
"skipped_urls",
@ -271,6 +273,6 @@ def translate_legacy_rules_in_ssowant_conf_json_persistent():
"uris": protected_urls + persistent["permissions"].get("custom_protected", {}).get("uris", []),
}
write_to_json("/etc/ssowat/conf.json.persistent", persistent, sort_keys=True, indent=4)
write_to_json(persistent_file_name, persistent, sort_keys=True, indent=4)
logger.warning("Yunohost automatically translated some legacy rules in /etc/ssowat/conf.json.persistent to match the new permission system")