Print this page
NEX-18462 SMB can't view ACL if posix ID can't be mapped
Review by: Gordon Ross <gordon.ross@nexenta.com>
Review by: Evan Layton <evan.layton@nexenta.com>
NEX-14547 Get UNIX group info. from AD/LDAP with partial RFC2307 schema
NEX-13132 smbd dumping core in nss_ldap.so.1`getbymember
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/nsswitch/ldap/common/ldap_common.c
          +++ new/usr/src/lib/nsswitch/ldap/common/ldap_common.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  23   24   */
  24   25  
  25   26  #include "ldap_common.h"
  26   27  #include <malloc.h>
  27   28  #include <synch.h>
  28   29  #include <syslog.h>
  29   30  #include <rpcsvc/ypclnt.h>
  30   31  #include <rpcsvc/yp_prot.h>
  31   32  #include <thread.h>
  32   33  #include <ctype.h>
↓ open down ↓ 64 lines elided ↑ open up ↑
  97   98  
  98   99  
  99  100  nss_status_t
 100  101  switch_err(int rc, ns_ldap_error_t *error)
 101  102  {
 102  103          switch (rc) {
 103  104          case NS_LDAP_SUCCESS:
 104  105                  return (NSS_SUCCESS);
 105  106  
 106  107          case NS_LDAP_NOTFOUND:
      108 +                errno = 0;
 107  109                  return (NSS_NOTFOUND);
 108  110  
 109  111          case NS_LDAP_PARTIAL:
 110  112                  return (NSS_TRYAGAIN);
 111  113  
 112  114          case NS_LDAP_INTERNAL:
 113  115                  if (error && (error->status == LDAP_SERVER_DOWN ||
 114  116                      error->status == LDAP_TIMEOUT))
 115  117                          return (NSS_TRYAGAIN);
 116  118                  else
 117  119                          return (NSS_UNAVAIL);
 118  120  
 119  121          default:
 120  122                  return (NSS_UNAVAIL);
 121  123          }
 122  124  }
 123  125  /* ARGSUSED */
 124  126  nss_status_t
 125  127  _nss_ldap_lookup(ldap_backend_ptr be, nss_XbyY_args_t *argp,
 126      -                char *database, char *searchfilter, char *domain,
 127      -                int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
 128      -                char **realfilter, const void *userdata),
 129      -                const void *userdata)
      128 +    char *database, char *searchfilter, char *domain,
      129 +    int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
      130 +    char **realfilter, const void *userdata),
      131 +    const void *userdata)
 130  132  {
 131  133          int             callbackstat = 0;
 132  134          ns_ldap_error_t *error = NULL;
 133  135          int             rc;
 134  136  
 135  137  #ifdef  DEBUG
 136  138          (void) fprintf(stdout, "\n[ldap_common.c: _nss_ldap_lookup]\n");
 137  139          (void) fprintf(stdout, "\tsearchfilter: %s\n", searchfilter);
 138  140          (void) fprintf(stdout,
 139  141              "\tuserdata: %s\n", userdata ? userdata : "NULL");
↓ open down ↓ 99 lines elided ↑ open up ↑
 239  241  }
 240  242  
 241  243  /*
 242  244   *  This function is similar to _nss_ldap_lookup except it does not
 243  245   *  do a callback.  It is only used by getnetgrent.c
 244  246   */
 245  247  
 246  248  /* ARGSUSED */
 247  249  nss_status_t
 248  250  _nss_ldap_nocb_lookup(ldap_backend_ptr be, nss_XbyY_args_t *argp,
 249      -                char *database, char *searchfilter, char *domain,
 250      -                int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
 251      -                char **realfilter, const void *userdata),
 252      -                const void *userdata)
      251 +    char *database, char *searchfilter, const char * const *attrs,
      252 +    int (*init_filter_cb)(const ns_ldap_search_desc_t *desc,
      253 +    char **realfilter, const void *userdata),
      254 +    const void *userdata)
 253  255  {
 254  256          ns_ldap_error_t *error = NULL;
 255  257          int             rc;
 256  258  
      259 +        if (attrs == NULL)
      260 +                attrs = be->attrs;
      261 +
 257  262  #ifdef  DEBUG
 258  263          (void) fprintf(stdout, "\n[ldap_common.c: _nss_ldap_nocb_lookup]\n");
 259  264          (void) fprintf(stdout, "\tsearchfilter: %s\n", searchfilter);
 260  265          (void) fprintf(stdout, "\tdatabase: %s\n", database);
 261  266          (void) fprintf(stdout,
 262  267              "\tuserdata: %s\n", userdata ? userdata : "NULL");
 263  268  #endif  /* DEBUG */
 264  269  
 265  270          (void) __ns_ldap_freeResult(&be->result);
 266  271  
 267  272          if ((rc = __ns_ldap_list(database, searchfilter, init_filter_cb,
 268      -            be->attrs, NULL, 0, &be->result, &error, NULL,
      273 +            attrs, NULL, 0, &be->result, &error, NULL,
 269  274              userdata)) != NS_LDAP_SUCCESS) {
 270  275                  if (argp != NULL)
 271  276                          argp->returnval = 0;
 272  277                  rc = switch_err(rc, error);
 273  278                  (void) __ns_ldap_freeError(&error);
 274  279                  return (rc);
 275  280          }
 276  281  
 277  282          return ((nss_status_t)NSS_SUCCESS);
 278  283  }
↓ open down ↓ 245 lines elided ↑ open up ↑
 524  529          return ((nss_status_t)NSS_SUCCESS);
 525  530  }
 526  531  
 527  532  
 528  533  /*
 529  534   *
 530  535   */
 531  536  
 532  537  nss_backend_t *
 533  538  _nss_ldap_constr(ldap_backend_op_t ops[], int nops, char *tablename,
 534      -                const char **attrs, fnf ldapobj2str)
      539 +    const char **attrs, fnf ldapobj2str)
 535  540  {
 536  541          ldap_backend_ptr        be;
 537  542  
 538  543  #ifdef  DEBUG
 539  544          (void) fprintf(stdout, "\n[ldap_common.c: _nss_ldap_constr]\n");
 540  545  #endif  /* DEBUG */
 541  546  
 542  547          if ((be = (ldap_backend_ptr) calloc(1, sizeof (*be))) == 0)
 543  548                  return (0);
 544  549          be->ops = ops;
↓ open down ↓ 61 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX