The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3956

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <[email protected]>
From 7e9d4966cbecdcc7fc9a5f7136f95f946c39b380 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]>
Date: Wed, 18 Oct 2017 17:51:28 -0400
Subject: [PATCH] client: Fix crash when missing cookiejar
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <[email protected]>
---
 client/connection.go | 2 ++
 client/lxd.go        | 1 +
 lxc/config/config.go | 2 ++
 lxc/config/remote.go | 5 ++++-
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/client/connection.go b/client/connection.go
index 825c8a415..0a606452d 100644
--- a/client/connection.go
+++ b/client/connection.go
@@ -173,9 +173,11 @@ func httpsLXD(url string, args *ConnectionArgs) 
(ContainerServer, error) {
        if err != nil {
                return nil, err
        }
+
        if args.CookieJar != nil {
                httpClient.Jar = args.CookieJar
        }
+
        server.http = httpClient
        if args.AuthType == "macaroons" {
                server.setupBakeryClient()
diff --git a/client/lxd.go b/client/lxd.go
index d85c43e5f..6aef4cf17 100644
--- a/client/lxd.go
+++ b/client/lxd.go
@@ -76,6 +76,7 @@ func (r *ProtocolLXD) do(req *http.Request) (*http.Response, 
error) {
                r.addMacaroonHeaders(req)
                return r.bakeryClient.Do(req)
        }
+
        return r.http.Do(req)
 }
 
diff --git a/lxc/config/config.go b/lxc/config/config.go
index 3a175f1eb..486b39afd 100644
--- a/lxc/config/config.go
+++ b/lxc/config/config.go
@@ -64,10 +64,12 @@ func NewConfig(configDir string, defaults bool) *Config {
                config.Remotes = DefaultRemotes
                config.DefaultRemote = "local"
        }
+
        if configDir != "" {
                config.cookiejar, _ = cookiejar.New(
                        &cookiejar.Options{
                                Filename: filepath.Join(configDir, "cookies")})
        }
+
        return config
 }
diff --git a/lxc/config/remote.go b/lxc/config/remote.go
index 1aa54ed82..bc1acf63e 100644
--- a/lxc/config/remote.go
+++ b/lxc/config/remote.go
@@ -137,11 +137,14 @@ func (c *Config) getConnectionArgs(name string) 
(*lxd.ConnectionArgs, error) {
        remote, _ := c.Remotes[name]
        args := lxd.ConnectionArgs{
                UserAgent:      c.UserAgent,
-               CookieJar:      c.cookiejar,
                AuthType:       remote.AuthType,
                AuthInteractor: c.authInteractor,
        }
 
+       if c.cookiejar != nil {
+               args.CookieJar = c.cookiejar
+       }
+
        // Client certificate
        if shared.PathExists(c.ConfigPath("client.crt")) {
                content, err := ioutil.ReadFile(c.ConfigPath("client.crt"))
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to