userfs

package
v0.0.0-...-9f8393d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2019 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const UserAllowedDefaultTimeout = 10 * time.Second

UserAllowedDefaultTimeout is the default timeout for waiting for a response from the user.

Variables

View Source
var ErrUserNotAllowed = userNotAllowedError(syscall.EACCES)

ErrUserNotAllowed is returned if the user denied access or timed out waiting for a response.

Functions

This section is empty.

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS for user files, such as their home, documents, other personal files.

func New

func New(srcPath, newPath string) *FS

New user FS.

func (*FS) AcceptUserAllowRequests

func (f *FS) AcceptUserAllowRequests(ch chan<- UserRequest)

AcceptUserAllowRequests - paths are sent to the channel, use SetUserAllowed to respond. If the channel is full, requests are dropped. Note that if SetUserAllowed is not called on a path sent to the channel, said path will not be sent again. (The previous statement is not true in the case of StopUserAllowRequests and AutoUserAllowRequests) If asking the user to accept/deny, consider using UserAllowNoneOnce if they take too long (timeout)

func (*FS) AutoUserAllowRequests

func (f *FS) AutoUserAllowRequests(allow UserAllow, until time.Time)

AutoUserAllowRequests - While the current time is less than until, any user allow reqeusts are suppressed and auto replied with allow. To cancel early, call again with a time not in the future (such as Now, or time.Time's zero value) Note: any previous and future SetUserAllowed calls still apply! they override the auto requests.

func (*FS) IsUserAllowed

func (f *FS) IsUserAllowed(ctx context.Context, req UserRequest) bool

IsUserAllowed - is the user allowed? waits for up to UserAllowedDefaultTimeout for the user to respond.

func (*FS) IsUserAllowedFast

func (f *FS) IsUserAllowedFast(ctx context.Context, req UserRequest) bool

IsUserAllowedFast - quickly checks if the user allowed, without waiting.

func (*FS) Root

func (f *FS) Root() (fs.Node, error)

Root node (dir)

func (*FS) SetLogger

func (f *FS) SetLogger(logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
})

SetLogger sets the logger.

func (*FS) SetUserAllowed

func (f *FS) SetUserAllowed(threadPID uint32, path string, allow UserAllow)

SetUserAllowed responds to a path user request.

func (*FS) Statfs

func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error

Statfs is the FS statistics info.

func (*FS) StopUserAllowRequests

func (f *FS) StopUserAllowRequests()

StopUserAllowRequests - Requests will not be sent after this call.

type UserAllow

type UserAllow byte

UserAllow is how access is allowed or denied.

const (
	UserAllowNone     UserAllow = iota
	UserAllowNoneOnce           // transient, only used by SetUserAllowed. good for user timeout.
	UserAllowOnce
	UserAllowAll
)

func (UserAllow) Allowed

func (allow UserAllow) Allowed() bool

type UserRequest

type UserRequest struct {
	Deadline  time.Time
	Path      string
	Action    string
	UID, GID  uint32
	ThreadPID uint32 // The thread, or 0 if not known.
	PID       uint32 // The process, or 0 if not known.
}

Note: PID can be 0 if not known or it is the OS.

func (UserRequest) Command

func (req UserRequest) Command() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL