From 97693cc6117ce1c956baede91de5dd48b904e175 Mon Sep 17 00:00:00 2001
From: Keagan McClelland
Date: Thu, 1 Oct 2020 08:45:24 -0600
Subject: [PATCH] feat: add disable exec flag (#1090)
---
cmd/config.go | 1 +
cmd/root.go | 4 +++
frontend/public/index.html | 4 +--
frontend/src/components/Header.vue | 5 ++--
.../src/components/settings/Permissions.vue | 6 +++--
frontend/src/components/settings/UserForm.vue | 6 +++--
frontend/src/utils/constants.js | 4 ++-
frontend/src/views/Layout.vue | 6 +++--
frontend/src/views/settings/Global.vue | 14 +++++++----
http/commands.go | 2 +-
http/data.go | 2 +-
http/static.go | 1 +
runner/runner.go | 25 +++++++++++--------
settings/settings.go | 1 +
14 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/cmd/config.go b/cmd/config.go
index 8b69e7b7..4cdd3ee2 100644
--- a/cmd/config.go
+++ b/cmd/config.go
@@ -140,6 +140,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
fmt.Fprintf(w, "\tAddress:\t%s\n", ser.Address)
fmt.Fprintf(w, "\tTLS Cert:\t%s\n", ser.TLSCert)
fmt.Fprintf(w, "\tTLS Key:\t%s\n", ser.TLSKey)
+ fmt.Fprintf(w, "\tExec Enabled:\t%t\n", ser.EnableExec)
fmt.Fprintln(w, "\nDefaults:")
fmt.Fprintf(w, "\tScope:\t%s\n", set.Defaults.Scope)
fmt.Fprintf(w, "\tLocale:\t%s\n", set.Defaults.Locale)
diff --git a/cmd/root.go b/cmd/root.go
index b096a7c0..8fe0393a 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -64,6 +64,7 @@ func addServerFlags(flags *pflag.FlagSet) {
flags.Int("img-processors", 4, "image processors count")
flags.Bool("disable-thumbnails", false, "disable image thumbnails")
flags.Bool("disable-preview-resize", false, "disable resize of image previews")
+ flags.Bool("disable-exec", false, "disables Command Runner feature")
}
var rootCmd = &cobra.Command{
@@ -241,6 +242,9 @@ func getRunParams(flags *pflag.FlagSet, st *storage.Storage) *settings.Server {
_, disablePreviewResize := getParamB(flags, "disable-preview-resize")
server.ResizePreview = !disablePreviewResize
+ _, disableExec := getParamB(flags, "disable-exec")
+ server.EnableExec = !disableExec
+
return server
}
diff --git a/frontend/public/index.html b/frontend/public/index.html
index 7625aae3..6dd9d32a 100644
--- a/frontend/public/index.html
+++ b/frontend/public/index.html
@@ -13,7 +13,7 @@
-
+
@@ -31,7 +31,7 @@
diff --git a/frontend/src/components/settings/UserForm.vue b/frontend/src/components/settings/UserForm.vue
index 35a872f8..8082d5e1 100644
--- a/frontend/src/components/settings/UserForm.vue
+++ b/frontend/src/components/settings/UserForm.vue
@@ -25,7 +25,7 @@
-
+
{{ $t('settings.rules') }}
@@ -40,6 +40,7 @@ import Languages from './Languages'
import Rules from './Rules'
import Permissions from './Permissions'
import Commands from './Commands'
+import { enableExec } from '@/utils/constants'
export default {
name: 'user',
@@ -53,7 +54,8 @@ export default {
computed: {
passwordPlaceholder () {
return this.isNew ? '' : this.$t('settings.avoidChanges')
- }
+ },
+ isExecEnabled: () => enableExec
},
watch: {
'user.perm.admin': function () {
diff --git a/frontend/src/utils/constants.js b/frontend/src/utils/constants.js
index e4689dae..d4a8fd79 100644
--- a/frontend/src/utils/constants.js
+++ b/frontend/src/utils/constants.js
@@ -13,6 +13,7 @@ const loginPage = window.FileBrowser.LoginPage
const theme = window.FileBrowser.Theme
const enableThumbs = window.FileBrowser.EnableThumbs
const resizePreview = window.FileBrowser.ResizePreview
+const enableExec = window.FileBrowser.EnableExec
export {
name,
@@ -28,5 +29,6 @@ export {
loginPage,
theme,
enableThumbs,
- resizePreview
+ resizePreview,
+ enableExec
}
diff --git a/frontend/src/views/Layout.vue b/frontend/src/views/Layout.vue
index c5e6c2ef..85991d48 100644
--- a/frontend/src/views/Layout.vue
+++ b/frontend/src/views/Layout.vue
@@ -7,7 +7,7 @@
-
+
@@ -19,6 +19,7 @@ import Sidebar from '@/components/Sidebar'
import Prompts from '@/components/prompts/Prompts'
import SiteHeader from '@/components/Header'
import Shell from '@/components/Shell'
+import { enableExec } from '@/utils/constants'
export default {
name: 'layout',
@@ -30,7 +31,8 @@ export default {
},
computed: {
...mapGetters([ 'isLogged', 'progress' ]),
- ...mapState([ 'user' ])
+ ...mapState([ 'user' ]),
+ isExecEnabled: () => enableExec
},
watch: {
'$route': function () {
diff --git a/frontend/src/views/settings/Global.vue b/frontend/src/views/settings/Global.vue
index a0fbfa8a..fd72ae5d 100644
--- a/frontend/src/views/settings/Global.vue
+++ b/frontend/src/views/settings/Global.vue
@@ -14,9 +14,11 @@
{{ $t('settings.globalRules') }}
- {{ $t('settings.executeOnShell') }}
- {{ $t('settings.executeOnShellDescription') }}
-
+
+
{{ $t('settings.executeOnShell') }}
+
{{ $t('settings.executeOnShellDescription') }}
+
+
{{ $t('settings.branding') }}
@@ -67,7 +69,7 @@
-