Lines Matching defs:ag
117 struct auth_group *ag, *cagtmp;
127 TAILQ_FOREACH_SAFE(ag, &conf->conf_auth_groups, ag_next, cagtmp)
128 auth_group_delete(ag);
139 auth_new(struct auth_group *ag)
146 auth->a_auth_group = ag;
147 TAILQ_INSERT_TAIL(&ag->ag_auths, auth, a_next);
164 auth_find(const struct auth_group *ag, const char *user)
168 TAILQ_FOREACH(auth, &ag->ag_auths, a_next) {
238 auth_new_chap(struct auth_group *ag, const char *user,
243 if (ag->ag_type == AG_TYPE_UNKNOWN)
244 ag->ag_type = AG_TYPE_CHAP;
245 if (ag->ag_type != AG_TYPE_CHAP) {
246 if (ag->ag_name != NULL)
248 "other types for auth-group \"%s\"", ag->ag_name);
252 ag->ag_target->t_name);
256 auth = auth_new(ag);
266 auth_new_chap_mutual(struct auth_group *ag, const char *user,
271 if (ag->ag_type == AG_TYPE_UNKNOWN)
272 ag->ag_type = AG_TYPE_CHAP_MUTUAL;
273 if (ag->ag_type != AG_TYPE_CHAP_MUTUAL) {
274 if (ag->ag_name != NULL)
277 ag->ag_name);
281 ag->ag_target->t_name);
285 auth = auth_new(ag);
297 auth_name_new(struct auth_group *ag, const char *name)
304 an->an_auth_group = ag;
306 TAILQ_INSERT_TAIL(&ag->ag_names, an, an_next);
320 auth_name_defined(const struct auth_group *ag)
322 if (TAILQ_EMPTY(&ag->ag_names))
328 auth_name_find(const struct auth_group *ag, const char *name)
332 TAILQ_FOREACH(auth_name, &ag->ag_names, an_next) {
341 auth_name_check(const struct auth_group *ag, const char *initiator_name)
343 if (!auth_name_defined(ag))
346 if (auth_name_find(ag, initiator_name) == NULL)
353 auth_portal_new(struct auth_group *ag, const char *portal)
362 ap->ap_auth_group = ag;
400 TAILQ_INSERT_TAIL(&ag->ag_portals, ap, ap_next);
420 auth_portal_defined(const struct auth_group *ag)
422 if (TAILQ_EMPTY(&ag->ag_portals))
428 auth_portal_find(const struct auth_group *ag, const struct sockaddr_storage *ss)
435 TAILQ_FOREACH(ap, &ag->ag_portals, ap_next) {
467 auth_portal_check(const struct auth_group *ag, const struct sockaddr_storage *sa)
470 if (!auth_portal_defined(ag))
473 if (auth_portal_find(ag, sa) == NULL)
482 struct auth_group *ag;
485 ag = auth_group_find(conf, name);
486 if (ag != NULL) {
492 ag = calloc(1, sizeof(*ag));
493 if (ag == NULL)
496 ag->ag_name = checked_strdup(name);
497 TAILQ_INIT(&ag->ag_auths);
498 TAILQ_INIT(&ag->ag_names);
499 TAILQ_INIT(&ag->ag_portals);
500 ag->ag_conf = conf;
501 TAILQ_INSERT_TAIL(&conf->conf_auth_groups, ag, ag_next);
503 return (ag);
507 auth_group_delete(struct auth_group *ag)
513 TAILQ_REMOVE(&ag->ag_conf->conf_auth_groups, ag, ag_next);
515 TAILQ_FOREACH_SAFE(auth, &ag->ag_auths, a_next, auth_tmp)
517 TAILQ_FOREACH_SAFE(auth_name, &ag->ag_names, an_next, auth_name_tmp)
519 TAILQ_FOREACH_SAFE(auth_portal, &ag->ag_portals, ap_next,
522 free(ag->ag_name);
523 free(ag);
529 struct auth_group *ag;
532 TAILQ_FOREACH(ag, &conf->conf_auth_groups, ag_next) {
533 if (ag->ag_name != NULL && strcmp(ag->ag_name, name) == 0)
534 return (ag);
541 auth_group_set_type(struct auth_group *ag, const char *str)
554 if (ag->ag_name != NULL)
556 "\"%s\"", str, ag->ag_name);
559 "\"%s\"", str, ag->ag_target->t_name);
563 if (ag->ag_type != AG_TYPE_UNKNOWN && ag->ag_type != type) {
564 if (ag->ag_name != NULL) {
567 "type", str, ag->ag_name);
571 str, ag->ag_target->t_name);
576 ag->ag_type = type;
1596 struct auth_group *ag;
1606 TAILQ_FOREACH(ag, &conf->conf_auth_groups, ag_next) {
1607 fprintf(stderr, "auth-group %s {\n", ag->ag_name);
1608 TAILQ_FOREACH(auth, &ag->ag_auths, a_next)
1612 TAILQ_FOREACH(auth_name, &ag->ag_names, an_next)
1615 TAILQ_FOREACH(auth_portal, &ag->ag_portals, ap_next)
1702 struct auth_group *ag;
1772 TAILQ_FOREACH(ag, &conf->conf_auth_groups, ag_next) {
1773 if (ag->ag_name == NULL)
1774 assert(ag->ag_target != NULL);
1776 assert(ag->ag_target == NULL);
1780 if (targ->t_auth_group == ag) {
1786 if (port->p_auth_group == ag) {
1792 if (pg->pg_discovery_auth_group == ag) {
1797 if (!found && ag->ag_name != NULL &&
1798 strcmp(ag->ag_name, "default") != 0 &&
1799 strcmp(ag->ag_name, "no-authentication") != 0 &&
1800 strcmp(ag->ag_name, "no-access") != 0) {
1802 "to any target", ag->ag_name);
2570 struct auth_group *ag;
2578 ag = auth_group_new(conf, "default");
2579 assert(ag != NULL);
2581 ag = auth_group_new(conf, "no-authentication");
2582 assert(ag != NULL);
2583 ag->ag_type = AG_TYPE_NO_AUTHENTICATION;
2585 ag = auth_group_new(conf, "no-access");
2586 assert(ag != NULL);
2587 ag->ag_type = AG_TYPE_DENY;
2607 ag = auth_group_find(conf, "default");
2608 assert(ag != NULL);
2609 ag->ag_type = AG_TYPE_DENY;