[X2Go-Commits] [x2gobroker] 02/02: Load defaults.conf via authservices and for logger configuration, as well.

git-admin at x2go.org git-admin at x2go.org
Wed Oct 29 08:42:36 CET 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gobroker.

commit 1f1db9609ab8e652685fbf5fb434b16c938439a0
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Oct 29 08:42:17 2014 +0100

    Load defaults.conf via authservices and for logger configuration, as well.
---
 debian/changelog            |    1 +
 sbin/x2gobroker-authservice |   33 +++++++++++++++++++++++++++++++++
 x2gobroker/loggers.py       |    8 ++++++++
 3 files changed, 42 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index b293f38..d1d57d8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -172,6 +172,7 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low
     - Provide legacy support for deprecated x2gobroker.conf global parameter
       'check-credentials'.
     - Configure broker / authservice environment via .service files.
+    - Load defaults.conf via authservices and for logger configuration, as well.
   * debian/control:
     + Provide separate bin:package for SSH brokerage: x2gobroker-ssh.
     + Replace LDAP support with session brokerage support in LONG_DESCRIPTION.
diff --git a/sbin/x2gobroker-authservice b/sbin/x2gobroker-authservice
index 318c2f0..af8cb6e 100755
--- a/sbin/x2gobroker-authservice
+++ b/sbin/x2gobroker-authservice
@@ -30,6 +30,7 @@ import getpass
 import logging.config
 import pam
 import atexit
+import ConfigParser
 
 if os.path.isdir('/run'):
     RUNDIR = '/run'
@@ -110,26 +111,58 @@ def cleanup_on_exit():
     except: pass
 
 
+# load the defaults.conf file, if present
+iniconfig_loaded = None
+iniconfig_section = '-'.join(PROG_NAME.split('-')[1:])
+X2GOBROKER_DEFAULTS = "/etc/x2go/broker/defaults.conf"
+if os.path.isfile(X2GOBROKER_DEFAULTS) and os.access(X2GOBROKER_DEFAULTS, os.R_OK):
+    iniconfig = ConfigParser.SafeConfigParser()
+    iniconfig.optionxform = str
+    iniconfig_loaded = iniconfig.read(X2GOBROKER_DEFAULTS)
+
 # normally this would go into defaults.py, however, we do not want to pull in defaults.py here as that will create
 # unwanted logfiles (access.log, broker.log, error.log) when x2gobroker-authservice is installed as standalone service
 if os.environ.has_key('X2GOBROKER_DEBUG'):
     X2GOBROKER_DEBUG = ( os.environ['X2GOBROKER_DEBUG'].lower() in ('1', 'on', 'true', 'yes', ) )
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DEBUG'):
+    X2GOBROKER_DEBUG=iniconfig.get(iniconfig_section, 'X2GOBROKER_DEBUG')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DEBUG'):
+    X2GOBROKER_DEBUG=iniconfig.get('common', 'X2GOBROKER_DEBUG')
 else:
     X2GOBROKER_DEBUG = False
 if os.environ.has_key('X2GOBROKER_TESTSUITE'):
     X2GOBROKER_TESTSUITE = ( os.environ['X2GOBROKER_TESTSUITE'].lower() in ('1', 'on', 'true', 'yes', ) )
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_TESTSUITE'):
+    X2GOBROKER_TESTSUITE=iniconfig.get(iniconfig_section, 'X2GOBROKER_TESTSUITE')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_TESTSUITE'):
+    X2GOBROKER_TESTSUITE=iniconfig.get('common', 'X2GOBROKER_TESTSUITE')
 else:
     X2GOBROKER_TESTSUITE = False
+
 if os.environ.has_key('X2GOBROKER_DAEMON_USER'):
     X2GOBROKER_DAEMON_USER=os.environ['X2GOBROKER_DAEMON_USER']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DAEMON_USER'):
+    X2GOBROKER_DAEMON_USER=iniconfig.get(iniconfig_section, 'X2GOBROKER_DAEMON_USER')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DAEMON_USER'):
+    X2GOBROKER_DAEMON_USER=iniconfig.get('common', 'X2GOBROKER_DAEMON_USER')
 else:
     X2GOBROKER_DAEMON_USER="x2gobroker"
+
 if os.environ.has_key('X2GOBROKER_AUTHSERVICE_LOGCONFIG'):
     X2GOBROKER_AUTHSERVICE_LOGCONFIG=os.environ['X2GOBROKER_AUTHSERVICE_LOGCONFIG']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_LOGCONFIG'):
+    X2GOBROKER_AUTHSERVICE_LOGCONFIG=iniconfig.get(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_LOGCONFIG')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AUTHSERVICE_LOGCONFIG'):
+    X2GOBROKER_AUTHSERVICE_LOGCONFIG=iniconfig.get('common', 'X2GOBROKER_AUTHSERVICE_LOGCONFIG')
 else:
     X2GOBROKER_AUTHSERVICE_LOGCONFIG="/etc/x2go/broker/x2gobroker-authservice-logger.conf"
+
 if os.environ.has_key('X2GOBROKER_AUTHSERVICE_SOCKET'):
     X2GOBROKER_AUTHSERVICE_SOCKET=os.environ['X2GOBROKER_AUTHSERVICE_SOCKET']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_SOCKET'):
+    X2GOBROKER_AUTHSERVICE_SOCKET=iniconfig.get(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_SOCKET')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AUTHSERVICE_SOCKET'):
+    X2GOBROKER_AUTHSERVICE_SOCKET=iniconfig.get('common', 'X2GOBROKER_AUTHSERVICE_SOCKET')
 else:
     X2GOBROKER_AUTHSERVICE_SOCKET="{run}/x2gobroker/x2gobroker-authservice.socket".format(run=RUNDIR)
 
diff --git a/x2gobroker/loggers.py b/x2gobroker/loggers.py
index c4b77df..c46c13c 100644
--- a/x2gobroker/loggers.py
+++ b/x2gobroker/loggers.py
@@ -55,10 +55,18 @@ def init_console_loggers():
 # normally this would go into defaults.py, however, we do not want to create a dependency loop between loggers.py and defaults.py...
 if os.environ.has_key('X2GOBROKER_DAEMON_USER'):
     X2GOBROKER_DAEMON_USER=os.environ['X2GOBROKER_DAEMON_USER']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DAEMON_USER'):
+    X2GOBROKER_DAEMON_USER=iniconfig.get(iniconfig_section, 'X2GOBROKER_DAEMON_USER')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DAEMON_USER'):
+    X2GOBROKER_DAEMON_USER=iniconfig.get('common', 'X2GOBROKER_DAEMON_USER')
 else:
     X2GOBROKER_DAEMON_USER="x2gobroker"
 if os.environ.has_key('X2GOBROKER_LOGCONFIG'):
     X2GOBROKER_LOGCONFIG=os.environ['X2GOBROKER_LOGCONFIG']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_LOGCONFIG'):
+    X2GOBROKER_LOGCONFIG=iniconfig.get(iniconfig_section, 'X2GOBROKER_LOGCONFIG')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_LOGCONFIG'):
+    X2GOBROKER_LOGCONFIG=iniconfig.get('common', 'X2GOBROKER_LOGCONFIG')
 else:
     X2GOBROKER_LOGCONFIG="/etc/x2go/broker/x2gobroker-loggers.conf"
 

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git


More information about the x2go-commits mailing list