View | Details | Raw Unified | Return to bug 38823 | Differences between
and this patch

Collapse All | Expand All

(-)a/univention-directory-listener/debian/changelog (+6 lines)
 Lines 1-3    Link Here 
1
univention-directory-listener (12.0.1-12) unstable; urgency=low
2
3
  * Issue #2387: Implement local cache filter
4
5
 -- Philipp Hahn <hahn@univention.de>  Wed, 01 Jul 2015 17:07:10 +0200
6
1
univention-directory-listener (12.0.1-11) unstable; urgency=low
7
univention-directory-listener (12.0.1-11) unstable; urgency=low
2
8
3
  * create /etc/ldap/rootpw.conf if missing 
9
  * create /etc/ldap/rootpw.conf if missing 
(-)a/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables (+6 lines)
 Lines 27-29   Description[de]=Ist diese Variable auf 'yes' gesetzt, führt der Univention Dire Link Here 
27
Description[en]=If this variable is set to 'yes', the Univention Directory Listener performs consistency checks to prevent a user name being added into a group multiple times. These checks can be deactivated by setting the variables 'listener/memberuid/skip' and 'listener/uniquemember/skip' to 'no'.
27
Description[en]=If this variable is set to 'yes', the Univention Directory Listener performs consistency checks to prevent a user name being added into a group multiple times. These checks can be deactivated by setting the variables 'listener/memberuid/skip' and 'listener/uniquemember/skip' to 'no'.
28
Type=str
28
Type=str
29
Categories=service-ln
29
Categories=service-ln
30
31
[listener/cache/filter]
32
Description[de]=LDAP filter string, um das lokale Cachen zu verhindern.
33
Description[en]=LDAP filter string to prevent local caching
34
Type=str
35
Categories=service-ln
(-)a/univention-directory-listener/src/Makefile (-2 / +2 lines)
 Lines 32-43    Link Here 
32
CC=gcc
32
CC=gcc
33
DB_LDADD=-ldb3
33
DB_LDADD=-ldb3
34
DB_CFLAGS=-I/usr/include/db3 -DWITH_DB3
34
DB_CFLAGS=-I/usr/include/db3 -DWITH_DB3
35
DB_OBJS=cache.o cache_entry.o cache_lowlevel.o base64.o
35
DB_OBJS=cache.o cache_entry.o cache_lowlevel.o base64.o filter.o
36
36
37
CFLAGS=-g -Wall -Werror -D_FILE_OFFSET_BITS=64 $(DB_CFLAGS)
37
CFLAGS=-g -Wall -Werror -D_FILE_OFFSET_BITS=64 $(DB_CFLAGS)
38
LDADD=-g -luniventiondebug
38
LDADD=-g -luniventiondebug
39
LISTENER_LDADD=$(LDADD) -luniventionpolicy -lldap -lpython2.6 $(DB_LDADD)
39
LISTENER_LDADD=$(LDADD) -luniventionpolicy -lldap -lpython2.6 $(DB_LDADD)
40
LISTENER_OBJS=main.o notifier.o transfile.o handlers.o cache.o cache_entry.o cache_lowlevel.o change.o network.o filter.o signals.o base64.o select_server.o
40
LISTENER_OBJS=main.o notifier.o transfile.o handlers.o change.o network.o signals.o select_server.o $(DB_OBJS)
41
DUMP_LDADD=$(LDADD) -lldap -luniventionconfig $(DB_LDADD)
41
DUMP_LDADD=$(LDADD) -lldap -luniventionconfig $(DB_LDADD)
42
DUMP_OBJS=dump.o dump_signals.o $(DB_OBJS)
42
DUMP_OBJS=dump.o dump_signals.o $(DB_OBJS)
43
DEMO_LDADD=$(LDADD) -luniventionconfig
43
DEMO_LDADD=$(LDADD) -luniventionconfig
(-)a/univention-directory-listener/src/cache.c (+22 lines)
 Lines 71-76    Link Here 
71
#include <stdbool.h>
71
#include <stdbool.h>
72
72
73
#include <univention/debug.h>
73
#include <univention/debug.h>
74
#include <univention/config.h>
74
75
75
#include "common.h"
76
#include "common.h"
76
#include "cache.h"
77
#include "cache.h"
 Lines 78-83    Link Here 
