[lxc-devel] [lxd/master] lxd/api: Restrict access to daemon config

stgraber on Github lxc-bot at linuxcontainers.org
Tue Sep 29 14:06:56 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200929/e61090a4/attachment-0001.bin>
-------------- next part --------------
From afe4734d43143cba7bc84489941e698faf585cd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 29 Sep 2020 10:06:31 -0400
Subject: [PATCH] lxd/api: Restrict access to daemon config
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>
---
 lxd/api_1.0.go | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go
index a9cc397146..72212579a2 100644
--- a/lxd/api_1.0.go
+++ b/lxd/api_1.0.go
@@ -251,9 +251,12 @@ func api10Get(d *Daemon, r *http.Request) response.Response {
 
 	fullSrv := api.Server{ServerUntrusted: srv}
 	fullSrv.Environment = env
-	fullSrv.Config, err = daemonConfigRender(d.State())
-	if err != nil {
-		return response.InternalError(err)
+
+	if d.userIsAdmin(r) {
+		fullSrv.Config, err = daemonConfigRender(d.State())
+		if err != nil {
+			return response.InternalError(err)
+		}
 	}
 
 	return response.SyncResponseETag(true, fullSrv, fullSrv.Config)


More information about the lxc-devel mailing list