From e3a1669c8168320318291325f70ca35e2ab2eec3 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Mon, 9 Nov 2020 14:21:21 +0300 Subject: New tests, remove errors.go --- util/isolate.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'util') 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{ -- cgit v1.2.3