2024-03-28 13:09:42 +00:00
|
|
|
package helpers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"git.kmsign.ru/royalcat/tstor/pkg/ctxbilly"
|
|
|
|
nfs "git.kmsign.ru/royalcat/tstor/pkg/go-nfs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewNullAuthHandler creates a handler for the provided filesystem
|
|
|
|
func NewNullAuthHandler(fs nfs.Filesystem) nfs.Handler {
|
|
|
|
return &NullAuthHandler{fs}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NullAuthHandler returns a NFS backing that exposes a given file system in response to all mount requests.
|
|
|
|
type NullAuthHandler struct {
|
|
|
|
fs nfs.Filesystem
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mount backs Mount RPC Requests, allowing for access control policies.
|
|
|
|
func (h *NullAuthHandler) Mount(ctx context.Context, conn net.Conn, req nfs.MountRequest) (status nfs.MountStatus, hndl nfs.Filesystem, auths []nfs.AuthFlavor) {
|
|
|
|
status = nfs.MountStatusOk
|
|
|
|
hndl = h.fs
|
|
|
|
auths = []nfs.AuthFlavor{nfs.AuthFlavorNull}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change provides an interface for updating file attributes.
|
|
|
|
func (h *NullAuthHandler) Change(fs nfs.Filesystem) nfs.Change {
|
|
|
|
if c, ok := h.fs.(ctxbilly.Change); ok {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FSStat provides information about a filesystem.
|
2024-06-16 21:34:46 +00:00
|
|
|
func (h *NullAuthHandler) FSStat(context.Context, nfs.Filesystem, *nfs.FSStat) error {
|
2024-03-28 13:09:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToHandle handled by CachingHandler
|
2024-06-16 21:34:46 +00:00
|
|
|
func (h *NullAuthHandler) ToHandle(context.Context, nfs.Filesystem, []string) []byte {
|
2024-03-28 13:09:42 +00:00
|
|
|
return []byte{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromHandle handled by CachingHandler
|
2024-06-16 21:34:46 +00:00
|
|
|
func (h *NullAuthHandler) FromHandle(context.Context, []byte) (nfs.Filesystem, []string, error) {
|
2024-03-28 13:09:42 +00:00
|
|
|
return nil, []string{}, nil
|
|
|
|
}
|
|
|
|
|
2024-06-16 21:34:46 +00:00
|
|
|
func (c *NullAuthHandler) InvalidateHandle(context.Context, nfs.Filesystem, []byte) error {
|
2024-03-28 13:09:42 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// HandleLImit handled by cachingHandler
|
|
|
|
func (h *NullAuthHandler) HandleLimit() int {
|
|
|
|
return -1
|
|
|
|
}
|