Rename func UnveilPath to Unveil
UnveilPath is confusing, it's kept only for backwards compatibility & users should use Unveil & UnveilStrict instead of UnveilPath & UnveilPathStrict.
This commit is contained in:
parent
f479b82ff8
commit
6e5a88bc77
52
README.org
52
README.org
|
@ -13,6 +13,32 @@ currently only /OpenBSD/ is supported.
|
||||||
| GitHub (Mirror) | [[https://github.com/andinus/lynx][Lynx - GitHub]] |
|
| GitHub (Mirror) | [[https://github.com/andinus/lynx][Lynx - GitHub]] |
|
||||||
|
|
||||||
* Examples
|
* Examples
|
||||||
|
** Unveil / UnveilStrict
|
||||||
|
Unveil takes a path, permission & unveils it, it will return an error if unveil
|
||||||
|
fails at any step. "no such file or directory" error is ignored, if you want to
|
||||||
|
get that error too then use UnveilStrict.
|
||||||
|
|
||||||
|
#+BEGIN_SRC go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "tildegit.org/andinus/lynx"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
path := "/dev/null"
|
||||||
|
flags := "rw"
|
||||||
|
|
||||||
|
err = lynx.Unveil(path, flags)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will return an error if the path doesn't exist.
|
||||||
|
err = lynx.UnveilStrict(path, flags)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#+END_SRC
|
||||||
** UnveilCommands
|
** UnveilCommands
|
||||||
UnveilCommands takes a slice of commands & unveils them one by one, it will
|
UnveilCommands takes a slice of commands & unveils them one by one, it will
|
||||||
return an error if unveil fails at any step. "no such file or directory" error
|
return an error if unveil fails at any step. "no such file or directory" error
|
||||||
|
@ -64,32 +90,6 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** UnveilPath / UnveilPathStrict
|
|
||||||
UnveilPath takes a path, permission & unveils it, it will return an error if
|
|
||||||
unveil fails at any step. "no such file or directory" error is ignored, if you
|
|
||||||
want to get that error too then use UnveilPathStrict.
|
|
||||||
|
|
||||||
#+BEGIN_SRC go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "tildegit.org/andinus/lynx"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
path := "/dev/null"
|
|
||||||
flags := "rw"
|
|
||||||
|
|
||||||
err = lynx.UnveilPath(path, flags)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// This will return an error if the path doesn't exist.
|
|
||||||
err = lynx.UnveilPathStrict(path, flags)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#+END_SRC
|
|
||||||
** UnveilBlock
|
** UnveilBlock
|
||||||
UnveilBlock is just a wrapper around unix.UnveilBlock, it does nothing extra.
|
UnveilBlock is just a wrapper around unix.UnveilBlock, it does nothing extra.
|
||||||
You should use unix.UnveilBlock.
|
You should use unix.UnveilBlock.
|
||||||
|
|
|
@ -4,10 +4,10 @@ package lynx
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
// UnveilPath takes a path, permission & unveils it, returning an
|
// Unveil takes a path, permission & unveils it, returning an
|
||||||
// error if unveil fails. "no such file or directory" error is
|
// error if unveil fails. "no such file or directory" error is
|
||||||
// ignored.
|
// ignored.
|
||||||
func UnveilPath(path string, flags string) (err error) {
|
func Unveil(path string, flags string) (err error) {
|
||||||
err = unix.Unveil(path, flags)
|
err = unix.Unveil(path, flags)
|
||||||
|
|
||||||
// "no such file or directory" error is ignored.
|
// "no such file or directory" error is ignored.
|
||||||
|
@ -22,7 +22,18 @@ func UnveilPath(path string, flags string) (err error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnveilPathStrict is just a wrapper around unix.Unveil.
|
// UnveilPath is kept for backwards compatibility, use Unveil instead.
|
||||||
func UnveilPathStrict(path string, flags string) error {
|
func UnveilPath(path string, flags string) (err error) {
|
||||||
|
return Unveil(path, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnveilStrict is just a wrapper around unix.Unveil.
|
||||||
|
func UnveilStrict(path string, flags string) error {
|
||||||
return unix.Unveil(path, flags)
|
return unix.Unveil(path, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnveilPathStrict is kept for backwards compatibility, use
|
||||||
|
// UnveilStrict instead.
|
||||||
|
func UnveilPathStrict(path string, flags string) error {
|
||||||
|
return UnveilStrict(path, flags)
|
||||||
|
}
|
Loading…
Reference in New Issue