78
#include "cache_entry.h"
79
#include "cache_entry.h"
79
#include "network.h"
80
#include "network.h"
80
#include "signals.h"
81
#include "signals.h"
82
#include "filter.h"
83
#include "utils.h"
81
84
82
#define MASTER_KEY "__master__"
85
#define MASTER_KEY "__master__"
83
#define MASTER_KEY_SIZE (sizeof MASTER_KEY)
86
#define MASTER_KEY_SIZE (sizeof MASTER_KEY)
 Lines 94-99   DB_ENV *dbenvp; Link Here 
94
#endif
97
#endif
95
static FILE *lock_fp=NULL;
98
static FILE *lock_fp=NULL;
96
99
100
static struct filter cache_filter;
101
static struct filter *cache_filters[] = {&cache_filter, NULL};
102
103
static void setup_cache_filter(void) {
104
	cache_filter.filter = univention_config_get_string("listener/cache/filter");
105
	if (cache_filter.filter && cache_filter.filter[0]) {
106
		cache_filter.base = univention_config_get_string("ldap/base");
107
		cache_filter.scope = LDAP_SCOPE_SUBTREE;
108
	} else {
109
		FREE(cache_filter.filter);
110
		FREE(cache_filter.base);
111
	}
112
}
113
97
#ifdef WITH_DB42
114
#ifdef WITH_DB42
98
static void cache_panic_call(DB_ENV *dbenvp, int errval)
115
static void cache_panic_call(DB_ENV *dbenvp, int errval)
99
{
116
{
 Lines 192-197   int cache_init(void) Link Here 
192
	}
209
	}
193
	dbp->set_errcall(dbp, cache_error_message);
210
	dbp->set_errcall(dbp, cache_error_message);
194
#endif
211
#endif
212
	setup_cache_filter();
195
	return 0;
213
	return 0;
196
}
214
}
197
215
 Lines 429-434   int cache_update_entry_lower(NotifierID id, char *dn, CacheEntry *entry) Link Here 
429
	char *lower_dn;
447
	char *lower_dn;
430
	int rv = 0;
448
	int rv = 0;
431
449
450
	/* IN8 Issue 2387: Skip caching certain entries matching LDAP filter */
451
	if (cache_filter.filter && cache_entry_ldap_filter_match(cache_filters, dn, entry))
452
		return rv;
453
432
	lower_dn = _convert_to_lower(dn);
454
	lower_dn = _convert_to_lower(dn);
433
	rv = cache_update_entry(id, lower_dn, entry);
455
	rv = cache_update_entry(id, lower_dn, entry);
434
456
(-)a/univention-directory-listener/src/handlers.c (-2 / +2 lines)
 Lines 88-94   static PyObject* module_import(char *filename) Link Here 
88
88
89
	namep = strrchr(filename, '.');
89
	namep = strrchr(filename, '.');
90
	if ((namep != NULL) && (strcmp(namep, ".pyo") == 0)) {
90
	if ((namep != NULL) && (strcmp(namep, ".pyo") == 0)) {
91
		long magic;
91
		__attribute__((unused)) long magic;
92
92
93
		magic = PyMarshal_ReadLongFromFile(fp);
93
		magic = PyMarshal_ReadLongFromFile(fp);
94
		/* we should probably check the magic here */
94
		/* we should probably check the magic here */
 Lines 936-942   int handlers_set_data_all(char *key, char *value) Link Here 
936
{
936
{
937
	Handler *handler;
937
	Handler *handler;
938
	PyObject *argtuple;
938
	PyObject *argtuple;
939
	int rv = 1;
939
	__attribute__((unused))  int rv = 1;
940
940
941
	univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "setting data for all handlers: key=%s  value=%s", key, strcmp("bindpw", key) ? value : "<HIDDEN>");
941
	univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "setting data for all handlers: key=%s  value=%s", key, strcmp("bindpw", key) ? value : "<HIDDEN>");
942
942
(-)a/univention-directory-listener/src/utils.h (-1 / +5 lines)
 Lines 4-9    Link Here 
4
#include <ldap.h>
4
#include <ldap.h>
5
5
6
6
7
#define FREE(ptr) \
8
	free(ptr); \
9
	ptr = NULL;
10
11
7
static inline bool BERSTREQ(const struct berval *ber, const char *str, size_t len) {
12
static inline bool BERSTREQ(const struct berval *ber, const char *str, size_t len) {
8
	return ber->bv_len == len && memcmp(ber->bv_val, str, len) == 0;
13
	return ber->bv_len == len && memcmp(ber->bv_val, str, len) == 0;
9
}
14
}
10
- 

Return to bug 38823