From e9e63b09836dbffd233394e07f311883418fd3d7 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 15 Jan 2025 23:14:18 +0700 Subject: [PATCH] cmd/cli: check root privilege for log commands --- cmd/cli/commands.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/cli/commands.go b/cmd/cli/commands.go index 0982647..e5f655f 100644 --- a/cmd/cli/commands.go +++ b/cmd/cli/commands.go @@ -37,6 +37,9 @@ func initLogCmd() *cobra.Command { Use: "send", Short: "Send runtime debug logs to ControlD", Args: cobra.NoArgs, + PreRun: func(cmd *cobra.Command, args []string) { + checkHasElevatedPrivilege() + }, Run: func(cmd *cobra.Command, args []string) { dir, err := socketDir() if err != nil { @@ -74,6 +77,9 @@ func initLogCmd() *cobra.Command { Use: "view", Short: "View current runtime debug logs", Args: cobra.NoArgs, + PreRun: func(cmd *cobra.Command, args []string) { + checkHasElevatedPrivilege() + }, Run: func(cmd *cobra.Command, args []string) { dir, err := socketDir() if err != nil {