ctdb/docs: Include ceph rados namespace support in man page
[samba.git] / source3 / winbindd / nss_info.c
index a3f95c649351e7e7ce052fc3938d8e296fa3e4da..3b58ca2932414bb446d07ec3e97a0aa55e90419c 100644 (file)
@@ -20,7 +20,6 @@
 */
 
 #include "includes.h"
-#include "ads.h"
 #include "nss_info.h"
 
 static struct nss_function_entry *backends = NULL;
@@ -33,7 +32,7 @@ static struct nss_domain_entry *nss_domain_list = NULL;
 
 static struct nss_function_entry *nss_get_backend(const char *name )
 {
-       struct nss_function_entry *entry = backends;
+       struct nss_function_entry *entry = NULL;
 
        for(entry = backends; entry; entry = entry->next) {
                if ( strequal(entry->name, name) )
@@ -47,7 +46,8 @@ static struct nss_function_entry *nss_get_backend(const char *name )
  Allow a module to register itself as a backend.
 **********************************************************************/
 
- NTSTATUS smb_register_idmap_nss(int version, const char *name, struct nss_info_methods *methods)
+ NTSTATUS smb_register_idmap_nss(int version, const char *name,
+                                const struct nss_info_methods *methods)
 {
        struct nss_function_entry *entry;
 
@@ -66,7 +66,7 @@ static struct nss_function_entry *nss_get_backend(const char *name )
        }
 
        if ( nss_get_backend(name) ) {
-               DEBUG(0,("smb_register_idmap_nss: idmap module %s "
+               DEBUG(5,("smb_register_idmap_nss: idmap module %s "
                         "already registered!\n", name));
                return NT_STATUS_OBJECT_NAME_COLLISION;
        }
@@ -85,7 +85,10 @@ static struct nss_function_entry *nss_get_backend(const char *name )
 /********************************************************************
  *******************************************************************/
 
-static bool parse_nss_parm( const char *config, char **backend, char **domain )
+static bool parse_nss_parm(TALLOC_CTX *mem_ctx,
+                          const char *config,
+                          char **backend,
+                          char **domain)
 {
        char *p;
 
@@ -99,17 +102,17 @@ static bool parse_nss_parm( const char *config, char **backend, char **domain )
        /* if no : then the string must be the backend name only */
 
        if ( !p ) {
-               *backend = SMB_STRDUP( config );
+               *backend = talloc_strdup(mem_ctx, config);
                return (*backend != NULL);
        }
 
        /* split the string and return the two parts */
 
        if ( strlen(p+1) > 0 ) {
-               *domain = SMB_STRDUP( p+1 );
+               *domain = talloc_strdup(mem_ctx, p + 1);
        }
 
-       *backend = SMB_STRNDUP(config, PTR_DIFF(p, config));
+       *backend = talloc_strndup(mem_ctx, config, PTR_DIFF(p, config));
        return (*backend != NULL);
 }
 
@@ -159,8 +162,9 @@ static NTSTATUS nss_init(const char **nss_list)
        NTSTATUS status;
        static bool nss_initialized = false;
        int i;
-       char *backend, *domain;
+       char *backend = NULL, *domain = NULL;
        struct nss_function_entry *nss_backend;
+       TALLOC_CTX *frame;
 
        /* check for previous successful initializations */
 
@@ -168,20 +172,24 @@ static NTSTATUS nss_init(const char **nss_list)
                return NT_STATUS_OK;
        }
 
+       frame = talloc_stackframe();
+
        /* The "template" backend should always be registered as it
           is a static module */
 
        nss_backend = nss_get_backend("template");
        if (nss_backend == NULL) {
-               static_init_nss_info;
+               static_init_nss_info(NULL);
        }
 
        /* Create the list of nss_domains (loading any shared plugins
           as necessary) */
 
        for ( i=0; nss_list && nss_list[i]; i++ ) {
+               bool ok;
 
-               if ( !parse_nss_parm(nss_list[i], &backend, &domain) ) {
+               ok = parse_nss_parm(frame, nss_list[i], &backend, &domain);
+               if (!ok) {
                        DEBUG(0,("nss_init: failed to parse \"%s\"!\n",
                                 nss_list[i]));
                        continue;
@@ -239,10 +247,11 @@ static NTSTATUS nss_init(const char **nss_list)
 
                /* cleanup */
 
-               SAFE_FREE( backend );
-               SAFE_FREE( domain );
+               TALLOC_FREE(domain);
+               TALLOC_FREE(backend);
        }
 
+
        if ( !nss_domain_list ) {
                DEBUG(3,("nss_init: no nss backends configured.  "
                         "Defaulting to \"template\".\n"));
@@ -253,6 +262,7 @@ static NTSTATUS nss_init(const char **nss_list)
 
        nss_initialized = true;
 
+       TALLOC_FREE(frame);
        return NT_STATUS_OK;
 }
 
@@ -303,32 +313,6 @@ static struct nss_domain_entry *find_nss_domain( const char *domain )
        return p;
 }
 
-/********************************************************************
- *******************************************************************/
-
-NTSTATUS nss_get_info( const char *domain, const struct dom_sid *user_sid,
-                      TALLOC_CTX *ctx,
-                      const char **homedir, const char **shell,
-                      const char **gecos, gid_t *p_gid)
-{
-       struct nss_domain_entry *p;
-       struct nss_info_methods *m;
-
-       DEBUG(10, ("nss_get_info called for sid [%s] in domain '%s'\n",
-                  sid_string_dbg(user_sid), domain?domain:"NULL"));
-
-       if ( (p = find_nss_domain( domain )) == NULL ) {
-               DEBUG(4,("nss_get_info: Failed to find nss domain pointer for %s\n",
-                        domain ));
-               return NT_STATUS_NOT_FOUND;
-       }
-
-       m = p->backend->methods;
-
-       return m->get_nss_info( p, user_sid, ctx,
-                               homedir, shell, gecos, p_gid );
-}
-
 /********************************************************************
  *******************************************************************/
 
@@ -336,7 +320,7 @@ NTSTATUS nss_get_info( const char *domain, const struct dom_sid *user_sid,
                            const char *name, char **alias )
 {
        struct nss_domain_entry *p;
-       struct nss_info_methods *m;
+       const struct nss_info_methods *m;
 
        if ( (p = find_nss_domain( domain )) == NULL ) {
                DEBUG(4,("nss_map_to_alias: Failed to find nss domain pointer for %s\n",
@@ -357,7 +341,7 @@ NTSTATUS nss_get_info( const char *domain, const struct dom_sid *user_sid,
                              const char *alias, char **name )
 {
        struct nss_domain_entry *p;
-       struct nss_info_methods *m;
+       const struct nss_info_methods *m;
 
        if ( (p = find_nss_domain( domain )) == NULL ) {
                DEBUG(4,("nss_map_from_alias: Failed to find nss domain pointer for %s\n",