From c07c167edb71568ab18f016346e60803d1195d42 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 21 Feb 2013 12:31:19 -0700 Subject: [PATCH] s3-winbindd: Move idmap_fetch_secret to idmap_utils.c for reuse Reviewed-by: Andrew Bartlett --- source3/winbindd/idmap_ldap.c | 24 ------------------------ source3/winbindd/idmap_proto.h | 2 ++ source3/winbindd/idmap_util.c | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c index 03872e7ab1d..0520f213ef6 100644 --- a/source3/winbindd/idmap_ldap.c +++ b/source3/winbindd/idmap_ldap.c @@ -39,30 +39,6 @@ #include "smbldap.h" #include "passdb/pdb_ldap_schema.h" -static char *idmap_fetch_secret(const char *backend, - const char *domain, const char *identity) -{ - char *tmp, *ret; - int r; - - r = asprintf(&tmp, "IDMAP_%s_%s", backend, domain); - - if (r < 0) - return NULL; - - /* make sure the key is case insensitive */ - if (!strupper_m(tmp)) { - SAFE_FREE(tmp); - return NULL; - } - - ret = secrets_fetch_generic(tmp, identity); - - SAFE_FREE(tmp); - - return ret; -} - struct idmap_ldap_context { struct smbldap_state *smbldap_state; char *url; diff --git a/source3/winbindd/idmap_proto.h b/source3/winbindd/idmap_proto.h index a709807f68e..f7af8ed639d 100644 --- a/source3/winbindd/idmap_proto.h +++ b/source3/winbindd/idmap_proto.h @@ -57,6 +57,8 @@ bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom); struct id_map *idmap_find_map_by_id(struct id_map **maps, enum id_type type, uint32_t id); struct id_map *idmap_find_map_by_sid(struct id_map **maps, struct dom_sid *sid); +char *idmap_fetch_secret(const char *backend, const char *domain, + const char *identity); /* max number of ids requested per LDAP batch query */ #define IDMAP_LDAP_MAX_IDS 30 diff --git a/source3/winbindd/idmap_util.c b/source3/winbindd/idmap_util.c index cbad91d151e..a0682989685 100644 --- a/source3/winbindd/idmap_util.c +++ b/source3/winbindd/idmap_util.c @@ -24,6 +24,7 @@ #include "idmap.h" #include "idmap_cache.h" #include "../libcli/security/security.h" +#include "secrets.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_IDMAP @@ -213,3 +214,27 @@ struct id_map *idmap_find_map_by_sid(struct id_map **maps, struct dom_sid *sid) return NULL; } + +char *idmap_fetch_secret(const char *backend, const char *domain, + const char *identity) +{ + char *tmp, *ret; + int r; + + r = asprintf(&tmp, "IDMAP_%s_%s", backend, domain); + + if (r < 0) + return NULL; + + /* make sure the key is case insensitive */ + if (!strupper_m(tmp)) { + SAFE_FREE(tmp); + return NULL; + } + + ret = secrets_fetch_generic(tmp, identity); + + SAFE_FREE(tmp); + + return ret; +} -- 2.11.4.GIT