strict file validation

This commit is contained in:
Devaev Maxim
2019-10-24 01:21:34 +03:00
parent 372bf2a4af
commit 97e2d9128c
6 changed files with 52 additions and 27 deletions

View File

@@ -26,7 +26,7 @@ import passlib.apache
from ...yamlconf import Option
from ...validators.os import valid_abs_path_exists
from ...validators.os import valid_abs_file
from . import BaseAuthService
@@ -39,7 +39,7 @@ class Plugin(BaseAuthService):
@classmethod
def get_plugin_options(cls) -> Dict:
return {
"file": Option("/etc/kvmd/htpasswd", type=valid_abs_path_exists, unpack_as="path"),
"file": Option("/etc/kvmd/htpasswd", type=valid_abs_file, unpack_as="path"),
}
async def authorize(self, user: str, passwd: str) -> bool:

View File

@@ -29,7 +29,7 @@ from typing import AsyncGenerator
from ...yamlconf import Option
from ...validators.os import valid_abs_path_exists
from ...validators.os import valid_abs_dir
from ...validators.os import valid_command
from . import MsdOperationError
@@ -48,7 +48,7 @@ class Plugin(BaseMsd):
def get_plugin_options(cls) -> Dict:
sudo = ["/usr/bin/sudo", "--non-interactive"]
return {
"storage": Option("/var/lib/kvmd/msd", type=valid_abs_path_exists, unpack_as="storage_path"),
"storage": Option("/var/lib/kvmd/msd", type=valid_abs_dir, unpack_as="storage_path"),
"remount_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-remount", "{mode}"], type=valid_command),
"unlock_cmd": Option([*sudo, "/usr/bin/kvmd-helper-otgmsd-unlock", "unlock"], type=valid_command),
}