diff options
author | Devaev Maxim <[email protected]> | 2019-10-24 01:21:34 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-10-24 01:21:34 +0300 |
commit | 97e2d9128c37805ba649807f5f923d1d1e92907f (patch) | |
tree | 36ddaa7318cea97edf55ef994052b14a28e36305 /kvmd/apps | |
parent | 372bf2a4afc93726ad63090202b517c939a183d9 (diff) |
strict file validation
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/__init__.py | 11 | ||||
-rw-r--r-- | kvmd/apps/otgmsd/__init__.py | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 04c1b621..c4b0b0bc 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -58,7 +58,8 @@ from ..validators.auth import valid_user from ..validators.auth import valid_users_list from ..validators.os import valid_abs_path -from ..validators.os import valid_abs_path_exists +from ..validators.os import valid_abs_file +from ..validators.os import valid_abs_dir from ..validators.os import valid_unix_mode from ..validators.os import valid_command @@ -87,7 +88,7 @@ def init( args_parser = argparse.ArgumentParser(prog=(prog or argv[0]), description=description, add_help=add_help) args_parser.add_argument("-c", "--config", dest="config_path", default="/etc/kvmd/main.yaml", metavar="<file>", - type=valid_abs_path_exists, help="Set config file path") + type=valid_abs_file, help="Set config file path") args_parser.add_argument("-o", "--set-options", dest="set_options", default=[], nargs="+", help="Override config options list (like sec/sub/opt=value)") args_parser.add_argument("-m", "--dump-config", dest="dump_config", action="store_true", @@ -205,8 +206,8 @@ def _get_config_scheme() -> Dict: }, "info": { - "meta": Option("/etc/kvmd/meta.yaml", type=valid_abs_path_exists, unpack_as="meta_path"), - "extras": Option("/usr/share/kvmd/extras", type=valid_abs_path_exists, unpack_as="extras_path"), + "meta": Option("/etc/kvmd/meta.yaml", type=valid_abs_file, unpack_as="meta_path"), + "extras": Option("/usr/share/kvmd/extras", type=valid_abs_dir, unpack_as="extras_path"), }, "hid": { @@ -303,7 +304,7 @@ def _get_config_scheme() -> Dict: }, "auth": { - "file": Option("/etc/kvmd/ipmipasswd", type=valid_abs_path_exists, unpack_as="path"), + "file": Option("/etc/kvmd/ipmipasswd", type=valid_abs_file, unpack_as="path"), }, }, } diff --git a/kvmd/apps/otgmsd/__init__.py b/kvmd/apps/otgmsd/__init__.py index b22c0dfb..2fe566ba 100644 --- a/kvmd/apps/otgmsd/__init__.py +++ b/kvmd/apps/otgmsd/__init__.py @@ -33,7 +33,7 @@ import psutil from ...validators.basic import valid_bool from ...validators.basic import valid_number -from ...validators.os import valid_abs_path_exists +from ...validators.os import valid_abs_file from .. import init @@ -98,7 +98,7 @@ def main(argv: Optional[List[str]]=None) -> None: metavar="<1|0|yes|no>", help="Set CD-ROM flag") parser.add_argument("--set-rw", default=None, type=valid_bool, metavar="<1|0|yes|no>", help="Set RW flag") - parser.add_argument("--set-image", default=None, type=valid_abs_path_exists, + parser.add_argument("--set-image", default=None, type=valid_abs_file, metavar="<path>", help="Set the image file") parser.add_argument("--eject", action="store_true", help="Eject the image") |