summaryrefslogtreecommitdiff
path: root/source4/libcli/auth
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-08-11 16:13:25 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:50 -0500
commit1bcd36ed8ac4cb748f80d75c3f3b9c33fb474a8d (patch)
tree6864fb521b5b55b2bfef13a1972581d4f4dc2374 /source4/libcli/auth
parent8ed563cfbbe3921a7a07479a50de85fcf71cd41a (diff)
downloadsamba-1bcd36ed8ac4cb748f80d75c3f3b9c33fb474a8d.tar.gz
samba-1bcd36ed8ac4cb748f80d75c3f3b9c33fb474a8d.tar.bz2
samba-1bcd36ed8ac4cb748f80d75c3f3b9c33fb474a8d.zip
r1724: Add a new function to return the list of available OIDs.
(Used in our SPNEGO code). Andrew Bartlett (This used to be commit c91d6b6f9b53e64069fd5860f677bc1b4c250f0c)
Diffstat (limited to 'source4/libcli/auth')
-rw-r--r--source4/libcli/auth/gensec.c48
1 files changed, 39 insertions, 9 deletions
diff --git a/source4/libcli/auth/gensec.c b/source4/libcli/auth/gensec.c
index d635378117..3db6002639 100644
--- a/source4/libcli/auth/gensec.c
+++ b/source4/libcli/auth/gensec.c
@@ -25,12 +25,12 @@
/* the list of currently registered GENSEC backends */
const static struct gensec_security_ops **generic_security_ops;
-static int num_backends;
+static int gensec_num_backends;
static const struct gensec_security_ops *gensec_security_by_authtype(uint8_t auth_type)
{
int i;
- for (i=0; i < num_backends; i++) {
+ for (i=0; i < gensec_num_backends; i++) {
if (generic_security_ops[i]->auth_type == auth_type) {
return generic_security_ops[i];
}
@@ -42,7 +42,7 @@ static const struct gensec_security_ops *gensec_security_by_authtype(uint8_t aut
static const struct gensec_security_ops *gensec_security_by_oid(const char *oid_string)
{
int i;
- for (i=0; i < num_backends; i++) {
+ for (i=0; i < gensec_num_backends; i++) {
if (generic_security_ops[i]->oid &&
(strcmp(generic_security_ops[i]->oid, oid_string) == 0)) {
return generic_security_ops[i];
@@ -55,7 +55,7 @@ static const struct gensec_security_ops *gensec_security_by_oid(const char *oid_
static const struct gensec_security_ops *gensec_security_by_sasl_name(const char *sasl_name)
{
int i;
- for (i=0; i < num_backends; i++) {
+ for (i=0; i < gensec_num_backends; i++) {
if (generic_security_ops[i]->sasl_name
&& (strcmp(generic_security_ops[i]->sasl_name, sasl_name) == 0)) {
return generic_security_ops[i];
@@ -68,7 +68,7 @@ static const struct gensec_security_ops *gensec_security_by_sasl_name(const char
static const struct gensec_security_ops *gensec_security_by_name(const char *name)
{
int i;
- for (i=0; i < num_backends; i++) {
+ for (i=0; i < gensec_num_backends; i++) {
if (generic_security_ops[i]->name
&& (strcmp(generic_security_ops[i]->name, name) == 0)) {
return generic_security_ops[i];
@@ -80,10 +80,40 @@ static const struct gensec_security_ops *gensec_security_by_name(const char *nam
const struct gensec_security_ops **gensec_security_all(int *num_backends_out)
{
- *num_backends_out = num_backends;
+ *num_backends_out = gensec_num_backends;
return generic_security_ops;
}
+const char **gensec_security_oids(TALLOC_CTX *mem_ctx, const char *skip)
+{
+ int i, j = 0;
+ const char **oid_list;
+ int num_backends;
+ const struct gensec_security_ops **ops = gensec_security_all(&num_backends);
+ if (!ops) {
+ return NULL;
+ }
+ oid_list = talloc_array_p(mem_ctx, const char *, num_backends + 1);
+ if (!oid_list) {
+ return NULL;
+ }
+
+ for (i=0; i<num_backends; i++) {
+ if (!ops[i]->oid) {
+ continue;
+ }
+
+ if (skip && strcmp(skip, ops[i]->oid)==0) {
+ continue;
+ }
+
+ oid_list[j] = ops[i]->oid;
+ j++;
+ }
+ oid_list[j] = NULL;
+ return oid_list;
+}
+
static NTSTATUS gensec_start(struct gensec_security **gensec_security)
{
TALLOC_CTX *mem_ctx;
@@ -643,14 +673,14 @@ static NTSTATUS gensec_register(const void *_ops)
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- generic_security_ops = Realloc(generic_security_ops, sizeof(generic_security_ops[0]) * (num_backends+1));
+ generic_security_ops = Realloc(generic_security_ops, sizeof(generic_security_ops[0]) * (gensec_num_backends+1));
if (!generic_security_ops) {
smb_panic("out of memory in gensec_register");
}
- generic_security_ops[num_backends] = ops;
+ generic_security_ops[gensec_num_backends] = ops;
- num_backends++;
+ gensec_num_backends++;
DEBUG(3,("GENSEC backend '%s' registered\n",
ops->name));