[lxc-devel] [lxd/master] Fix config dir on Windows
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Jul 21 12:59:12 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 914 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170721/c029f247/attachment.bin>
-------------- next part --------------
From 0d927771bee6d2fc7cd7ce077a927969af97724e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 21 Jul 2017 14:40:45 +0200
Subject: [PATCH 1/2] lxc: Cross-platform HOME handling
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #3573
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc/main.go | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lxc/main.go b/lxc/main.go
index 3d0c245d9..d5b940fca 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
+ "os/user"
"path"
"path/filepath"
"strings"
@@ -48,9 +49,16 @@ func run() error {
forceLocal := gnuflag.Bool("force-local", false, i18n.G("Force using the local unix socket"))
noAlias := gnuflag.Bool("no-alias", false, i18n.G("Ignore aliases when determining what command to run"))
- configDir := "$HOME/.config/lxc"
+ var configDir string
if os.Getenv("LXD_CONF") != "" {
configDir = os.Getenv("LXD_CONF")
+ } else {
+ user, err := user.Current()
+ if err != nil {
+ return err
+ }
+
+ configDir = path.Join(user.HomeDir, ".config", "lxc")
}
configPath = os.ExpandEnv(path.Join(configDir, "config.yml"))
From d2af30d1e8d935e723983df50a16e7c7abff8821 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 21 Jul 2017 14:55:04 +0200
Subject: [PATCH 2/2] lxc: Create missing config paths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc/remote.go | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lxc/remote.go b/lxc/remote.go
index 8d1c8269d..594d24566 100644
--- a/lxc/remote.go
+++ b/lxc/remote.go
@@ -71,6 +71,14 @@ func (c *remoteCmd) flags() {
}
func (c *remoteCmd) generateClientCertificate(conf *config.Config) error {
+ // Create the config path if needed
+ if !shared.PathExists(conf.ConfigDir) {
+ err := os.MkdirAll(conf.ConfigDir, 0750)
+ if err != nil {
+ return fmt.Errorf(i18n.G("Could not create config dir"))
+ }
+ }
+
// Generate a client certificate if necessary. The default repositories are
// either local or public, neither of which requires a client certificate.
// Generation of the cert is delayed to avoid unnecessary overhead, e.g in
More information about the lxc-devel
mailing list