summaryrefslogtreecommitdiffstats
path: root/source/nsswitch/nss_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/nsswitch/nss_info.c')
-rw-r--r--source/nsswitch/nss_info.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/source/nsswitch/nss_info.c b/source/nsswitch/nss_info.c
index 0b0caeee022..d2516296629 100644
--- a/source/nsswitch/nss_info.c
+++ b/source/nsswitch/nss_info.c
@@ -131,11 +131,17 @@ static BOOL parse_nss_parm( const char *config, char **backend, char **domain )
NTSTATUS nss_init( const char **nss_list )
{
NTSTATUS status;
+ static NTSTATUS nss_initialized = NT_STATUS_UNSUCCESSFUL;
int i;
char *backend, *domain;
struct nss_function_entry *nss_backend;
struct nss_domain_entry *nss_domain;
+ /* check for previous successful initializations */
+
+ if ( NT_STATUS_IS_OK(nss_initialized) )
+ return NT_STATUS_OK;
+
/* The "template" backend should alqays be registered as it
is a static module */
@@ -207,20 +213,25 @@ static BOOL parse_nss_parm( const char *config, char **backend, char **domain )
}
+ nss_initialized = NT_STATUS_OK;
+
return NT_STATUS_OK;
}
/********************************************************************
*******************************************************************/
- NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid,
- TALLOC_CTX *ctx,
- ADS_STRUCT *ads, LDAPMessage *msg,
- char **homedir, char **shell, char **gecos,
- gid_t *p_gid)
+static struct nss_domain_entry *find_nss_domain( const char *domain )
{
+ NTSTATUS status;
struct nss_domain_entry *p;
- struct nss_info_methods *m;
+
+ status = nss_init( lp_winbind_nss_info() );
+ if ( !NT_STATUS_IS_OK(status) ) {
+ DEBUG(4,("nss_get_info: Failed to init nss_info API (%s)!\n",
+ nt_errstr(status)));
+ return NULL;
+ }
for ( p=nss_domain_list; p; p=p->next ) {
if ( strequal( p->domain, domain ) )
@@ -231,12 +242,33 @@ static BOOL parse_nss_parm( const char *config, char **backend, char **domain )
if ( !p ) {
if ( !nss_domain_list ) {
- return NT_STATUS_NOT_FOUND;
+ return NULL;
}
p = nss_domain_list;
}
+ return p;
+}
+
+/********************************************************************
+ *******************************************************************/
+
+ NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid,
+ TALLOC_CTX *ctx,
+ ADS_STRUCT *ads, LDAPMessage *msg,
+ char **homedir, char **shell, char **gecos,
+ gid_t *p_gid)
+{
+ struct nss_domain_entry *p;
+ struct nss_info_methods *m;
+
+ 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, ads, msg,