View | Details | Raw Unified | Return to bug 42573
Collapse All | Expand All

(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache.c (-3 / +3 lines)
 Lines 268-278   int cache_set_int(char *key, const NotifierID value) Link Here 
268
	if (rv < 0 || rv >= PATH_MAX)
268
	if (rv < 0 || rv >= PATH_MAX)
269
		return rv;
269
		return rv;
270
	if ((fp = fopen(tmpfile, "w")) == NULL)
270
	if ((fp = fopen(tmpfile, "w")) == NULL)
271
		return 1;
271
		abort_io("open", tmpfile);
272
	fprintf(fp, "%ld", value);
272
	fprintf(fp, "%ld", value);
273
	rv = fclose(fp);
273
	rv = fclose(fp);
274
	if (rv != 0)
274
	if (rv != 0)
275
		return rv;
275
		abort_io("close", tmpfile);
276
276
277
	rv = snprintf(file, PATH_MAX, "%s/%s", cache_dir, key);
277
	rv = snprintf(file, PATH_MAX, "%s/%s", cache_dir, key);
278
	if (rv < 0 || rv >= PATH_MAX)
278
	if (rv < 0 || rv >= PATH_MAX)
 Lines 700-706   int cache_free_cursor(DBC *cur) Link Here 
700
700
701
int cache_close(void)
701
int cache_close(void)
702
{
702
{
703
	int rv;
703
	int rv = 0;
704
704
705
	if (dbp && (rv = dbp->close(dbp, 0)) != 0) {
705
	if (dbp && (rv = dbp->close(dbp, 0)) != 0) {
706
		dbp->err(dbp, rv, "close");
706
		dbp->err(dbp, rv, "close");
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.c (-4 / +13 lines)
 Lines 37-42    Link Here 
37
#include <ctype.h>
37
#include <ctype.h>
38
#include <stdbool.h>
38
#include <stdbool.h>
39
#include <limits.h>
39
#include <limits.h>
40
#include <errno.h>
40
#include <sys/types.h>
41
#include <sys/types.h>
41
42
42
#include <univention/debug.h>
43
#include <univention/debug.h>
 Lines 279-288   int parse_entry(void *data, u_int32_t size, CacheEntry *entry) Link Here 
279
			rv = snprintf(filename, PATH_MAX, "%s/bad_cache", cache_dir);
280
			rv = snprintf(filename, PATH_MAX, "%s/bad_cache", cache_dir);
280
			if (rv < 0 || rv >= PATH_MAX)
281
			if (rv < 0 || rv >= PATH_MAX)
281
				abort();
282
				abort();
282
			if ((file = fopen(filename, "w")) != NULL) {
283
			if ((file = fopen(filename, "w")) == NULL)
283
				fprintf(file, "Check log file");
284
				abort_io("open", filename);
284
				fclose(file);
285
			fprintf(file, "Check log file");
285
			}
286
			rv = fclose(file);
287
			if (rv != 0)
288
				abort_io("close", filename);
286
289
287
			return -1;
290
			return -1;
288
		}
291
		}
 Lines 290-292   int parse_entry(void *data, u_int32_t size, CacheEntry *entry) Link Here 
290
293
291
	return 0;
294
	return 0;
292
}
295
}
296
297
void abort_io(const char *func, const char *filename)
298
{
299
	univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "Fatal %s(%s): %s", func, filename, strerror(errno));
300
	abort();
301
}
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.h (+1 lines)
 Lines 42-46   int parse_entry (void *data, Link Here 
42
			 u_int32_t	  size,
42
			 u_int32_t	  size,
43
			 CacheEntry	 *entry);
43
			 CacheEntry	 *entry);
44
void hex_dump(int level, void *data, u_int32_t start, u_int32_t size);
44
void hex_dump(int level, void *data, u_int32_t start, u_int32_t size);
45
void abort_io(const char *func, const char *filename) __attribute__((noreturn));
45
46
46
#endif /* _CACHE_LOWLEVEL_ */
47
#endif /* _CACHE_LOWLEVEL_ */
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/handlers.c (-1 / +3 lines)
 Lines 550-556   void handler_write_state(Handler *handler) { Link Here 
550
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not open %s", state_filename);
550
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not open %s", state_filename);
551
	} else {
551
	} else {
552
		fprintf(state_fp, "%d", handler->state);
552
		fprintf(state_fp, "%d", handler->state);
553
		fclose(state_fp);
553
		rv = fclose(state_fp);
554
		if (rv != 0)
555
			abort_io("close", state_filename);
554
	}
556
	}
555
}
557
}
556
558
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/transfile.c (-3 / +5 lines)
 Lines 92-99   static FILE* fopen_lock(const char *name, const char *type, FILE **l_file) Link Here 
