This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2gobroker. from 902de4c agent/call_remote_broker_agent: fix quoting for the remote command new f99c628 x2gobroker-agent: be more precise when checking public key existence and removing public keys new 2bc9739 agent.py: fix buggy call of os.path.expanduser() new da33b36 x2gobroker-agent: literally test for the pubkey, ignore regexp-like expressions in pubkey hashes new 21cd416 x2gobroker-daemon-debug: don't fail to start if DAEMON_BIND_ADDRESS is unset new f92fc10 Fully rewrite agent.py new db86895 Fix broker crashes when no session status is available for certain session profiles. new 700270b drop obsolete function parameter 'query_mode' when calling agent tasks The 7 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 | 3 + lib/x2gobroker-agent.pl | 4 +- sbin/x2gobroker-daemon-debug | 6 +- x2gobroker/agent.py | 139 ++++++++++++++++--------------------- x2gobroker/brokers/base_broker.py | 16 ++--- 5 files changed, 76 insertions(+), 92 deletions(-) -- Alioth's /srv/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 f99c628cdccb7b693de28b9cffa378f153374c02 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 11:53:48 2014 +0100 x2gobroker-agent: be more precise when checking public key existence and removing public keys --- lib/x2gobroker-agent.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/x2gobroker-agent.pl b/lib/x2gobroker-agent.pl index ccb8ebb..c1fb216 100755 --- a/lib/x2gobroker-agent.pl +++ b/lib/x2gobroker-agent.pl @@ -83,7 +83,7 @@ sub AddAuthKey system ("sudo", "-u", "$uid", "--", "mkdir", "-p", "$authkeydir"); system ("sudo", "-u", "$uid", "--", "touch", "$authkeyfile"); my $authorized_keys = `sudo -u $uid -- cat "$authkeyfile"`; - if ( ! ( $authorized_keys =~ m/$pubkey/ ) ) + if ( ! ( $authorized_keys =~ m/^$pubkey$/ ) ) { open my $saveout, ">&STDOUT"; open STDOUT, '>', "/dev/null"; @@ -110,7 +110,7 @@ sub DelAuthKey open STDOUT, '>', "/dev/null"; open my $saveerr, ">&STDERR"; open STDERR, '>', "/dev/null"; - system("sudo", "-u", "$uid", "--", "sed", "-e", "s!$pubkey!!", "-e", "/^\$/d", "-i", "$authkeyfile"); + system("sudo", "-u", "$uid", "--", "sed", "-e", "s!^$pubkey\$!!", "-e", "/^\$/d", "-i", "$authkeyfile"); open STDOUT, ">&", $saveout; open STDERR, ">&", $saveerr; } -- Alioth's /srv/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 2bc973982aa0d08d54e94d2942e172278ab81217 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 12:58:04 2014 +0100 agent.py: fix buggy call of os.path.expanduser() --- x2gobroker/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py index 01c92d7..55fc083 100644 --- a/x2gobroker/agent.py +++ b/x2gobroker/agent.py @@ -155,8 +155,8 @@ def call_remote_broker_agent(username, mode, cmdline_args=[], remote_agent=None) try: client = paramiko.SSHClient() client.load_system_host_keys() - if os.path.exists(os.expanduser("~/.ssh/known_hosts")): - client.load_host_keys(os.expanduser("~/.ssh/known_hosts")) + if os.path.exists(os.path.expanduser("~/.ssh/known_hosts")): + client.load_host_keys(os.path.expanduser("~/.ssh/known_hosts")) client.set_missing_host_key_policy(remote_agent['host_key_policy']) client.connect(remote_hostname, remote_port, remote_username, look_for_keys=True, allow_agent=True) -- Alioth's /srv/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 21cd416db814166c98868ca7b54fc33e8999dccb Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 13:19:05 2014 +0100 x2gobroker-daemon-debug: don't fail to start if DAEMON_BIND_ADDRESS is unset --- sbin/x2gobroker-daemon-debug | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sbin/x2gobroker-daemon-debug b/sbin/x2gobroker-daemon-debug index 86225eb..8426ecb 100755 --- a/sbin/x2gobroker-daemon-debug +++ b/sbin/x2gobroker-daemon-debug @@ -34,4 +34,8 @@ if [ -e /etc/default/x2gobroker-daemon ]; then . /etc/default/x2gobroker-daemon fi -su - x2gobroker -c "X2GOBROKER_SSL_CERTFILE=\"$X2GOBROKER_SSL_CERTFILE\" X2GOBROKER_SSL_KEYFILE=\"$X2GOBROKER_SSL_KEYFILE\" DAEMON_BIND_ADDRESS=\"$DAEAMON_BIND_ADDRESS\" x2gobroker-daemon -M http -b$DAEMON_BIND_ADDRESS -i $@" +if [ -n "$DAEMON_BIND_ADDRESS" ]; then + su - x2gobroker -c "X2GOBROKER_SSL_CERTFILE=\"$X2GOBROKER_SSL_CERTFILE\" X2GOBROKER_SSL_KEYFILE=\"$X2GOBROKER_SSL_KEYFILE\" DAEMON_BIND_ADDRESS=\"$DAEMON_BIND_ADDRESS\" x2gobroker-daemon -M http -b $DAEMON_BIND_ADDRESS -i $@" +else + su - x2gobroker -c "X2GOBROKER_SSL_CERTFILE=\"$X2GOBROKER_SSL_CERTFILE\" X2GOBROKER_SSL_KEYFILE=\"$X2GOBROKER_SSL_KEYFILE\" x2gobroker-daemon -M http -i $@" +fi -- Alioth's /srv/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 700270b04644b2df8fb3b49d2d6cef4b895404eb Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 14:43:50 2014 +0100 drop obsolete function parameter 'query_mode' when calling agent tasks --- x2gobroker/brokers/base_broker.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py index 8da869c..2b1cdf4 100644 --- a/x2gobroker/brokers/base_broker.py +++ b/x2gobroker/brokers/base_broker.py @@ -875,7 +875,7 @@ class X2GoBroker(object): remote_agent = {u'hostname': remote_agent_server, u'port': remote_agent_port, } try: - if x2gobroker.agent.ping(query_mode=agent_query_mode, remote_agent=remote_agent): + if x2gobroker.agent.ping(remote_agent=remote_agent): break except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: remote_agent = None @@ -928,7 +928,7 @@ class X2GoBroker(object): agent_query_mode = ( remote_agent == u'LOCAL') and u'LOCAL' or u'SSH' if remote_agent: try: - running_sessions, suspended_sessions = x2gobroker.agent.has_sessions(username, query_mode=agent_query_mode, remote_agent=remote_agent) + running_sessions, suspended_sessions = x2gobroker.agent.has_sessions(username, remote_agent=remote_agent) if running_sessions: logger_broker.debug('base_broker.X2GoBroker.list_profiles(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(running_sessions))) if suspended_sessions: @@ -980,7 +980,7 @@ class X2GoBroker(object): # query remote agent for session info busy_servers = None try: - busy_servers = x2gobroker.agent.find_busy_servers(username=username, query_mode=agent_query_mode, remote_agent=remote_agent) + busy_servers = x2gobroker.agent.find_busy_servers(username=username, remote_agent=remote_agent) except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: pass @@ -1048,7 +1048,7 @@ class X2GoBroker(object): if remote_agent and server_list and username: try: - session_list = x2gobroker.agent.list_sessions(username=username, query_mode=agent_query_mode, remote_agent=remote_agent) + session_list = x2gobroker.agent.list_sessions(username=username, remote_agent=remote_agent) except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: session_list = [] @@ -1069,7 +1069,7 @@ class X2GoBroker(object): session_info = suspended_sessions[0] else: session_info = running_sessions[0] - x2gobroker.agent.suspend_session(username=username, session_name=session_info.split('|')[1], query_mode=agent_query_mode, remote_agent=remote_agent) + x2gobroker.agent.suspend_session(username=username, session_name=session_info.split('|')[1], remote_agent=remote_agent) # this is the turn-around in x2gocleansessions, so waiting as along as the daemon that will suspend the session time.sleep(2) session_info = session_info.replace('|R|', '|S|') @@ -1105,7 +1105,6 @@ class X2GoBroker(object): x2gobroker.agent.add_authorized_key(username=username, pubkey_hash=pubkey, authorized_keys_file=self.get_authorized_keys_file(profile_id), - query_mode=agent_query_mode, remote_agent=remote_agent, ), selected_session.update({ @@ -1114,7 +1113,6 @@ class X2GoBroker(object): x2gobroker.agent.delete_authorized_key(username=username, pubkey_hash=pubkey, authorized_keys_file=self.get_authorized_keys_file(profile_id), - query_mode=agent_query_mode, remote_agent=remote_agent, delay_deletion=20, ) @@ -1123,7 +1121,6 @@ class X2GoBroker(object): x2gobroker.agent.add_authorized_key(username=username, pubkey_hash=pubkey, authorized_keys_file=self.get_authorized_keys_file(profile_id), - query_mode=agent_query_mode, remote_agent=remote_agent, ), selected_session.update({ @@ -1132,7 +1129,6 @@ class X2GoBroker(object): x2gobroker.agent.delete_authorized_key(username=username, pubkey_hash=pubkey, authorized_keys_file=self.get_authorized_keys_file(profile_id), - query_mode=agent_query_mode, remote_agent=remote_agent, delay_deletion=20, ) -- Alioth's /srv/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 da33b36a3ed9f133292da68bdbdf5514cf78866b Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 12:59:10 2014 +0100 x2gobroker-agent: literally test for the pubkey, ignore regexp-like expressions in pubkey hashes --- lib/x2gobroker-agent.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/x2gobroker-agent.pl b/lib/x2gobroker-agent.pl index c1fb216..e0c52a4 100755 --- a/lib/x2gobroker-agent.pl +++ b/lib/x2gobroker-agent.pl @@ -83,7 +83,7 @@ sub AddAuthKey system ("sudo", "-u", "$uid", "--", "mkdir", "-p", "$authkeydir"); system ("sudo", "-u", "$uid", "--", "touch", "$authkeyfile"); my $authorized_keys = `sudo -u $uid -- cat "$authkeyfile"`; - if ( ! ( $authorized_keys =~ m/^$pubkey$/ ) ) + if ( ! ( $authorized_keys =~ m/\Q$pubkey\E$/ ) ) { open my $saveout, ">&STDOUT"; open STDOUT, '>', "/dev/null"; -- Alioth's /srv/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 f92fc103e73bef1f6ed92e0d7ec60cdf1133e531 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 14:39:48 2014 +0100 Fully rewrite agent.py --- debian/changelog | 1 + x2gobroker/agent.py | 135 ++++++++++++++++++++++----------------------------- 2 files changed, 59 insertions(+), 77 deletions(-) diff --git a/debian/changelog b/debian/changelog index a65728d..fd5259b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -113,6 +113,7 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low - Fix https brokerage in x2gobroker-daemon-debug. - Load X2GOBROKER_DAEMON_USER's known_hosts key file before doing remote agent calls. + - Fully rewrite agent.py. * debian/control: + Replace LDAP support with session brokerage support in LONG_DESCRIPTION. + Fix SYNOPSIS texts. diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py index 55fc083..b5f0631 100644 --- a/x2gobroker/agent.py +++ b/x2gobroker/agent.py @@ -78,21 +78,41 @@ def has_remote_broker_agent_setup(): elif os.path.exists(os.path.join(home, '.ssh', 'id_ecdsa')): return True +def call_broker_agent(username, task, cmdline_args=[], remote_agent=None, **kwargs): + """\ + Launch X2Go Broker Agent and process its output. -def call_local_broker_agent(username, mode, cmdline_args=[]): + @param username: run the broker agent for this user + @type username: C{unicode} + @param task: task name to execute via the broker agent (listsessions, getservers, etc.) + @type task: C{unicode} + @param cmdline_args: additional command line parameters for the broker agent + @type cmdline_args: C{list} + @param remote_agent: if not C{None} call a remote broker agent via SSH + @type remoate_agent: C{dict} + + """ + if remote_agent in (u'LOCAL', None): + result = _call_local_broker_agent(username=username, task=task, cmdline_args=cmdline_args) + else: + result = _call_remote_broker_agent(username=username, task=task, cmdline_args=cmdline_args, remote_agent=remote_agent) + +def _call_local_broker_agent(username, task, cmdline_args=[]): """\ Launch X2Go Broker Agent locally 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} + @param task: task name to execute via the broker agent (listsessions, getservers, etc.) + @type task: C{unicode} + @param cmdline_args: additional command line parameters for the broker agent + @type cmdline_args: C{list} """ cmd_line = [ '{x2gobroker_agent_binary}'.format(x2gobroker_agent_binary=x2gobroker.defaults.X2GOBROKER_AGENT_CMD), '{username}'.format(username=username), - '{mode}'.format(mode=mode), + '{task}'.format(task=task), ] for cmdline_arg in cmdline_args: @@ -118,14 +138,16 @@ def call_local_broker_agent(username, mode, cmdline_args=[]): raise x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException('Query to local X2Go Broker Agent failed with no response') -def call_remote_broker_agent(username, mode, cmdline_args=[], remote_agent=None): +def _call_remote_broker_agent(username, task, cmdline_args=[], remote_agent=None): """\ Launch remote X2Go Broker Agent via SSH 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} + @param task: task name to execute via the broker agent (listsessions, getservers, etc.) + @type task: C{unicode} + @param cmdline_args: additional command line parameters for the broker agent + @type cmdline_args: C{list} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} @@ -138,7 +160,7 @@ def call_remote_broker_agent(username, mode, cmdline_args=[], remote_agent=None) cmd_line = [ '{x2gobroker_agent_binary}'.format(x2gobroker_agent_binary=x2gobroker.defaults.X2GOBROKER_AGENT_CMD), '{username}'.format(username=username), - '{mode}'.format(mode=mode), + '{task}'.format(task=task), ] for cmdline_arg in cmdline_args: @@ -212,92 +234,73 @@ def icmp_ping(hostname): return True -def ping(query_mode='LOCAL', remote_agent=None, **kwargs): +def ping(remote_agent=None, **kwargs): """\ Ping X2Go Broker Agent. - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ username='foo' - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='ping') + if remote_agent is None: + return _call_local_broker_agent(username) else: return remote_agent is not None and \ icmp_ping(remote_agent['hostname']) and \ - call_remote_broker_agent(username, mode='ping', remote_agent=remote_agent) + _call_remote_broker_agent(username, task='ping', remote_agent=remote_agent) tasks['ping'] = ping -def list_sessions(username, query_mode='LOCAL', remote_agent=None): +def list_sessions(username, remote_agent=None, **kwargs): """\ Query X2Go Broker Agent for a session list for a given username. @param username: run the query on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='listsessions') - else: - return call_remote_broker_agent(username, mode='listsessions', remote_agent=remote_agent) + return call_broker_agent(username, task='listsessions', remote_agent=remote_agent, **kwargs) tasks['listsessions'] = list_sessions -def suspend_session(username, session_name, query_mode='LOCAL', remote_agent=None, **kwargs): +def suspend_session(username, session_name, remote_agent=None, **kwargs): """\ Trigger a session suspensions via the X2Go Broker Agent. @param username: suspend the session on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='suspendsession', cmdline_args=[session_name, ], ) - else: - return call_remote_broker_agent(username, mode='suspendsession', cmdline_args=[session_name, ], remote_agent=remote_agent) + return call_broker_agent(username, task='suspendsession', cmdline_args=[session_name, ], remote_agent=remote_agent, **kwargs) tasks['suspendsession'] = suspend_session -def terminate_session(username, session_name, query_mode='LOCAL', remote_agent=None, **kwargs): +def terminate_session(username, session_name, remote_agent=None, **kwargs): """\ Trigger a session termination via the X2Go Broker Agent. @param username: terminate the session on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='terminatesession', cmdline_args=[session_name, ], ) - else: - return call_remote_broker_agent(username, mode='terminatesession', cmdline_args=[session_name, ], remote_agent=remote_agent) + return call_broker_agent(username, task='terminatesession', cmdline_args=[session_name, ], remote_agent=remote_agent, **kwargs) tasks['terminatesession'] = terminate_session -def has_sessions(username, query_mode='LOCAL', remote_agent=None): +def has_sessions(username, remote_agent=None, **kwargs): """\ Query X2Go Broker Agent to detect running/suspended sessions on the remote X2Go Server (farm). @param username: run the query on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} @@ -305,11 +308,14 @@ def has_sessions(username, query_mode='LOCAL', remote_agent=None): @rtype: C{tuple} """ - _session_list = list_sessions(username, query_mode=query_mode, remote_agent=remote_agent) - return ([ s.split('|')[3] for s in _session_list if s.split('|')[4] == 'R' ], [ s.split('|')[3] for s in _session_list if s.split('|')[4] == 'S' ]) + _session_list = list_sessions(username, remote_agent=remote_agent, **kwargs) + if type(_session_list) is types.ListType: + return ([ s.split('|')[3] for s in _session_list if s.split('|')[4] == 'R' ], [ s.split('|')[3] for s in _session_list if s.split('|')[4] == 'S' ]) + else: + return ([], []) -def find_busy_servers(username, query_mode='LOCAL', remote_agent=None, **kwargs): +def find_busy_servers(username, remote_agent=None, **kwargs): """\ Query X2Go Broker Agent for a list of servers with running and/or suspended sessions and a percentage that tells about @@ -319,16 +325,11 @@ def find_busy_servers(username, query_mode='LOCAL', remote_agent=None, **kwargs) @param username: run the query on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - server_list = call_local_broker_agent(username, mode='findbusyservers') - else: - server_list = call_remote_broker_agent(username, mode='findbusyservers', remote_agent=remote_agent) + server_list = call_broker_agent(username, task='findbusyservers', remote_agent=remote_agent, **kwargs) server_usage = {} @@ -343,7 +344,7 @@ def find_busy_servers(username, query_mode='LOCAL', remote_agent=None, **kwargs) tasks['findbusyservers'] = find_busy_servers -def add_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', query_mode='LOCAL', remote_agent=None, **kwargs): +def add_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', remote_agent=None, **kwargs): """\ Add a public key hash to the user's authorized_keys file. @@ -353,20 +354,15 @@ def add_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/aut @type pubkey_hash: C{unicode} @param authorized_keys_file: the full path to the remote X2Go server's authorized_keys file @type authorized_keys_file: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='addauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ]) - else: - return call_remote_broker_agent(username, mode='addauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ], remote_agent=remote_agent) + return call_broker_agent(username, task='addauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ], remote_agent=remote_agent, **kwargs) tasks['addauthkey'] = add_authorized_key -def delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', query_mode='LOCAL', remote_agent=None, delay_deletion=0, **kwargs): +def delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', remote_agent=None, delay_deletion=0, **kwargs): """\ Remove a public key hash from the user's authorized_keys file. @@ -376,30 +372,25 @@ def delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/ @type pubkey_hash: C{unicode} @param authorized_keys_file: the full path to the remote X2Go server's authorized_keys file @type authorized_keys_file: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ # this is for the logger output - if remote_agent in (None, u'LOCAL'): + if remote_agent in ('LOCAL', None): _hostname = 'LOCAL' else: _hostname = remote_agent['hostname'] if delay_deletion > 0: - delayed_execution(delete_authorized_key, delay=delay_deletion, username=username, pubkey_hash=pubkey_hash, authorized_keys_file=authorized_keys_file, query_mode=query_mode, remote_agent=remote_agent, ) + delayed_execution(delete_authorized_key, delay=delay_deletion, username=username, pubkey_hash=pubkey_hash, authorized_keys_file=authorized_keys_file, remote_agent=remote_agent, ) logger_broker.debug('Scheduled deletion of authorized key in {delay}s: user={user}, host={host}'.format(delay=delay_deletion, user=username, host=_hostname)) else: - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='delauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ]) - else: - return call_remote_broker_agent(username, mode='delauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ], remote_agent=remote_agent) + return call_broker_agent(username, task='delauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ], remote_agent=remote_agent, **kwargs) tasks['delauthkey'] = delete_authorized_key -def get_servers(username, query_mode='LOCAL', remote_agent=None, **kwargs): +def get_servers(username, remote_agent=None, **kwargs): """\ Query X2Go Broker Agent for the list of currently used servers. @@ -407,20 +398,15 @@ def get_servers(username, query_mode='LOCAL', remote_agent=None, **kwargs): @param username: run the query on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='getservers') - else: - return call_remote_broker_agent(username, mode='getservers', remote_agent=remote_agent) + return call_broker_agent(username, task='getservers', remote_agent=remote_agent, **kwargs) tasks['getservers'] = get_servers -def tasks_available(username, query_mode='LOCAL', remote_agent=None, **kwargs): +def tasks_available(username, remote_agent=None, **kwargs): """\ Query X2Go Broker Agent for the list of available tasks. @@ -429,16 +415,11 @@ def tasks_available(username, query_mode='LOCAL', remote_agent=None, **kwargs): @param username: run the query on behalf of this username @type username: C{unicode} - @param query_mode: query mode used when calling X2Go Broker Agent (C{LOCAL} or C{SSH}) - @type query_mode: C{unicode} @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} """ - if unicode(query_mode).upper() == u'LOCAL': - return call_local_broker_agent(username, mode='availabletasks') - else: - return call_remote_broker_agent(username, mode='availabletasks', remote_agent=remote_agent) + return call_broker_agent(username, task='availabletasks', remote_agent=remote_agent, **kwargs) tasks['availabletasks'] = tasks_available -- Alioth's /srv/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 db86895adeabb75aca02c9d084101c23cbc18a90 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Mon Mar 24 14:40:27 2014 +0100 Fix broker crashes when no session status is available for certain session profiles. --- debian/changelog | 2 ++ x2gobroker/brokers/base_broker.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index fd5259b..ee2b51d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -114,6 +114,8 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low - Load X2GOBROKER_DAEMON_USER's known_hosts key file before doing remote agent calls. - Fully rewrite agent.py. + - Fix broker crashes when no session status is available for certain + session profiles. * debian/control: + Replace LDAP support with session brokerage support in LONG_DESCRIPTION. + Fix SYNOPSIS texts. diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py index 6a5e879..8da869c 100644 --- a/x2gobroker/brokers/base_broker.py +++ b/x2gobroker/brokers/base_broker.py @@ -935,7 +935,7 @@ class X2GoBroker(object): logger_broker.debug('base_broker.X2GoBroker.list_profiles(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(suspended_sessions))) if x2gobroker.utils.matching_hostnames(profile['host'], running_sessions): profile['status'] = u'R' if x2gobroker.utils.matching_hostnames(profile['host'], suspended_sessions): profile['status'] = u'S' - if profile['status']: + if profile.has_key('status') and profile['status']: logger_broker.debug('base_broker.X2GoBroker.list_profiles(): marking session profile {name} as {status}'.format(name=profile['name'], status=profile['status'])) except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git