openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/nss-pam-ldapd/0.9.8-r0/nss-pam-ldapd-0.9.8/nslcd/myldap.c
int myldap_bind(MYLDAP_SESSION* session, const char* dn, const char* password,
                int* response, const char** message)
{
    MYLDAP_SEARCH* search;
    static const char* attrs[2];
    int rc;
    /* error out when buffers are too small */
    if (strlen(dn) >= sizeof(session->binddn))
    {
        log_log(LOG_ERR,
                "myldap_bind(): binddn buffer too small (%lu required)",
                (unsigned long)strlen(dn));
        return LDAP_LOCAL_ERROR;
    }
    if (strlen(password) >= sizeof(session->bindpw))
    {
        log_log(LOG_ERR,
                "myldap_bind(): bindpw buffer too small (%lu required)",
                (unsigned long)strlen(password));
        return LDAP_LOCAL_ERROR;
    }
    /* copy dn and password into session */
    strncpy(session->binddn, dn, sizeof(session->binddn));
    session->binddn[sizeof(session->binddn) - 1] = '\0';
    strncpy(session->bindpw, password, sizeof(session->bindpw));
    session->bindpw[sizeof(session->bindpw) - 1] = '\0';
    /* construct a fake search to trigger the BIND operation */
    attrs[0] = "dn";
    attrs[1] = NULL;
    search = myldap_search(session, session->binddn, MYLDAP_SCOPE_BINDONLY,
                           "(objectClass=*)", attrs, &rc);
    if (search != NULL)
        myldap_search_close(search);
    /* return ppolicy results */
    if (response != NULL)
        *response = session->policy_response;
    if (message != NULL)
        *message = session->policy_message;
    return rc;
}
/* Perform a simple bind operation and return the ppolicy results. */
Perform a simple bind operation and return the ppolicy results.
Perform a simple bind operation and return the ppolicy results .
int myldap_bind(MYLDAP_SESSION* session, const char* dn, const char* password,
                int* response, const char** message)
{
    MYLDAP_SEARCH* search;
    static const char* attrs[2];
    int rc;
    if (strlen(dn) >= sizeof(session->binddn))
    {
        log_log(LOG_ERR,
                "myldap_bind(): binddn buffer too small (%lu required)",
                (unsigned long)strlen(dn));
        return LDAP_LOCAL_ERROR;
    }
    if (strlen(password) >= sizeof(session->bindpw))
    {
        log_log(LOG_ERR,
                "myldap_bind(): bindpw buffer too small (%lu required)",
                (unsigned long)strlen(password));
        return LDAP_LOCAL_ERROR;
    }
    strncpy(session->binddn, dn, sizeof(session->binddn));
    session->binddn[sizeof(session->binddn) - 1] = '\0';
    strncpy(session->bindpw, password, sizeof(session->bindpw));
    session->bindpw[sizeof(session->bindpw) - 1] = '\0';
    attrs[0] = "dn";
    attrs[1] = NULL;
    search = myldap_search(session, session->binddn, MYLDAP_SCOPE_BINDONLY,
                           "(objectClass=*)", attrs, &rc);
    if (search != NULL)
        myldap_search_close(search);
    if (response != NULL)
        *response = session->policy_response;
    if (message != NULL)
        *message = session->policy_message;
    return rc;
}
int myldap_bind ( MYLDAP_SESSION * session , const char * dn , const char * password , int * response , const char * * message ) { MYLDAP_SEARCH * search ; static const char * attrs [ 2 ] ; int rc ; if ( strlen ( dn ) >= sizeof ( session -> binddn ) ) { log_log ( LOG_ERR , " " , ( unsigned long ) strlen ( dn ) ) ; return LDAP_LOCAL_ERROR ; } if ( strlen ( password ) >= sizeof ( session -> bindpw ) ) { log_log ( LOG_ERR , " " , ( unsigned long ) strlen ( password ) ) ; return LDAP_LOCAL_ERROR ; } strncpy ( session -> binddn , dn , sizeof ( session -> binddn ) ) ; session -> binddn [ sizeof ( session -> binddn ) - 1 ] = ' \0 ' ; strncpy ( session -> bindpw , password , sizeof ( session -> bindpw ) ) ; session -> bindpw [ sizeof ( session -> bindpw ) - 1 ] = ' \0 ' ; attrs [ 0 ] = " " ; attrs [ 1 ] = NULL ; search = myldap_search ( session , session -> binddn , MYLDAP_SCOPE_BINDONLY , " " , attrs , & rc ) ; if ( search != NULL ) myldap_search_close ( search ) ; if ( response != NULL ) * response = session -> policy_response ; if ( message != NULL ) * message = session -> policy_message ; return rc ; }
Perform a simple bind operation and return the ppolicy results.
Perform a simple bind operation and return the ppolicy results .
/* error out when buffers are too small */ /* copy dn and password into session */ /* construct a fake search to trigger the BIND operation */ /* return ppolicy results */