s3-winbindd: Move idmap_fetch_secret to idmap_utils.c for reuse
authorChristof Schmitt <christof.schmitt@us.ibm.com>
Thu, 21 Feb 2013 19:31:19 +0000 (12:31 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 9 Mar 2013 05:30:22 +0000 (06:30 +0100)
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/winbindd/idmap_ldap.c
source3/winbindd/idmap_proto.h
source3/winbindd/idmap_util.c

index 03872e7ab1db1bee2f8a03c13aa2dcb972950240..0520f213ef6d0c9fefc3e3260c29b8cbd4efb7cb 100644 (file)
 #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;
index a709807f68e81a58e0d57d1f97f253bfd6d7a758..f7af8ed639de804659758ddc88a5c37f64f7f856 100644 (file)
@@ -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
index cbad91d151ef1fdd3469616a58835e445a303a7d..a068298968514fefb4c4152fe359760224445201 100644 (file)
@@ -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;
+}