Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-09-14 23:51:38 +0200
committerArthur de Jong <arthur@arthurdejong.org>2007-09-14 23:51:38 +0200
commitb928d6184346cd5a93f103633a5c7e5307437cd5 (patch)
tree810e4aaad4fe40c7e3f2a3d48043c87aabdeafbf
parent50ca074832b567ee1440b18c33b1fdbab6a2c25e (diff)
move _nss_ldap_dn2uid() from util.c to group.c
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@399 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/group.c39
-rw-r--r--nslcd/util.c49
-rw-r--r--nslcd/util.h7
3 files changed, 39 insertions, 56 deletions
diff --git a/nslcd/group.c b/nslcd/group.c
index 9d85917..532e7f3 100644
--- a/nslcd/group.c
+++ b/nslcd/group.c
@@ -487,6 +487,45 @@ do_construct_range_attribute (const char *attribute,
return NSS_STATUS_SUCCESS;
}
+static enum nss_status _nss_ldap_dn2uid(MYLDAP_SESSION *session,const char *dn,char **uid,char **buffer,
+ size_t * buflen,int *pIsNestedGroup,
+ LDAPMessage **pRes)
+{
+ enum nss_status status;
+ const char *attrs[4];
+ LDAPMessage *res,*e;
+
+ *pIsNestedGroup = 0;
+
+ attrs[0] = attmap_passwd_uid;
+ attrs[1] = attmap_group_uniqueMember;
+ attrs[2] = "objectClass";
+ attrs[3] = NULL;
+
+ if ((status=_nss_ldap_read_sync(session,dn,attrs,&res))==NSS_STATUS_SUCCESS)
+ {
+ e=_nss_ldap_first_entry(session,res);
+ if (e != NULL)
+ {
+ /* FIXME: somehow replace this with the dynamic stuff in group.c */
+ if (has_objectclass(session,e,"posixGroup"))
+ {
+ *pIsNestedGroup = 1;
+ *pRes = res;
+ log_log(LOG_DEBUG,"<== _nss_ldap_dn2uid (nested group)");
+ return NSS_STATUS_SUCCESS;
+ }
+
+ status=_nss_ldap_assign_attrval(session,e,attmap_passwd_uid,uid,buffer,buflen);
+ }
+ }
+ ldap_msgfree (res);
+
+ log_log(LOG_DEBUG,"<== _nss_ldap_dn2uid");
+
+ return status;
+}
+
/*
* Expand group members, including nested groups
*/
diff --git a/nslcd/util.c b/nslcd/util.c
index 0dad86c..3b737c3 100644
--- a/nslcd/util.c
+++ b/nslcd/util.c
@@ -309,55 +309,6 @@ dn2uid_cache_get (const char *dn, char **uid, char **buffer, size_t * buflen)
return NSS_STATUS_SUCCESS;
}
-/* TODO: move to group.c */
-enum nss_status _nss_ldap_dn2uid(MYLDAP_SESSION *session,const char *dn,char **uid,char **buffer,
- size_t * buflen,int *pIsNestedGroup,
- LDAPMessage **pRes)
-{
- enum nss_status status;
-
- log_log(LOG_DEBUG,"==> _nss_ldap_dn2uid");
-
- *pIsNestedGroup = 0;
-
- status = dn2uid_cache_get (dn, uid, buffer, buflen);
- if (status == NSS_STATUS_NOTFOUND)
- {
- const char *attrs[4];
- LDAPMessage *res;
-
- attrs[0] = attmap_passwd_uid;
- attrs[1] = attmap_group_uniqueMember;
- attrs[2] = "objectClass";
- attrs[3] = NULL;
-
- if (_nss_ldap_read_sync(session,dn,attrs,&res)==NSS_STATUS_SUCCESS)
- {
- LDAPMessage *e=_nss_ldap_first_entry(session,res);
- if (e != NULL)
- {
- /* FIXME: somehow replace this with the dynamic stuff in group.c */
- if (has_objectclass(session,e,"posixGroup"))
- {
- *pIsNestedGroup = 1;
- *pRes = res;
- log_log(LOG_DEBUG,"<== _nss_ldap_dn2uid (nested group)");
- return NSS_STATUS_SUCCESS;
- }
-
- status=_nss_ldap_assign_attrval(session,e,attmap_passwd_uid,uid,buffer,buflen);
- if (status == NSS_STATUS_SUCCESS)
- dn2uid_cache_put (dn, *uid);
- }
- }
- ldap_msgfree (res);
- }
-
- log_log(LOG_DEBUG,"<== _nss_ldap_dn2uid");
-
- return status;
-}
-
static enum nss_status
do_getrdnvalue (const char *dn,
const char *rdntype,
diff --git a/nslcd/util.h b/nslcd/util.h
index 63ecfff..c118f50 100644
--- a/nslcd/util.h
+++ b/nslcd/util.h
@@ -35,13 +35,6 @@ enum nss_status _nss_ldap_getrdnvalue(
char **rval,char **buffer,size_t * buflen);
/*
- * map a distinguished name to a login name, or group entry
- */
-enum nss_status _nss_ldap_dn2uid(
- MYLDAP_SESSION *session,const char *dn,char **uid,char **buffer,
- size_t *buflen,int *pIsNestedGroup,LDAPMessage **pRes);
-
-/*
* Escape '*' in a string for use as a filter
*/
int _nss_ldap_escape_string(const char *src,char *buffer,size_t buflen);