48 lines
792 B
Go
48 lines
792 B
Go
//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
|
|
}
|