[X2go-Commits] pyhoca-cli.git - master (branch) updated: 0.1.4.1-8-g473364d

X2go dev team git-admin at x2go.org
Wed Sep 7 20:15:06 CEST 2011


The branch, master has been updated
       via  473364d57429435b36b1f546e1442cd882cc624e (commit)
      from  d5c1ff7f2e31a150aa241acd7317fabb940e5439 (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 -----------------------------------------------------------------
commit 473364d57429435b36b1f546e1442cd882cc624e
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Sep 7 20:16:04 2011 +0200

    Add cmd line option --auth-attempts.

-----------------------------------------------------------------------

Summary of changes:
 debian/changelog       |    1 +
 man/man1/pyhoca-cli.1  |    7 ++++++-
 pyhoca-cli             |    6 ++++++
 pyhoca/cli/frontend.py |   13 ++++++++++---
 4 files changed, 23 insertions(+), 4 deletions(-)

The diff of changes is:
diff --git a/debian/changelog b/debian/changelog
index 17142c2..31c4b03 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ pyhoca-cli (0.1.4.2-0~x2go1) UNRELEASED; urgency=low
     - Allow ,,NEWEST'' and ,,OLDEST'' as session name when resuming (closes
       upstream issue #86).
     - Add cmd line option --terminate-on-ctrl-c.
+    - Add cmd line option --auth-attempts.
 
  -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Wed, 06 Jul 2011 22:18:01 +0200
 
diff --git a/man/man1/pyhoca-cli.1 b/man/man1/pyhoca-cli.1
index 35678ff..b16cbee 100644
--- a/man/man1/pyhoca-cli.1
+++ b/man/man1/pyhoca-cli.1
@@ -128,9 +128,14 @@ Use X2go printing (default: disabled).
 .TP 
 \*(T<\fB\-\-share-mode\fR \fI{0|1}\fR\*(T> 
 Share mode for X2go desktop sharing (0: view-only, 1: full access).
-.TP 
+.TP
 \*(T<\fB\-\-time-to-wait\fR\*(T> 
 Time to wait for session startup/resume (default: 8s). There should be no need to touch this, unless on very slow network connections.
+.TP
+\*(T<\fB\-\-auth-attempts\fR \fI{0,1,2,3,...}\fR\*(T> 
+Number of interactive authentication attempts in case authentication with the server fails (wrong password?). A value that equals 0
+disables interactive authentication completely and requires that a private SSH key has been given on the command line or in the
+session profile or that the --password command line option is used.
 .SH LDAP OPTIONS
 LDAP support is planned to be added into \fBpyhoca-cli\fR in the near future. So stay tuned...
 .PP
diff --git a/pyhoca-cli b/pyhoca-cli
index 741f9cd..c6752d9 100755
--- a/pyhoca-cli
+++ b/pyhoca-cli
@@ -124,6 +124,7 @@ x2go_options =   [
                    {'args':['--clean-sessions'], 'default': False, 'action': 'store_true', 'help': 'clean all suspended sessions before starting a new one', },
                    {'args':['--terminate-on-ctrl-c'], 'default': False, 'action': 'store_true', 'help': 'terminate the connected session when pressing CTRL+C (instead of suspending the session)', },
                    {'args':['--time-to-wait'], 'default': '8', 'help': 'time to wait for session startup/resume (default: 8s)', },
+                   {'args':['--auth-attempts'], 'default': 3, 'help': 'number of authentication attempts before authentication fails (default: 3)', },
                  ]
 print_options =  [ 
                    {'args':['--print-action'], 'default': 'PDFVIEW', 'choices': PRINT_ACTIONS, 'help': 'action to be performed for incoming X2go print jobs (default: \'PDFVIEW\')', },
@@ -295,6 +296,11 @@ Possible values for the --pack NX option are:
     if a.share_local_folders is not None:
         a.share_local_folders = a.share_local_folders.split(',')
 
+    try:
+        _dummy = int(a.auth_attempts)
+    except ValueError:
+        runtime_error ("value for cmd line argument --auth-attempts has to be of type integer", parser=p, exitcode=1)
+
     if a.server:
 
         ##### TODO: ssh_config to be moved into Python X2go!!!!
diff --git a/pyhoca/cli/frontend.py b/pyhoca/cli/frontend.py
index e5b3672..363d9e9 100644
--- a/pyhoca/cli/frontend.py
+++ b/pyhoca/cli/frontend.py
@@ -286,6 +286,8 @@ class PyHocaCLI(x2go.X2goClient):
         if self.args.session_profile and not _profiles.has_profile(self.args.session_profile):
             self._runtime_error('no such session profile of name: %s' % (self.args.session_profile), exitcode=31)
 
+        self.auth_attempts = int(self.args.auth_attempts)
+
         if self.args.session_profile:
 
             _cmdlineopt_to_sessionopt = {
@@ -347,7 +349,7 @@ class PyHocaCLI(x2go.X2goClient):
         _username = self.args.username or self._X2goClient__get_session_username(self.x2go_session_hash)
         try:
 
-            _auth_count = 4
+            _auth_count = self.auth_attempts +1
             while not connected and _auth_count:
                 try:
                     self._X2goClient__connect_session(self.x2go_session_hash, username=_username, password=self.args.password, force_password_auth=force_password_auth)
@@ -375,8 +377,13 @@ class PyHocaCLI(x2go.X2goClient):
 
                 _auth_count -= 1
 
-                if not _auth_count:
-                    self._runtime_error('Authentication failed, too many failures during interactive login', exitcode=-201)
+                if not connected and not _auth_count:
+                    if self.auth_attempts >= 2:
+                        self._runtime_error('authentication failed, too many failures during interactive login', exitcode=-201)
+                    elif self.auth_attempts == 1:
+                        self._runtime_error('interactive authentication failed', exitcode=-202)
+                    else:
+                        self._runtime_error('non-interactive authentication failed', exitcode=-203)
 
         except socket.error, e:
             self._runtime_error('a socket error occured while establishing the connection: %s' % str(e), exitcode=-245)


hooks/post-receive
-- 
pyhoca-cli.git (Python X2go Client (command line client))

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 "pyhoca-cli.git" (Python X2go Client (command line client)).




More information about the x2go-commits mailing list