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/group.c
static int mkfilter_group_bymember(MYLDAP_SESSION* session, const char* uid,
                                   char* buffer, size_t buflen)
{
    char dn[BUFLEN_DN];
    char safeuid[BUFLEN_SAFENAME];
    char safedn[BUFLEN_SAFEDN];
    /* escape attribute */
    if (myldap_escape(uid, safeuid, sizeof(safeuid)))
    {
        log_log(LOG_ERR, "mkfilter_group_bymember(): safeuid buffer too small");
        return -1;
    }
    /* try to translate uid to DN */
    if ((strcasecmp(attmap_group_member, "\"\"") == 0) ||
        (uid2dn(session, uid, dn, sizeof(dn)) == NULL))
        return mysnprintf(buffer, buflen, "(&%s(%s=%s))", group_filter,
                          attmap_group_memberUid, safeuid);
    /* escape DN */
    if (myldap_escape(dn, safedn, sizeof(safedn)))
    {
        log_log(LOG_ERR, "mkfilter_group_bymember(): safedn buffer too small");
        return -1;
    }
    /* also lookup using user DN */
    return mysnprintf(buffer, buflen, "(&%s(|(%s=%s)(%s=%s)))", group_filter,
                      attmap_group_memberUid, safeuid, attmap_group_member,
                      safedn);
}
/* create a search filter for searching a group entry
   by member uid, return -1 on errors */
create a search filter for searching a group entry
by member uid, return -1 on errors
create a search filter for searching a group entry by member uid return - 1 on errors
static int mkfilter_group_bymember(MYLDAP_SESSION* session, const char* uid,
                                   char* buffer, size_t buflen)
{
    char dn[BUFLEN_DN];
    char safeuid[BUFLEN_SAFENAME];
    char safedn[BUFLEN_SAFEDN];
    if (myldap_escape(uid, safeuid, sizeof(safeuid)))
    {
        log_log(LOG_ERR, "mkfilter_group_bymember(): safeuid buffer too small");
        return -1;
    }
    if ((strcasecmp(attmap_group_member, "\"\"") == 0) ||
        (uid2dn(session, uid, dn, sizeof(dn)) == NULL))
        return mysnprintf(buffer, buflen, "(&%s(%s=%s))", group_filter,
                          attmap_group_memberUid, safeuid);
    if (myldap_escape(dn, safedn, sizeof(safedn)))
    {
        log_log(LOG_ERR, "mkfilter_group_bymember(): safedn buffer too small");
        return -1;
    }
    return mysnprintf(buffer, buflen, "(&%s(|(%s=%s)(%s=%s)))", group_filter,
                      attmap_group_memberUid, safeuid, attmap_group_member,
                      safedn);
}
static int mkfilter_group_bymember ( MYLDAP_SESSION * session , const char * uid , char * buffer , size_t buflen ) { char dn [ BUFLEN_DN ] ; char safeuid [ BUFLEN_SAFENAME ] ; char safedn [ BUFLEN_SAFEDN ] ; if ( myldap_escape ( uid , safeuid , sizeof ( safeuid ) ) ) { log_log ( LOG_ERR , " " ) ; return -1 ; } if ( ( strcasecmp ( attmap_group_member , " \" \" " ) == 0 ) || ( uid2dn ( session , uid , dn , sizeof ( dn ) ) == NULL ) ) return mysnprintf ( buffer , buflen , " " , group_filter , attmap_group_memberUid , safeuid ) ; if ( myldap_escape ( dn , safedn , sizeof ( safedn ) ) ) { log_log ( LOG_ERR , " " ) ; return -1 ; } return mysnprintf ( buffer , buflen , " " , group_filter , attmap_group_memberUid , safeuid , attmap_group_member , safedn ) ; }
create a search filter for searching a group entry
by member uid, return -1 on errors
create a search filter for searching a group entry by member uid return - 1 on errors
/* escape attribute */ /* try to translate uid to DN */ /* escape DN */ /* also lookup using user DN */