filepath-securejoin icon indicating copy to clipboard operation
filepath-securejoin copied to clipboard

Plan 9 support: Remove dependency on syscall.ELOOP

Open rminnich opened this issue 6 months ago • 7 comments

Provide package level ErrLoop instead.

rminnich avatar Jun 03 '25 16:06 rminnich

Plan9 doesn't have symlinks so I'm not sure what the benefit is of using this on Plan9 -- filepath.Join should theoretically be correct on Plan9 (it isn't race-safe but neither is SecureJoin).

error.Is(err, unix.ELOOP) continuing to work would be nice as well.

cyphar avatar Jun 03 '25 17:06 cyphar

what's a better way to do this? Maybe just rewrite the whole thing for plan 9 without symlinks? I can't remove it, somebody else is using it ...

go-nfs

rminnich avatar Jun 03 '25 17:06 rminnich

This will be zero behavioral change on unix, and only change what happens on plan 9

rminnich avatar Jun 03 '25 18:06 rminnich

Basically my suggestion would be to have something like

//go:build plan9

// SecureJoin is equivalent to filepath.Join, as plan9 doesn't have symlinks.
func SecureJoin(root, unsafePath string) (string, error) {
    return filepath.Join(root, unsafePath), nil
}

// Ditto for SecureJoinVFS.

But I'm not sure if that's really preferable...

cyphar avatar Jun 03 '25 18:06 cyphar

Your suggestion is much preferable to what I've done.

rminnich avatar Jun 12 '25 20:06 rminnich

All non-symlink tests pass on Plan 9, and in fact found an error, thanks for the push.

rminnich avatar Jun 26 '25 21:06 rminnich

@rminnich Do you know of any way to get GHA to run a Plan9 VM (and a recommendation of which VM systems might work well with it) by any chance?

cyphar avatar Sep 10 '25 14:09 cyphar