~ubuntu-branches/debian/experimental/389-ds-base/experimental

« back to all changes in this revision

Viewing changes to ldap/servers/slapd/ldaputil.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2014-07-08 15:50:11 UTC
  • mfrom: (0.2.2)
  • Revision ID: package-import@ubuntu.com-20140708155011-r66lvtioamqwaype
Tags: 1.3.2.19-1
* New upstream release.
* admin_scripts.diff: Updated to fix more bashisms.
* watch: Update the url.
* Install failedbinds.py and logregex.py scripts.
* init: Use status from init-functions.
* control: Update my email.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1022
1022
       than the currently unused clientctrls */
1023
1023
    ldap_get_option(ld, LDAP_OPT_CLIENT_CONTROLS, &clientctrls);
1024
1024
    if (clientctrls && clientctrls[0] &&
1025
 
        slapi_control_present(clientctrls, START_TLS_OID, NULL, NULL)) {
1026
 
        secure = 2;
 
1025
        slapi_control_present(clientctrls, START_TLS_OID, NULL, NULL)) {
 
1026
        secure = 2;
1027
1027
    } else {
1028
1028
#if defined(USE_OPENLDAP)
1029
1029
        /* openldap doesn't have a SSL/TLS yes/no flag - so grab the
1062
1062
            slapi_log_error(SLAPI_LOG_SHELL, "slapi_ldap_bind",
1063
1063
                            "Set up conn to use client auth\n");
1064
1064
        }
1065
 
        bvcreds.bv_val = NULL; /* ignore username and passed in creds */
1066
 
        bvcreds.bv_len = 0; /* for external auth */
1067
 
        bindid = NULL;
 
1065
        bvcreds.bv_val = NULL; /* ignore username and passed in creds */
 
1066
        bvcreds.bv_len = 0; /* for external auth */
 
1067
        bindid = NULL;
1068
1068
    } else { /* other type of auth */
1069
 
        bvcreds.bv_val = (char *)creds;
1070
 
        bvcreds.bv_len = creds ? strlen(creds) : 0;
 
1069
        bvcreds.bv_val = (char *)creds;
 
1070
        bvcreds.bv_len = creds ? strlen(creds) : 0;
1071
1071
    }
1072
1072
 
1073
1073
    if (secure == 2) { /* send start tls */
1095
1095
                        bindid, creds);
1096
1096
        if ((rc = ldap_sasl_bind(ld, bindid, mech, &bvcreds, serverctrls,
1097
1097
                                 NULL /* clientctrls */, &mymsgid))) {
1098
 
            char *myhostname = NULL;
1099
 
            char *copy = NULL;
 
1098
            char *hostname = NULL;
 
1099
            char *host_port = NULL;
1100
1100
            char *ptr = NULL;
1101
1101
            int myerrno = errno;
1102
1102
            int gaierr = 0;
1103
1103
 
1104
 
            ldap_get_option(ld, LDAP_OPT_HOST_NAME, &myhostname);
1105
 
            if (myhostname) {
1106
 
                ptr = strchr(myhostname, ':');
 
1104
            ldap_get_option(ld, LDAP_OPT_HOST_NAME, &host_port);
 
1105
            if (host_port) {
 
1106
                ptr = strchr(host_port, ':');
1107
1107
                if (ptr) {
1108
 
                    copy = slapi_ch_strdup(myhostname);
1109
 
                    *(copy + (ptr - myhostname)) = '\0';
1110
 
                    slapi_ch_free_string(&myhostname);
1111
 
                    myhostname = copy;
 
1108
                    hostname = slapi_ch_strdup(host_port);
 
1109
                    *(hostname + (ptr - host_port)) = '\0';
1112
1110
                }
1113
1111
            }
1114
 
 
1115
1112
            if (0 == myerrno) {
1116
1113
                struct addrinfo *result = NULL;
1117
 
                gaierr = getaddrinfo(myhostname, NULL, NULL, &result);
 
1114
                gaierr = getaddrinfo(hostname, NULL, NULL, &result);
1118
1115
                myerrno = errno;
1119
1116
                if (result) {
1120
1117
                    freeaddrinfo(result);
1121
1118
                }
1122
1119
            }
 
1120
 
1123
1121
            slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_bind",
1124
1122
                            "Error: could not send bind request for id "
1125
1123
                            "[%s] authentication mechanism [%s]: error %d (%s), system error %d (%s), "
1130
1128
                            PR_GetError(), slapd_pr_strerror(PR_GetError()),
1131
1129
                            myerrno ? myerrno : gaierr,
1132
1130
                            myerrno ? slapd_system_strerror(myerrno) : gai_strerror(gaierr),
1133
 
                            myhostname ? myhostname : "unknown host");
1134
 
            slapi_ch_free_string(&myhostname);
 
1131
                            host_port ? host_port : "unknown host");
 
1132
            slapi_ch_free_string(&hostname);
 
1133
            slapi_ch_free_string(&host_port);
1135
1134
            goto done;
1136
1135
        }
1137
1136