From b1f4259cd5ecebfe7e4c4eb73aa32e1ed9b366b8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 1 Mar 2007 03:16:38 +0000 Subject: r21616: Delay initialization of idmap and nss_info backends until necessary so they can honor the offline logon state. (This used to be commit 15b13dfe81e861b94077c94b80117a85a5ffb999) --- source3/nsswitch/nss_info.c | 46 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) (limited to 'source3/nsswitch/nss_info.c') diff --git a/source3/nsswitch/nss_info.c b/source3/nsswitch/nss_info.c index 0b0caeee02..d251629662 100644 --- a/source3/nsswitch/nss_info.c +++ b/source3/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, -- cgit