[lxc-devel] [lxd/master] usb: vendorid is mandatory, productid isn't

stgraber on Github lxc-bot at linuxcontainers.org
Thu Oct 6 15:54:05 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 738 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20161006/aeeec31c/attachment.bin>
-------------- next part --------------
From 91f16b707e014bf960744256f12309e0051804b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 6 Oct 2016 17:49:30 +0200
Subject: [PATCH] usb: vendorid is mandatory, productid isn't
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The code was doing the right thing, skipping devices that didn't match
vendorid and allowing devices that don't have a productid set to still
be passed through.

But the documentation and configuration parser were doing things the
other way around, requiring a productid and considering vendorid
optional.

So fix the documentation and config parser to do the right thing.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 doc/configuration.md | 4 ++--
 lxd/container.go     | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/doc/configuration.md b/doc/configuration.md
index ce0036d..ecb70b5 100644
--- a/doc/configuration.md
+++ b/doc/configuration.md
@@ -270,8 +270,8 @@ The following properties exist:
 
 Key         | Type      | Default           | Required  | Description
 :--         | :--       | :--               | :--       | :--
-productid   | string    | -                 | yes       | The product id of the USB device.
-vendorid    | string    | -                 | no        | The vendor id of the USB device.
+vendorid    | string    | -                 | yes       | The vendor id of the USB device.
+productid   | string    | -                 | no        | The product id of the USB device.
 uid         | int       | 0                 | no        | UID of the device owner in the container
 gid         | int       | 0                 | no        | GID of the device owner in the container
 mode        | int       | 0660              | no        | Mode of the device in the container
diff --git a/lxd/container.go b/lxd/container.go
index cd6060f..72849ae 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -250,8 +250,8 @@ func containerValidDevices(devices shared.Devices, profile bool, expanded bool)
 				return fmt.Errorf("Unix device entry is missing the required \"path\" property.")
 			}
 		} else if m["type"] == "usb" {
-			if m["productid"] == "" {
-				return fmt.Errorf("Missing productid for USB device.")
+			if m["vendorid"] == "" {
+				return fmt.Errorf("Missing vendorid for USB device.")
 			}
 		} else if m["type"] == "none" {
 			continue


More information about the lxc-devel mailing list