commit this WIP stuff to a feature branch
This commit is contained in:
47
envs/funcs_staticenv_nix.go
Normal file
47
envs/funcs_staticenv_nix.go
Normal file
@@ -0,0 +1,47 @@
|
||||
//go:build !(windows || plan9 || wasip1 || js || ios)
|
||||
|
||||
package envs
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func (s *StaticEnv) platChecks() (err error) {
|
||||
|
||||
if s.proc != nil && !s.self {
|
||||
// Check for ptrace caps/perms
|
||||
if err = unix.PtraceAttach(int(s.proc.Pid)); err != nil {
|
||||
return
|
||||
}
|
||||
if err = unix.PtraceDetach(int(s.proc.Pid)); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *StaticEnv) setProcVal(key, value string) (err error) {
|
||||
|
||||
if s.self {
|
||||
if err = unix.Setenv(key, value); err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err = unix.PtraceAttach(int(s.proc.Pid)); err != nil {
|
||||
return
|
||||
}
|
||||
if err = unix.PtraceDetach(int(s.proc.Pid)); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *StaticEnv) unsetProcVal(key string) (err error) {
|
||||
|
||||
err = unix.Unsetenv(key)
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user