[X2Go-Commits] x2gobroker.git - tmp (branch) updated: 0.0.0.5-33-g993c8cd

X2Go dev team git-admin at x2go.org
Tue Apr 23 21:08:55 CEST 2013


The branch, tmp has been updated
       via  993c8cda4b2aa59cf181cb54d2fa5dfc90102c53 (commit)
      from  cacfe491f405d6db68079b6166d729f4c502d0dd (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/agent.py               |   19 +++++++++++++++----
 x2gobroker/brokers/base_broker.py |    7 +++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

The diff of changes is:
diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py
index ad2a989..1ea3373 100644
--- a/x2gobroker/agent.py
+++ b/x2gobroker/agent.py
@@ -22,6 +22,7 @@
 import subprocess
 import paramiko
 import cStringIO
+import gevent
 
 import x2gobroker._paramiko
 x2gobroker._paramiko.monkey_patch_paramiko()
@@ -61,6 +62,7 @@ def call_local_broker_agent(username, mode, cmdline_args=[]):
     if result[0].startswith('OK'):
         return [ r for r in result[1:] if r ]
 
+
 def call_remote_broker_agent(username, mode, cmdline_args=[], remote_agent=None):
     """\
     Launch remote X2Go Broker Agent via SSH and process its output.
@@ -109,6 +111,7 @@ def call_remote_broker_agent(username, mode, cmdline_args=[], remote_agent=None)
     except paramiko.SSHException:
         logger_error.error('could not connect to remote X2Go Broker Agent (user: {user}, hostname: {hostname}, port: {port}'.format(user=remote_username, hostname=remote_hostname, port=remote_port))
 
+
 def list_sessions(username, query_mode='LOCAL', remote_agent=None):
     """\
     Query X2Go Broker Agent for a session list for a given username.
@@ -126,6 +129,7 @@ def list_sessions(username, query_mode='LOCAL', remote_agent=None):
     else:
         return call_remote_broker_agent(username, mode='listsessions', remote_agent=remote_agent)
 
+
 def find_busy_servers(username, query_mode='LOCAL', remote_agent=None):
     """\
     Query X2Go Broker Agent for a list of  servers with running
@@ -157,6 +161,7 @@ def find_busy_servers(username, query_mode='LOCAL', remote_agent=None):
 
     return server_usage
 
+
 def add_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', query_mode='LOCAL', remote_agent=None):
     """\
     Add a public key hash to the user's authorized_keys file.
@@ -178,7 +183,8 @@ def add_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/aut
     else:
         return call_remote_broker_agent(username, mode='addauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ], remote_agent=remote_agent)
 
-def delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', query_mode='LOCAL', remote_agent=None):
+
+def delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', query_mode='LOCAL', remote_agent=None, delay_deletion=0):
     """\
     Remove a public key hash from the user's authorized_keys file.
 
@@ -194,10 +200,14 @@ def delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/
     @type remote_agent: C{dict}
 
     """
-    if query_mode.upper() == u'LOCAL':
-        return call_local_broker_agent(username, mode='delauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ])
+    if delay_deletion > 0:
+        gevent.spawn_later(delay_deletion, delete_authorized_key, username=username, authorized_keys_file=authorized_keys_file, query_mode=query_mode, remote_agent=remote_agent, )
     else:
-        return call_remote_broker_agent(username, mode='delauthkey', cmdline_args=[pubkey_hash, authorized_keys_file, ], remote_agent=remote_agent)
+        if 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)
+
 
 def get_servers(username, query_mode='LOCAL', remote_agent=None):
     """\
@@ -218,6 +228,7 @@ def get_servers(username, query_mode='LOCAL', remote_agent=None):
     else:
         return call_local_broker_agent(username, mode='getservers', remote_agent=remote_agent)
 
+
 def genkeypair(local_username, client_address, key_type='RSA'):
     """\
     Generate an SSH pub/priv key pair without writing the private key to file.
diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py
index c3dbc7f..a19f6d9 100644
--- a/x2gobroker/brokers/base_broker.py
+++ b/x2gobroker/brokers/base_broker.py
@@ -871,6 +871,13 @@ class X2GoBroker(object):
             selected_session.update({
                 'authentication_privkey': privkey,
             })
+            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=60,
+            ),
 
         return selected_session
 


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).




More information about the x2go-commits mailing list