dissect.target.filesystems.nfs¶
Module Contents¶
Classes¶
Filesystem implementation of a NFS share |
|
Base class for filesystem entries. |
|
Basic buffered stream that provides aligned reads. |
Attributes¶
- dissect.target.filesystems.nfs.ConCredentials¶
- dissect.target.filesystems.nfs.ConVerifier¶
- dissect.target.filesystems.nfs.ClientFactory¶
- dissect.target.filesystems.nfs.AuthSetter¶
- exception dissect.target.filesystems.nfs.AuthFlavorNotSupported(supported_flavors: list[int], provided_flavor: int)¶
Bases:
ExceptionCommon base class for all non-exit exceptions.
- supported¶
- provided¶
- __str__() str¶
Return str(self).
- class dissect.target.filesystems.nfs.NfsFilesystem(client_factory: ClientFactory, root_handle: dissect.target.helpers.nfs.nfs3.FileHandle)¶
Bases:
dissect.target.filesystem.FilesystemFilesystem implementation of a NFS share
The connection is lazily established to not waste resources. Use the
connectmethod to conveniently create a new instance.- __type__ = 'nfs'¶
A short string identifying the type of filesystem.
- classmethod connect(address: str, exported_dir: str, auth: dissect.target.helpers.sunrpc.client.AuthScheme[ConCredentials, ConVerifier] | AuthSetter, local_port: int | dissect.target.helpers.sunrpc.client.LocalPortPolicy = 0, timeout_in_seconds: float | None = 5.0) typing_extensions.Self¶
Utility function to setup a connection to a NFS share.
- Parameters:
hostname – The remote hostname.
port – The remote port.
auth – The authentication scheme.
local_port – The local port to bind to. If equal to
LocalPortPolicy.PRIVILEGEDor -1, bind to the first free privileged port. If equal toLocalPortPolicy.ANYor 0, bind to any free port. Otherwise, bind to the specified port.timeout_in_seconds – The timeout for making the connection.
- static detect(_: BinaryIO) bool¶
Detect whether the
fhfile-handle is supported by thisFilesystemimplementation.The position of
fhwill be restored before returning.- Parameters:
fh – A file-like object, usually a disk or partition.
- Returns:
Trueiffhis supported,Falseotherwise.
- get(path: str, relentry: NfsFilesystemEntry | None = None) NfsFilesystemEntry¶
Get a filesystem entry.
- Parameters:
path – The path to the entry. The path is relative to
relentry, if provided.relentry – The relative entry to start from. If not provided, the root entry is used.
- class dissect.target.filesystems.nfs.NfsFilesystemEntry(fs: NfsFilesystem, path: str, file_handle: dissect.target.helpers.nfs.nfs3.FileHandle, attributes: dissect.target.helpers.nfs.nfs3.FileAttributes | None = None)¶
Bases:
dissect.target.filesystem.FilesystemEntryBase class for filesystem entries.
- fs: NfsFilesystem¶
- get(path: str) NfsFilesystemEntry¶
Get a new filesystem entry relative to this entry
- is_file(follow_symlinks: bool = True) bool¶
Determine if this entry is a file.
- Parameters:
follow_symlinks – Whether to resolve the entry if it is a symbolic link.
- Returns:
Trueif the entry is a file or a symbolic link to a file, returnFalseotherwise. Iffollow_symlinksisFalse, returnTrueonly if the entry is a file (without following symlinks).
- is_dir(follow_symlinks: bool = True) bool¶
Determine if this entry is a directory.
- Parameters:
follow_symlinks – Whether to resolve the entry if it is a symbolic link.
- Returns:
Trueif the entry is a directory or a symbolic link to a directory, returnFalseotherwise. Iffollow_symlinksisFalse, returnTrueonly if the entry is a directory (without following symlinks).
- is_symlink() bool¶
Determine whether this entry is a symlink.
- Returns:
Trueif the entry is a symbolic link,Falseotherwise.
- readlink() str¶
Read the link where this entry points to, return the resulting path as string.
If it is a symlink and returns the entry that corresponds to that path. This means it follows the path a link points to, it tries to do it recursively.
- Returns:
The path the link points to.
- readlink_ext() NfsFilesystemEntry¶
Read the link where this entry points to, return the resulting path as
FilesystemEntry.If it is a symlink and returns the string that corresponds to that path. This means it follows the path a link points to, it tries to do it recursively.
- Returns:
The filesystem entry the link points to.
- iterdir() collections.abc.Iterator[str]¶
Iterate over the contents of a directory, return them as strings.
- Returns:
An iterator of directory entries as path strings.
- scandir() collections.abc.Iterator[dissect.target.filesystem.FilesystemEntry]¶
Iterate over the contents of a directory, yields
FilesystemEntry.- Returns:
An iterator of
FilesystemEntry.
- open() NfsStream¶
Open this filesystem entry.
- Returns:
A file-like object. Resolves symlinks when possible
- stat(follow_symlinks: bool = True) dissect.target.helpers.fsutil.stat_result¶
Determine the stat information of this entry.
If the entry is a symlink and
follow_symlinksisTrue, it gets resolved, attempting to stat the path where it points to.- Parameters:
follow_symlinks – Whether to resolve the symbolic link if this entry is a symbolic link.
- Returns:
The stat information of this entry.
- lstat() dissect.target.helpers.fsutil.stat_result¶
Determine the stat information of this entry, without resolving the symlinks.
When it detects a symlink, it will stat the information of the symlink, not the path it points to.
- Returns:
The stat information of this entry.
- class dissect.target.filesystems.nfs.NfsStream(client: dissect.target.helpers.nfs.client.nfs.Client, file_handle: dissect.target.helpers.nfs.nfs3.FileHandle, size: int | None)¶
Bases:
dissect.util.stream.AlignedStreamBasic buffered stream that provides aligned reads.
- Must be subclassed for various stream implementations. Subclasses can implement:
_read()_seek()
The offset and length for
_readare guaranteed to be aligned for streams of a known size. If your stream has an unknown size (i.e.size == None), reads of length-1(i.e. read until EOF) will be passed through to your implementation of_read. The only time that overriding_seekwould make sense is if there’s no known size of your stream, but still want to provideSEEK_ENDfunctionality.Most subclasses of
AlignedStreamtake one or more file-like objects as source. Operations on these subclasses, like reading, will modify the source file-like object as a side effect.- Parameters:
size – The size of the stream. This is used in read and seek operations.
Noneif unknown.align – The alignment size. Read operations are aligned on this boundary. Also determines buffer size.
- _seek(pos: int, whence: int = 0) int¶
Calculate and return the new stream position after a seek.