func isAnyUserDefined(root *command.ConfNode) bool { node, err := root.Get("username") if err != nil { return false } return len(node.Children) > 0 }
func getHostname(root *command.ConfNode) string { node, err := root.Get("hostname") if err != nil { return "hostname?" } return command.LastToken(node.Children[0].Path) }
func checkPassword(root *command.ConfNode, username, password string) bool { path := fmt.Sprintf("username %s password", username) node, err := root.Get(path) if err != nil { return false } if len(node.Children) != 1 { return false } return password == command.LastToken(node.Children[0].Path) }