Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTypeAssertion = errors.New("type assertion")
var LogHandler func(error)
LogHandler is a configurable log handler
Functions ¶
func ResolveSymlinks ¶ added in v0.1.2
ResolveSymlinks returns the list of paths that is followed to get the the specified path.
func TraversedDirectories ¶ added in v0.1.2
TraversedDirectories returns the list of directories that is followed to get the the specified inode. We first clean up the path, i.e. .. is replaced. We also follow symlinks. E.g. /sbin/../bin/bash would return [/, /usr, /usr/bin] because /bin is symlink to /usr/bin. The last directory should be the real path of the directory of the inode. Note that the existence or type of the inode itself is not checked.
Types ¶
type File ¶
type File interface { Chdir() error Chmod(os.FileMode) error Chown(uid, gid int) error Close() error Fd() uintptr Name() string Read(b []byte) (int, error) ReadAt(b []byte, off int64) (int, error) ReadDir(n int) ([]os.DirEntry, error) ReadFrom(r io.Reader) (int64, error) Readdir(n int) ([]os.FileInfo, error) Readdirnames(n int) ([]string, error) Seek(offset int64, whence int) (int64, error) SetDeadline(t time.Time) error SetReadDeadline(t time.Time) error SetWriteDeadline(t time.Time) error Stat() (os.FileInfo, error) Sync() error SyscallConn() (syscall.RawConn, error) Truncate(size int64) error Write(b []byte) (int, error) WriteAt(b []byte, off int64) (int, error) WriteString(s string) (int, error) }
type OS ¶
type OS interface { CurrentUser() User Chmod(name string, mode os.FileMode) error Chown(name string, uid, gid int) error Chtimes(name string, atime, mtime time.Time) error Lchown(name string, uid, gid int) error Mkdir(name string, perm os.FileMode) error MkdirAll(path string, perm os.FileMode) error ReadFile(name string) ([]byte, error) Readlink(name string) (string, error) Remove(name string) error RemoveAll(path string) error Rename(oldpath, newpath string) error Symlink(oldname, newname string) error Truncate(name string, size int64) error WriteFile(name string, data []byte, perm os.FileMode) error Stat(name string) (os.FileInfo, error) Lstat(name string) (os.FileInfo, error) Create(name string) (File, error) Open(name string) (File, error) OpenFile(name string, flag int, perm os.FileMode) (File, error) ReadDir(name string) ([]os.DirEntry, error) EvalSymlinks(name string) (string, error) Walk(name string, walkFn filepath.WalkFunc) error }
type Permission ¶
type Permission uint32
const ( Read Permission = 4 Write Permission = 2 Execute Permission = 1 )
type User ¶
func (User) CanReadInode ¶
CanReadInode checks whether the user can read the file inode at the specified path, i.e. whether the inode can be statted (= execution bit on the parent directory). The inode itself doesn't have to exist, its parent directory should exist. If nil is returned, the inode is readable by the user.
func (User) CanReadObject ¶
CanReadObject checks whether the user can read the file or directory at the specified path. The file or directory needs to exist, as its permission bits are checked. Symlinks are followed. If nil is returned, the object is readable by the user.
func (User) CanWriteInode ¶
CanWriteInode checks whether the user can write to the file inode at the specified path. The inode itself doesn't have to exist, its parent directory should exist. If nil is returned, the inode is writable by the user.
func (User) CanWriteObject ¶
CanWriteObject checks whether the user can write to the file or directory at the specified path. The file or directory needs to exist, as its permission bits are checked. Symlinks are followed. If nil is returned, the object is writable by the user.
func (User) Lowns ¶
Lowns checks whether the user owns the file or directory at the specified path. The file or directory needs to exist, as its owner is checked. Symlinks are not followed. If nil is returned, the object is owned by the user.