add cli options for execEnabled

This commit is contained in:
Aiden McClelland 2020-09-21 14:10:24 -06:00
parent 9f2cad9bff
commit 0e1d9ea096
4 changed files with 12 additions and 5 deletions

View File

@ -31,6 +31,7 @@ func addConfigFlags(flags *pflag.FlagSet) {
addServerFlags(flags)
addUserFlags(flags)
flags.BoolP("signup", "s", false, "allow users to signup")
flags.BoolP("execEnabled", "", true, "enable the Command Runner feature")
flags.String("shell", "", "shell command to which other commands should be appended")
flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type")
@ -126,6 +127,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
fmt.Fprintf(w, "Sign up:\t%t\n", set.Signup)
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod)
fmt.Fprintf(w, "Exec Enabled:\t%t\n", set.ExecEnabled)
fmt.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
fmt.Fprintln(w, "\nBranding:")
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)

View File

@ -32,6 +32,7 @@ override the options.`,
s := &settings.Settings{
Key: generateKey(),
Signup: mustGetBool(flags, "signup"),
ExecEnabled: true,
Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "),
AuthMethod: authMethod,
Defaults: defaults,

View File

@ -49,6 +49,8 @@ you want to change. Other options will remain unchanged.`,
set.Signup = mustGetBool(flags, flag.Name)
case "auth.method":
hasAuth = true
case "execEnabled":
set.ExecEnabled = mustGetBool(flags, flag.Name)
case "shell":
set.Shell = strings.Split(strings.TrimSpace(mustGetString(flags, flag.Name)), " ")
case "branding.name":

View File

@ -14,6 +14,7 @@ type settingsData struct {
Defaults settings.UserDefaults `json:"defaults"`
Rules []rules.Rule `json:"rules"`
Branding settings.Branding `json:"branding"`
ExecEnabled bool `json:"execEnabled"`
Shell []string `json:"shell"`
Commands map[string][]string `json:"commands"`
}
@ -25,6 +26,7 @@ var settingsGetHandler = withAdmin(func(w http.ResponseWriter, r *http.Request,
Defaults: d.settings.Defaults,
Rules: d.settings.Rules,
Branding: d.settings.Branding,
ExecEnabled: d.settings.ExecEnabled,
Shell: d.settings.Shell,
Commands: d.settings.Commands,
}