diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-08-03 11:43:58 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2013-08-10 09:18:56 +0200 |
commit | 59b09564a7edac8dc241269587146342244ce58b (patch) | |
tree | 767ad97c7138e06073771b56e172287d0e74cc79 | |
parent | 45c74c8084d2db14fef6a79cd98068be2ab73f30 (diff) | |
download | samba-59b09564a7edac8dc241269587146342244ce58b.tar.gz samba-59b09564a7edac8dc241269587146342244ce58b.tar.bz2 samba-59b09564a7edac8dc241269587146342244ce58b.zip |
auth/gensec: add gensec_security_by_auth_type()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | auth/gensec/gensec.h | 3 | ||||
-rw-r--r-- | auth/gensec/gensec_start.c | 26 |
2 files changed, 29 insertions, 0 deletions
diff --git a/auth/gensec/gensec.h b/auth/gensec/gensec.h index 396a16dc24..c080861664 100644 --- a/auth/gensec/gensec.h +++ b/auth/gensec/gensec.h @@ -268,6 +268,9 @@ const struct gensec_security_ops *gensec_security_by_oid(struct gensec_security const char *oid_string); const struct gensec_security_ops *gensec_security_by_sasl_name(struct gensec_security *gensec_security, const char *sasl_name); +const struct gensec_security_ops *gensec_security_by_auth_type( + struct gensec_security *gensec_security, + uint32_t auth_type); struct gensec_security_ops **gensec_security_mechs(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx); const struct gensec_security_ops_wrapper *gensec_security_by_oid_list( diff --git a/auth/gensec/gensec_start.c b/auth/gensec/gensec_start.c index e46f0ee851..c2cfa1c375 100644 --- a/auth/gensec/gensec_start.c +++ b/auth/gensec/gensec_start.c @@ -246,6 +246,32 @@ _PUBLIC_ const struct gensec_security_ops *gensec_security_by_sasl_name( return NULL; } +_PUBLIC_ const struct gensec_security_ops *gensec_security_by_auth_type( + struct gensec_security *gensec_security, + uint32_t auth_type) +{ + int i; + struct gensec_security_ops **backends; + const struct gensec_security_ops *backend; + TALLOC_CTX *mem_ctx = talloc_new(gensec_security); + if (!mem_ctx) { + return NULL; + } + backends = gensec_security_mechs(gensec_security, mem_ctx); + for (i=0; backends && backends[i]; i++) { + if (!gensec_security_ops_enabled(backends[i], gensec_security)) + continue; + if (backends[i]->auth_type == auth_type) { + backend = backends[i]; + talloc_free(mem_ctx); + return backend; + } + } + talloc_free(mem_ctx); + + return NULL; +} + static const struct gensec_security_ops *gensec_security_by_name(struct gensec_security *gensec_security, const char *name) { |