Univention Bugzilla – Attachment 8389 Details for
Bug 41335
Multiple AD-Connector instances
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch: prevent multiple ad-connector instances
0001-Bug-41335-prevent-multiple-ad-connector-instances.patch (text/plain), 1.86 KB, created by
Lukas Oyen
on 2017-01-31 15:18 CET
(
hide
)
Description:
Patch: prevent multiple ad-connector instances
Filename:
MIME Type:
Creator:
Lukas Oyen
Created:
2017-01-31 15:18 CET
Size:
1.86 KB
patch
obsolete
>From 7028b8fcab3ca6f184bf4f0d098771b87fc281c7 Mon Sep 17 00:00:00 2001 >From: Lukas Oyen <oyen@univention.de> >Date: Mon, 30 Jan 2017 19:35:17 +0100 >Subject: [PATCH] Bug 41335: prevent multiple ad-connector instances > >--- > .../modules/univention/connector/ad/main.py | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > >diff --git a/services/univention-ad-connector/modules/univention/connector/ad/main.py b/services/univention-ad-connector/modules/univention/connector/ad/main.py >index 0939ecd..e30648e 100755 >--- a/services/univention-ad-connector/modules/univention/connector/ad/main.py >+++ b/services/univention-ad-connector/modules/univention/connector/ad/main.py >@@ -34,6 +34,7 @@ > > import sys > import string >+import fcntl > import os > import time > import signal >@@ -66,7 +67,7 @@ sys.path = ['/etc/univention/%s/ad/' % CONFIGBASENAME] + sys.path > import mapping > > >-def daemon(): >+def daemon(lock_file): > try: > pid = os.fork() > except OSError, e: >@@ -96,6 +97,8 @@ def daemon(): > maxfd = 256 # default maximum > > for fd in range(0, maxfd): >+ if fd == lock_file.fileno(): >+ continue > try: > os.close(fd) > except OSError: # ERROR (ignore) >@@ -284,14 +287,27 @@ def connect(): > ad.close_debug() > > >+def lock(filename): >+ lock_file = open(filename, "a+") >+ fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB) >+ return lock_file >+ >+ > def main(): > >- daemon() >+ try: >+ lock_file = lock('/var/lock/univention-s4-%s' % CONFIGBASENAME) >+ except IOError: >+ print >> sys.stderr, 'Error: Another S4 connector process is already running.' >+ sys.exit(1) >+ >+ daemon(lock_file) > > while True: > try: > connect() > except SystemExit: >+ lock_file.close() > raise > except: > f = open(STATUSLOGFILE, 'w+') >@@ -312,6 +328,8 @@ def main(): > > f.close() > >+ lock_file.close() >+ > > if __name__ == "__main__": > main() >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 41335
:
8389
|
8390