Skip to content

resolve relative symlinks server side on gateway #284

@Jorropo

Description

@Jorropo

When a unixfs symlink is hit, if the mode is file (not block or car), gateway should emulate nginx and apache, that means resolve the symlink server side and return whatever file is being pointed to.

This proposal only targets relative symlinks (I have no idea what should happen with absolute ones).

To resolve it mean, take the current base path (the path of the folder containing the symlink).
Add the symlink path, do a lexical simplification (remove a/.. and . entries), and repeat the usual gateway process at that point.

Gateway MUST error if the lexical simplification errors (such as by a symlink having more .. than how deep it is in the dag).

Gateway MUST support recursively doing that (symlinks pointing to other symlinks). It MUST support a depth of at least 32, and SHOULD raise an error if number gets too big.

For example take this tree:

CID
+ a
| +- symlink (../b/example)
+ b
  +- example

Loading CID/a/symlink the gateway would need to send the content of CID/b/example.
Because
First it resolve /a/symlink see that it's a symlink applies the content to the base path /a/../b/example
And then do a lexical simplification /b/example and then send this path content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need/triageNeeds initial labeling and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions