|
Lines 60-66
Link Here
|
| 60 |
|
60 |
|
| 61 |
from ..resources import moduleManager, categoryManager |
61 |
from ..resources import moduleManager, categoryManager |
| 62 |
from ..log import CORE, CRYPT, RESOURCES |
62 |
from ..log import CORE, CRYPT, RESOURCES |
| 63 |
from ..config import ucr, SERVER_MAX_CONNECTIONS |
63 |
from ..config import ucr, SERVER_MAX_CONNECTIONS, get_ucr_notifier |
| 64 |
from ..statistics import statistics |
64 |
from ..statistics import statistics |
| 65 |
|
65 |
|
| 66 |
class MagicBucket( object ): |
66 |
class MagicBucket( object ): |
|
Lines 380-386
Link Here
|
| 380 |
self.reload() |
380 |
self.reload() |
| 381 |
|
381 |
|
| 382 |
# register dispatch function to reload UCR Variables on change |
382 |
# register dispatch function to reload UCR Variables on change |
| 383 |
notifier.dispatcher_add(self._get_ucr_inotify_callback()) |
383 |
try: |
|
|
384 |
callback = get_ucr_notifier() |
| 385 |
except OSError, exc: |
| 386 |
# inotify limit is reached |
| 387 |
CORE.warn('Cannot register UCR notifier: %s' % (exc)) |
| 388 |
else: |
| 389 |
notifier.dispatcher_add(callback) |
| 384 |
|
390 |
|
| 385 |
CORE.info( 'Initialising server process' ) |
391 |
CORE.info( 'Initialising server process' ) |
| 386 |
self.__port = port |
392 |
self.__port = port |
|
Lines 468-503
Link Here
|
| 468 |
CORE.info( '__verify_cert_cb: errnum=%d depth=%d ok=%d' % (errnum, depth, ok) ) |
474 |
CORE.info( '__verify_cert_cb: errnum=%d depth=%d ok=%d' % (errnum, depth, ok) ) |
| 469 |
return ok |
475 |
return ok |
| 470 |
|
476 |
|
| 471 |
def _get_ucr_inotify_callback(self): |
|
|
| 472 |
''' returns a function which calls an event to reload UCR Variables if they have changed ''' |
| 473 |
class UCR_update_handler(pyinotify.ProcessEvent): |
| 474 |
def __init__(self): |
| 475 |
self.running = None |
| 476 |
def process(self): |
| 477 |
''' reloads UCR Variables ''' |
| 478 |
ucr.load() |
| 479 |
CORE.info('UCR Variables have been reloaded') |
| 480 |
self.running = None |
| 481 |
return False # destroy timer |
| 482 |
def process_IN_MODIFY(self, event): |
| 483 |
if self.running: |
| 484 |
# remove running timer |
| 485 |
notifier.timer_remove(self.running) |
| 486 |
# add a timer which reloads UCR Variables in 10 seconds |
| 487 |
self.running = notifier.timer_add( 10000, self.process ) |
| 488 |
return True |
| 489 |
|
| 490 |
wm = pyinotify.WatchManager() |
| 491 |
wm.add_watch('/etc/univention/base.conf', pyinotify.IN_MODIFY) |
| 492 |
ucr_notifier = pyinotify.Notifier(wm, UCR_update_handler()) |
| 493 |
|
| 494 |
def cb(): |
| 495 |
ucr_notifier.process_events() |
| 496 |
if ucr_notifier.check_events(10): |
| 497 |
ucr_notifier.read_events() |
| 498 |
return True |
| 499 |
return cb |
| 500 |
|
| 501 |
def _connection( self, socket ): |
477 |
def _connection( self, socket ): |
| 502 |
'''Signal callback: Invoked on incoming connections.''' |
478 |
'''Signal callback: Invoked on incoming connections.''' |
| 503 |
socket, addr = socket.accept() |
479 |
socket, addr = socket.accept() |