|
30 |
# /usr/share/common-licenses/AGPL-3; if not, see |
30 |
# /usr/share/common-licenses/AGPL-3; if not, see |
31 |
# <http://www.gnu.org/licenses/>. |
31 |
# <http://www.gnu.org/licenses/>. |
32 |
|
32 |
|
33 |
import re |
|
|
34 |
|
35 |
from univention.admin.layout import Tab, Group |
33 |
from univention.admin.layout import Tab, Group |
36 |
from univention.admin import configRegistry |
34 |
from univention.admin import configRegistry |
37 |
|
35 |
|
38 |
import univention.admin.filter |
36 |
import univention.admin.filter |
39 |
import univention.admin.handlers |
37 |
import univention.admin.handlers |
40 |
import univention.admin.localization |
38 |
import univention.admin.localization |
|
|
39 |
from univention.admin.handlers.dns import ARPA_IP4, ARPA_IP6, escapeSOAemail, unescapeSOAemail |
41 |
|
40 |
|
42 |
translation=univention.admin.localization.translation('univention.admin.handlers.dns') |
41 |
translation=univention.admin.localization.translation('univention.admin.handlers.dns') |
43 |
_=translation.translate |
42 |
_=translation.translate |
44 |
|
43 |
|
45 |
def makeContactPerson(object, arg): |
|
|
46 |
domain=object.position.getDomain() |
47 |
return 'root@%s.' %(domain.replace(',dc=','.').replace('dc=','')) |
48 |
|
49 |
module='dns/forward_zone' |
44 |
module='dns/forward_zone' |
50 |
operations=['add','edit','remove','search'] |
45 |
operations=['add','edit','remove','search'] |
51 |
usewizard=1 |
46 |
usewizard=1 |
Lines 252-289
class object(univention.admin.handlers.simpleLdap):
|
Link Here
|
---|
|
252 |
|
247 |
|
253 |
univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes ) |
248 |
univention.admin.handlers.simpleLdap.__init__(self, co, lo, position, dn, superordinate, attributes = attributes ) |
254 |
|
249 |
|
255 |
def unescapeSOAemail(self, email): |
|
|
256 |
ret = '' |
257 |
i = 0 |
258 |
while i < len(email): |
259 |
if email[i] == '\\': |
260 |
i += 1 |
261 |
if i >= len(email): |
262 |
raise ValueError() |
263 |
elif email[i] == '.': |
264 |
i += 1 |
265 |
if i >= len(email): |
266 |
raise ValueError() |
267 |
ret += '@' |
268 |
ret += email[i:] |
269 |
return ret |
270 |
ret += email[i] |
271 |
i += 1 |
272 |
raise ValueError() |
273 |
|
274 |
def escapeSOAemail(self, email): |
275 |
SPECIAL_CHARACTERS = set('"(),.:;<>@[\\]') |
276 |
if not '@' in email: |
277 |
raise ValueError() |
278 |
(local, domain, ) = email.rsplit('@', 1) |
279 |
tmp = '' |
280 |
for c in local: |
281 |
if c in SPECIAL_CHARACTERS: |
282 |
tmp += '\\' |
283 |
tmp += c |
284 |
local = tmp |
285 |
return local + '.' + domain |
286 |
|
287 |
def open(self): |
250 |
def open(self): |
288 |
univention.admin.handlers.simpleLdap.open(self) |
251 |
univention.admin.handlers.simpleLdap.open(self) |
289 |
self.info['a'] = [] |
252 |
self.info['a'] = [] |
Lines 294-301
class object(univention.admin.handlers.simpleLdap):
|
Link Here
|
---|
|
294 |
|
257 |
|
295 |
soa=self.oldattr.get('sOARecord',[''])[0].split(' ') |
258 |
soa=self.oldattr.get('sOARecord',[''])[0].split(' ') |
296 |
if len(soa) > 6: |
259 |
if len(soa) > 6: |
297 |
self['contact']=self.unescapeSOAemail(soa[1]) |
260 |
self['contact'] = unescapeSOAemail(soa[1]) |
298 |
self['serial']=soa[2] |
261 |
self['serial'] = soa[2] |
299 |
self['refresh'] = univention.admin.mapping.unmapUNIX_TimeInterval( soa[3] ) |
262 |
self['refresh'] = univention.admin.mapping.unmapUNIX_TimeInterval( soa[3] ) |
300 |
self['retry'] = univention.admin.mapping.unmapUNIX_TimeInterval( soa[4] ) |
263 |
self['retry'] = univention.admin.mapping.unmapUNIX_TimeInterval( soa[4] ) |
301 |
self['expire'] = univention.admin.mapping.unmapUNIX_TimeInterval( soa[5] ) |
264 |
self['expire'] = univention.admin.mapping.unmapUNIX_TimeInterval( soa[5] ) |
Lines 316-332
class object(univention.admin.handlers.simpleLdap):
|
Link Here
|
---|
|
316 |
ml=univention.admin.handlers.simpleLdap._ldap_modlist(self) |
279 |
ml=univention.admin.handlers.simpleLdap._ldap_modlist(self) |
317 |
if self.hasChanged(['nameserver', 'contact', 'serial', 'refresh', 'retry', 'expire', 'ttl']): |
280 |
if self.hasChanged(['nameserver', 'contact', 'serial', 'refresh', 'retry', 'expire', 'ttl']): |
318 |
if self['contact'] and not self['contact'].endswith('.'): |
281 |
if self['contact'] and not self['contact'].endswith('.'): |
319 |
self['contact'] = '%s.' % self['contact'] |
282 |
self['contact'] += '.' |
320 |
if len (self['nameserver'][0]) > 0 \ |
283 |
if len (self['nameserver'][0]) > 0 \ |
321 |
and self['nameserver'][0].find (':') == -1 \ |
284 |
and ':' not in self['nameserver'][0] \ |
322 |
and self['nameserver'][0].find ('.') != -1 \ |
285 |
and '.' in self['nameserver'][0] \ |
323 |
and not self['nameserver'][0][-1] == '.': |
286 |
and not self['nameserver'][0].endswith('.'): |
324 |
self['nameserver'][0] = '%s.' % self['nameserver'][0] |
287 |
self['nameserver'][0] += '.' |
325 |
refresh = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'refresh' ] ) |
288 |
refresh = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'refresh' ] ) |
326 |
retry = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'retry' ] ) |
289 |
retry = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'retry' ] ) |
327 |
expire = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'expire' ] ) |
290 |
expire = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'expire' ] ) |
328 |
ttl = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'ttl' ] ) |
291 |
ttl = univention.admin.mapping.mapUNIX_TimeInterval( self[ 'ttl' ] ) |
329 |
soa='%s %s %s %s %s %s %s' % (self['nameserver'][0], self.escapeSOAemail(self['contact']), self['serial'], refresh, retry, expire, ttl ) |
292 |
soa='%s %s %s %s %s %s %s' % (self['nameserver'][0], escapeSOAemail(self['contact']), self['serial'], refresh, retry, expire, ttl ) |
330 |
ml.append(('sOARecord', self.oldattr.get('sOARecord', []), [soa])) |
293 |
ml.append(('sOARecord', self.oldattr.get('sOARecord', []), [soa])) |
331 |
|
294 |
|
332 |
oldAddresses = self.oldinfo.get('a') |
295 |
oldAddresses = self.oldinfo.get('a') |
Lines 362-369
def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0,
|
Link Here
|
---|
|
362 |
filter=univention.admin.filter.conjunction('&', [ |
325 |
filter=univention.admin.filter.conjunction('&', [ |
363 |
univention.admin.filter.expression('objectClass', 'dNSZone'), |
326 |
univention.admin.filter.expression('objectClass', 'dNSZone'), |
364 |
univention.admin.filter.expression('relativeDomainName', '@'), |
327 |
univention.admin.filter.expression('relativeDomainName', '@'), |
365 |
univention.admin.filter.conjunction('!', [univention.admin.filter.expression('zoneName', '*.in-addr.arpa')]), |
328 |
univention.admin.filter.conjunction('!', [univention.admin.filter.expression('zoneName', '*%s' % ARPA_IP4)]), |
366 |
univention.admin.filter.conjunction('!', [univention.admin.filter.expression('zoneName', '*.ip6.arpa')]), |
329 |
univention.admin.filter.conjunction('!', [univention.admin.filter.expression('zoneName', '*%s' % ARPA_IP6)]), |
367 |
]) |
330 |
]) |
368 |
|
331 |
|
369 |
if filter_s: |
332 |
if filter_s: |
Lines 376-381
def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=0,
|
Link Here
|
---|
|
376 |
res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs ))) |
339 |
res.append((object(co, lo, None, dn=dn, superordinate=superordinate, attributes = attrs ))) |
377 |
return res |
340 |
return res |
378 |
|
341 |
|
379 |
|
|
|
380 |
def identify(dn, attr, canonical=0): |
342 |
def identify(dn, attr, canonical=0): |
381 |
return 'dNSZone' in attr.get('objectClass', []) and ['@'] == attr.get('relativeDomainName', []) and not attr['zoneName'][0].endswith('.in-addr.arpa') and not attr['zoneName'][0].endswith('.ip6.arpa') |
343 |
return 'dNSZone' in attr.get('objectClass', []) and ['@'] == attr.get('relativeDomainName', []) and not attr['zoneName'][0].endswith(ARPA_IP4) and not attr['zoneName'][0].endswith(ARPA_IP6) |