nss-pam-ldapd commit: r1281 - in nss-pam-ldapd-solaris: . nss
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1281 - in nss-pam-ldapd-solaris: . nss
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1281 - in nss-pam-ldapd-solaris: . nss
- Date: Fri, 15 Oct 2010 13:22:49 +0200 (CEST)
Author: arthur
Date: Fri Oct 15 13:22:47 2010
New Revision: 1281
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1281
Log:
switch to using SETs to follow the netgroups
Modified:
nss-pam-ldapd-solaris/configure.ac
nss-pam-ldapd-solaris/nss/Makefile.am
nss-pam-ldapd-solaris/nss/common.c
nss-pam-ldapd-solaris/nss/common.h
nss-pam-ldapd-solaris/nss/netgroup.c
Modified: nss-pam-ldapd-solaris/configure.ac
==============================================================================
--- nss-pam-ldapd-solaris/configure.ac Fri Oct 15 12:58:46 2010 (r1280)
+++ nss-pam-ldapd-solaris/configure.ac Fri Oct 15 13:22:47 2010 (r1281)
@@ -704,6 +704,9 @@
AC_SUBST(nslcd_LIBS)
fi
+AM_CONDITIONAL([NSS_FLAVOUR_GLIBC], [test "x${with_nss_flavour}" = xglibc])
+AM_CONDITIONAL([NSS_FLAVOUR_SOLARIS], [test "x${with_nss_flavour}" = xsolaris])
+
# generate files
AC_CONFIG_FILES([Makefile compat/Makefile common/Makefile nss/Makefile
pam/Makefile nslcd/Makefile man/Makefile tests/Makefile])
Modified: nss-pam-ldapd-solaris/nss/Makefile.am
==============================================================================
--- nss-pam-ldapd-solaris/nss/Makefile.am Fri Oct 15 12:58:46 2010
(r1280)
+++ nss-pam-ldapd-solaris/nss/Makefile.am Fri Oct 15 13:22:47 2010
(r1281)
@@ -33,6 +33,9 @@
shadow.c
nss_ldap_so_DEPENDENCIES = $(NSS_MODULE_OBJS)
nss_ldap_so_LDADD = $(NSS_MODULE_OBJS) ../common/libtio.a ../common/libprot.a
+if NSS_FLAVOUR_SOLARIS
+nss_ldap_so_LDADD += ../common/libdict.a
+endif
EXTRA_DIST = exports.glibc exports.solaris
Modified: nss-pam-ldapd-solaris/nss/common.c
==============================================================================
--- nss-pam-ldapd-solaris/nss/common.c Fri Oct 15 12:58:46 2010 (r1280)
+++ nss-pam-ldapd-solaris/nss/common.c Fri Oct 15 13:22:47 2010 (r1281)
@@ -1,8 +1,7 @@
/*
- common.c - common functions for NSS lookups
+ common.c - common definitions
Copyright (C) 2010 Arthur de Jong
- Copyright (C) 2010 Symas Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -20,92 +19,4 @@
02110-1301 USA
*/
-#include "config.h"
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif /* HAVE_STDINT_H */
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#ifdef HAVE_NSS_H
-#include <nss.h>
-#endif /* HAVE_NSS_H */
-#include <string.h>
-
-#include "nslcd.h"
-#include "common.h"
-#include "common/tio.h"
-
-/* flag used to disable NSS lookups using this module */
int _nss_ldap_enablelookups=1;
-
-#ifdef NSS_FLAVOUR_SOLARIS
-/* Adapted from PADL */
-
-/* add a nested netgroup or group to the namelist */
-nss_status_t _nss_ldap_namelist_push(struct name_list **head,const char *name)
-{
- struct name_list *nl;
- nl=(struct name_list *)malloc(sizeof(*nl));
- if (nl==NULL)
- return NSS_STATUS_TRYAGAIN;
- nl->name=strdup(name);
- if (nl->name==NULL)
- {
- free(nl);
- return NSS_STATUS_TRYAGAIN;
- }
- nl->next=*head;
- *head=nl;
- return NSS_STATUS_SUCCESS;
-}
-
-/* remove last nested netgroup or group from the namelist */
-void _nss_ldap_namelist_pop(struct name_list **head)
-{
- struct name_list *nl;
- nl=*head;
- *head=nl->next;
- free(nl->name);
- free(nl);
-}
-
-/* cleanup nested netgroup or group namelist */
-void _nss_ldap_namelist_destroy(struct name_list **head)
-{
- struct name_list *p,*next;
- for (p=*head;p!=NULL;p=next)
- {
- next=p->next;
- if (p->name!=NULL)
- free(p->name);
- free(p);
- }
- *head=NULL;
-}
-
-/*
- *Check whether we have already seen a netgroup or group,
- *to avoid loops in nested netgroup traversal
- */
-int _nss_ldap_namelist_find(struct name_list *head,const char *netgroup)
-{
- struct name_list *p;
- int found=0;
- for (p=head;p!=NULL;p=p->next)
- {
- if (strcasecmp(p->name,netgroup)==0)
- {
- found++;
- break;
- }
- }
- return found;
-}
-
-#endif /* NSS_FLAVOUR_SOLARIS */
Modified: nss-pam-ldapd-solaris/nss/common.h
==============================================================================
--- nss-pam-ldapd-solaris/nss/common.h Fri Oct 15 12:58:46 2010 (r1280)
+++ nss-pam-ldapd-solaris/nss/common.h Fri Oct 15 13:22:47 2010 (r1281)
@@ -31,18 +31,6 @@
#include "compat/attrs.h"
#include "compat/nss_compat.h"
-/* Adapted from PADL */
-/* Routines for managing namelists */
-struct name_list
-{
- char *name;
- struct name_list *next;
-};
-nss_status_t _nss_ldap_namelist_push(struct name_list **head,const char *name);
-void _nss_ldap_namelist_pop(struct name_list **head);
-int _nss_ldap_namelist_find(struct name_list *head,const char *netgroup);
-void _nss_ldap_namelist_destroy(struct name_list **head);
-
/* These are macros for handling read and write problems, they are
NSS specific due to the return code so are defined here. They
genrally close the open file, set an error code and return with
Modified: nss-pam-ldapd-solaris/nss/netgroup.c
==============================================================================
--- nss-pam-ldapd-solaris/nss/netgroup.c Fri Oct 15 12:58:46 2010
(r1280)
+++ nss-pam-ldapd-solaris/nss/netgroup.c Fri Oct 15 13:22:47 2010
(r1281)
@@ -30,6 +30,7 @@
#include "prototypes.h"
#include "common.h"
#include "compat/attrs.h"
+#include "common/set.h"
/* we redefine this here because we need to return NSS_STATUS_RETURN
instead of NSS_STATUS_NOTFOUND */
@@ -146,8 +147,8 @@
nss_backend_op_t *ops;
int n_ops;
ent_context_t *state;
- struct name_list *known_groups; /* netgroups seen, for loop detection */
- struct name_list *needed_groups; /* nested netgroups to chase */
+ SET *known_groups; /* netgroups seen, for loop detection */
+ SET *needed_groups; /* nested netgroups to chase */
};
typedef struct nss_ldap_netgr_backend nss_ldap_netgr_backend_t;
@@ -157,35 +158,20 @@
}
/* find a netgroup that has not been traversed */
-static char *_nss_ldap_chase_netgroup(nss_ldap_netgr_backend_t *ngbe)
+static char *find_unseen_netgroup(nss_ldap_netgr_backend_t *ngbe)
{
- nss_status_t status;
- char *group=NULL;
- int found=0;
- if (!ngbe->needed_groups)
- {
- /* exhausted all netgroups */
- return NULL;
- }
- while (ngbe->needed_groups&&!found)
+ char *group;
+ while (1)
{
- if (_nss_ldap_namelist_find(ngbe->known_groups,
- ngbe->needed_groups->name))
+ group=set_pop(ngbe->needed_groups);
+ if (group==NULL)
+ return NULL;
+ if (set_contains(ngbe->known_groups,group))
{
- /* netgroup seen before,ignore it */
- _nss_ldap_namelist_pop(&ngbe->needed_groups);
+ set_add(ngbe->known_groups,group);
+ return group;
}
- else
- found=1;
- }
- if (found)
- {
- group=strdup(ngbe->needed_groups->name);
- status=_nss_ldap_namelist_push(&ngbe->known_groups,
- ngbe->needed_groups->name);
- _nss_ldap_namelist_pop(&ngbe->needed_groups);
}
- return group;
}
/* thread-local file pointer to an ongoing request */
@@ -236,7 +222,7 @@
while (!found)
{
/* find a nested netgroup to pursue further */
- group=_nss_ldap_chase_netgroup(ngbe);
+ group=find_unseen_netgroup(ngbe);
if (!group)
{
/* no more netgroup */
@@ -263,11 +249,7 @@
if (result.type==group_val)
{
/* a netgroup nested within the current netgroup */
- rc=_nss_ldap_namelist_push(&ngbe->needed_groups,result.val.group);
- if (rc!=NSS_STATUS_SUCCESS)
- {
- /* unable to push the group name for later netgroup */
- }
+ set_add(ngbe->needed_groups,result.val.group);
}
else if (result.type==triple_val)
{
@@ -298,8 +280,8 @@
{
nss_ldap_netgr_backend_t *ngbe=(nss_ldap_netgr_backend_t *)be;
/* free list of nested netgroups */
- _nss_ldap_namelist_destroy(&ngbe->known_groups);
- _nss_ldap_namelist_destroy(&ngbe->needed_groups);
+ set_free(ngbe->known_groups);
+ set_free(ngbe->needed_groups);
free(ngbe);
return NSS_STATUS_SUCCESS;
}
@@ -338,12 +320,7 @@
return stat;
}
/* place the group name in known list */
- stat=_nss_ldap_namelist_push(&ngbe->known_groups,args->netgroup);
- if (stat!=NSS_STATUS_SUCCESS)
- {
- destructor((nss_backend_t *)ngbe,NULL);
- return stat;
- }
+ set_add(ngbe->known_groups,args->netgroup);
args->iterator=(nss_backend_t *)ngbe;
return stat;
}
@@ -356,8 +333,8 @@
return NULL;
be->ops=netgroup_ops;
be->n_ops=sizeof(netgroup_ops)/sizeof(nss_backend_op_t);
- be->known_groups=NULL;
- be->needed_groups=NULL;
+ be->known_groups=set_new();
+ be->needed_groups=set_new();
return (nss_backend_t *)be;
}
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1281 - in nss-pam-ldapd-solaris: . nss,
Commits of the nss-pam-ldapd project