|
45 |
import errno |
45 |
import errno |
46 |
import signal |
46 |
import signal |
47 |
import grp |
47 |
import grp |
|
|
48 |
import re |
48 |
|
49 |
|
49 |
name = 'bind' |
50 |
name = 'bind' |
50 |
description = 'Update BIND zones' |
51 |
description = 'Update BIND zones' |
Lines 62-67
SIGNAL = dict([(getattr(signal, _), _) for _ in dir(signal) if _.startswith('SIG
|
Link Here
|
---|
|
62 |
|
63 |
|
63 |
__zone_created_or_removed = False |
64 |
__zone_created_or_removed = False |
64 |
|
65 |
|
|
|
66 |
reZoneName = re.compile('^([a-zA-Z0-9]([a-zA-Z0-9-]{0,63}[a-zA-Z0-9])?)([.]([a-zA-Z0-9]([a-zA-Z0-9-]{0,63}[a-zA-Z0-9])?))*$') |
65 |
|
67 |
|
66 |
def initialize(): |
68 |
def initialize(): |
67 |
"""Initialize module on first run.""" |
69 |
"""Initialize module on first run.""" |
Lines 92-109
def handler(dn, new, old):
|
Link Here
|
---|
|
92 |
try: |
94 |
try: |
93 |
if new and not old: |
95 |
if new and not old: |
94 |
# Add |
96 |
# Add |
95 |
_new_zone(listener.configRegistry, new['zoneName'][0], dn) |
97 |
if reZoneName.match(new['zoneName'][0]): |
|
|
98 |
_new_zone(listener.configRegistry, new['zoneName'][0], dn) |
99 |
else: |
100 |
ud.debug(ud.LISTENER, ud.WARN, 'Ignoring addition of invalid zoneName %r' % (new['zoneName'][0], )) |
96 |
elif old and not new: |
101 |
elif old and not new: |
97 |
# Remove |
102 |
# Remove |
98 |
_remove_zone(old['zoneName'][0]) |
103 |
if reZoneName.match(old['zoneName'][0]): |
|
|
104 |
_remove_zone(old['zoneName'][0]) |
105 |
else: |
106 |
ud.debug(ud.LISTENER, ud.WARN, 'Ignoring removal of invalid zoneName %r' % (old['zoneName'][0], )) |
99 |
if new.get('zoneName'): |
107 |
if new.get('zoneName'): |
100 |
# Change |
108 |
# Change |
101 |
# Create an empty file to trigger the postrun() |
109 |
if reZoneName.match(new.get('zoneName')[0]): |
102 |
zonefile = os.path.join(PROXY_CACHE_DIR, "%s.zone" % (new['zoneName'][0],)) |
110 |
# Create an empty file to trigger the postrun() |
103 |
proxy_cache = open(zonefile, 'w') |
111 |
zonefile = os.path.join(PROXY_CACHE_DIR, "%s.zone" % (new['zoneName'][0],)) |
104 |
proxy_cache.close() |
112 |
proxy_cache = open(zonefile, 'w') |
105 |
os.chmod(zonefile, 0o640) |
113 |
proxy_cache.close() |
106 |
chgrp_bind(zonefile) |
114 |
os.chmod(zonefile, 0o640) |
|
|
115 |
chgrp_bind(zonefile) |
116 |
else: |
117 |
ud.debug(ud.LISTENER, ud.WARN, 'Ignoring change of invalid zoneName %r' % (new.get('zoneName')[0], )) |
107 |
finally: |
118 |
finally: |
108 |
listener.unsetuid() |
119 |
listener.unsetuid() |
109 |
|
120 |
|