Replace deprecated ldap_explode_dn() with calls to ldap_str2dn()
and ldap_rdn2str().
This commit is contained in:
23
ldap.c
23
ldap.c
@@ -856,9 +856,8 @@ sudo_ldap_display_privs(nss, pw)
|
|||||||
{
|
{
|
||||||
struct berval **bv, **p;
|
struct berval **bv, **p;
|
||||||
LDAP *ld = (LDAP *) nss->handle;
|
LDAP *ld = (LDAP *) nss->handle;
|
||||||
LDAPMessage *entry = NULL, *result = NULL; /* used for searches */
|
LDAPMessage *entry = NULL, *result = NULL;
|
||||||
char *filt; /* used to parse attributes */
|
char *filt, *dn, *rdn;
|
||||||
char *dn, **edn;
|
|
||||||
int rc, do_netgr;
|
int rc, do_netgr;
|
||||||
|
|
||||||
if (ld == NULL)
|
if (ld == NULL)
|
||||||
@@ -916,14 +915,20 @@ sudo_ldap_display_privs(nss, pw)
|
|||||||
sudo_ldap_check_user_netgroup(ld, entry, pw->pw_passwd)) &&
|
sudo_ldap_check_user_netgroup(ld, entry, pw->pw_passwd)) &&
|
||||||
sudo_ldap_check_host(ld, entry)) {
|
sudo_ldap_check_host(ld, entry)) {
|
||||||
|
|
||||||
/* collect the dn, only show the rdn */
|
/* collect the dn, only show the first rdn */
|
||||||
dn = ldap_get_dn(ld, entry);
|
rdn = NULL;
|
||||||
edn = dn ? ldap_explode_dn(dn, 1) : NULL;
|
if ((dn = ldap_get_dn(ld, entry)) != NULL) {
|
||||||
printf("\nLDAP Role: %s\n", (edn && *edn) ? *edn : "UNKNOWN");
|
LDAPDN tmpDN;
|
||||||
|
if (ldap_str2dn(dn, &tmpDN, LDAP_DN_FORMAT_LDAP) == LDAP_SUCCESS) {
|
||||||
|
ldap_rdn2str(tmpDN[0], &rdn, LDAP_DN_FORMAT_UFN);
|
||||||
|
ldap_dnfree(tmpDN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\nLDAP Role: %s\n", rdn ? rdn : "UNKNOWN");
|
||||||
if (dn)
|
if (dn)
|
||||||
ldap_memfree(dn);
|
ldap_memfree(dn);
|
||||||
if (edn)
|
if (rdn)
|
||||||
ldap_value_free(edn);
|
ldap_memfree(rdn);
|
||||||
|
|
||||||
/* get the Option Values from the entry */
|
/* get the Option Values from the entry */
|
||||||
bv = ldap_get_values_len(ld, entry, "sudoOption");
|
bv = ldap_get_values_len(ld, entry, "sudoOption");
|
||||||
|
Reference in New Issue
Block a user