Quote systemd DefaultEnvironment Proxy values, as documented in systemd.conf man page:

Example:
DefaultEnvironment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"
Sets three variables "VAR1", "VAR2", "VAR3".

Double quote is not escaped, as there is no chance it appears in a proxy value. User can still espace it if really necessary

Signed-off-by: Philippe Martin <phmartin@redhat.com>
This commit is contained in:
Philippe Martin
2024-08-20 09:51:06 +02:00
parent 8bb61c7f33
commit 3e58e04d3e
3 changed files with 83 additions and 5 deletions

View File

@@ -76,10 +76,12 @@ var _ = Describe("podman machine proxy settings propagation", func() {
Expect(stopSession).To(Exit(0))
// Now update proxy env, lets use some special vars to make sure our scripts can handle it
proxy1 := "http:// some special @;\" here"
proxy2 := "https://abc :£$%6 : |\"\""
proxy1 := "http://foo:b%%40r@example.com:8080"
proxy2 := "https://foo:bar%%3F@example.com:8080"
noproxy := "noproxy1.example.com,noproxy2.example.com"
os.Setenv("HTTP_PROXY", proxy1)
os.Setenv("HTTPS_PROXY", proxy2)
os.Setenv("NO_PROXY", noproxy)
// changing SSL_CERT vars should not have an effect
os.Setenv("SSL_CERT_FILE", "/tmp/1")
@@ -90,10 +92,10 @@ var _ = Describe("podman machine proxy settings propagation", func() {
Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0))
sshSession, err = mb.setName(name).setCmd(sshProxy.withSSHCommand([]string{"printenv", "HTTP_PROXY", "HTTPS_PROXY"})).run()
sshSession, err = mb.setName(name).setCmd(sshProxy.withSSHCommand([]string{"printenv", "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))
Expect(string(sshSession.Out.Contents())).To(Equal(proxy1 + "\n" + proxy2 + "\n"))
Expect(string(sshSession.Out.Contents())).To(Equal(proxy1 + "\n" + proxy2 + "\n" + noproxy + "\n"))
// SSL_CERT not implemented for WSL
if !isVmtype(define.WSLVirt) {