summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-09 14:21:21 +0300
committerValery Piashchynski <[email protected]>2020-11-09 14:21:21 +0300
commite3a1669c8168320318291325f70ca35e2ab2eec3 (patch)
treef14875ecb4a86805226812108efcab72898b6125 /util
parent9fbe7726dd55cfedda724b7644e1b6bf7c1a6cb4 (diff)
New tests, remove errors.go
Diffstat (limited to 'util')
-rwxr-xr-xutil/isolate.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/util/isolate.go b/util/isolate.go
index 005c430e..2bdb9d6c 100755
--- a/util/isolate.go
+++ b/util/isolate.go
@@ -9,6 +9,8 @@ import (
"os/user"
"strconv"
"syscall"
+
+ "github.com/spiral/errors"
)
// IsolateProcess change gpid for the process to avoid bypassing signals to php processes.
@@ -18,19 +20,20 @@ func IsolateProcess(cmd *exec.Cmd) {
// ExecuteFromUser may work only if run RR under root user
func ExecuteFromUser(cmd *exec.Cmd, u string) error {
+ const op = errors.Op("execute from user")
usr, err := user.Lookup(u)
if err != nil {
- return err
+ return errors.E(op, err)
}
usrI32, err := strconv.Atoi(usr.Uid)
if err != nil {
- return err
+ return errors.E(op, err)
}
grI32, err := strconv.Atoi(usr.Gid)
if err != nil {
- return err
+ return errors.E(op, err)
}
// For more information:
@@ -44,7 +47,7 @@ func ExecuteFromUser(cmd *exec.Cmd, u string) error {
return fmt.Errorf("unable to test user namespaces due to permissions")
}
- return fmt.Errorf("failed to stat /proc/self/ns/user: %v", err)
+ return errors.E(op, errors.Errorf("failed to stat /proc/self/ns/user: %v", err))
}
cmd.SysProcAttr.Credential = &syscall.Credential{