Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/winbindd/nss_info.c

    r414 r745  
    2121
    2222#include "includes.h"
     23#include "ads.h"
    2324#include "nss_info.h"
    2425
     
    8889{
    8990        char *p;
    90         char *q;
    91         int len;
    9291
    9392        *backend = *domain = NULL;
     
    111110        }
    112111
    113         len = PTR_DIFF(p,config)+1;
    114         if ( (q = SMB_MALLOC_ARRAY( char, len )) == NULL ) {
    115                 SAFE_FREE( *backend );
    116                 return False;
    117         }
    118 
    119         StrnCpy( q, config, len-1);
    120         q[len-1] = '\0';
    121         *backend = q;
    122 
    123         return True;
     112        *backend = SMB_STRNDUP(config, PTR_DIFF(p, config));
     113        return (*backend != NULL);
    124114}
    125115
     
    165155 *******************************************************************/
    166156
    167  NTSTATUS nss_init( const char **nss_list )
     157static NTSTATUS nss_init(const char **nss_list)
    168158{
    169159        NTSTATUS status;
    170         static NTSTATUS nss_initialized = NT_STATUS_UNSUCCESSFUL;
     160        static bool nss_initialized = false;
    171161        int i;
    172162        char *backend, *domain;
     
    175165        /* check for previous successful initializations */
    176166
    177         if ( NT_STATUS_IS_OK(nss_initialized) )
     167        if (nss_initialized) {
    178168                return NT_STATUS_OK;
    179 
    180         /* The "template" backend should alqays be registered as it
     169        }
     170
     171        /* The "template" backend should always be registered as it
    181172           is a static module */
    182173
    183         if ( (nss_backend = nss_get_backend( "template" )) == NULL ) {
     174        nss_backend = nss_get_backend("template");
     175        if (nss_backend == NULL) {
    184176                static_init_nss_info;
    185177        }
     
    201193                /* validate the backend */
    202194
    203                 if ( (nss_backend = nss_get_backend( backend )) == NULL ) {
     195                nss_backend = nss_get_backend(backend);
     196                if (nss_backend == NULL) {
     197                        /*
     198                         * This is a freaking hack. We don't have proper
     199                         * modules for nss_info backends. Right now we have
     200                         * our standard nss_info backends in the ad backend.
     201                         */
     202                        status = smb_probe_module("idmap", "ad");
     203                        if ( !NT_STATUS_IS_OK(status) ) {
     204                                continue;
     205                        }
     206                }
     207
     208                nss_backend = nss_get_backend(backend);
     209                if (nss_backend == NULL) {
    204210                        /* attempt to register the backend */
    205211                        status = smb_probe_module( "nss_info", backend );
     
    207213                                continue;
    208214                        }
    209 
    210                         /* try again */
    211                         if ( (nss_backend = nss_get_backend( backend )) == NULL ) {
    212                                 DEBUG(0,("nss_init: unregistered backend %s!.  Skipping\n",
    213                                          backend));
    214                                 continue;
    215                         }
     215                }
     216
     217                /* try again */
     218                nss_backend = nss_get_backend(backend);
     219                if (nss_backend == NULL) {
     220                        DEBUG(0, ("nss_init: unregistered backend %s!. "
     221                                  "Skipping\n", backend));
     222                        continue;
    216223                }
    217224
     
    242249
    243250
    244                 /* we shouild default to use template here */
    245         }
    246 
    247         nss_initialized = NT_STATUS_OK;
     251                /* we should default to use template here */
     252        }
     253
     254        nss_initialized = true;
    248255
    249256        return NT_STATUS_OK;
     
    260267        status = nss_init( lp_winbind_nss_info() );
    261268        if ( !NT_STATUS_IS_OK(status) ) {
    262                 DEBUG(4,("nss_get_info: Failed to init nss_info API (%s)!\n",
    263                          nt_errstr(status)));
     269                DEBUG(4,("find_nss_domain: Failed to init nss_info API "
     270                         "(%s)!\n", nt_errstr(status)));
    264271                return NULL;
    265272        }
     
    300307 *******************************************************************/
    301308
    302 NTSTATUS nss_get_info( const char *domain, const DOM_SID *user_sid,
     309NTSTATUS nss_get_info( const char *domain, const struct dom_sid *user_sid,
    303310                       TALLOC_CTX *ctx,
    304                        ADS_STRUCT *ads, LDAPMessage *msg,
    305311                       const char **homedir, const char **shell,
    306312                       const char **gecos, gid_t *p_gid)
     
    320326        m = p->backend->methods;
    321327
    322         return m->get_nss_info( p, user_sid, ctx, ads, msg,
     328        return m->get_nss_info( p, user_sid, ctx,
    323329                                homedir, shell, gecos, p_gid );
    324330}
Note: See TracChangeset for help on using the changeset viewer.