92
/* Close file and lock file. */
92
/* Close file and lock file. */
93
static int fclose_lock(FILE **file, FILE **l_file)
93
static int fclose_lock(FILE **file, FILE **l_file)
94
{
94
{
95
	int rv = 0;
96
95
	if (*file != NULL) {
97
	if (*file != NULL) {
96
		fclose(*file);
98
		rv |= fclose(*file);
97
		*file = NULL;
99
		*file = NULL;
98
	}
100
	}
99
101
 Lines 102-112   static int fclose_lock(FILE **file, FILE **l_file) Link Here 
102
		int rc = lockf(l_fd, F_ULOCK, 0);
104
		int rc = lockf(l_fd, F_ULOCK, 0);
103
		if (rc)
105
		if (rc)
104
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_ALL, "unlockf(): %d", rc);
106
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_ALL, "unlockf(): %d", rc);
105
		fclose(*l_file);
107
		rv |= fclose(*l_file);
106
		*l_file = NULL;
108
		*l_file = NULL;
107
	}
109
	}
108
110
109
	return 0;
111
	return rv;
110
}
112
}
111
113
112
114
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/notifier.c (+35 lines)
 Lines 43-50    Link Here 
43
#include <string.h>
43
#include <string.h>
44
#include <time.h>
44
#include <time.h>
45
#include <sys/time.h>
45
#include <sys/time.h>
46
#include <sys/statvfs.h>
46
47
47
#include <univention/debug.h>
48
#include <univention/debug.h>
49
#include <univention/config.h>
48
#include <univention/ldap.h>
50
#include <univention/ldap.h>
49
#ifdef WITH_KRB5
51
#ifdef WITH_KRB5
50
#include <univention/krb5.h>
52
#include <univention/krb5.h>
 Lines 84-89   static int connect_to_ldap(univention_ldap_parameters_t *lp, Link Here 
84
	return LDAP_SUCCESS;
86
	return LDAP_SUCCESS;
85
}
87
}
86
88
89
static void check_free_space()
90
{
91
	static int min_mib = -2;
92
	const char *dirnames[] = {
93
		cache_dir,
94
		ldap_dir,
95
		NULL
96
	}, **dirname;
97
98
	if (min_mib == -2)
99
		min_mib = univention_config_get_int("listener/freespace");
100
101
	if (min_mib <= 0)
102
		return;
103
104
	for (dirname=dirnames; *dirname; dirname++) {
105
		struct statvfs buf;
106
		int free_mib;
107
108
		if (statvfs(*dirname, &buf))
109
			continue;
110
111
		free_mib = ((long)buf.f_bavail * (long)buf.f_frsize) >> 20;
112
		if (free_mib >= min_mib)
113
			continue;
114
115
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "File system '%s' full: %d < %d", *dirname, free_mib, min_mib);
116
		abort();
117
	}
118
}
119
87
/* listen for ldap updates */
120
/* listen for ldap updates */
88
int notifier_listen(univention_ldap_parameters_t *lp,
121
int notifier_listen(univention_ldap_parameters_t *lp,
89
		univention_krb5_parameters_t *kp,
122
		univention_krb5_parameters_t *kp,
 Lines 101-106   int notifier_listen(univention_ldap_parameters_t *lp, Link Here 
101
		int		msgid;
134
		int		msgid;
102
		time_t		timeout = DELAY_LDAP_CLOSE;
135
		time_t		timeout = DELAY_LDAP_CLOSE;
103
136
137
		check_free_space();
138
104
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "Last Notifier ID: %lu", id);
139
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "Last Notifier ID: %lu", id);
105
		if ((msgid = notifier_get_dn(NULL, id + 1)) < 1)
140
		if ((msgid = notifier_get_dn(NULL, id + 1)) < 1)
106
			break;
141
			break;
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables (+6 lines)
 Lines 45-47   Description[de]=Anzahl der Versuche zum Verbindungsaufbau zum LDAP-Server im Fal Link Here 
45
Description[en]=Number of retries to re-connect the LDAP server in case of errors. Default: 5
45
Description[en]=Number of retries to re-connect the LDAP server in case of errors. Default: 5
46
Type=int
46
Type=int
47
Categories=service-ln
47
Categories=service-ln
48
49
[listener/freespace]
50
Description[de]=Diese Variable legt die untere Grenze für den freien Speicherplatz in den Verzeichnissen '/var/lib/univention-ldap/' und '/var/lib/univention-directory-listener/', ab der der Listener gestoppt wird. Standard is 10 [MiB].
51
Description[en]=This variable configures the lower limit for free space in the directories '/var/lib/univention-ldap/' and '/var/lib/univention-directory-listener/', when the Listener will be stopped. Default is 10 [MiB].
52
Type=int
53
Categories=service-ln

Return to bug 42573