Print this page
12236 getmembers_DN doesn't properly handle errors from __ns_ldap_dn2uid
12240 nss_ldap does not properly look up group members by distinguished name


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #include <stdlib.h>
  26 #include <strings.h>
  27 #include <ctype.h>
  28 #include <locale.h>
  29 #include <syslog.h>
  30 #include "ns_internal.h"
  31 
  32 /*
  33  * Calculate a hash for a string
  34  * Based on elf_hash algorithm, hash is case insensitive
  35  * Uses tolower instead of _tolower because of I18N
  36  */
  37 
  38 static unsigned long
  39 ns_hash(const char *str)
  40 {
  41         unsigned int    hval = 0;
  42 


 278                         dptr++;
 279                 i = dptr - sptr + 1;
 280                 *mapp = (char *)malloc(i);
 281                 if (*mapp == NULL) {
 282                         free(*sid);
 283                         *sid = NULL;
 284                         free(*origA);
 285                         *origA = NULL;
 286                         __s_api_free2dArray(*mapA);
 287                         *mapA = NULL;
 288                         return (NS_HASH_RC_NO_MEMORY);
 289                 }
 290                 (void) strlcpy(*mapp, sptr, i);
 291                 mapp++;
 292                 sptr = dptr;
 293         }
 294         return (NS_HASH_RC_SUCCESS);
 295 }
 296 
 297 
 298 static void
 299 __ns_ldap_freeASearchDesc(ns_ldap_search_desc_t *ptr)
 300 {
 301         if (ptr == NULL)
 302                 return;
 303         if (ptr->basedn)
 304                 free(ptr->basedn);
 305         if (ptr->filter)
 306                 free(ptr->filter);
 307         free(ptr);
 308 }
 309 
 310 /*
 311  * Parse a service descriptor
 312  * and create a service descriptor struct
 313  * SD Format:
 314  *    serviceid:[base][?[scope][?[filter]]];[[base][?[scope][?[filter]]]]
 315  * desc format:
 316  *    [base][?[scope][?[filter]]]
 317  */
 318 




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2020 Joyent, Inc.
  24  */
  25 
  26 #include <stdlib.h>
  27 #include <strings.h>
  28 #include <ctype.h>
  29 #include <locale.h>
  30 #include <syslog.h>
  31 #include "ns_internal.h"
  32 
  33 /*
  34  * Calculate a hash for a string
  35  * Based on elf_hash algorithm, hash is case insensitive
  36  * Uses tolower instead of _tolower because of I18N
  37  */
  38 
  39 static unsigned long
  40 ns_hash(const char *str)
  41 {
  42         unsigned int    hval = 0;
  43 


 279                         dptr++;
 280                 i = dptr - sptr + 1;
 281                 *mapp = (char *)malloc(i);
 282                 if (*mapp == NULL) {
 283                         free(*sid);
 284                         *sid = NULL;
 285                         free(*origA);
 286                         *origA = NULL;
 287                         __s_api_free2dArray(*mapA);
 288                         *mapA = NULL;
 289                         return (NS_HASH_RC_NO_MEMORY);
 290                 }
 291                 (void) strlcpy(*mapp, sptr, i);
 292                 mapp++;
 293                 sptr = dptr;
 294         }
 295         return (NS_HASH_RC_SUCCESS);
 296 }
 297 
 298 
 299 void
 300 __ns_ldap_freeASearchDesc(ns_ldap_search_desc_t *ptr)
 301 {
 302         if (ptr == NULL)
 303                 return;
 304         if (ptr->basedn)
 305                 free(ptr->basedn);
 306         if (ptr->filter)
 307                 free(ptr->filter);
 308         free(ptr);
 309 }
 310 
 311 /*
 312  * Parse a service descriptor
 313  * and create a service descriptor struct
 314  * SD Format:
 315  *    serviceid:[base][?[scope][?[filter]]];[[base][?[scope][?[filter]]]]
 316  * desc format:
 317  *    [base][?[scope][?[filter]]]
 318  */
 319