mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-16 13:46:31 +00:00
Quote CIFS password to remove strict requirements
This commit is contained in:
parent
8b4e8e9804
commit
6f614c91d7
@ -358,7 +358,8 @@ class CIFSMount(NetworkMount):
|
|||||||
def options(self) -> list[str]:
|
def options(self) -> list[str]:
|
||||||
"""Options to use to mount."""
|
"""Options to use to mount."""
|
||||||
return (
|
return (
|
||||||
super().options + [f"username={self.username}", f"password={self.password}"]
|
super().options
|
||||||
|
+ [f"username={self.username}", f"password='{self.password}'"]
|
||||||
if self.username
|
if self.username
|
||||||
else []
|
else []
|
||||||
)
|
)
|
||||||
|
@ -21,13 +21,11 @@ from .const import (
|
|||||||
|
|
||||||
RE_MOUNT_NAME = re.compile(r"^\w+$")
|
RE_MOUNT_NAME = re.compile(r"^\w+$")
|
||||||
RE_PATH_PART = re.compile(r"^[^\\\/]+")
|
RE_PATH_PART = re.compile(r"^[^\\\/]+")
|
||||||
RE_MOUNT_OPTION = re.compile(r"^[^,=]+$")
|
|
||||||
|
|
||||||
VALIDATE_NAME = vol.Match(RE_MOUNT_NAME)
|
VALIDATE_NAME = vol.Match(RE_MOUNT_NAME)
|
||||||
VALIDATE_SERVER = vol.Match(RE_PATH_PART)
|
VALIDATE_SERVER = vol.Match(RE_PATH_PART)
|
||||||
VALIDATE_SHARE = vol.Match(RE_PATH_PART)
|
VALIDATE_SHARE = vol.Match(RE_PATH_PART)
|
||||||
VALIDATE_USERNAME = vol.Match(RE_MOUNT_OPTION)
|
|
||||||
VALIDATE_PASSWORD = vol.Match(RE_MOUNT_OPTION)
|
|
||||||
|
|
||||||
_SCHEMA_BASE_MOUNT_CONFIG = vol.Schema(
|
_SCHEMA_BASE_MOUNT_CONFIG = vol.Schema(
|
||||||
{
|
{
|
||||||
@ -49,8 +47,8 @@ SCHEMA_MOUNT_CIFS = _SCHEMA_MOUNT_NETWORK.extend(
|
|||||||
{
|
{
|
||||||
vol.Required(ATTR_TYPE): MountType.CIFS.value,
|
vol.Required(ATTR_TYPE): MountType.CIFS.value,
|
||||||
vol.Required(ATTR_SHARE): VALIDATE_SHARE,
|
vol.Required(ATTR_SHARE): VALIDATE_SHARE,
|
||||||
vol.Inclusive(ATTR_USERNAME, "basic_auth"): VALIDATE_USERNAME,
|
vol.Inclusive(ATTR_USERNAME, "basic_auth"): str,
|
||||||
vol.Inclusive(ATTR_PASSWORD, "basic_auth"): VALIDATE_PASSWORD,
|
vol.Inclusive(ATTR_PASSWORD, "basic_auth"): str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ async def test_cifs_mount(
|
|||||||
"server": "test.local",
|
"server": "test.local",
|
||||||
"share": "camera",
|
"share": "camera",
|
||||||
"username": "admin",
|
"username": "admin",
|
||||||
"password": "password",
|
"password": "p@assword!,=",
|
||||||
}
|
}
|
||||||
mount: CIFSMount = Mount.from_dict(coresys, mount_data)
|
mount: CIFSMount = Mount.from_dict(coresys, mount_data)
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ async def test_cifs_mount(
|
|||||||
assert mount.what == "//test.local/camera"
|
assert mount.what == "//test.local/camera"
|
||||||
assert mount.where == Path("/mnt/data/supervisor/mounts/test")
|
assert mount.where == Path("/mnt/data/supervisor/mounts/test")
|
||||||
assert mount.local_where == tmp_supervisor_data / "mounts" / "test"
|
assert mount.local_where == tmp_supervisor_data / "mounts" / "test"
|
||||||
assert mount.options == ["username=admin", "password=password"]
|
assert mount.options == ["username=admin", "password='p@assword!,='"]
|
||||||
|
|
||||||
assert not mount.local_where.exists()
|
assert not mount.local_where.exists()
|
||||||
assert mount.to_dict(skip_secrets=False) == mount_data
|
assert mount.to_dict(skip_secrets=False) == mount_data
|
||||||
@ -73,7 +73,7 @@ async def test_cifs_mount(
|
|||||||
"mnt-data-supervisor-mounts-test.mount",
|
"mnt-data-supervisor-mounts-test.mount",
|
||||||
"fail",
|
"fail",
|
||||||
[
|
[
|
||||||
["Options", Variant("s", "username=admin,password=password")],
|
["Options", Variant("s", "username=admin,password='p@assword!,='")],
|
||||||
["Type", Variant("s", "cifs")],
|
["Type", Variant("s", "cifs")],
|
||||||
["Description", Variant("s", "Supervisor cifs mount: test")],
|
["Description", Variant("s", "Supervisor cifs mount: test")],
|
||||||
["What", Variant("s", "//test.local/camera")],
|
["What", Variant("s", "//test.local/camera")],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user