mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Prevent full-domain app to be moved to a subpath with change-url ?
This commit is contained in:
parent
1e046dcd37
commit
80f4b892e6
1 changed files with 17 additions and 19 deletions
|
@ -33,7 +33,7 @@ import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import List, Tuple, Dict
|
from typing import List, Tuple, Dict, Any
|
||||||
|
|
||||||
from moulinette import Moulinette, m18n
|
from moulinette import Moulinette, m18n
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
|
@ -51,7 +51,6 @@ from yunohost.utils import packages
|
||||||
from yunohost.utils.config import (
|
from yunohost.utils.config import (
|
||||||
ConfigPanel,
|
ConfigPanel,
|
||||||
ask_questions_and_parse_answers,
|
ask_questions_and_parse_answers,
|
||||||
Question,
|
|
||||||
DomainQuestion,
|
DomainQuestion,
|
||||||
PathQuestion,
|
PathQuestion,
|
||||||
)
|
)
|
||||||
|
@ -384,8 +383,9 @@ def app_change_url(operation_logger, app, domain, path):
|
||||||
"app_change_url_identical_domains", domain=domain, path=path
|
"app_change_url_identical_domains", domain=domain, path=path
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check the url is available
|
app_setting_path = os.path.join(APPS_SETTING_PATH, app)
|
||||||
_assert_no_conflicting_apps(domain, path, ignore_app=app)
|
path_requirement = _guess_webapp_path_requirement(app_setting_path)
|
||||||
|
_validate_webpath_requirement({"domain": domain, "path": path}, path_requirement, ignore_app=app)
|
||||||
|
|
||||||
tmp_workdir_for_app = _make_tmp_workdir_for_app(app=app)
|
tmp_workdir_for_app = _make_tmp_workdir_for_app(app=app)
|
||||||
|
|
||||||
|
@ -777,8 +777,8 @@ def app_install(
|
||||||
}
|
}
|
||||||
|
|
||||||
# Validate domain / path availability for webapps
|
# Validate domain / path availability for webapps
|
||||||
path_requirement = _guess_webapp_path_requirement(questions, extracted_app_folder)
|
path_requirement = _guess_webapp_path_requirement(extracted_app_folder)
|
||||||
_validate_webpath_requirement(questions, path_requirement)
|
_validate_webpath_requirement(args, path_requirement)
|
||||||
|
|
||||||
# Attempt to patch legacy helpers ...
|
# Attempt to patch legacy helpers ...
|
||||||
_patch_legacy_helpers(extracted_app_folder)
|
_patch_legacy_helpers(extracted_app_folder)
|
||||||
|
@ -2214,13 +2214,16 @@ def _check_manifest_requirements(manifest: Dict, app: str):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _guess_webapp_path_requirement(questions: List[Question], app_folder: str) -> str:
|
def _guess_webapp_path_requirement(app_folder: str) -> str:
|
||||||
|
|
||||||
# If there's only one "domain" and "path", validate that domain/path
|
# If there's only one "domain" and "path", validate that domain/path
|
||||||
# is an available url and normalize the path.
|
# is an available url and normalize the path.
|
||||||
|
|
||||||
domain_questions = [question for question in questions if question.type == "domain"]
|
manifest = _get_manifest_of_app(app_folder)
|
||||||
path_questions = [question for question in questions if question.type == "path"]
|
raw_questions = manifest.get("arguments", {}).get("install", {})
|
||||||
|
|
||||||
|
domain_questions = [question for question in raw_questions if question.get("type") == "domain"]
|
||||||
|
path_questions = [question for question in raw_questions if question.get("type") == "path"]
|
||||||
|
|
||||||
if len(domain_questions) == 0 and len(path_questions) == 0:
|
if len(domain_questions) == 0 and len(path_questions) == 0:
|
||||||
return ""
|
return ""
|
||||||
|
@ -2248,22 +2251,17 @@ def _guess_webapp_path_requirement(questions: List[Question], app_folder: str) -
|
||||||
|
|
||||||
|
|
||||||
def _validate_webpath_requirement(
|
def _validate_webpath_requirement(
|
||||||
questions: List[Question], path_requirement: str
|
args: Dict[str, Any], path_requirement: str, ignore_app=None
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
domain_questions = [question for question in questions if question.type == "domain"]
|
domain = args.get("domain")
|
||||||
path_questions = [question for question in questions if question.type == "path"]
|
path = args.get("path")
|
||||||
|
|
||||||
if path_requirement == "domain_and_path":
|
if path_requirement == "domain_and_path":
|
||||||
|
_assert_no_conflicting_apps(domain, path, ignore_app=ignore_app)
|
||||||
domain = domain_questions[0].value
|
|
||||||
path = path_questions[0].value
|
|
||||||
_assert_no_conflicting_apps(domain, path, full_domain=True)
|
|
||||||
|
|
||||||
elif path_requirement == "full_domain":
|
elif path_requirement == "full_domain":
|
||||||
|
_assert_no_conflicting_apps(domain, "/", full_domain=True, ignore_app=ignore_app)
|
||||||
domain = domain_questions[0].value
|
|
||||||
_assert_no_conflicting_apps(domain, "/", full_domain=True)
|
|
||||||
|
|
||||||
|
|
||||||
def _get_conflicting_apps(domain, path, ignore_app=None):
|
def _get_conflicting_apps(domain, path, ignore_app=None):
|
||||||
|
|
Loading…
Add table
Reference in a new issue