unpriv

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chmod

func Chmod(path string, mode os.FileMode) error

Chmod is a wrapper around os.Chmod which has been wrapped with unpriv.Wrap to make it possible to change the permission bits of a path even if you do not currently have the required access bits to access the path.

func Chtimes

func Chtimes(path string, atime, mtime time.Time) error

Chtimes is a wrapper around os.Chtimes which has been wrapped with unpriv.Wrap to make it possible to change the modified times of a path even if you do not currently have the required access bits to access the path.

func Create

func Create(path string) (*os.File, error)

Create is a wrapper around os.Create which has been wrapped with unpriv.Wrap to make it possible to create paths even if you do not currently have read permission. Note that the returned file handle references a path that you do not have read access to (since all changes are reverted when this function returns).

func Lchown

func Lchown(path string, uid, gid int) error

Lchown is a wrapper around os.Lchown which has been wrapped with unpriv.Wrap to make it possible to change the owner of a path even if you do not currently have the required access bits to access the path. Note that this function is not particularly useful in most rootless scenarios.

FIXME: This probably should be removed because it's questionably useful.

func Lclearxattrs

func Lclearxattrs(path string, except map[string]struct{}) error

Lclearxattrs is similar to system.Lclearxattrs but in order to implement it properly all of the internal functions were wrapped with unpriv.Wrap to make it possible to create a path even if you do not currently have enough access bits.

func Lgetxattr

func Lgetxattr(path, name string) ([]byte, error)

Lgetxattr is a wrapper around system.Lgetxattr which has been wrapped with unpriv.Wrap to make it possible to get a path even if you do not currently have the required access bits to resolve the path.

func Link(linkname, path string) error

Link is a wrapper around os.Link which has been wrapped with unpriv.Wrap to make it possible to create a hard link even if you do not currently have the required access bits to create the hard link. Note that you may not have resolve access after this function returns because all of the trickery is reverted by unpriv.Wrap.

func Llistxattr

func Llistxattr(path string) ([]string, error)

Llistxattr is a wrapper around system.Llistxattr which has been wrapped with unpriv.Wrap to make it possible to remove a path even if you do not currently have the required access bits to resolve the path.

func Lremovexattr

func Lremovexattr(path, name string) error

Lremovexattr is a wrapper around system.Lremovexattr which has been wrapped with unpriv.Wrap to make it possible to remove a path even if you do not currently have the required access bits to resolve the path.

func Lsetxattr

func Lsetxattr(path, name string, value []byte, flags int) error

Lsetxattr is a wrapper around system.Lsetxattr which has been wrapped with unpriv.Wrap to make it possible to set a path even if you do not currently have the required access bits to resolve the path.

func Lstat

func Lstat(path string) (os.FileInfo, error)

Lstat is a wrapper around os.Lstat which has been wrapped with unpriv.Wrap to make it possible to get os.FileInfo about a path even if you do not currently have the required mode bits set to resolve the path. Note that you may not have resolve access after this function returns because all of the trickery is reverted by unpriv.Wrap.

func Lstatx added in v0.3.0

func Lstatx(path string) (unix.Stat_t, error)

Lstatx is like Lstat but uses unix.Lstat and returns unix.Stat_t instead

func Lutimes

func Lutimes(path string, atime, mtime time.Time) error

Lutimes is a wrapper around system.Lutimes which has been wrapped with unpriv.Wrap to make it possible to change the modified times of a path even if you do no currently have the required access bits to access the path.

func Mkdir

func Mkdir(path string, perm os.FileMode) error

Mkdir is a wrapper around os.Mkdir which has been wrapped with unpriv.Wrap to make it possible to remove a path even if you do not currently have the required access bits to modify or resolve the path.

func MkdirAll

func MkdirAll(path string, perm os.FileMode) error

MkdirAll is similar to os.MkdirAll but in order to implement it properly all of the internal functions were wrapped with unpriv.Wrap to make it possible to create a path even if you do not currently have enough access bits.

func Mknod

func Mknod(path string, mode os.FileMode, dev uint64) error

Mknod is a wrapper around unix.Mknod which has been wrapped with unpriv.Wrap to make it possible to remove a path even if you do not currently have the required access bits to modify or resolve the path.

func Open

func Open(path string) (*os.File, error)

Open is a wrapper around os.Open which has been wrapped with unpriv.Wrap to make it possible to open paths even if you do not currently have read permission. Note that the returned file handle references a path that you do not have read access to (since all changes are reverted when this function returns), so attempts to do Readdir() or similar functions that require doing lstat(2) may fail.

func Readdir

func Readdir(path string) ([]os.FileInfo, error)

Readdir is a wrapper around (*os.File).Readdir which has been wrapper with unpriv.Wrap to make it possible to get []os.FileInfo for the set of children of the provided directory path. The interface for this is quite different to (*os.File).Readdir because we have to have a proper filesystem path in order to get the set of child FileInfos (because all of the child paths need to be resolveable).

func Readlink(path string) (string, error)

Readlink is a wrapper around os.Readlink which has been wrapped with unpriv.Wrap to make it possible to get the linkname of a symlink even if you do not currently have teh required mode bits set to resolve the path. Note that you may not have resolve access after this function returns because all of this trickery is reverted by unpriv.Wrap.

func Remove

func Remove(path string) error

Remove is a wrapper around os.Remove which has been wrapped with unpriv.Wrap to make it possible to remove a path even if you do not currently have the required access bits to modify or resolve the path.

func RemoveAll

func RemoveAll(path string) error

RemoveAll is similar to os.RemoveAll but with all of the internal functions wrapped with unpriv.Wrap to make it possible to remove a path (even if it has child paths) even if you do not currently have enough access bits.

func Symlink(linkname, path string) error

Symlink is a wrapper around os.Symlink which has been wrapped with unpriv.Wrap to make it possible to create a symlink even if you do not currently have the required access bits to create the symlink. Note that you may not have resolve access after this function returns because all of the trickery is reverted by unpriv.Wrap.

func Walk added in v0.4.0

func Walk(root string, walkFn filepath.WalkFunc) error

Walk is a reimplementation of filepath.Walk, wrapping all of the relevant function calls with Wrap, allowing you to walk over a tree even in the face of multiple nested cases where paths are not normally accessible. The os.FileInfo passed to walkFn is the "pristine" version (as opposed to the currently-on-disk version that may have been temporarily modified by Wrap).

func Wrap

func Wrap(path string, fn WrapFunc) error

Wrap will wrap a given function, and call it in a context where all of the parent directories in the given path argument are such that the path can be resolved (you may need to make your own changes to the path to make it readable). Note that the provided function may be called several times, and if the error returned is such that !os.IsPermission(err), then no trickery will be performed. If fn returns an error, so will this function. All of the trickery is reverted when this function returns (which is when fn returns).

Types

type WrapFunc added in v0.4.0

type WrapFunc func(path string) error

WrapFunc is a function that can be passed to Wrap. It takes a path (and presumably operates on it -- since Wrap only ensures that the path given is resolvable) and returns some form of error.

Jump to

Keyboard shortcuts

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