summaryrefslogtreecommitdiff
path: root/pkg/env/env_windows.go
diff options
context:
space:
mode:
authorJason T. Greene <jason.greene@redhat.com>2022-01-19 11:28:09 -0600
committerJason T. Greene <jason.greene@redhat.com>2022-01-19 12:05:04 -0600
commit4693fc6db14e00db7f1af0b02fad15da35fb3799 (patch)
tree459b8300737e31c7bc991bed0a360a23c73cb6a4 /pkg/env/env_windows.go
parent1c81b67341300853d7fe9b6568b247e579c34969 (diff)
downloadpodman-4693fc6db14e00db7f1af0b02fad15da35fb3799.tar.gz
podman-4693fc6db14e00db7f1af0b02fad15da35fb3799.tar.bz2
podman-4693fc6db14e00db7f1af0b02fad15da35fb3799.zip
Implement env parsing on Windows
Fixes #12056 Also, enables existing parsing logic for all Unix derived OSs Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
Diffstat (limited to 'pkg/env/env_windows.go')
-rw-r--r--pkg/env/env_windows.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/env/env_windows.go b/pkg/env/env_windows.go
new file mode 100644
index 000000000..5df08fadc
--- /dev/null
+++ b/pkg/env/env_windows.go
@@ -0,0 +1,25 @@
+package env
+
+// ParseSlice parses the specified slice and transforms it into an environment
+// map.
+func ParseSlice(s []string) (map[string]string, error) {
+ env := make(map[string]string, len(s))
+ for _, e := range s {
+ if len(e) > 0 && e[0] == '=' {
+ // The legacy Windows CMD command interpreter uses a hack, where to emulate
+ // DOS semantics, it uses an illegal (by windows definition) env name for
+ // state storage to avoid conlficting with user defined env names. This is
+ // used to preserve drive letter paths. E.g., typing c: from another drive
+ // will remember the last CWD because CMD stores it in an env named "=C:".
+ // Since these are illegal, they are filtered from standard user access but
+ // are still available in the underlying win32 API calls. Since they have
+ // zero value to a container, we filter as well.
+ continue
+ }
+
+ if err := parseEnv(env, e); err != nil {
+ return nil, err
+ }
+ }
+ return env, nil
+}