"""The file shares the host serves and the ones it has mounted (NetOrk/netork#3104). Both readings are napalm-device-types': the NFS exports and Samba shares the host serves (``PosixSharesMixin``) and the NFS exports and SMB shares it has mounted (``NetworkMountsMixin``). Both commands are read-only and read files every user may read, so they run on an exec channel under ``sh`` as the login user, never through sudo. """ from __future__ import annotations from shlex import quote from typing import TYPE_CHECKING from napalm_device_types import NetworkMountsMixin, PosixSharesMixin if TYPE_CHECKING: # pragma: no cover - for type checkers only from napalm_device_types import CommandResult class LinuxSharesMixin(PosixSharesMixin, NetworkMountsMixin): """The transports for ``get_shares`` and ``get_network_mounts``.""" if TYPE_CHECKING: # pragma: no cover - declared for type checkers only def run_command( self, command: str, *, privileged: bool = False, timeout: float = 60, stdin: bytes | None = None, ) -> CommandResult: ... def _run_shares_command(self, command: str) -> str: return self.run_command(f"sh -c {quote(command)}", timeout=60).stdout def _run_network_mounts_command(self, command: str) -> str: return self.run_command(f"sh -c {quote(command)}", timeout=30).stdout