func userExists()

in lib/ec2macosinit/util.go [153:165]


func userExists(username string) (exists bool, err error) {
	out, err := executeCommand([]string{"dscacheutil", "-q", "user", "-a", "name", username}, "", []string{})
	if err != nil {
		return false, fmt.Errorf("ec2macosinit: error while checking dscacheutil for user %s: %s\n", username, err)
	}
	// If dscacheutil output containing the username, the user exists
	if strings.Contains(out.stdout, username) {
		return true, nil
	}

	// No output means the user does not exist
	return false, nil
}