The branch, twofactorauth has been updated via 63c93d1376cf14bfc549ecdb33189212d3c1dc0b (commit) from 78f0a40ac8dc79a9338cc949ddbacf213421ab31 (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: x2go/session.py | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) The diff of changes is: diff --git a/x2go/session.py b/x2go/session.py index fd51534..6687105 100644 --- a/x2go/session.py +++ b/x2go/session.py @@ -343,6 +343,7 @@ class X2goSession(paramiko.SSHClient): _session_auth_rsakey = None _remote_home = None + _remote_x2gousers = None def __init__(self, geometry="800x600", depth=24, link="adsl", pack="16m-jpeg-9", @@ -442,9 +443,9 @@ class X2goSession(paramiko.SSHClient): else: raise x2go_exceptions.X2goSessionException('the Paramiko/SSH client is not connected') - def _x2go_sftp_put(self, local_path, remote_path, loglevel=log.loglevel_INFO): + def _x2go_sftp_put(self, local_path, remote_path): - self.logger('sFTP-put: %s -> %s:%s' % (local_path, self.session_info.hostname, remote_path), loglevel) + self.logger('sFTP-put: %s -> %s:%s' % (local_path, self.session_info.hostname, remote_path), loglevel=log.loglevel_DEBUG) self.sftp_client.put(local_path, remote_path) def _x2go_sftp_write(self, remote_path, content, loglevel=log.loglevel_INFO): @@ -455,9 +456,9 @@ class X2goSession(paramiko.SSHClient): remote_fileobj.write(content) remote_fileobj.close() - def _x2go_sftp_remove(self, remote_path, loglevel=log.loglevel_INFO): + def _x2go_sftp_remove(self, remote_path): - self.logger('sFTP-write: removing remote file %s on host %s' % (remote_path, self.session_info.hostname), loglevel) + self.logger('sFTP-write: removing remote file %s on host %s' % (remote_path, self.session_info.hostname), loglevel=log.loglevel_DEBUG) self.sftp_client.remove(remote_path) @property @@ -466,11 +467,23 @@ class X2goSession(paramiko.SSHClient): if self._remote_home is None: (stdin, stdout, stderr) = self._x2go_exec_command('echo $HOME') self._remote_home = stdout.read().split()[0] + self.logger('remote user\' home directory: %s' % self._remote_home, loglevel=log.loglevel_DEBUG) return self._remote_home else: return self._remote_home @property + def _x2go_remote_x2gousers(self): + + if self._remote_x2gousers is None: + (stdin, stdout, stderr) = self._x2go_exec_command('getent group x2gousers | cut -d":" -f4') + self._remote_x2gousers = stdout.read().split('\n')[0].split(',') + self.logger('remote x2gousers group: %s' % self._remote_x2gousers, loglevel=log.loglevel_DEBUG) + return self._remote_x2gousers + else: + return self._remote_x2gousers + + @property def _x2go_session_auth_rsakey(self): if self._session_auth_rsakey is None: self._session_auth_rsakey = paramiko.RSAKey.generate(defaults.RSAKEY_STRENGTH) @@ -593,6 +606,8 @@ class X2goSession(paramiko.SSHClient): self.guardian_thread.start() self.guardian_thread.active_threads.append(self.get_transport()) + return (self.get_transport() is not None) + def start(self, **kwargs): """\ Start a new X2go session. @@ -603,6 +618,10 @@ class X2goSession(paramiko.SSHClient): """ self.params.update(kwargs) + _remote_username = self.get_transport().get_username() + if _remote_username not in self._x2go_remote_x2gousers: + raise x2go_exceptions.X2goSessionException('remote user %s is not member of X2go server group x2gousers' % _remote_username) + setkbd = "0" if self.params.kblayout or self.params.kbtype: setkbd = "1" @@ -620,8 +639,9 @@ class X2goSession(paramiko.SSHClient): ] (stdin, stdout, stderr) = self._x2go_exec_command(cmd_line) + self.session_info.initialize(stdout.read(), - username=self.get_transport().get_username(), + username=_remote_username, hostname=self.get_transport().getpeername(), ) @@ -636,7 +656,9 @@ class X2goSession(paramiko.SSHClient): self.proxy = self.proxy_class(session_info=self.session_info, ssh_transport=self.get_transport(), logger=self.logger) self.proxy_subprocess = self.proxy.start() + self.associated = True + return self.ok() def start_sound(self): """\ @@ -1031,11 +1053,10 @@ class X2goSession(paramiko.SSHClient): self.session_info.remote_container = '%s/%s/C-%s' % (self._x2go_remote_home, _X2GO_SESSION_ROOTDIR, self.session_info.name, ) - - return True + return self.ok() else: - return False + raise X2goSessionException('This X2go session instance is not associated to any server-side X2go session.') def suspend(self, session_name=None): """\ hooks/post-receive -- python-x2go.git (Python X2Go Client API) 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 "python-x2go.git" (Python X2Go Client API).