*/
#include "includes.h"
-#include "ads.h"
#include "nss_info.h"
static struct nss_function_entry *backends = 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) )
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;
}
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;
}
/********************************************************************
*******************************************************************/
-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;
/* 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);
}
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 */
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;
/* 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"));
nss_initialized = true;
+ TALLOC_FREE(frame);
return NT_STATUS_OK;
}
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 );
-}
-
/********************************************************************
*******************************************************************/
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",
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",