The branch, statusflag has been updated
via 441738987b1baad30e9195c811bce85b3cc6809e (commit)
from 0aca8cade7297dbe428473bcb5ca4e00d4f4bc10 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]x2gobroker-daemon.init | 3 +++
1 file changed, 3 insertions(+)
The diff of changes is:
diff --git a/debian/x2gobroker-daemon.init b/debian/x2gobroker-daemon.init
index 7d945ed..fba7672 100755
--- a/debian/x2gobroker-daemon.init
+++ b/debian/x2gobroker-daemon.init
@@ -46,7 +46,10 @@ mkdir -p $RUNDIR/x2gobroker
chown $X2GOBROKER_DAEMON_USER:nogroup $RUNDIR/x2gobroker
chmod 0700 $RUNDIR/x2gobroker
+# mend user ID variables when --chuid $X2GOBROKER_DAEMON_USER is used with start-stop-daemon
export LOGNAME=$X2GOBROKER_DAEMON_USER
+export USER=$X2GOBROKER_DAEMON_USER
+export USERNAME=$X2GOBROKER_DAEMON_USER
export X2GOBROKER_DEBUG
export X2GOBROKER_DAEMON_USER
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via 58da6a1d6504def84dccbc9f3328cca439fefa3b (commit)
from f1ea959ac2800e88d57018b80b648f7ab48fc9a8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]changelog | 2 ++
debian/x2gobroker-daemon.default | 5 ++++-
debian/x2gobroker-daemon.init | 8 +++++++-
x2gobroker/defaults.py | 14 ++++++++++++--
x2gobroker/loggers.py | 1 -
5 files changed, 25 insertions(+), 5 deletions(-)
mode change 100644 => 100755 debian/x2gobroker-daemon.init
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 467aa58..c7be8e3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ x2gobroker (0.0.0.2-0~x2go1) UNRELEASED; urgency=low
- Add man page for x2gobroker executable.
- Add logrotate configuration for x2gobroker log files.
- Make the daemon user ID configurable through x2gobroker-daemon.default.
+ - Handle different situation for X2GOBROKER_DAEMON_USER. Make sure
+ the getpass.getuser() function sees the correct effective UID.
* /debian/control:
+ Add bin:package x2gobroker-agent.
diff --git a/debian/x2gobroker-daemon.default b/debian/x2gobroker-daemon.default
index 589aedb..8b8bea2 100644
--- a/debian/x2gobroker-daemon.default
+++ b/debian/x2gobroker-daemon.default
@@ -3,7 +3,10 @@
# Uncomment to enable the X2Go Session Broker standalone daemon
START_DAEMON=true
-# the posix user ID the broker runs under
+# the posix user ID the broker runs under (do not change!)
+# if you change it nonetheless, make sure that the log file
+# directory (default: /var/log/x2gobroker) and files in there are
+# writable by that user
#X2GOBROKER_DAEMON_USER=x2gobroker
# run XGo Session Broker in debug mode, this will make the broker
diff --git a/debian/x2gobroker-daemon.init b/debian/x2gobroker-daemon.init
old mode 100644
new mode 100755
index 4d89e64..789291b
--- a/debian/x2gobroker-daemon.init
+++ b/debian/x2gobroker-daemon.init
@@ -37,6 +37,12 @@ X2GOBROKER_SSL_CERTFILE=
X2GOBROKER_SSL_KEYFILE=
test -f $DEBIANCONFIG && . $DEBIANCONFIG
+if ! getent passwd $X2GOBROKER_DAEMON_USER 1>/dev/null 2>/dev/null; then
+ X2GOBROKER_DAEMON_USER=nobody
+fi
+
+export LOGNAME=$X2GOBROKER_DAEMON_USER
+
export X2GOBROKER_DEBUG
export X2GOBROKER_DAEMON_USER
export X2GOBROKER_CONFIG
@@ -62,7 +68,7 @@ case "${1:-}" in
log_daemon_msg "Starting X2Go Session Broker standalone daemon" "x2gobroker"
mkdir -p $RUNDIR
set +e
- start-stop-daemon -u $X2GOBROKER_DAEMON_USER -b -m -S -p $PIDFILE -x $DAEMON -- -b $DAEMON_BIND_ADDRESS
+ start-stop-daemon --chuid $X2GOBROKER_DAEMON_USER -b -m -S -p $PIDFILE -x $DAEMON -- -b $DAEMON_BIND_ADDRESS
log_end_msg $?
set -e
fi
diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py
index 1f250c2..4099d57 100644
--- a/x2gobroker/defaults.py
+++ b/x2gobroker/defaults.py
@@ -39,15 +39,25 @@ else:
X2GOBROKER_DEBUG = False
if X2GOBROKER_USER != X2GOBROKER_DAEMON_USER:
X2GOBROKER_DEBUG = True
-
+X2GOBROKER_DEBUG = True
if X2GOBROKER_DEBUG:
logger_broker.setLevel(logging.DEBUG)
logger_access.setLevel(logging.DEBUG)
logger_error.setLevel(logging.DEBUG)
-if X2GOBROKER_USER != X2GOBROKER_DAEMON_USER:
+logger_broker.warn('os.getuid() = %s' % os.getuid())
+logger_broker.warn('os.geteuid() = %s' % os.geteuid())
+logger_broker.warn('getpass.getuser() = %s' % getpass.getuser())
+
+# check effective UID the broker runs as and complain appropriately...
+if X2GOBROKER_USER != X2GOBROKER_DAEMON_USER and os.geteuid() != 0:
logger_broker.warn('X2Go Session Broker has been started interactively by user {username}, better run as user {daemon_username}.'.format(username=X2GOBROKER_USER, daemon_username=X2GOBROKER_DAEMON_USER))
logger_broker.info('Automatically switching to DEBUG mode due to interactive launch of this application.')
+elif X2GOBROKER_DAEMON_USER != 'root' and os.geteuid() == 0:
+ logger_broker.warn('X2Go Session Broker should not be run as root, better run as user {daemon_username}.'.format(daemon_username=X2GOBROKER_DAEMON_USER))
+elif os.geteuid() == 0:
+ logger_broker.warn('X2Go Session Broker should not be run as root, better run as non-privileged user')
+
logger_broker.info('Setting up the broker\'s environment...')
logger_broker.info(' X2GOBROKER_DEBUG: {value}'.format(value=X2GOBROKER_DEBUG))
diff --git a/x2gobroker/loggers.py b/x2gobroker/loggers.py
index d7fb60a..7791bbd 100644
--- a/x2gobroker/loggers.py
+++ b/x2gobroker/loggers.py
@@ -65,4 +65,3 @@ else:
logger_error = logging.getLogger('error')
logger_error.addHandler(stdout_handler)
logger_error.propagate = 0
-
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via 499a783d677c3610974fdffd48573ff5037194a5 (commit)
from b25ebf6134b77a3e18ba1f7883c27cd29cebe61b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
x2gobroker/…
[View More]defaults.py | 4 ----
1 file changed, 4 deletions(-)
The diff of changes is:
diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py
index 4099d57..fdbd881 100644
--- a/x2gobroker/defaults.py
+++ b/x2gobroker/defaults.py
@@ -45,10 +45,6 @@ if X2GOBROKER_DEBUG:
logger_access.setLevel(logging.DEBUG)
logger_error.setLevel(logging.DEBUG)
-logger_broker.warn('os.getuid() = %s' % os.getuid())
-logger_broker.warn('os.geteuid() = %s' % os.geteuid())
-logger_broker.warn('getpass.getuser() = %s' % getpass.getuser())
-
# check effective UID the broker runs as and complain appropriately...
if X2GOBROKER_USER != X2GOBROKER_DAEMON_USER and os.geteuid() != 0:
logger_broker.warn('X2Go Session Broker has been started interactively by user {username}, better run as user {daemon_username}.'.format(username=X2GOBROKER_USER, daemon_username=X2GOBROKER_DAEMON_USER))
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via 80fd7e03f7094ef1dcc3e61d9d4e30a5020ed78a (commit)
from b5df92c61e0c84ec314b29acc60e635d43f3b7b0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]changelog | 1 +
debian/x2gobroker-daemon.default | 3 +++
debian/x2gobroker-daemon.init | 4 +++-
x2gobroker/loggers.py | 6 ++++--
4 files changed, 11 insertions(+), 3 deletions(-)
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 9ed8b0d..467aa58 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,7 @@ x2gobroker (0.0.0.2-0~x2go1) UNRELEASED; urgency=low
- Add foundation for logging support.
- Add man page for x2gobroker executable.
- Add logrotate configuration for x2gobroker log files.
+ - Make the daemon user ID configurable through x2gobroker-daemon.default.
* /debian/control:
+ Add bin:package x2gobroker-agent.
diff --git a/debian/x2gobroker-daemon.default b/debian/x2gobroker-daemon.default
index 452a75b..589aedb 100644
--- a/debian/x2gobroker-daemon.default
+++ b/debian/x2gobroker-daemon.default
@@ -3,6 +3,9 @@
# Uncomment to enable the X2Go Session Broker standalone daemon
START_DAEMON=true
+# the posix user ID the broker runs under
+#X2GOBROKER_DAEMON_USER=x2gobroker
+
# run XGo Session Broker in debug mode, this will make the broker
# available through http GET method calls (otherwise: POST method
# only) and you will be able to test the broker through your web
diff --git a/debian/x2gobroker-daemon.init b/debian/x2gobroker-daemon.init
index d14bb8f..4d89e64 100644
--- a/debian/x2gobroker-daemon.init
+++ b/debian/x2gobroker-daemon.init
@@ -28,6 +28,7 @@ test -x "$DAEMON" || exit 0
START_DAEMON=false
DAEMON_BIND_ADDRESS=127.0.0.1:8080
X2GOBROKER_DEBUG=0
+X2GOBROKER_DAEMON_USER='x2gobroker'
X2GOBROKER_DEFAULT_BACKEND="zeroconf"
X2GOBROKER_CONFIG="/etc/x2go/x2gobroker.conf"
X2GOBROKER_SESSIONPROFILES="/etc/x2go/broker/x2gobroker-sessionprofiles.conf"
@@ -37,6 +38,7 @@ X2GOBROKER_SSL_KEYFILE=
test -f $DEBIANCONFIG && . $DEBIANCONFIG
export X2GOBROKER_DEBUG
+export X2GOBROKER_DAEMON_USER
export X2GOBROKER_CONFIG
export X2GOBROKER_DEFAULT_BACKEND
export X2GOBROKER_SESSIONPROFILES
@@ -60,7 +62,7 @@ case "${1:-}" in
log_daemon_msg "Starting X2Go Session Broker standalone daemon" "x2gobroker"
mkdir -p $RUNDIR
set +e
- start-stop-daemon -b -m -S -p $PIDFILE -x $DAEMON -- -b $DAEMON_BIND_ADDRESS
+ start-stop-daemon -u $X2GOBROKER_DAEMON_USER -b -m -S -p $PIDFILE -x $DAEMON -- -b $DAEMON_BIND_ADDRESS
log_end_msg $?
set -e
fi
diff --git a/x2gobroker/loggers.py b/x2gobroker/loggers.py
index e35a9a7..94e00ec 100644
--- a/x2gobroker/loggers.py
+++ b/x2gobroker/loggers.py
@@ -25,9 +25,11 @@ import getpass
import logging
import logging.config
-X2GOBROKER_DAEMON_USER = 'x2gobroker'
-
# 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']
+else:
+ X2GOBROKER_DAEMON_USER="x2gobroker"
if os.environ.has_key('X2GOBROKER_LOGCONFIG'):
X2GOBROKER_LOGCONFIG=os.environ['X2GOBROKER_LOGCONFIG']
else:
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via bbe2c8ab570f8f3e4b0e54a79117b9d93488de40 (commit)
from fe7f06c112518bbac361c7e9f80ed721379a0e3b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]changelog | 1 +
debian/python-x2gobroker.dirs | 3 +-
...r-agent.postinst => python-x2gobroker.postinst} | 27 +------
...roker-agent.postrm => python-x2gobroker.postrm} | 11 +--
etc/broker/x2gobroker-loggers.conf | 81 ++++++++++++++++++++
x2gobroker/defaults.py | 5 ++
x2gobroker/{brokers/ldap_broker.py => loggers.py} | 20 ++---
7 files changed, 107 insertions(+), 41 deletions(-)
copy debian/{x2gobroker-agent.postinst => python-x2gobroker.postinst} (51%)
copy debian/{x2gobroker-agent.postrm => python-x2gobroker.postrm} (70%)
create mode 100644 etc/broker/x2gobroker-loggers.conf
copy x2gobroker/{brokers/ldap_broker.py => loggers.py} (68%)
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 0984633..c8ec285 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,7 @@ x2gobroker (0.0.0.2-0~x2go1) UNRELEASED; urgency=low
- Make CC, CFLAGS and LDFLAGS configurable through build system.
- Make host session option a list, not string.
- Add load balancing support.
+ - Add foundation for logging support.
* /debian/control:
+ Add bin:package x2gobroker-agent.
diff --git a/debian/python-x2gobroker.dirs b/debian/python-x2gobroker.dirs
index 2fd303e..2396e1d 100644
--- a/debian/python-x2gobroker.dirs
+++ b/debian/python-x2gobroker.dirs
@@ -1,2 +1,3 @@
/etc/x2go
-/etc/pam.d
\ No newline at end of file
+/etc/pam.d
+/var/log/x2gobroker
\ No newline at end of file
diff --git a/debian/x2gobroker-agent.postinst b/debian/python-x2gobroker.postinst
similarity index 51%
copy from debian/x2gobroker-agent.postinst
copy to debian/python-x2gobroker.postinst
index 95faece..861b3e0 100755
--- a/debian/x2gobroker-agent.postinst
+++ b/debian/python-x2gobroker.postinst
@@ -1,13 +1,10 @@
#!/bin/sh
-# postinst script for x2gobroker-agent
+# postinst script for python-x2gobroker
#
# see: dh_installdeb(1)
set -e
-# Source debconf library.
-. /usr/share/debconf/confmodule
-
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
@@ -24,25 +21,9 @@ set -e
case "$1" in
configure)
- # setup user/group x2gobroker
- if ! getent group x2gobroker >/dev/null; then
- echo "Creating x2gobroker group." >&2
- addgroup --system x2gobroker
- else
- echo "Group x2gobroker already exists." >&2
- fi
- if ! getent passwd x2gobroker >/dev/null; then
- echo "Creating x2gobroker user." >&2
- adduser --system --no-create-home \
- --disabled-password --disabled-login \
- --shell /bin/false --group --home /dev/null x2gobroker
- else
- echo "User x2gobroker already exists." >&2
- fi
-
- # the x2gobroker-agent has to be installed setuid root
- if ! dpkg-statoverride --list /usr/lib/x2go/x2gobroker-agent >/dev/null; then
- dpkg-statoverride --add --update root x2gobroker 4750 /usr/lib/x2go/x2gobroker-agent
+ # the python-x2gobroker needs special permissions on its log directory
+ if ! dpkg-statoverride --list /var/log/x2gobroker >/dev/null; then
+ dpkg-statoverride --add --update x2gobroker adm 0750 /var/log/x2gobroker
fi
;;
diff --git a/debian/x2gobroker-agent.postrm b/debian/python-x2gobroker.postrm
similarity index 70%
copy from debian/x2gobroker-agent.postrm
copy to debian/python-x2gobroker.postrm
index d703d32..22abe93 100755
--- a/debian/x2gobroker-agent.postrm
+++ b/debian/python-x2gobroker.postrm
@@ -18,15 +18,10 @@ set -e
case "$1" in
purge)
- if dpkg-statoverride --list /usr/lib/x2go/x2gobroker-agent >/dev/null; then
- dpkg-statoverride --remove /usr/lib/x2go/x2gobroker-agent
+ if dpkg-statoverride --list /var/log/x2gobroker >/dev/null; then
+ dpkg-statoverride --remove /var/log/x2gobroker
fi
- # remove user/group x2gobroker from system
- getent passwd x2gobroker >/dev/null && deluser x2gobroker
- getent group x2gobroker >/dev/null && delgroup x2gobroker
- getent group x2gobroker >/dev/null && delgroup x2gobroker
-
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
@@ -41,4 +36,4 @@ esac
#DEBHELPER#
-exit 0
\ No newline at end of file
+exit 0
diff --git a/etc/broker/x2gobroker-loggers.conf b/etc/broker/x2gobroker-loggers.conf
new file mode 100644
index 0000000..36d5e3e
--- /dev/null
+++ b/etc/broker/x2gobroker-loggers.conf
@@ -0,0 +1,81 @@
+# This file is part of the X2Go Project - http://www.x2go.org
+# Copyright (C) 2011-2012 by Oleksandr Shneyder <oleksandr.shneyder(a)obviously-nice.de>
+# Copyright (C) 2011-2012 by Heinz-Markus Graesing <heinz-m.graesing(a)obviously-nice.de>
+# Copyright (C) 2012 by Mike Gabriel <mike.gabriel(a)das-netzwerkteam.de>
+#
+# X2Go Session Broker is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# X2Go Session Broker is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+[loggers]
+keys=root,broker,access,error
+
+[logger_root]
+level=NOTSET
+handlers=stdoutHandler
+
+[handlers]
+keys=stdoutHandler,brokerFileHandler,accessFileHandler,errorFileHandler
+
+[formatters]
+keys=brokerFormatter,accessFormatter,errorFormatter
+
+[handler_stdoutHandler]
+class=StreamHandler
+args=(sys.stdout,)
+
+[logger_broker]
+level=DEBUG
+handlers=brokerFileHandler
+qualname=broker
+propagate=0
+
+[handler_brokerFileHandler]
+class=FileHandler
+formatter=brokerFormatter
+args=('/var/log/x2gobroker/broker.log',)
+
+[formatter_brokerFormatter]
+format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
+datefmt=
+
+[logger_access]
+level=DEBUG
+handlers=accessFileHandler
+qualname=access
+propagate=0
+
+[handler_accessFileHandler]
+class=FileHandler
+formatter=accessFormatter
+args=('/var/log/x2gobroker/access.log',)
+
+[formatter_accessFormatter]
+format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
+datefmt=
+
+[logger_error]
+level=DEBUG
+handlers=errorFileHandler
+qualname=error
+propagate=0
+
+[handler_errorFileHandler]
+class=FileHandler
+formatter=accessFormatter
+args=('/var/log/x2gobroker/error.log',)
+
+[formatter_errorFormatter]
+format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
+datefmt=
diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py
index 48b61d8..b85a296 100644
--- a/x2gobroker/defaults.py
+++ b/x2gobroker/defaults.py
@@ -31,6 +31,11 @@ if os.environ.has_key('X2GOBROKER_CONFIG'):
else:
X2GOBROKER_CONFIG="/etc/x2go/x2gobroker.conf"
+if os.environ.has_key('X2GOBROKER_LOGCONFIG'):
+ X2GOBROKER_LOGCONFIG=os.environ['X2GOBROKER_LOGCONFIG']
+else:
+ X2GOBROKER_LOGCONFIG="/etc/x2go/broker/x2gobroker-loggers.conf"
+
if os.environ.has_key('X2GOBROKER_SESSIONPROFILES'):
X2GOBROKER_SESSIONPROFILES=os.environ['X2GOBROKER_SESSIONPROFILES']
else:
diff --git a/x2gobroker/brokers/ldap_broker.py b/x2gobroker/loggers.py
similarity index 68%
copy from x2gobroker/brokers/ldap_broker.py
copy to x2gobroker/loggers.py
index 61857d8..4493091 100644
--- a/x2gobroker/brokers/ldap_broker.py
+++ b/x2gobroker/loggers.py
@@ -2,6 +2,7 @@
# Copyright (C) 2012 by Mike Gabriel <mike.gabriel(a)das-netzwerkteam.de>
# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder(a)obviously-nice.de>
+# Copyright (C) 2012 by Heinz-Markus Graesing <heinz-m.graesing(a)obviously-nice.de>
#
# X2Go Session Broker is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -18,16 +19,17 @@
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-"""\
-L{ldap.X2GoBroker} class - a production X2GoBroker implementations that uses LDAP as configuration backend
+import logging
+import logging.config
-"""
-__NAME__ = 'x2gobroker-pylib'
+from x2gobroker.defaults import X2GOBROKER_LOGCONFIG as _X2GOBROKER_LOGCONFIG
-# modules
-import x2gobroker.base_broker as base
+logging.config.fileConfig(_X2GOBROKER_LOGCONFIG)
-class X2GoBroker(x2gobroker.base.X2GoBroker):
- """\
+print dir(logging.config)
+
+# create loggers
+logger_broker = logging.getLogger('broker')
+logger_access = logging.getLogger('access')
+logger_error = logging.getLogger('error')
- """
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via 5231ba48183cc603a5193400884dd01b360491ba (commit)
from 716736e53b9bf284d5bc196b708bc3b2362b50a4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]changelog | 1 +
lib/x2gobroker-agent.pl | 37 ++++++++++++++
x2gobroker/agent.py | 87 +++++++++++++++++++++++++++++++++
x2gobroker/brokers/base_broker.py | 32 ++++++++++--
x2gobroker/brokers/zeroconf_broker.py | 2 +-
x2gobroker/web/plain.py | 2 +-
6 files changed, 156 insertions(+), 5 deletions(-)
create mode 100644 x2gobroker/agent.py
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 025cc4c..0984633 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ x2gobroker (0.0.0.2-0~x2go1) UNRELEASED; urgency=low
* New upstream version (0.0.0.2):
- Make CC, CFLAGS and LDFLAGS configurable through build system.
- Make host session option a list, not string.
+ - Add load balancing support.
* /debian/control:
+ Add bin:package x2gobroker-agent.
diff --git a/lib/x2gobroker-agent.pl b/lib/x2gobroker-agent.pl
index 6a64bbf..74e0751 100755
--- a/lib/x2gobroker-agent.pl
+++ b/lib/x2gobroker-agent.pl
@@ -98,6 +98,43 @@ if($mode eq 'listsessions')
exec ("/bin/su - $uid -c \"x2golistsessions --all-servers\"");
}
+if($mode eq 'findbestserver_by_sessionstats') || ($mode eq 'findbestserver')
+{
+ InitX2GoUser($uid, $uidNumber, $gidNumber, $home);
+ print "OK\n";
+ my $session_list = `/bin/su - -c \"x2golistsessions_root --all-servers\"`;
+ my $avail_servers = `/bin/su - $uid -c \"x2gogetservers\"`;
+ my $amount_sessions = 0;
+
+ # initialize server_load hash
+ my %server_load = ();
+ foreach (split('\n', $avail_servers))
+ {
+ $server_load{$_} = 0;
+ }
+
+ # count sessions per server
+ my @session_list = split(/\n/, $session_list);
+ foreach (@session_list)
+ {
+ my ($apid, $sid, $disp, $hostname, $stat, $dcreated, $cookie, $gport, $sndport, $dsusp, $username, $fsport) = split('\\|', $_);
+ $amount_sessions++;
+ $server_load{$hostname} += 1;
+ }
+
+ # render the output result
+ my @result;
+ for my $hostname ( keys %server_load ) {
+ my $available = 100-$server_load{$hostname}/$amount_sessions*100;
+ if ($available eq 0) {
+ $available = 100;
+ }
+ push @result, sprintf '%1$d:%2$s', $available, $hostname;
+ }
+ print join('\n', sort @result);
+ print "\n";
+}
+
if($mode eq 'getservers')
{
diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py
new file mode 100644
index 0000000..3e7cdc6
--- /dev/null
+++ b/x2gobroker/agent.py
@@ -0,0 +1,87 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2012 by Mike Gabriel <mike.gabriel(a)das-netzwerkteam.de>
+# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder(a)obviously-nice.de>
+# Copyright (C) 2012 by Heinz-Markus Graesing <heinz-m.graesing(a)obviously-nice.de>
+#
+# X2Go Session Broker is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# X2Go Session Broker is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import subprocess
+
+# X2Go Broker modules
+import x2gobroker.defaults
+
+def call_x2gobroker_agent(username, mode):
+ """\
+ Launch X2Go Broker Agent and process its output.
+
+ @param username: run the broker agent for this user
+ @type username: C{unicode}
+ @param mode: execution mode of the broker (listsessions, getservers, etc.)
+ @type mode: C{unicode}
+
+ """
+ cmdline = [
+ '{x2gobroker_agent_binary}'.format(x2gobroker_agent_binary=x2gobroker.defaults.X2GOBROKER_AGENT_CMD),
+ '{username}'.format(username=username),
+ '{mode}'.format(mode=mode),
+ ]
+
+ subprocess.Popen(cmd_line,
+ stdin=None,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ shell=False,
+ )
+
+ return subprocess.stdout.read()
+
+def list_sessions(username):
+ """\
+ Query X2Go Broker Agent for a session list for a given username.
+
+ @param username: username for who to query a session list
+ @type username: C{unicode}
+
+ """
+ return call_broker_agent(username, mode='listsessions')
+
+def find_best_server(username=None):
+ """\
+ Query X2Go Broker Agent for the best server for the given user.
+ In many cases the username does not have an effect on the
+ detection of an optimal server.
+
+ @param username: username for who to query a session list
+ @type username: C{unicode}
+
+ """
+ server_list = call_broker_agent(username, mode='findbestserver')
+ server_list.sort(reverse=True)
+ return server_list[0].split(':')[1]
+
+def get_servers(username=None):
+ """\
+ Query X2Go Broker Agent for the list of available servers
+ for the given user. In many cases the username does not
+ have an effect on the list of available servers.
+
+ @param username: username for who to query a session list
+ @type username: C{unicode}
+
+ """
+ return call_broker_agent(username, mode='getservers')
+
diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py
index c06dfa6..9c710b3 100644
--- a/x2gobroker/brokers/base_broker.py
+++ b/x2gobroker/brokers/base_broker.py
@@ -29,10 +29,12 @@ import types
import copy
import uuid
import netaddr
+import random
# X2Go Broker modules
import x2gobroker.config
import x2gobroker.defaults
+import x2gobroker.agent
class X2GoBroker(object):
"""\
@@ -685,7 +687,7 @@ class X2GoBroker(object):
return list_of_profiles
- def select_session(self, profile_id):
+ def select_session(self, profile_id, username=None):
"""\
Start/resume a session by selecting a profile name offered by the X2Go client.
@@ -693,16 +695,40 @@ class X2GoBroker(object):
broker.
@param profile_id: the selected profile ID. This matches one of the dictionary keys offered by the C{list_profiles} method
- @type profile_id: C{dict}
+ @type profile_id: C{unicode}
+ @param username: specify username that this operation runs for
+ @type username: C{unicode}
"""
profile = self.get_profile(profile_id)
+ # if we have more than one server, pick one server randomly for X2Go Broker Agent queries
+ server_list = profile[u'host']
+ random.shuffle(server_list)
+ agent_query_server = server_list[0]
+
+ best_server = x2gobroker.agent.find_best_server()
+
selected_session = {
- 'server': profile[u'host'][0],
+ 'server': best_server,
'port': profile[u'sshport'],
}
+ # do some load balancing if more than one server is configured
+ if len(server_list) >= 1 and username:
+
+ session_list = x2gobroker.agent.list_sessions(username=username)
+ if session_list:
+
+ # if resuming, always select the first session in the list, there should only be one suspended session
+ server_name = session_list[0].split('|')[3]
+ session_info = session_list[0].split('|')[1]
+
+ selected_session.update({
+ 'server': server_name,
+ 'session_info': session_info,
+ })
+
return selected_session
def change_password(self, new='', old=''):
diff --git a/x2gobroker/brokers/zeroconf_broker.py b/x2gobroker/brokers/zeroconf_broker.py
index ad21567..5970659 100644
--- a/x2gobroker/brokers/zeroconf_broker.py
+++ b/x2gobroker/brokers/zeroconf_broker.py
@@ -76,7 +76,7 @@ class X2GoBroker(base.X2GoBroker):
}
return list_of_profiles
- def select_session(self, profile_id):
+ def select_session(self, profile_id, username=None):
selectprofile_output = {
'server': 'localhost',
diff --git a/x2gobroker/web/plain.py b/x2gobroker/web/plain.py
index b6c5f83..e25b5c0 100644
--- a/x2gobroker/web/plain.py
+++ b/x2gobroker/web/plain.py
@@ -142,7 +142,7 @@ class X2GoBrokerWebPlain:
if profile_id:
- profile_info = broker_backend.select_session(profile_id=profile_id)
+ profile_info = broker_backend.select_session(profile_id=profile_id, username=username)
if profile_info.has_key('server'):
output += "SERVER:"
output += profile_info['server']
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via abebae8791274f6634adb39d930ae055feed5fbb (commit)
from 2ce613977c17b31475dc3207652daa00a78f2537 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]python-x2gobroker.postinst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
The diff of changes is:
diff --git a/debian/python-x2gobroker.postinst b/debian/python-x2gobroker.postinst
index 861b3e0..6299aea 100755
--- a/debian/python-x2gobroker.postinst
+++ b/debian/python-x2gobroker.postinst
@@ -23,7 +23,7 @@ case "$1" in
# the python-x2gobroker needs special permissions on its log directory
if ! dpkg-statoverride --list /var/log/x2gobroker >/dev/null; then
- dpkg-statoverride --add --update x2gobroker adm 0750 /var/log/x2gobroker
+ dpkg-statoverride --add --update x2gobroker adm 2750 /var/log/x2gobroker
fi
;;
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via d04c71a2781be037ebbb3bdc9441019409c9c2a8 (commit)
from bbe2c8ab570f8f3e4b0e54a79117b9d93488de40 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]changelog | 1 +
debian/x2gobroker.manpages | 1 +
man/man8/x2gobroker.8 | 56 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+)
create mode 100644 debian/x2gobroker.manpages
create mode 100644 man/man8/x2gobroker.8
The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index c8ec285..f1e7e25 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ x2gobroker (0.0.0.2-0~x2go1) UNRELEASED; urgency=low
- Make host session option a list, not string.
- Add load balancing support.
- Add foundation for logging support.
+ - Add man page for x2gobroker executable.
* /debian/control:
+ Add bin:package x2gobroker-agent.
diff --git a/debian/x2gobroker.manpages b/debian/x2gobroker.manpages
new file mode 100644
index 0000000..b010d6d
--- /dev/null
+++ b/debian/x2gobroker.manpages
@@ -0,0 +1 @@
+man/man8/x2gobroker.8
\ No newline at end of file
diff --git a/man/man8/x2gobroker.8 b/man/man8/x2gobroker.8
new file mode 100644
index 0000000..6782fda
--- /dev/null
+++ b/man/man8/x2gobroker.8
@@ -0,0 +1,56 @@
+'\" -*- coding: utf-8 -*-
+.if \n(.g .ds T< \\FC
+.if \n(.g .ds T> \\F[\n[.fam]]
+.de URL
+\\$2 \(la\\$1\(ra\\$3
+..
+.if \n(.g .mso www.tmac
+.TH x2gobroker 8 "Feb 2013" "Version 0.0.1.y" "X2Go Session Broker"
+.SH NAME
+x2gobroker \- Session Broker for X2Go
+.SH SYNOPSIS
+'nh
+.fi
+.ad l
+\fBx2gobroker\fR \kx
+.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
+'in \n(.iu+\nxu
+[
+\fIoptions\fR
+]
+'in \n(.iu-\nxu
+.ad b
+'hy
+.SH DESCRIPTION
+\fBx2gobroker\fR is a Web.py based implementation of the X2Go Session Broker API.
+.PP
+See the included README and TODO for further information on \fBx2gobroker\fR.
+.SH COMMON OPTIONS
+\fBx2gobroker\fR accepts the following common options:
+.TP
+\*(T<\fB\-h, \-\-help\fR\*(T>
+Display a help with all available command line options and exit.
+.TP
+\*(T<\fB\-d, \-\-debug\fR\*(T>
+Enable debugging code. This also makes http\'s POST method available as GET method, which then allows it to test the
+broker API through a normal web browser.
+.TP
+\*(T<\fB\-d, \-\-config FILENAME\fR\*(T>
+Specify an alternative configuration file name, default is: \fI/etc/x2go/x2gobroker.conf\fR.
+.SH DAEMON OPTIONS
+\fBx2gobroker\fR accepts the following daemon options:
+.TP
+\*(T<\fB\-b, \-\-bind ADDRESS:PORT\fR\*(T>
+The [address:]port that the Web.py http-engine will bind to (default: 127.0.0.1:8080).
+.SH "FILES"
+/etc/x2go/x2gobroker.conf, /etc/x2go/broker/* (configuration files)
+.PP
+/etc/default/x2gobroker-daemon (environment for X2Go Session Broker when run
+as standalone daemon)
+.PP
+/var/log/x2gobroker/* (log files of X2Go Session Broker)
+.SH "SEE ALSO"
+\fB/usr/share/doc/x2gobroker\fR
+.SH AUTHOR
+This manual has been written for the X2Go project by
+Mike Gabriel <mike.gabriel(a)das-netzwerkteam.de>.
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]
The branch, statusflag has been updated
via fe7f06c112518bbac361c7e9f80ed721379a0e3b (commit)
from 5231ba48183cc603a5193400884dd01b360491ba (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
debian/…
[View More]x2gobroker-daemon.default | 9 ++++++++-
debian/x2gobroker-daemon.init | 6 +++---
etc/x2gobroker.conf | 2 +-
sbin/x2gobroker | 3 +++
4 files changed, 15 insertions(+), 5 deletions(-)
The diff of changes is:
diff --git a/debian/x2gobroker-daemon.default b/debian/x2gobroker-daemon.default
index 47ccb43..452a75b 100644
--- a/debian/x2gobroker-daemon.default
+++ b/debian/x2gobroker-daemon.default
@@ -24,7 +24,14 @@ START_DAEMON=true
# path to the X2Go Session Broker's agent command
#X2GOBROKER_AGENT_CMD=/usr/lib/x2go/x2gobroker-agent
-### enable SSL, you will have to create your own SSL certificates ###
+##########################################################
+### ###
+### Enable SSL Support ###
+### o You have to create your own SSL certificates ###
+### o You have to actively uncomment the below SSL ###
+### relevant line to enable https:// in x2gobroker ###
+### ###
+##########################################################
# SSL certificate file
#X2GOBROKER_SSL_CERTFILE=/etc/x2go/broker/ssl/broker.crt
diff --git a/debian/x2gobroker-daemon.init b/debian/x2gobroker-daemon.init
index 0ee9aed..d14bb8f 100644
--- a/debian/x2gobroker-daemon.init
+++ b/debian/x2gobroker-daemon.init
@@ -36,10 +36,10 @@ X2GOBROKER_SSL_CERTFILE=
X2GOBROKER_SSL_KEYFILE=
test -f $DEBIANCONFIG && . $DEBIANCONFIG
-export X2GOBROKER_DEBUG=0
-export X2GOBROKER_CONFIG="/etc/x2go/x2gobroker.conf"
+export X2GOBROKER_DEBUG
+export X2GOBROKER_CONFIG
export X2GOBROKER_DEFAULT_BACKEND
-export X2GOBROKER_SESSIONPROFILES="/etc/x2go/broker/x2gobroker-sessionprofiles.conf"
+export X2GOBROKER_SESSIONPROFILES
export X2GOBROKER_AGENT_CMD
export X2GOBROKER_SSL_CERTFILE
export X2GOBROKER_SSL_KEYFILE
diff --git a/etc/x2gobroker.conf b/etc/x2gobroker.conf
index 0999376..83f6bd8 100644
--- a/etc/x2gobroker.conf
+++ b/etc/x2gobroker.conf
@@ -88,7 +88,7 @@
# on large deployments it is recommended to ignore primary group memberships
# traversing into all user accounts for primary group detection can be quite
# CPU intensive on the X2Go Broker server.
-#ignore-primary-group-memberships = True
+#ignore-primary-group-memberships = true
###
### BACKEND section
diff --git a/sbin/x2gobroker b/sbin/x2gobroker
index 5c1fdd8..7ca11ce 100755
--- a/sbin/x2gobroker
+++ b/sbin/x2gobroker
@@ -61,6 +61,9 @@ if __name__ == "__main__":
x2gobroker.defaults.X2GOBROKER_CONFIG = cmdline_args.config_file
x2gobroker.defaults.X2GOBROKER_DEBUG = cmdline_args.debug
+ # some people just give the port but prepend a colon, webpy does not like this, so we strip if off
+ cmdline_args.bind = cmdline_args.bind.lstrip(':')
+
# import classes serving the different web.py URLs
from x2gobroker.web.plain import *
hooks/post-receive
--
x2gobroker.git (HTTP(S) Session broker for X2Go)
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).
[View Less]