Documentation
¶
Overview ¶
Package fileaccess says what one request of the file API may reach: the box's roots ([file] ManagementRoots, fileroots.Default) for the owner and the box's own services, and, for an account of role user, only the folders the owner gave it, a write only in the ones it may write (CasaOS#168).
The Gateway opens Files to an account with at least one folder, but it does not see the paths of a call (bodies, multipart uploads): this is where they are held to the folders, with the same openat2 resolution as the box's roots (a link or `..` does not lead out).
Index ¶
- Variables
- type Intent
- type Scope
- func (s *Scope) Check(intent Intent, paths ...*string) error
- func (s *Scope) CheckEntries(paths ...*string) error
- func (s *Scope) FolderOf(p string) (folder, rel string)
- func (s *Scope) Listing() *fileroots.Roots
- func (s *Scope) Pin(p string) (pinned string, f *os.File, err error)
- func (s *Scope) Readable() []string
- func (s *Scope) Root(intent Intent, p string, entry bool) (root *os.Root, folder, rel string, err error)
- func (s *Scope) User() bool
- func (s *Scope) Writable() []string
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRoleUnknown: user-service has not said yet what the account is; asked again shortly. ErrRoleUnknown = errors.New("the account's role is not known yet: try again in a moment") // ErrAccountGone: the account was deleted. ErrAccountGone = errors.New("this account no longer exists") // ErrNoFolder: no folder of Files is given to the account. ErrNoFolder = errors.New("no folder of Files is given to this account") // ErrReadOnly: the account may read this folder, not change it. ErrReadOnly = errors.New("this folder is read-only for this account") )
var ( AccountOf = external.Account FoldersOf = external.FoldersOf )
AccountOf and FoldersOf are what user-service says of an account (variables for the tests of this package and of the routes).
var ErrNotAFileOrFolder = errors.New("this is neither a file nor a folder")
ErrNotAFileOrFolder is a device, a pipe or a socket: not read for an account.
var ErrPathNotRooted = errors.New("this is not open to an account")
ErrPathNotRooted is a route that does not yet reach an account's folders through their root: it is not open to an account (see Pin and Root).
var Owner = &Scope{}
Owner reaches what the box's roots allow.
Functions ¶
This section is empty.
Types ¶
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope is what one request may reach.
func For ¶
For is the scope of a request: internal (the box's own services) or the owner's account reach the box's roots; an account of role user reaches its folders only. Closed when user-service has no fresh answer: a role not known is ErrRoleUnknown, never taken as the owner's, and a user's folders are none unless the answer is fresh.
No userID is the box's own: the token check sets it on every signed-in request, and is skipped only for an internal one.
func (*Scope) Check ¶
Check replaces each *path with its canonical spelling once it is below the box's roots and, for an account, below one of its folders (a writable one for Write).
func (*Scope) CheckEntries ¶
CheckEntries is for what deletes, renames or moves the entry itself: its folder is checked, not what it leads to, and a root (an account's folder itself) is refused. An account needs a writable folder.
func (*Scope) FolderOf ¶
FolderOf is the account's folder that holds the canonical path p (as Check gives it), and p relative to it ("." for the folder itself); "" when none does.
func (*Scope) Listing ¶
Listing is the roots a listing follows: above them, a folder shows only the way down.
func (*Scope) Pin ¶
Pin opens p for reading, for an account through the root of its folder, and gives the path that reaches that very file or folder from now on: /proc/self/fd/N, which a later rename does not move. The caller closes f once it is done with pinned.
func (*Scope) Root ¶
func (s *Scope) Root(intent Intent, p string, entry bool) (root *os.Root, folder, rel string, err error)
Root is, for an account, the os.Root of its folder that holds p, and p relative to it, once p passes Check (CheckEntries for an entry renamed or deleted). Whatever is renamed after, an operation through the root stays in the folder. folder is the folder's path.