This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2gobroker. from bea1db3 improve last changelog entry new f74b487 agent.py: Use os.fork() instead of threading.Thread() to handle delayed executions of broker agent tasks. This assures that SSH pub keys are removed via the delauthkey broker agent task, if the SSH broker is used. (Fixes: #491). The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: debian/changelog | 4 ++++ x2gobroker/agent.py | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit f74b48714caedc16767d543c104e14ed5195aa85 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Apr 2 06:11:59 2015 +0200 agent.py: Use os.fork() instead of threading.Thread() to handle delayed executions of broker agent tasks. This assures that SSH pub keys are removed via the delauthkey broker agent task, if the SSH broker is used. (Fixes: #491). --- debian/changelog | 4 ++++ x2gobroker/agent.py | 30 ++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index 37715fb..b826a6d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -304,6 +304,10 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low further possible substitutions for deriving the full path of the authorized_keys file where X2Go Broker Agent's deploys public SSH user keys to. (Fixes: #665). + - agent.py: Use os.fork() instead of threading.Thread() to handle + delayed executions of broker agent tasks. This assures that SSH pub keys + are removed via the delauthkey broker agent task, if the SSH broker + is used. (Fixes: #491). * debian/control: + Provide separate bin:package for SSH brokerage: x2gobroker-ssh. + Replace LDAP support with session brokerage support in LONG_DESCRIPTION. diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py index b5c6b06..bf7ecfe 100644 --- a/x2gobroker/agent.py +++ b/x2gobroker/agent.py @@ -17,13 +17,13 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +import os import os.path import types import subprocess import paramiko import cStringIO import time -import threading import socket import logging @@ -42,22 +42,28 @@ from x2gobroker.loggers import logger_broker, logger_error tasks = {} -class delayed_execution(threading.Thread): +def delayed_execution(agent_func, delay=0, **kwargs): - def __init__(self, agent_func, delay=0, **kwargs): - threading.Thread.__init__(self) - self.agent_func = agent_func - self.delay = delay - self.kwargs = kwargs - self.daemon = True - self.start() + forkpid = os.fork() + if forkpid == 0: - def run(self): + # close stdin, stdout and stderr in the forked process... + for nm in os.listdir("/proc/self/fd"): + if nm.startswith('.'): + continue + fd = int(nm) + if fd in (0,1,2): + os.close(fd) + + # wait for the given delay period i = 0 - while i < self.delay: + while i < delay: time.sleep(1) i += 1 - self.agent_func(**self.kwargs) + + # execute the function requested + agent_func(**kwargs) + os._exit(0) def has_remote_broker_agent_setup(): -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git