[lxc-devel] [lxd/master] Bugfixes

stgraber on Github lxc-bot at linuxcontainers.org
Tue Jan 2 21:05:52 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 393 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180102/09de5508/attachment.bin>
-------------- next part --------------
From a1a0475defb8b051ccbcd3eb3967f1a28f61136b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:18:58 +0100
Subject: [PATCH 1/7] storage/btrfs: Fix handling of UUID-based mounts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4121

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_btrfs.go | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index 20a2dd45b..1218ee271 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -108,7 +108,12 @@ func (s *storageBtrfs) StoragePoolCreate() error {
 	s.pool.Config["volatile.initial_source"] = s.pool.Config["source"]
 
 	isBlockDev := false
-	source := shared.HostPath(s.pool.Config["source"])
+
+	source := s.pool.Config["source"]
+	if strings.HasPrefix(source, "/") {
+		source = shared.HostPath(s.pool.Config["source"])
+	}
+
 	if source == "" {
 		source = filepath.Join(shared.VarPath("disks"), fmt.Sprintf("%s.img", s.pool.Name))
 		s.pool.Config["source"] = source
@@ -259,7 +264,11 @@ func (s *storageBtrfs) StoragePoolCreate() error {
 func (s *storageBtrfs) StoragePoolDelete() error {
 	logger.Infof("Deleting BTRFS storage pool \"%s\".", s.pool.Name)
 
-	source := shared.HostPath(s.pool.Config["source"])
+	source := s.pool.Config["source"]
+	if strings.HasPrefix(source, "/") {
+		source = shared.HostPath(s.pool.Config["source"])
+	}
+
 	if source == "" {
 		return fmt.Errorf("no \"source\" property found for the storage pool")
 	}
@@ -324,7 +333,11 @@ func (s *storageBtrfs) StoragePoolDelete() error {
 func (s *storageBtrfs) StoragePoolMount() (bool, error) {
 	logger.Debugf("Mounting BTRFS storage pool \"%s\".", s.pool.Name)
 
-	source := shared.HostPath(s.pool.Config["source"])
+	source := s.pool.Config["source"]
+	if strings.HasPrefix(source, "/") {
+		source = shared.HostPath(s.pool.Config["source"])
+	}
+
 	if source == "" {
 		return false, fmt.Errorf("no \"source\" property found for the storage pool")
 	}

From 444808c3e492ca0d3e0e88a165119ca739058590 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:26:27 +0100
Subject: [PATCH 2/7] doc: Add /images/<fingerprint>/secret to API list
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>
---
 doc/rest-api.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/rest-api.md b/doc/rest-api.md
index b9249da59..0d77f3b47 100644
--- a/doc/rest-api.md
+++ b/doc/rest-api.md
@@ -200,6 +200,7 @@ won't work and PUT needs to be used instead.
        * `/1.0/images/<fingerprint>`
          * `/1.0/images/<fingerprint>/export`
          * `/1.0/images/<fingerprint>/refresh`
+         * `/1.0/images/<fingerprint>/secret`
        * `/1.0/images/aliases`
          * `/1.0/images/aliases/<name>`
      * `/1.0/networks`

From c7a011e6723689bdd82e20f8cdd0312cffcc9125 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:26:50 +0100
Subject: [PATCH 3/7] doc: List /1.0/storage-pools API endpoints
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>
---
 doc/rest-api.md | 56 +++++---------------------------------------------------
 1 file changed, 5 insertions(+), 51 deletions(-)

diff --git a/doc/rest-api.md b/doc/rest-api.md
index 0d77f3b47..1c082c12f 100644
--- a/doc/rest-api.md
+++ b/doc/rest-api.md
@@ -211,6 +211,11 @@ won't work and PUT needs to be used instead.
          * `/1.0/operations/<uuid>/websocket`
      * `/1.0/profiles`
        * `/1.0/profiles/<name>`
+     * `/1.0/storage-pools`
+       * `/1.0/storage-pools/<name>`
+         * `/1.0/storage-pools/<name>/resources`
+         * `/1.0/storage-pools/<name>/volumes`
+           * `/1.0/storage-pools/<name>/volumes/<volume type>/<volume>`
      * `/1.0/resources`
 
 # API details
@@ -2264,57 +2269,6 @@ Input (none at present):
         "/1.0/storage-pools/default/volumes/images/62e850a334bb9d99cac00b2e618e0291e5e7bb7db56c4246ecaf8e46fa0631a6"
     ]
 
-## `/1.0/storage-pools/<pool>/volumes`
-### GET
- * Description: list all storage volumes on a storage pool
- * Introduced: with API extension `storage`
- * Authentication: trusted
- * Operation: sync
- * Return: standard return value or standard error
-
-    {
-        "type": "sync",
-        "status": "Success",
-        "status_code": 200,
-        "error_code": 0,
-        "error": "",
-        "metadata": [
-            {
-                "type": "container",
-                "used_by": [],
-                "name": "alp1",
-                "config": {
-                "size": "0"
-                }
-            },
-            {
-                "type": "container",
-                "used_by": [],
-                "name": "alp1/snap0",
-                "config": {
-                    "size": "0"
-                }
-            },
-            {
-                "type": "image",
-                "used_by": [],
-                "name": "ade3a9bcd7ba27456673611304238c424ced1772f69d7c6b031356831d94e8ee",
-                "config": {
-                    "size": "0"
-                }
-            },
-            {
-                "type": "custom",
-                "used_by": [],
-                "name": "bla",
-                "config": {
-                    "size": "0"
-                }
-            }
-        ]
-    }
-
-
 ### POST
  * Description: create a new storage volume on a given storage pool
  * Introduced: with API extension `storage`

From 51ea2cefdf5cd98fb54c3c60c9a030fe3be5e9e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:33:37 +0100
Subject: [PATCH 4/7] lxd/containers: No slahses in snapshot names
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/snapshot.go           |  8 --------
 lxd/container_snapshot.go | 11 +++++++++++
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lxc/snapshot.go b/lxc/snapshot.go
index dd3f0a88f..bcd59b8bb 100644
--- a/lxc/snapshot.go
+++ b/lxc/snapshot.go
@@ -1,10 +1,7 @@
 package main
 
 import (
-	"fmt"
-
 	"github.com/lxc/lxd/lxc/config"
-	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/gnuflag"
 	"github.com/lxc/lxd/shared/i18n"
@@ -48,11 +45,6 @@ func (c *snapshotCmd) run(conf *config.Config, args []string) error {
 		snapname = args[1]
 	}
 
-	// we don't allow '/' in snapshot names
-	if shared.IsSnapshot(snapname) {
-		return fmt.Errorf(i18n.G("'/' not allowed in snapshot name"))
-	}
-
 	remote, name, err := conf.ParseRemote(args[0])
 	if err != nil {
 		return err
diff --git a/lxd/container_snapshot.go b/lxd/container_snapshot.go
index fec770b5c..07ea52681 100644
--- a/lxd/container_snapshot.go
+++ b/lxd/container_snapshot.go
@@ -7,6 +7,7 @@ import (
 	"io/ioutil"
 	"net/http"
 	"strconv"
+	"strings"
 
 	"github.com/gorilla/mux"
 
@@ -92,6 +93,11 @@ func containerSnapshotsPost(d *Daemon, r *http.Request) Response {
 		req.Name = fmt.Sprintf("snap%d", i)
 	}
 
+	// Validate the name
+	if strings.Contains(req.Name, "/") {
+		return BadRequest(fmt.Errorf("Snapshot names may not contain slashes"))
+	}
+
 	fullName := name +
 		shared.SnapshotDelimiter +
 		req.Name
@@ -244,6 +250,11 @@ func snapshotPost(d *Daemon, r *http.Request, sc container, containerName string
 		return BadRequest(err)
 	}
 
+	// Validate the name
+	if strings.Contains(newName, "/") {
+		return BadRequest(fmt.Errorf("Snapshot names may not contain slashes"))
+	}
+
 	fullName := containerName + shared.SnapshotDelimiter + newName
 
 	// Check that the name isn't already in use

From f78e6936d9b78313cbded7da42f3e3a6da84fd88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:34:10 +0100
Subject: [PATCH 5/7] i18n: Update translation template
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>
---
 po/de.po      | 15 +++++++--------
 po/el.po      | 10 +++-------
 po/fi.po      | 10 +++-------
 po/fr.po      | 13 ++++++-------
 po/id.po      | 10 +++-------
 po/it.po      | 13 ++++++-------
 po/ja.po      | 13 ++++++-------
 po/lxd.pot    |  6 +-----
 po/nb_NO.po   | 10 +++-------
 po/nl.po      | 10 +++-------
 po/pt_BR.po   | 10 +++-------
 po/ru.po      | 13 ++++++-------
 po/sr.po      | 10 +++-------
 po/sv.po      | 10 +++-------
 po/tr.po      | 10 +++-------
 po/zh.po      | 10 +++-------
 po/zh_Hans.po | 10 +++-------
 17 files changed, 65 insertions(+), 118 deletions(-)

diff --git a/po/de.po b/po/de.po
index 6e6a0b1f5..6b4f84fc2 100644
--- a/po/de.po
+++ b/po/de.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: LXD\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: 2017-02-14 17:11+0000\n"
 "Last-Translator: Tim Rose <tim at netlope.de>\n"
 "Language-Team: German <https://hosted.weblate.org/projects/linux-containers/"
@@ -270,11 +270,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-#, fuzzy
-msgid "'/' not allowed in snapshot name"
-msgstr "'/' ist kein gültiges Zeichen im Namen eines Sicherungspunktes\n"
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2334,7 +2329,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2477,7 +2472,7 @@ msgstr ""
 "Laufenden Zustand des Containers aus dem Sicherungspunkt (falls vorhanden) "
 "wiederherstellen oder nicht"
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr "Zustand des laufenden Containers sichern oder nicht"
 
@@ -2596,6 +2591,10 @@ msgstr "falsche Anzahl an Parametern für Unterbefehl"
 msgid "yes"
 msgstr ""
 
+#, fuzzy
+#~ msgid "'/' not allowed in snapshot name"
+#~ msgstr "'/' ist kein gültiges Zeichen im Namen eines Sicherungspunktes\n"
+
 #, fuzzy
 #~ msgid "Could not create config dir"
 #~ msgstr "Kann Verzeichnis für Zertifikate auf dem Server nicht erstellen"
diff --git a/po/el.po b/po/el.po
index 1d246d017..02689d3cc 100644
--- a/po/el.po
+++ b/po/el.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: 2017-02-14 08:00+0000\n"
 "Last-Translator: Simos Xenitellis <simos.65 at gmail.com>\n"
 "Language-Team: Greek <https://hosted.weblate.org/projects/linux-containers/"
@@ -166,10 +166,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2024,7 +2020,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2161,7 +2157,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/fi.po b/po/fi.po
index 3f2c391fc..275c4ab60 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/fr.po b/po/fr.po
index c89c5c895..cc5c490cb 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: LXD\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: 2017-10-26 15:46+0000\n"
 "Last-Translator: Alban Vidal <alban.vidal at zordhak.fr>\n"
 "Language-Team: French <https://hosted.weblate.org/projects/linux-containers/"
@@ -261,10 +261,6 @@ msgstr "%v (interrompre encore deux fois pour forcer)"
 msgid "'%s' isn't a supported file type."
 msgstr "'%s' n'est pas un format de fichier pris en charge."
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr "'/' n'est pas autorisé dans le nom d'un instantané"
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr "(aucun)"
@@ -2600,7 +2596,7 @@ msgstr ""
 "Restaurer un instantané :\n"
 "    lxc restore u1 snap0"
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 #, fuzzy
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
@@ -2759,7 +2755,7 @@ msgstr ""
 "Restaurer ou pas l'état de fonctionnement du conteneur depuis l'instantané "
 "(s'il est disponible)"
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr "Réaliser ou pas l'instantané de l'état de fonctionnement du conteneur"
 
@@ -2879,6 +2875,9 @@ msgstr "nombre d'arguments incorrect pour la sous-comande"
 msgid "yes"
 msgstr "oui"
 
+#~ msgid "'/' not allowed in snapshot name"
+#~ msgstr "'/' n'est pas autorisé dans le nom d'un instantané"
+
 #, fuzzy
 #~ msgid "Could not create config dir"
 #~ msgstr "Impossible de créer le dossier de stockage des certificats serveurs"
diff --git a/po/id.po b/po/id.po
index 842cfaf15..ab1a3611e 100644
--- a/po/id.po
+++ b/po/id.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/it.po b/po/it.po
index 981e51d6f..30ea30769 100644
--- a/po/it.po
+++ b/po/it.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: 2017-08-18 14:22+0000\n"
 "Last-Translator: Alberto Donato <alberto.donato at gmail.com>\n"
 "Language-Team: Italian <https://hosted.weblate.org/projects/linux-containers/"
@@ -187,10 +187,6 @@ msgstr "%v (interrompi altre due volte per forzare)"
 msgid "'%s' isn't a supported file type."
 msgstr "'%s' non è un tipo di file supportato."
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr "'/' non è permesso nel nome di uno snapshot"
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr "(nessuno)"
@@ -2043,7 +2039,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2180,7 +2176,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
@@ -2296,5 +2292,8 @@ msgstr "numero errato di argomenti del sottocomando"
 msgid "yes"
 msgstr "si"
 
+#~ msgid "'/' not allowed in snapshot name"
+#~ msgstr "'/' non è permesso nel nome di uno snapshot"
+
 #~ msgid "not all the profiles from the source exist on the target"
 #~ msgstr "non tutti i profili dell'origine esistono nella destinazione"
diff --git a/po/ja.po b/po/ja.po
index aab506af1..ad8b750eb 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: LXD\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: 2017-09-28 20:29+0000\n"
 "Last-Translator: KATOH Yasufumi <karma at jazz.email.ne.jp>\n"
 "Language-Team: Japanese <https://hosted.weblate.org/projects/linux-"
@@ -167,10 +167,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr "'%s' はサポートされないタイプのファイルです。"
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr "'/' はスナップショットの名前には使用できません"
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2634,7 +2630,7 @@ msgstr ""
 "lxc restore u1 snap0\n"
 "    スナップショットからリストアします。"
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2877,7 +2873,7 @@ msgid ""
 msgstr ""
 "スナップショットからコンテナの稼動状態をリストアするかどうか (取得可能な場合)"
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr "コンテナの稼動状態のスナップショットを取得するかどうか"
 
@@ -2996,6 +2992,9 @@ msgstr "サブコマンドの引数の数が正しくありません"
 msgid "yes"
 msgstr ""
 
+#~ msgid "'/' not allowed in snapshot name"
+#~ msgstr "'/' はスナップショットの名前には使用できません"
+
 #, fuzzy
 #~ msgid "Could not create config dir"
 #~ msgstr "サーバ証明書格納用のディレクトリを作成できません"
diff --git a/po/lxd.pot b/po/lxd.pot
index a8c6ee04a..6fddc3348 100644
--- a/po/lxd.pot
+++ b/po/lxd.pot
@@ -7,7 +7,7 @@
 msgid   ""
 msgstr  "Project-Id-Version: lxd\n"
         "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-        "POT-Creation-Date: 2017-12-19 19:32-0500\n"
+        "POT-Creation-Date: 2018-01-02 18:33+0100\n"
         "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
         "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
         "Language-Team: LANGUAGE <LL at li.org>\n"
@@ -156,10 +156,6 @@ msgstr  ""
 msgid   "'%s' isn't a supported file type."
 msgstr  ""
 
-#: lxc/snapshot.go:53
-msgid   "'/' not allowed in snapshot name"
-msgstr  ""
-
 #: lxc/profile.go:337
 msgid   "(none)"
 msgstr  ""
diff --git a/po/nb_NO.po b/po/nb_NO.po
index a65162496..4ab6bba42 100644
--- a/po/nb_NO.po
+++ b/po/nb_NO.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/nl.po b/po/nl.po
index 2f64fdd55..f27e0d281 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 8cbd0cf8f..691d356c1 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/ru.po b/po/ru.po
index 099011d8a..9fac11d42 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: 2017-09-05 16:48+0000\n"
 "Last-Translator: Ilya Yakimavets <ilya.yakimavets at backend.expert>\n"
 "Language-Team: Russian <https://hosted.weblate.org/projects/linux-containers/"
@@ -248,10 +248,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr "Нельзя использовать '/' в имени снимка"
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr "(пусто)"
@@ -2120,7 +2116,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2257,7 +2253,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
@@ -2373,6 +2369,9 @@ msgstr ""
 msgid "yes"
 msgstr "да"
 
+#~ msgid "'/' not allowed in snapshot name"
+#~ msgstr "Нельзя использовать '/' в имени снимка"
+
 #, fuzzy
 #~ msgid "Could not create config dir"
 #~ msgstr "Не удалось создать каталог сертификата сервера"
diff --git a/po/sr.po b/po/sr.po
index 004a2b6a6..fd144daa5 100644
--- a/po/sr.po
+++ b/po/sr.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/sv.po b/po/sv.po
index 74baf44bb..118d2004c 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/tr.po b/po/tr.po
index 0d04ccc58..a301e24e4 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/zh.po b/po/zh.po
index 87fcf8b22..d46934274 100644
--- a/po/zh.po
+++ b/po/zh.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 
diff --git a/po/zh_Hans.po b/po/zh_Hans.po
index e3cdb15c8..833b6bca2 100644
--- a/po/zh_Hans.po
+++ b/po/zh_Hans.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: lxd\n"
 "Report-Msgid-Bugs-To: lxc-devel at lists.linuxcontainers.org\n"
-"POT-Creation-Date: 2017-12-19 19:32-0500\n"
+"POT-Creation-Date: 2018-01-02 17:49+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
@@ -163,10 +163,6 @@ msgstr ""
 msgid "'%s' isn't a supported file type."
 msgstr ""
 
-#: lxc/snapshot.go:53
-msgid "'/' not allowed in snapshot name"
-msgstr ""
-
 #: lxc/profile.go:337
 msgid "(none)"
 msgstr ""
@@ -2017,7 +2013,7 @@ msgid ""
 "    Restore the snapshot."
 msgstr ""
 
-#: lxc/snapshot.go:22
+#: lxc/snapshot.go:19
 msgid ""
 "Usage: lxc snapshot [<remote>:]<container> <snapshot name> [--stateful]\n"
 "\n"
@@ -2154,7 +2150,7 @@ msgid ""
 "available)"
 msgstr ""
 
-#: lxc/snapshot.go:36
+#: lxc/snapshot.go:33
 msgid "Whether or not to snapshot the container's running state"
 msgstr ""
 

From a0b4721a8bba360d7ef3a791bb49439547ab54e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:44:04 +0100
Subject: [PATCH 6/7] lxd/storage: Don't allow slashes in pool or volume names
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes: #4127

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage_pools.go   | 4 ++++
 lxd/storage_volumes.go | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/lxd/storage_pools.go b/lxd/storage_pools.go
index b08e0125a..6d4d80bc8 100644
--- a/lxd/storage_pools.go
+++ b/lxd/storage_pools.go
@@ -73,6 +73,10 @@ func storagePoolsPost(d *Daemon, r *http.Request) Response {
 		return BadRequest(fmt.Errorf("No name provided"))
 	}
 
+	if strings.Contains(req.Name, "/") {
+		return BadRequest(fmt.Errorf("Storage pool names may not contain slashes"))
+	}
+
 	if req.Driver == "" {
 		return BadRequest(fmt.Errorf("No driver provided"))
 	}
diff --git a/lxd/storage_volumes.go b/lxd/storage_volumes.go
index 32bdd955e..480029c41 100644
--- a/lxd/storage_volumes.go
+++ b/lxd/storage_volumes.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"net/http"
 	"strconv"
+	"strings"
 
 	"github.com/gorilla/mux"
 	"github.com/lxc/lxd/lxd/db"
@@ -154,6 +155,10 @@ func storagePoolVolumesTypePost(d *Daemon, r *http.Request) Response {
 		return BadRequest(fmt.Errorf("No name provided"))
 	}
 
+	if strings.Contains(req.Name, "/") {
+		return BadRequest(fmt.Errorf("Storage volume names may not contain slashes"))
+	}
+
 	// Check that the user gave use a storage volume type for the storage
 	// volume we are about to create.
 	if req.Type == "" {
@@ -213,6 +218,10 @@ func storagePoolVolumeTypePost(d *Daemon, r *http.Request) Response {
 		return BadRequest(fmt.Errorf("No name provided"))
 	}
 
+	if strings.Contains(req.Name, "/") {
+		return BadRequest(fmt.Errorf("Storage volume names may not contain slashes"))
+	}
+
 	// We currently only allow to create storage volumes of type
 	// storagePoolVolumeTypeCustom. So check, that nothing else was
 	// requested.

From 1f932668fa7d0b1192d8df8c343f30ae17b5f521 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 2 Jan 2018 18:47:15 +0100
Subject: [PATCH 7/7] lxd/init: Strip leading and trailing spaces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes: #4125

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/cmd/context.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/shared/cmd/context.go b/shared/cmd/context.go
index 0caa946b4..251a5240c 100644
--- a/shared/cmd/context.go
+++ b/shared/cmd/context.go
@@ -161,6 +161,7 @@ func (c *Context) invalidInput() {
 func (c *Context) readAnswer(defaultAnswer string) string {
 	answer, _ := c.stdin.ReadString('\n')
 	answer = strings.TrimSuffix(answer, "\n")
+	answer = strings.TrimSpace(answer)
 	if answer == "" {
 		answer = defaultAnswer
 	}


More information about the lxc-devel mailing list