[lxc-devel] [lxd/master] lxd: Better handle bad commands
stgraber on Github
lxc-bot at linuxcontainers.org
Mon Jun 24 19:22:10 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190624/3c1246f7/attachment.bin>
-------------- next part --------------
From 0c51a6574afe002a2ac795f42eff09f78eb9b5ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 24 Jun 2019 15:21:14 -0400
Subject: [PATCH] lxd: Better handle bad commands
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #5876
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/main_daemon.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lxd/main_daemon.go b/lxd/main_daemon.go
index cb849149e4..aa1fd75ecc 100644
--- a/lxd/main_daemon.go
+++ b/lxd/main_daemon.go
@@ -40,6 +40,10 @@ func (c *cmdDaemon) Command() *cobra.Command {
}
func (c *cmdDaemon) Run(cmd *cobra.Command, args []string) error {
+ if len(args) > 1 || (len(args) == 1 && args[0] != "daemon") {
+ return fmt.Errorf("unknown command \"%s\" for \"%s\"", args[0], cmd.CommandPath())
+ }
+
// Only root should run this
if os.Geteuid() != 0 {
return fmt.Errorf("This must be run as root")
More information about the lxc-devel
mailing list