[lxc-devel] [lxd/master] lxd/logs: Don't allow removing lxc.conf or lxc.log

stgraber on Github lxc-bot at linuxcontainers.org
Wed Nov 8 19:57:48 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 404 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171108/82b30cac/attachment.bin>
-------------- next part --------------
From c642bf29fb91391dc024d25fe27280ad03a01439 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 8 Nov 2017 12:27:31 -0500
Subject: [PATCH] lxd/logs: Don't allow removing lxc.conf or lxc.log
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Those files are used by the container runtime.

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

diff --git a/lxd/container_logs.go b/lxd/container_logs.go
index 963283eab..a30c6b002 100644
--- a/lxd/container_logs.go
+++ b/lxd/container_logs.go
@@ -93,6 +93,10 @@ func containerLogDelete(d *Daemon, r *http.Request) Response {
 		return BadRequest(fmt.Errorf("log file name %s not valid", file))
 	}
 
+	if file == "lxc.log" || file == "lxc.conf" {
+		return BadRequest(fmt.Errorf("lxc.log and lxc.conf may not be deleted"))
+	}
+
 	return SmartError(os.Remove(shared.LogPath(name, file)))
 }
 


More information about the lxc-devel mailing list