summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2007-01-17 15:35:45 +0000
committerArthur de Jong <arthur@arthurdejong.org>2007-01-17 15:35:45 +0000
commitc026629eedf04f9d3579180980bb6bfa6759d15b (patch)
tree5318f4af5959644343a502696cf6f9bc161a5ebd
parent971cc42b25ab2b0f014482562c734976915e3033 (diff)
move name_list stuff to group.c as that is the only place it's used at the moment
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@222 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--nslcd/group.c94
-rw-r--r--nslcd/ldap-nss.h6
-rw-r--r--nslcd/util.c106
-rw-r--r--nslcd/util.h7
4 files changed, 90 insertions, 123 deletions
diff --git a/nslcd/group.c b/nslcd/group.c
index f046982..1c92987 100644
--- a/nslcd/group.c
+++ b/nslcd/group.c
@@ -49,6 +49,12 @@
#include "common.h"
#include "log.h"
+struct name_list
+{
+ char *name;
+ struct name_list *next;
+};
+
#ifdef HAVE_USERSEC_H
typedef struct ldap_initgroups_args
{
@@ -94,11 +100,91 @@ ldap_initgroups_args_t;
#define GID_NOBODY UID_NOBODY
#endif
-static enum nss_status
-ng_chase (const char *dn, ldap_initgroups_args_t * lia);
+static enum nss_status ng_chase (const char *dn, ldap_initgroups_args_t * lia);
-static enum nss_status
-ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia);
+static enum nss_status ng_chase_backlink (const char ** membersOf, ldap_initgroups_args_t * lia);
+
+
+/*
+ * Add a nested netgroup or group to the namelist
+ */
+static enum nss_status _nss_ldap_namelist_push(struct name_list **head,const char *name)
+{
+ struct name_list *nl;
+
+ log_log(LOG_DEBUG,"==> _nss_ldap_namelist_push (%s)", name);
+
+ nl = (struct name_list *) malloc (sizeof (*nl));
+ if (nl == NULL)
+ {
+ log_log(LOG_DEBUG,"<== _nss_ldap_namelist_push");
+ return NSS_STATUS_TRYAGAIN;
+ }
+
+ nl->name = strdup (name);
+ if (nl->name == NULL)
+ {
+ log_log(LOG_DEBUG,"<== _nss_ldap_namelist_push");
+ free (nl);
+ return NSS_STATUS_TRYAGAIN;
+ }
+
+ nl->next = *head;
+
+ *head = nl;
+
+ log_log(LOG_DEBUG,"<== _nss_ldap_namelist_push");
+
+ return NSS_STATUS_SUCCESS;
+}
+
+/*
+ * Cleanup nested netgroup or group namelist.
+ */
+static void _nss_ldap_namelist_destroy(struct name_list **head)
+{
+ struct name_list *p, *next;
+
+ log_log(LOG_DEBUG,"==> _nss_ldap_namelist_destroy");
+
+ for (p = *head; p != NULL; p = next)
+ {
+ next = p->next;
+
+ if (p->name != NULL)
+ free (p->name);
+ free (p);
+ }
+
+ *head = NULL;
+
+ log_log(LOG_DEBUG,"<== _nss_ldap_namelist_destroy");
+}
+
+/*
+ * Check whether we have already seen a netgroup or group,
+ * to avoid loops in nested netgroup traversal
+ */
+static int _nss_ldap_namelist_find(struct name_list *head,const char *netgroup)
+{
+ struct name_list *p;
+ int found = 0;
+
+ log_log(LOG_DEBUG,"==> _nss_ldap_namelist_find");
+
+ for (p = head; p != NULL; p = p->next)
+ {
+ if (strcasecmp (p->name, netgroup) == 0)
+ {
+ found++;
+ break;
+ }
+ }
+
+ log_log(LOG_DEBUG,"<== _nss_ldap_namelist_find");
+
+ return found;
+}
/*
* Range retrieval logic was reimplemented from example in
diff --git a/nslcd/ldap-nss.h b/nslcd/ldap-nss.h
index ca683e1..2725392 100644
--- a/nslcd/ldap-nss.h
+++ b/nslcd/ldap-nss.h
@@ -257,12 +257,6 @@ struct ent_context
struct berval *ec_cookie; /* cookie for paged searches */
};
-struct name_list
-{
- char *name;
- struct name_list *next;
-};
-
typedef enum nss_status (*parser_t) (LDAPMessage *, struct ldap_state *, void *,
char *, size_t);
diff --git a/nslcd/util.c b/nslcd/util.c
index bccc49e..182c822 100644
--- a/nslcd/util.c
+++ b/nslcd/util.c
@@ -1610,112 +1610,6 @@ _nss_ldap_db_put (void *db,
return NSS_STATUS_SUCCESS;
}
-/*
- * Add a nested netgroup or group to the namelist
- */
-enum nss_status
-_nss_ldap_namelist_push (struct name_list **head, const char *name)
-{
- struct name_list *nl;
-
- log_log(LOG_DEBUG,"==> _nss_ldap_namelist_push (%s)", name);
-
- nl = (struct name_list *) malloc (sizeof (*nl));
- if (nl == NULL)
- {
- log_log(LOG_DEBUG,"<== _nss_ldap_namelist_push");
- return NSS_STATUS_TRYAGAIN;
- }
-
- nl->name = strdup (name);
- if (nl->name == NULL)
- {
- log_log(LOG_DEBUG,"<== _nss_ldap_namelist_push");
- free (nl);
- return NSS_STATUS_TRYAGAIN;
- }
-
- nl->next = *head;
-
- *head = nl;
-
- log_log(LOG_DEBUG,"<== _nss_ldap_namelist_push");
-
- 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;
-
- log_log(LOG_DEBUG,"==> _nss_ldap_namelist_pop");
-
- assert (*head != NULL);
- nl = *head;
-
- *head = nl->next;
-
- assert (nl->name != NULL);
- free (nl->name);
- free (nl);
-
- log_log(LOG_DEBUG,"<== _nss_ldap_namelist_pop");
-}
-
-/*
- * Cleanup nested netgroup or group namelist.
- */
-void
-_nss_ldap_namelist_destroy (struct name_list **head)
-{
- struct name_list *p, *next;
-
- log_log(LOG_DEBUG,"==> _nss_ldap_namelist_destroy");
-
- for (p = *head; p != NULL; p = next)
- {
- next = p->next;
-
- if (p->name != NULL)
- free (p->name);
- free (p);
- }
-
- *head = NULL;
-
- log_log(LOG_DEBUG,"<== _nss_ldap_namelist_destroy");
-}
-
-/*
- * 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;
-
- log_log(LOG_DEBUG,"==> _nss_ldap_namelist_find");
-
- for (p = head; p != NULL; p = p->next)
- {
- if (strcasecmp (p->name, netgroup) == 0)
- {
- found++;
- break;
- }
- }
-
- log_log(LOG_DEBUG,"<== _nss_ldap_namelist_find");
-
- return found;
-}
-
enum nss_status _nss_ldap_validateconfig (struct ldap_config *config)
{
struct stat statbuf;
diff --git a/nslcd/util.h b/nslcd/util.h
index 16ef3aa..44698d9 100644
--- a/nslcd/util.h
+++ b/nslcd/util.h
@@ -82,13 +82,6 @@ enum nss_status _nss_ldap_db_get (void *db,
const struct ldap_datum * key,
struct ldap_datum * value);
-/* Routines for managing namelists */
-
-enum nss_status _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);
-
enum nss_status
_nss_ldap_add_uri (struct ldap_config *result, const char *uri,
char **buffer, size_t *buflen);