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


   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 /*
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.

  25  */
  26 
  27 
  28 #ifndef _NS_INTERNAL_H
  29 #define _NS_INTERNAL_H
  30 
  31 #ifdef __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #include <stdio.h>
  36 #include <sys/types.h>
  37 #include <sys/time.h>
  38 #include <thread.h>
  39 #include <lber.h>
  40 #include <ldap.h>
  41 #include "ns_sldap.h"
  42 #include "ns_cache_door.h"
  43 
  44 /*


  50 #define FALSE                   0
  51 #define NSLDAPDIRECTORY         "/var/ldap"
  52 #define NSCONFIGFILE            "/var/ldap/ldap_client_file"
  53 #define NSCONFIGREFRESH         "/var/ldap/ldap_client_file.refresh"
  54 #define NSCREDFILE              "/var/ldap/ldap_client_cred"
  55 #define NSCREDREFRESH           "/var/ldap/ldap_client_cred.refresh"
  56 #define ROTORSIZE               256
  57 #define MASK                    0377
  58 #define LDAPMAXHARDLOOKUPTIME   256
  59 #define DONOTEDIT               \
  60         "Do not edit this file manually; your changes will be lost." \
  61         "Please use ldapclient (1M) instead."
  62 #define MAXPORTNUMBER           65535
  63 #define MAXPORTNUMBER_STR       "65535"
  64 #define CREDFILE                0
  65 #define CONFIGFILE              1
  66 #define UIDNUMFILTER            "(&(objectclass=posixAccount)(uidnumber=%s))"
  67 #define UIDNUMFILTER_SSD        "(&(%%s)(uidnumber=%s))"
  68 #define UIDFILTER               "(&(objectclass=posixAccount)(uid=%s))"
  69 #define UIDFILTER_SSD           "(&(%%s)(uid=%s))"
  70 #define UIDDNFILTER     "(&(objectclass=posixAccount)(distinguishedName=%s))"
  71 #define UIDDNFILTER_SSD         "(&(%%s)(distinguishedName=%s))"
  72 
  73 #define HOSTFILTER              "(&(objectclass=ipHost)(cn=%s))"
  74 #define HOSTFILTER_SSD          "(&(%%s)(cn=%s))"
  75 
  76 #define SIMPLEPAGECTRLFLAG      1
  77 #define VLVCTRLFLAG             2
  78 
  79 #define LISTPAGESIZE            1000
  80 #define ENUMPAGESIZE            100
  81 
  82 #define DEFMAX                  8
  83 #define TOKENSEPARATOR          '='
  84 #define QUOTETOK                '"'
  85 #define SPACETOK                ' '
  86 #define COMMATOK                ','
  87 #define COLONTOK                ':'
  88 #define QUESTTOK                '?'
  89 #define SEMITOK                 ';'
  90 #define TABTOK                  '\t'
  91 #define OPARATOK                '('


 748 
 749 /* internal connection APIs */
 750 void DropConnection(ConnectionID, int);
 751 int __s_api_getServers(char *** servers, ns_ldap_error_t ** error);
 752 
 753 int __s_get_enum_value(ns_config_t *ptr, char *value, ParamIndexType i);
 754 char *__s_get_auth_name(ns_config_t *ptr, AuthType_t type);
 755 char *__s_get_security_name(ns_config_t *ptr, TlsType_t type);
 756 char *__s_get_scope_name(ns_config_t *ptr, ScopeType_t type);
 757 char *__s_get_pref_name(PrefOnly_t type);
 758 char *__s_get_searchref_name(ns_config_t *ptr, SearchRef_t type);
 759 char *__s_get_shadowupdate_name(enableShadowUpdate_t type);
 760 char *__s_get_hostcertpath(void);
 761 void __s_api_free_sessionPool();
 762 int __s_api_requestServer(const char *request, const char *server,
 763         ns_server_info_t *ret, ns_ldap_error_t **error,  const char *addrType);
 764 
 765 
 766 /* ************ internal sldap-api functions *********** */
 767 void    __ns_ldap_freeEntry(ns_ldap_entry_t *ep);

 768 void    __s_api_split_key_value(char *buffer, char **name, char **value);
 769 int     __s_api_printResult(ns_ldap_result_t *);
 770 int     __s_api_getSearchScope(int *, ns_ldap_error_t **);
 771 int     __s_api_getDNs(char ***, const char *,
 772         ns_ldap_error_t **);
 773 int     __s_api_get_search_DNs_v1(char ***, const char *,
 774         ns_ldap_error_t **);
 775 int     __s_api_getConnection(const char *, const int,
 776         const ns_cred_t *, int *,
 777         Connection **, ns_ldap_error_t **, int, int, ns_conn_user_t *);
 778 char    **__s_api_cp2dArray(char **);
 779 void    __s_api_free2dArray(char **);
 780 
 781 int     __s_api_isCtrlSupported(Connection *, char *);
 782 ns_config_t *__ns_ldap_make_config(ns_ldap_result_t *result);
 783 ns_auth_t  *__s_api_AuthEnumtoStruct(const EnumAuthType_t i);
 784 boolean_t __s_api_peruser_proc(void);
 785 boolean_t __s_api_nscd_proc(void);
 786 char    *dvalue(char *);
 787 char    *evalue(char *);


 839 void            __s_api_destroy_hash(ns_config_t *config);
 840 int             __s_api_parse_map(char *cp, char **sid,
 841                                 char **origA, char ***mapA);
 842 char            **__ns_ldap_mapAttributeList(const char *service,
 843                                 const char * const *origAttrList);
 844 char            *__ns_ldap_mapAttribute(const char *service,
 845                                 const char *origAttr);
 846 
 847 /* internal configuration APIs */
 848 void            __ns_ldap_setServer(int set);
 849 ns_ldap_error_t *__ns_ldap_LoadConfiguration();
 850 ns_ldap_error_t *__ns_ldap_LoadDoorInfo(LineBuf *configinfo, char *domainname,
 851                                 ns_config_t *new, int cred_only);
 852 ns_ldap_error_t *__ns_ldap_DumpConfiguration(char *filename);
 853 ns_ldap_error_t *__ns_ldap_DumpLdif(char *filename);
 854 int             __ns_ldap_cache_ping();
 855 ns_ldap_error_t *__ns_ldap_print_config(int);
 856 void            __ns_ldap_default_config();
 857 int             __ns_ldap_download(const char *, char *, char *,
 858                                 ns_ldap_error_t **);
 859 int
 860 __ns_ldap_check_dns_preq(int foreground,
 861                 int mode_verbose,
 862                 int mode_quiet,
 863                 const char *fname,
 864                 ns_ldap_self_gssapi_config_t config,
 865                 ns_ldap_error_t **errpp);
 866 int
 867 __ns_ldap_check_gssapi_preq(int foreground,
 868                 int mode_verbose,
 869                 int mode_quiet,
 870                 ns_ldap_self_gssapi_config_t config,
 871                 ns_ldap_error_t **errpp);
 872 int
 873 __ns_ldap_check_all_preq(int foreground,
 874                 int mode_verbose,
 875                 int mode_quiet,
 876                 ns_ldap_self_gssapi_config_t config,
 877                 ns_ldap_error_t **errpp);
 878 



 879 /* internal un-exposed APIs */
 880 ns_cred_t       *__ns_ldap_dupAuth(const ns_cred_t *authp);
 881 boolean_t       __s_api_is_auth_matched(const ns_cred_t *auth1,
 882                     const ns_cred_t *auth2);
 883 int             __s_api_get_SSD_from_SSDtoUse_service(const char *service,
 884                         ns_ldap_search_desc_t ***SSDlist,
 885                         ns_ldap_error_t **errorp);
 886 int             __s_api_prepend_automountmapname(const char *service,
 887                         ns_ldap_search_desc_t ***SSDlist,
 888                         ns_ldap_error_t ** errorp);
 889 int             __s_api_prepend_automountmapname_to_dn(const char *service,
 890                         char **basedn,
 891                         ns_ldap_error_t ** errorp);
 892 int             __s_api_convert_automountmapname(const char *service,
 893                         char **dn, ns_ldap_error_t ** errorp);
 894 int             __s_api_replace_mapped_attr_in_dn(
 895                         const char *orig_attr, const char *mapped_attr,
 896                         const char *dn, char **new_dn);
 897 int             __s_api_append_default_basedn(
 898                         const char *dn,




   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 /*
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  25  * Copyright 2020 Joyent, Inc.
  26  */
  27 
  28 
  29 #ifndef _NS_INTERNAL_H
  30 #define _NS_INTERNAL_H
  31 
  32 #ifdef __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 #include <stdio.h>
  37 #include <sys/types.h>
  38 #include <sys/time.h>
  39 #include <thread.h>
  40 #include <lber.h>
  41 #include <ldap.h>
  42 #include "ns_sldap.h"
  43 #include "ns_cache_door.h"
  44 
  45 /*


  51 #define FALSE                   0
  52 #define NSLDAPDIRECTORY         "/var/ldap"
  53 #define NSCONFIGFILE            "/var/ldap/ldap_client_file"
  54 #define NSCONFIGREFRESH         "/var/ldap/ldap_client_file.refresh"
  55 #define NSCREDFILE              "/var/ldap/ldap_client_cred"
  56 #define NSCREDREFRESH           "/var/ldap/ldap_client_cred.refresh"
  57 #define ROTORSIZE               256
  58 #define MASK                    0377
  59 #define LDAPMAXHARDLOOKUPTIME   256
  60 #define DONOTEDIT               \
  61         "Do not edit this file manually; your changes will be lost." \
  62         "Please use ldapclient (1M) instead."
  63 #define MAXPORTNUMBER           65535
  64 #define MAXPORTNUMBER_STR       "65535"
  65 #define CREDFILE                0
  66 #define CONFIGFILE              1
  67 #define UIDNUMFILTER            "(&(objectclass=posixAccount)(uidnumber=%s))"
  68 #define UIDNUMFILTER_SSD        "(&(%%s)(uidnumber=%s))"
  69 #define UIDFILTER               "(&(objectclass=posixAccount)(uid=%s))"
  70 #define UIDFILTER_SSD           "(&(%%s)(uid=%s))"
  71 #define UIDDNFILTER             "(objectclass=posixAccount)"

  72 
  73 #define HOSTFILTER              "(&(objectclass=ipHost)(cn=%s))"
  74 #define HOSTFILTER_SSD          "(&(%%s)(cn=%s))"
  75 
  76 #define SIMPLEPAGECTRLFLAG      1
  77 #define VLVCTRLFLAG             2
  78 
  79 #define LISTPAGESIZE            1000
  80 #define ENUMPAGESIZE            100
  81 
  82 #define DEFMAX                  8
  83 #define TOKENSEPARATOR          '='
  84 #define QUOTETOK                '"'
  85 #define SPACETOK                ' '
  86 #define COMMATOK                ','
  87 #define COLONTOK                ':'
  88 #define QUESTTOK                '?'
  89 #define SEMITOK                 ';'
  90 #define TABTOK                  '\t'
  91 #define OPARATOK                '('


 748 
 749 /* internal connection APIs */
 750 void DropConnection(ConnectionID, int);
 751 int __s_api_getServers(char *** servers, ns_ldap_error_t ** error);
 752 
 753 int __s_get_enum_value(ns_config_t *ptr, char *value, ParamIndexType i);
 754 char *__s_get_auth_name(ns_config_t *ptr, AuthType_t type);
 755 char *__s_get_security_name(ns_config_t *ptr, TlsType_t type);
 756 char *__s_get_scope_name(ns_config_t *ptr, ScopeType_t type);
 757 char *__s_get_pref_name(PrefOnly_t type);
 758 char *__s_get_searchref_name(ns_config_t *ptr, SearchRef_t type);
 759 char *__s_get_shadowupdate_name(enableShadowUpdate_t type);
 760 char *__s_get_hostcertpath(void);
 761 void __s_api_free_sessionPool();
 762 int __s_api_requestServer(const char *request, const char *server,
 763         ns_server_info_t *ret, ns_ldap_error_t **error,  const char *addrType);
 764 
 765 
 766 /* ************ internal sldap-api functions *********** */
 767 void    __ns_ldap_freeEntry(ns_ldap_entry_t *ep);
 768 void    __ns_ldap_freeASearchDesc(ns_ldap_search_desc_t *);
 769 void    __s_api_split_key_value(char *buffer, char **name, char **value);
 770 int     __s_api_printResult(ns_ldap_result_t *);
 771 int     __s_api_getSearchScope(int *, ns_ldap_error_t **);
 772 int     __s_api_getDNs(char ***, const char *,
 773         ns_ldap_error_t **);
 774 int     __s_api_get_search_DNs_v1(char ***, const char *,
 775         ns_ldap_error_t **);
 776 int     __s_api_getConnection(const char *, const int,
 777         const ns_cred_t *, int *,
 778         Connection **, ns_ldap_error_t **, int, int, ns_conn_user_t *);
 779 char    **__s_api_cp2dArray(char **);
 780 void    __s_api_free2dArray(char **);
 781 
 782 int     __s_api_isCtrlSupported(Connection *, char *);
 783 ns_config_t *__ns_ldap_make_config(ns_ldap_result_t *result);
 784 ns_auth_t  *__s_api_AuthEnumtoStruct(const EnumAuthType_t i);
 785 boolean_t __s_api_peruser_proc(void);
 786 boolean_t __s_api_nscd_proc(void);
 787 char    *dvalue(char *);
 788 char    *evalue(char *);


 840 void            __s_api_destroy_hash(ns_config_t *config);
 841 int             __s_api_parse_map(char *cp, char **sid,
 842                                 char **origA, char ***mapA);
 843 char            **__ns_ldap_mapAttributeList(const char *service,
 844                                 const char * const *origAttrList);
 845 char            *__ns_ldap_mapAttribute(const char *service,
 846                                 const char *origAttr);
 847 
 848 /* internal configuration APIs */
 849 void            __ns_ldap_setServer(int set);
 850 ns_ldap_error_t *__ns_ldap_LoadConfiguration();
 851 ns_ldap_error_t *__ns_ldap_LoadDoorInfo(LineBuf *configinfo, char *domainname,
 852                                 ns_config_t *new, int cred_only);
 853 ns_ldap_error_t *__ns_ldap_DumpConfiguration(char *filename);
 854 ns_ldap_error_t *__ns_ldap_DumpLdif(char *filename);
 855 int             __ns_ldap_cache_ping();
 856 ns_ldap_error_t *__ns_ldap_print_config(int);
 857 void            __ns_ldap_default_config();
 858 int             __ns_ldap_download(const char *, char *, char *,
 859                                 ns_ldap_error_t **);
 860 int __ns_ldap_check_dns_preq(int foreground, int mode_verbose, int mode_quiet,
 861     const char *fname, ns_ldap_self_gssapi_config_t config,




 862     ns_ldap_error_t **errpp);
 863 
 864 int __ns_ldap_check_gssapi_preq(int foreground, int mode_verbose,
 865     int mode_quiet, ns_ldap_self_gssapi_config_t config,


 866     ns_ldap_error_t **errpp);






 867 
 868 int __ns_ldap_check_all_preq(int foreground, int mode_verbose, int mode_quiet,
 869     ns_ldap_self_gssapi_config_t config, ns_ldap_error_t **errpp);
 870 
 871 /* internal un-exposed APIs */
 872 ns_cred_t       *__ns_ldap_dupAuth(const ns_cred_t *authp);
 873 boolean_t       __s_api_is_auth_matched(const ns_cred_t *auth1,
 874                     const ns_cred_t *auth2);
 875 int             __s_api_get_SSD_from_SSDtoUse_service(const char *service,
 876                         ns_ldap_search_desc_t ***SSDlist,
 877                         ns_ldap_error_t **errorp);
 878 int             __s_api_prepend_automountmapname(const char *service,
 879                         ns_ldap_search_desc_t ***SSDlist,
 880                         ns_ldap_error_t ** errorp);
 881 int             __s_api_prepend_automountmapname_to_dn(const char *service,
 882                         char **basedn,
 883                         ns_ldap_error_t ** errorp);
 884 int             __s_api_convert_automountmapname(const char *service,
 885                         char **dn, ns_ldap_error_t ** errorp);
 886 int             __s_api_replace_mapped_attr_in_dn(
 887                         const char *orig_attr, const char *mapped_attr,
 888                         const char *dn, char **new_dn);
 889 int             __s_api_append_default_basedn(
 890                         const char *dn,