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) addServerFlags(flags)
addUserFlags(flags) addUserFlags(flags)
flags.BoolP("signup", "s", false, "allow users to signup") 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("shell", "", "shell command to which other commands should be appended")
flags.String("auth.method", string(auth.MethodJSONAuth), "authentication type") 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, "Sign up:\t%t\n", set.Signup)
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir) fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod) 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.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
fmt.Fprintln(w, "\nBranding:") fmt.Fprintln(w, "\nBranding:")
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name) fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)

View File

@ -30,11 +30,12 @@ override the options.`,
authMethod, auther := getAuthentication(flags) authMethod, auther := getAuthentication(flags)
s := &settings.Settings{ s := &settings.Settings{
Key: generateKey(), Key: generateKey(),
Signup: mustGetBool(flags, "signup"), Signup: mustGetBool(flags, "signup"),
Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "), ExecEnabled: true,
AuthMethod: authMethod, Shell: strings.Split(strings.TrimSpace(mustGetString(flags, "shell")), " "),
Defaults: defaults, AuthMethod: authMethod,
Defaults: defaults,
Branding: settings.Branding{ Branding: settings.Branding{
Name: mustGetString(flags, "branding.name"), Name: mustGetString(flags, "branding.name"),
DisableExternal: mustGetBool(flags, "branding.disableExternal"), DisableExternal: mustGetBool(flags, "branding.disableExternal"),

View File

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

View File

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