s3:winbind: Slightly simplify the logic of nss_init(), make it static
authorVolker Lendecke <vl@samba.org>
Mon, 5 Oct 2009 20:09:01 +0000 (22:09 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 5 Oct 2009 20:12:35 +0000 (22:12 +0200)
source3/include/nss_info.h
source3/winbindd/nss_info.c

index 90d992a3b948a7421a77602b8e638dcbfa967828..a60a6f0dc0ebdd43ee75d8f43272d145266b772f 100644 (file)
@@ -83,8 +83,6 @@ NTSTATUS smb_register_idmap_nss(int version,
                                const char *name, 
                                struct nss_info_methods *methods);
 
-NTSTATUS nss_init( const char **nss_list );
-
 NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid,
                       TALLOC_CTX *ctx,
                       ADS_STRUCT *ads, LDAPMessage *msg,
index ecf942a5d354b60b34820673ffd441cc3e4a745b..663fc9a2a57ceaf1a90d8d9ceb5485ddf6a683ff 100644 (file)
@@ -164,23 +164,25 @@ static NTSTATUS nss_domain_list_add_domain(const char *domain,
  to initialize the state on a per domain basis.
  *******************************************************************/
 
- NTSTATUS nss_init( const char **nss_list )
+static NTSTATUS nss_init(const char **nss_list)
 {
        NTSTATUS status;
-       static NTSTATUS nss_initialized = NT_STATUS_UNSUCCESSFUL;
+       static bool nss_initialized = false;
        int i;
        char *backend, *domain;
        struct nss_function_entry *nss_backend;
 
        /* check for previous successful initializations */
 
-       if ( NT_STATUS_IS_OK(nss_initialized) )
+       if (nss_initialized) {
                return NT_STATUS_OK;
+       }
 
        /* The "template" backend should always be registered as it
           is a static module */
 
-       if ( (nss_backend = nss_get_backend( "template" )) == NULL ) {
+       nss_backend = nss_get_backend("template");
+       if (nss_backend == NULL) {
                static_init_nss_info;
        }
 
@@ -200,19 +202,21 @@ static NTSTATUS nss_domain_list_add_domain(const char *domain,
 
                /* validate the backend */
 
-               if ( (nss_backend = nss_get_backend( backend )) == NULL ) {
+               nss_backend = nss_get_backend(backend);
+               if (nss_backend == NULL) {
                        /* attempt to register the backend */
                        status = smb_probe_module( "nss_info", backend );
                        if ( !NT_STATUS_IS_OK(status) ) {
                                continue;
                        }
+               }
 
-                       /* try again */
-                       if ( (nss_backend = nss_get_backend( backend )) == NULL ) {
-                               DEBUG(0,("nss_init: unregistered backend %s!.  Skipping\n",
-                                        backend));
-                               continue;
-                       }
+               /* try again */
+               nss_backend = nss_get_backend(backend);
+               if (nss_backend == NULL) {
+                       DEBUG(0, ("nss_init: unregistered backend %s!. "
+                                 "Skipping\n", backend));
+                       continue;
                }
 
                /*
@@ -244,7 +248,7 @@ static NTSTATUS nss_domain_list_add_domain(const char *domain,
                /* we should default to use template here */
        }
 
-       nss_initialized = NT_STATUS_OK;
+       nss_initialized = true;
 
        return NT_STATUS_OK;
 }