This commit is contained in:
+2
-18
@@ -14,6 +14,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"proxyctl/internal/pathutil"
|
||||
"proxyctl/internal/profile"
|
||||
"proxyctl/internal/securefs"
|
||||
"proxyctl/internal/target"
|
||||
@@ -84,24 +85,7 @@ func ResolveConfiguration(environment profile.IdentityEnvironment) (Configuratio
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ResolveConfigurationForCurrentProcess() (Configuration, error) {
|
||||
return ResolveConfiguration(systemEnvironment{})
|
||||
}
|
||||
|
||||
type systemEnvironment struct{}
|
||||
|
||||
func (systemEnvironment) CurrentUser() (profile.UserIdentity, error) {
|
||||
return profile.SystemCurrentUser()
|
||||
}
|
||||
func (systemEnvironment) LookupUser(name string) (profile.UserIdentity, error) {
|
||||
return profile.SystemLookupUser(name)
|
||||
}
|
||||
func (systemEnvironment) LookupEnv(name string) (string, bool) { return os.LookupEnv(name) }
|
||||
|
||||
func pathWithin(path, parent string) bool {
|
||||
relative, err := filepath.Rel(parent, path)
|
||||
return err == nil && relative != ".." && !strings.HasPrefix(relative, ".."+string(filepath.Separator))
|
||||
}
|
||||
func pathWithin(path, parent string) bool { return pathutil.Within(path, parent) }
|
||||
|
||||
type Environment interface{ LookupEnv(string) (string, bool) }
|
||||
type MapEnvironment map[string]string
|
||||
|
||||
Reference in New Issue
Block a user