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

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) ===
It seems that I didn't properly check the `LXD_SOCKET` implementation in #4426 . Because in the meantime I found a missing piece: `lxd callhook` also needs to support the environmental variable (see ganto/copr-lxc3#4).

> First check the LXD_SOCKET environment variable which might
> contain a user provided Unix socket before trying to connect
> to default LXD socket.
From 3186b980f36eafdc8d3054429ca2dd76a5f2c595 Mon Sep 17 00:00:00 2001
From: Reto Gantenbein <[email protected]>
Date: Thu, 10 May 2018 07:23:43 +0200
Subject: [PATCH] lxd/callhook: Respect LXD_SOCKET environment variable

First check the LXD_SOCKET environment variable which might
contain a user provided Unix socket before trying to connect
to default LXD socket.

Signed-off-by: Reto Gantenbein <[email protected]>
---
 lxd/main_callhook.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/main_callhook.go b/lxd/main_callhook.go
index 7d463808a..cf64860f4 100644
--- a/lxd/main_callhook.go
+++ b/lxd/main_callhook.go
@@ -3,6 +3,7 @@ package main
 import (
        "fmt"
        "os"
+       "path/filepath"
        "time"
 
        "github.com/spf13/cobra"
@@ -54,7 +55,11 @@ func (c *cmdCallhook) Run(cmd *cobra.Command, args []string) 
error {
        }
 
        // Connect to LXD
-       d, err := lxd.ConnectLXDUnix(fmt.Sprintf("%s/unix.socket", path), nil)
+       socket := os.Getenv("LXD_SOCKET")
+       if socket == "" {
+               socket = filepath.Join(path, "unix.socket")
+       }
+       d, err := lxd.ConnectLXDUnix(socket, nil)
        if err != nil {
                return err
        }
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to