file_manager: update reserved path handling

Allow components to register reserved paths, then perform reserved
path validation it upon request.  Reserved paths may be registered as
read-only or no access.  Any request to modify an file/folder that is
either reserved or a child of a reserved path is rejected.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan
2022-08-15 12:16:22 -04:00
committed by Eric Callahan
parent 4df6aba6c0
commit 069a655df8
7 changed files with 70 additions and 79 deletions

View File

@@ -16,6 +16,7 @@ from typing import (
)
if TYPE_CHECKING:
from confighelper import ConfigHelper
from .file_manager.file_manager import FileManager
class Secrets:
def __init__(self, config: ConfigHelper) -> None:
@@ -30,6 +31,8 @@ class Secrets:
fpath = pathlib.Path(path).expanduser().resolve()
self.type = "invalid"
self.values: Dict[str, Any] = {}
fm: FileManager = server.lookup_component("file_manager")
fm.add_reserved_path("secrets", fpath, False)
if fpath.is_file():
self.secrets_file = fpath
data = self.secrets_file.read_text()