summaryrefslogtreecommitdiffhomepage
path: root/src/acl.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-12-06 23:30:23 +0100
committerMichael Adam <obnox@samba.org>2009-12-07 00:22:46 +0100
commit8cb182e1b873fde40db6e4258ee23b05f956f397 (patch)
treee233d504ea8d6dbb06c5e218aa9ffa0b3d652f80 /src/acl.c
parent6266197e9257df1501b1962ad0a3e3ba757092f3 (diff)
Add access_list to the config struct instead of a global variable in acl.c.
Change insert_acl, check_acl and flush_access_list to take a corresponding argument. Michael
Diffstat (limited to 'src/acl.c')
-rw-r--r--src/acl.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/acl.c b/src/acl.c
index 81b6113..4efc82a 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -58,11 +58,6 @@ struct acl_s {
};
/*
- * All the access lists are stored in a vector.
- */
-static vector_t access_list = NULL;
-
-/*
* Fills in the netmask array given a numeric value.
*
* Returns:
@@ -109,11 +104,11 @@ fill_netmask_array (char *bitmask_string, unsigned char array[],
/**
* If the access list has not been set up, create it.
*/
-static int init_access_list(void)
+static int init_access_list(vector_t *access_list)
{
- if (!access_list) {
- access_list = vector_create ();
- if (!access_list) {
+ if (!*access_list) {
+ *access_list = vector_create ();
+ if (!*access_list) {
log_message (LOG_ERR,
"Unable to allocate memory for access list");
return -1;
@@ -132,7 +127,7 @@ static int init_access_list(void)
* -1 on failure
* 0 otherwise.
*/
-int insert_acl (char *location, acl_access_t access_type)
+int insert_acl (char *location, acl_access_t access_type, vector_t *access_list)
{
struct acl_s acl;
int ret;
@@ -140,7 +135,7 @@ int insert_acl (char *location, acl_access_t access_type)
assert (location != NULL);
- ret = init_access_list();
+ ret = init_access_list(access_list);
if (ret != 0) {
return -1;
}
@@ -189,7 +184,7 @@ int insert_acl (char *location, acl_access_t access_type)
}
}
- ret = vector_append (access_list, &acl, sizeof (struct acl_s));
+ ret = vector_append (*access_list, &acl, sizeof (struct acl_s));
return ret;
}
@@ -311,7 +306,7 @@ static int check_numeric_acl (const struct acl_s *acl, const char *ip)
* 1 if allowed
* 0 if denied
*/
-int check_acl (const char *ip, const char *host)
+int check_acl (const char *ip, const char *host, vector_t access_list)
{
struct acl_s *acl;
int perm = 0;
@@ -358,7 +353,7 @@ int check_acl (const char *ip, const char *host)
return 0;
}
-void flush_access_list (void)
+void flush_access_list (vector_t access_list)
{
struct acl_s *acl;
size_t i;