WIP: set jail properties
This commit is contained in:
41
cmd/start.go
41
cmd/start.go
@ -12,6 +12,45 @@ import (
|
||||
// "strconv"
|
||||
)
|
||||
|
||||
func SetJailProperties(args []string) {
|
||||
type properties struct {
|
||||
name string
|
||||
value string
|
||||
}
|
||||
|
||||
var jail Jail
|
||||
var props []properties
|
||||
|
||||
if len(args) > 0 {
|
||||
for i, a := range args {
|
||||
// This is the jail name
|
||||
if i == len(args)-1 {
|
||||
jail.Name = a
|
||||
} else {
|
||||
kv := strings.Split(a, "=")
|
||||
if len(kv) != 2 {
|
||||
// TODO : Show help
|
||||
fmt.Printf("Error parsing args: %s\n", a)
|
||||
return
|
||||
} else {
|
||||
p := properties{name: kv[0], value: kv[1]}
|
||||
props = append(props, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(jail.Name) == 0 || len(args) == 0 {
|
||||
// TODO : Show help
|
||||
fmt.Printf("Error\n")
|
||||
return
|
||||
}
|
||||
|
||||
for _, p := range props {
|
||||
setJailProperty(&jail, p.name, p.value)
|
||||
}
|
||||
}
|
||||
|
||||
// WIP. Not working now (need to address the real struct field, not a copy of it)
|
||||
// setJailProperty takes a string as propValue, whatever the real property type is.
|
||||
// It will be converted.
|
||||
@ -47,7 +86,7 @@ func setJailProperty(jail *Jail, propName string, propValue string) error {
|
||||
// panic: reflect: reflect.Value.Set using unaddressable value
|
||||
//val.Set(reflect.ValueOf(propValue).Elem())
|
||||
// ...Because val settability is false :-(
|
||||
fmt.Printf("settability of val: %v\n", val.CanSet())
|
||||
fmt.Printf("settability of val %s: %v\n", val.Interface(), val.CanSet())
|
||||
|
||||
// This is OK, using the index to get the real jail object
|
||||
//gJails[i].Config.Allow_mlock = 1
|
||||
|
Reference in New Issue
Block a user