Ejemplo n.º 1
0
func isAnyUserDefined(root *command.ConfNode) bool {
	node, err := root.Get("username")
	if err != nil {
		return false
	}

	return len(node.Children) > 0
}
Ejemplo n.º 2
0
func getHostname(root *command.ConfNode) string {
	node, err := root.Get("hostname")
	if err != nil {
		return "hostname?"
	}

	return command.LastToken(node.Children[0].Path)
}
Ejemplo n.º 3
0
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)
}