feat: publish verifiable proxyctl v1
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
//go:build proxyctl_process_test
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/user"
|
||||
"strconv"
|
||||
|
||||
"proxyctl/internal/profile"
|
||||
"proxyctl/internal/target"
|
||||
)
|
||||
|
||||
// This file is compiled only into the process-smoke binary. It gives that real
|
||||
// executable an identity whose home is inside the test sandbox and omits
|
||||
// production system Targets, so no command can reach developer or host state.
|
||||
func init() {
|
||||
processProductionTargets = func(profile.IdentityEnvironment) ([]target.Target, error) {
|
||||
return []target.Target{}, nil
|
||||
}
|
||||
processCurrentUser = func() (profile.UserIdentity, error) {
|
||||
home := os.Getenv("PROXYCTL_PROCESS_TEST_HOME")
|
||||
if home == "" {
|
||||
return profile.UserIdentity{}, errors.New("PROXYCTL_PROCESS_TEST_HOME is required by proxyctl_process_test builds")
|
||||
}
|
||||
current, err := user.Current()
|
||||
if err != nil {
|
||||
return profile.UserIdentity{}, err
|
||||
}
|
||||
uid, err := strconv.Atoi(current.Uid)
|
||||
if err != nil {
|
||||
return profile.UserIdentity{}, err
|
||||
}
|
||||
gid, err := strconv.Atoi(current.Gid)
|
||||
if err != nil {
|
||||
return profile.UserIdentity{}, err
|
||||
}
|
||||
return profile.UserIdentity{Username: current.Username, HomeDir: home, UID: uid, GID: gid}, nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user