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

(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-logger/directory_logger.py (-43 / +16 lines)
 Lines 40-46   import base64 Link Here 
40
import grp
40
import grp
41
import subprocess
41
import subprocess
42
import os
42
import os
43
import fcntl
44
43
45
import univention.debug
44
import univention.debug
46
import univention.misc
45
import univention.misc
 Lines 112-162   def filterOutUnchangedAttributes(old_copy, new_copy): Link Here 
112
111
113
def process_dellog(dn):
112
def process_dellog(dn):
114
	dellog = listener.configRegistry['ldap/logging/dellogdir']
113
	dellog = listener.configRegistry['ldap/logging/dellogdir']
115
	lockfilename = dellog + '.lock'
116
	lock = open(lockfilename, "w")
117
	fcntl.flock(lock, fcntl.LOCK_EX)
118
	try:
119
		dellist = os.listdir(dellog)
120
		dellist.sort()
121
		filename = dellist.pop(0)
122
		filename = os.path.join(dellog, filename)
123
		f = open(filename)
124
		(dellog_stamp, dellog_id, dellog_dn, dellog_bindDN, dellog_action) = [line.rstrip() for line in f]
125
		f.close()
126
		if dellog_dn != dn:
127
114
128
			# first clean up the mess:
115
	dellist = os.listdir(dellog)
129
			leftover = 1
116
	dellist.sort()
130
			if cleanupDellog:
117
	for leftover, filename in enumerate(dellist):
131
				os.unlink(filename)
118
		pathname = os.path.join(dellog, filename)
132
119
		try:
133
			# be nice: see if we can find dn in a later entry
120
			with open(pathname, 'r') as f:
134
			for filename in dellist:
121
				(dellog_stamp, dellog_id, dellog_dn, modifier, action) = [line.rstrip() for line in f]
135
				filename = os.path.join(dellog, filename)
136
				f = open(filename)
137
				(dellog_stamp, dellog_id, dellog_dn, dellog_bindDN, dellog_action) = [line.rstrip() for line in f]
138
				f.close()
139
				if dellog_dn == dn:
140
					univention.debug.debug(univention.debug.LISTENER, univention.debug.WARN, '%s: dn found in dellog entry %s, ID %s (+%s)' % (name, filename, dellog_id, leftover))
141
					break
142
				# damn, missed that one as well. Now it's too late, clean up:
143
				leftover += 1
144
				if cleanupDellog:
145
					os.unlink(filename)
146
147
		if dellog_dn == dn:  # haben wir's jetzt?
148
			timestamp = ldapTime2string(dellog_stamp)
149
			modifier = dellog_bindDN
150
			action = dellog_action
151
			os.unlink(filename)
152
		else:
153
			univention.debug.debug(univention.debug.LISTENER, univention.debug.ERROR, '%s: dn not found in dellog: %s' % (name, dn))
154
122
155
	finally:
123
			if cleanupDellog:
156
		fcntl.flock(lock, fcntl.LOCK_UN)
124
				os.unlink(pathname)
157
		os.unlink(lockfilename)
125
		except EnvironmentError:
126
			continue
158
127
159
	if not modifier:  # Fallback
128
		if dellog_dn == dn:
129
			univention.debug.debug(univention.debug.LISTENER, univention.debug.WARN, '%s: dn found in dellog entry %s, ID %s (+%s)' % (name, filename, dellog_id, leftover))
130
			timestamp = ldapTime2string(dellog_stamp)
131
			break
132
	else:
160
		timestamp = time.strftime(timestampfmt, time.gmtime())
133
		timestamp = time.strftime(timestampfmt, time.gmtime())
161
		dellog_id = '<NoID>'
134
		dellog_id = '<NoID>'
162
		modifier = '<unknown>'
135
		modifier = '<unknown>'
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-logger/debian/univention-directory-logger.postinst (-28 / +11 lines)
 Lines 33-71    Link Here 
33
#DEBHELPER#
33
#DEBHELPER#
34
34
35
registrySection='ldap/logging'
35
registrySection='ldap/logging'
36
workdir=/var/lib/univention-directory-logger
36
workdir='/var/lib/univention-directory-logger'
37
dellog=${workdir}/dellog
37
dellog="${workdir}/dellog"
38
38
39
[ -d "${workdir}" ] || /bin/mkdir -p "${workdir}"
40
41
if [ -d "${dellog}" ]; then
42
	/bin/rm -rf "${dellog}"
43
	/bin/rm -f "${dellog}".lock
44
	dpkg-statoverride --remove --force "${dellog}"
45
fi
46
47
/bin/mkdir -p "${dellog}"
48
dpkg-statoverride --add --update root adm 700 "${dellog}"
49
50
# if [ "$1" = "configure" -a -z "$2" ]; then	# only do this at installation time, not on update
51
if [ "$1" = "configure" ]; then
39
if [ "$1" = "configure" ]; then
52
	## set config-registry vriables
40
	install -m 0700 -o root -g adm -d "$workdir"
53
	univention-config-registry set "${registrySection}"?yes
41
	install -m 0700 -o root -g adm -d "$dellog"
54
	univention-config-registry set "${registrySection}/dellogdir"?"${dellog}"
55
42
56
	## commit the changes to slapd.conf multifile
57
	univention-config-registry commit /etc/ldap/slapd.conf
58
59
	## restart the OpenLDAP Server to load the module
60
	/etc/init.d/slapd crestart
61
62
	# exclude temporary objects by default
63
	eval "$(univention-config-registry shell ldap/base)"
43
	eval "$(univention-config-registry shell ldap/base)"
64
	univention-config-registry set "${registrySection}/exclude1"?"cn=temporary,cn=univention,$ldap_base"
44
	univention-config-registry set \
65
45
		"${registrySection}?yes" \
66
	## load the listener module
46
		"${registrySection}/dellogdir?${dellog}" \
67
	/etc/init.d/univention-directory-listener crestart
47
		"${registrySection}/exclude1?cn=temporary,cn=univention,$ldap_base"
68
48
49
	univention-config-registry commit /etc/ldap/slapd.conf
50
	invoke-rc.d slapd crestart
51
	invoke-rc.d univention-directory-listener crestart
69
fi
52
fi
70
53
71
exit 0
54
exit 0
(-)a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-logger/debian/univention-directory-logger.postrm (-20 / +10 lines)
 Lines 33-62    Link Here 
33
#DEBHELPER#
33
#DEBHELPER#
34
34
35
registrySection='ldap/logging'
35
registrySection='ldap/logging'
36
workdir=/var/lib/univention-directory-logger
36
workdir='/var/lib/univention-directory-logger'
37
dellog=${workdir}/dellog
37
dellog="${workdir}/dellog"
38
38
39
case "$1" in
39
case "$1" in
40
	"remove")
40
	"remove")
41
		## unload the listener module
41
		univention-config-registry unset \
42
		/etc/init.d/univention-directory-listener crestart
42
			"${registrySection}/dellogdir" \
43
43
			"${registrySection}"
44
		## unset directory variable, to stop dellog template activation
44
		invoke-rc.d univention-directory-listener crestart
45
		univention-config-registry unset "${registrySection}/dellogdir"
46
47
		## commit the changes to slapd.conf multifile
48
		univention-config-registry commit /etc/ldap/slapd.conf
45
		univention-config-registry commit /etc/ldap/slapd.conf
49
46
		invoke-rc.d slapd crestart
50
		## restart the OpenLDAP Server to unload the overlay
47
		;;
51
		/etc/init.d/slapd crestart
48
	"upgrade")
52
49
		dpkg-statoverride --force --quiet --remove "${dellog}"
53
		## unset main ucr variable
54
		univention-config-registry unset "${registrySection}"
55
56
		dpkg-statoverride --remove --force "${dellog}"
57
58
		rm -rf "${dellog}"
59
		rm -f "${dellog}".lock
60
		;;
50
		;;
61
	"purge")
51
	"purge")
62
		rm -rf "${workdir}"
52
		rm -rf "${workdir}"

Return to bug 34916