This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to annotated tag 0.1.4.2
in repository x2goclient.

commit 473364d57429435b36b1f546e1442cd882cc624e
Author: Mike Gabriel <mike.gabr...@das-netzwerkteam.de>
Date:   Wed Sep 7 20:16:04 2011 +0200

    Add cmd line option --auth-attempts.
---
 debian/changelog       |  1 +
 man/man1/pyhoca-cli.1  |  7 ++++++-
 pyhoca-cli             |  6 ++++++
 pyhoca/cli/frontend.py | 13 ++++++++++---
 4 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 17142c22..31c4b03a 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.gabr...@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 35678ff7..b16cbee3 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 741f9cdf..c6752d9c 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 e5b36729..363d9e92 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)

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on 
/srv/git/code.x2go.org/x2goclient.git
_______________________________________________
x2go-commits mailing list
x2go-commits@lists.x2go.org
https://lists.x2go.org/listinfo/x2go-commits

Reply via email to