mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
Clarify SourceAccessor
methods should never implicitly follow symlinks
The code has already been fixed (yay!) so what is left of this commit is just updating the API docs. Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
This commit is contained in:
parent
d4f6b1d38b
commit
ce4ca574d2
1 changed files with 14 additions and 1 deletions
|
@ -26,6 +26,13 @@ struct SourceAccessor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the contents of a file as a string.
|
* Return the contents of a file as a string.
|
||||||
|
*
|
||||||
|
* @note Unlike Unix, this method should *not* follow symlinks. Nix
|
||||||
|
* by default wants to manipulate symlinks explicitly, and not
|
||||||
|
* implictly follow them, as they are frequently untrusted user data
|
||||||
|
* and thus may point to arbitrary locations. Acting on the targets
|
||||||
|
* targets of symlinks should only occasionally be done, and only
|
||||||
|
* with care.
|
||||||
*/
|
*/
|
||||||
virtual std::string readFile(const CanonPath & path);
|
virtual std::string readFile(const CanonPath & path);
|
||||||
|
|
||||||
|
@ -34,7 +41,10 @@ struct SourceAccessor
|
||||||
* called with the size of the file before any data is written to
|
* called with the size of the file before any data is written to
|
||||||
* the sink.
|
* the sink.
|
||||||
*
|
*
|
||||||
* Note: subclasses of `SourceAccessor` need to implement at least
|
* @note Like the other `readFile`, this method should *not* follow
|
||||||
|
* symlinks.
|
||||||
|
*
|
||||||
|
* @note subclasses of `SourceAccessor` need to implement at least
|
||||||
* one of the `readFile()` variants.
|
* one of the `readFile()` variants.
|
||||||
*/
|
*/
|
||||||
virtual void readFile(
|
virtual void readFile(
|
||||||
|
@ -87,6 +97,9 @@ struct SourceAccessor
|
||||||
|
|
||||||
typedef std::map<std::string, DirEntry> DirEntries;
|
typedef std::map<std::string, DirEntry> DirEntries;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note Like `readFile`, this method should *not* follow symlinks.
|
||||||
|
*/
|
||||||
virtual DirEntries readDirectory(const CanonPath & path) = 0;
|
virtual DirEntries readDirectory(const CanonPath & path) = 0;
|
||||||
|
|
||||||
virtual std::string readLink(const CanonPath & path) = 0;
|
virtual std::string readLink(const CanonPath & path) = 0;
|
||||||
|
|
Loading…
Reference in a new issue