summary refs log tree commit diff stats
path: root/paths.go
blob: 2a3986e82f2fba98b55ce7b0502e753a029a2d71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Package lynx is a simple wrapper to unveil.
package lynx

import "golang.org/x/sys/unix"

// UnveilPaths takes a map of path, permission & unveils them one by
// one, it will return an error if unveil fails at any step. "no such
// file or directory" error is ignored.
func UnveilPaths(paths map[string]string) error {
	for k, v := range paths {
		err := unix.Unveil(k, v)

		// "no such file or directory" error is ignored.
		if err != nil && err.Error() != "no such file or directory" {
			// Better error message could be returned like
			// one that includes the path on which unveil
			// failed.
			return err
		}
	}
	// Returning nil because err can be "no such file or
	// directory" which needs to be ignored.
	return nil
}

// UnveilPathsStrict takes a map of path, permission & unveils them
// one by one, it will return an error if unveil fails at any steop.
// No error is ignored.
func UnveilPathsStrict(paths map[string]string) (err error) {
	for k, v := range paths {
		err = unix.Unveil(k, v)

		if err != nil {
			return
		}
	}
	return
}
pan>} result <- new character:type, capacity rewind-ingredients i:number <- copy 0 { # while read curr-value done?:boolean <- greater-or-equal i, capacity break-if done? curr-value:character, exists?:boolean <- next-ingredient assert exists?, [error in rewinding ingredients to new-array] *result <- put-index *result, i, curr-value i <- add i, 1 loop } return result ]