r40090 - in /branches/upstream/libauthen-tacacsplus-perl/current: Changes META.yml TacacsPlus.pm tacpluslib/tac_client.c

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Fri Jul 17 19:06:12 UTC 2009


Author: jawnsy-guest
Date: Fri Jul 17 19:06:05 2009
New Revision: 40090

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=40090
Log:
[svn-upgrade] Integrating new upstream version, libauthen-tacacsplus-perl (0.20)

Modified:
    branches/upstream/libauthen-tacacsplus-perl/current/Changes
    branches/upstream/libauthen-tacacsplus-perl/current/META.yml
    branches/upstream/libauthen-tacacsplus-perl/current/TacacsPlus.pm
    branches/upstream/libauthen-tacacsplus-perl/current/tacpluslib/tac_client.c

Modified: branches/upstream/libauthen-tacacsplus-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libauthen-tacacsplus-perl/current/Changes?rev=40090&op=diff
==============================================================================
--- branches/upstream/libauthen-tacacsplus-perl/current/Changes (original)
+++ branches/upstream/libauthen-tacacsplus-perl/current/Changes Fri Jul 17 19:06:05 2009
@@ -38,3 +38,9 @@
 
 0.19 Sun Mar 16 2008, Mike McCauley
      - Fixed 'make test' failure in taclibplus due to missing pure_all target
+
+0.20 Fri July 10, 2009 Mike McCauley
+     - Fixed incorect spelling of 'Authentication' in tac_client.c
+     - implements a 
+     timeout for the connect() operation. It uses the timeout value which is
+     passed to the init_tac_session() function. Contributed by Robert Leibl

Modified: branches/upstream/libauthen-tacacsplus-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libauthen-tacacsplus-perl/current/META.yml?rev=40090&op=diff
==============================================================================
--- branches/upstream/libauthen-tacacsplus-perl/current/META.yml (original)
+++ branches/upstream/libauthen-tacacsplus-perl/current/META.yml Fri Jul 17 19:06:05 2009
@@ -1,10 +1,18 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Authen-TacacsPlus
-version:      0.19
-version_from: TacacsPlus.pm
-installdirs:  site
-requires:
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+--- #YAML:1.0
+name:               Authen-TacacsPlus
+version:            0.20
+abstract:           ~
+author:  []
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+requires:  {}
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.48
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libauthen-tacacsplus-perl/current/TacacsPlus.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libauthen-tacacsplus-perl/current/TacacsPlus.pm?rev=40090&op=diff
==============================================================================
--- branches/upstream/libauthen-tacacsplus-perl/current/TacacsPlus.pm (original)
+++ branches/upstream/libauthen-tacacsplus-perl/current/TacacsPlus.pm Fri Jul 17 19:06:05 2009
@@ -17,7 +17,7 @@
 @EXPORT_OK = qw(
 	TACPLUS_CLIENT
 );
-$VERSION = '0.19';
+$VERSION = '0.20';
 
 sub new
 {

Modified: branches/upstream/libauthen-tacacsplus-perl/current/tacpluslib/tac_client.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libauthen-tacacsplus-perl/current/tacpluslib/tac_client.c?rev=40090&op=diff
==============================================================================
--- branches/upstream/libauthen-tacacsplus-perl/current/tacpluslib/tac_client.c (original)
+++ branches/upstream/libauthen-tacacsplus-perl/current/tacpluslib/tac_client.c Fri Jul 17 19:06:05 2009
@@ -117,7 +117,7 @@
 	case TAC_PLUS_AUTHEN_STATUS_PASS:
 	    return 1;
 	case TAC_PLUS_AUTHEN_STATUS_FAIL: 
-	    tac_err="Authentification failed";
+	    tac_err="Authentication failed";
 	    return 0;                 
 	default :
 	    tac_err="Protocol error";
@@ -160,6 +160,14 @@
 
 int init_tac_session(char* host_name, char* port_name, char* key, int timeout)
 {
+
+int flags;
+int res;
+int optval;
+socklen_t len;
+fd_set wset;
+struct timeval tv;
+
 gethostname(ourhost,127);
 ourhost_len=strlen(ourhost);
 ourtty_len=strlen(ourtty);
@@ -194,8 +202,64 @@
     }
 }
 if((tac_fd = socket (AF_INET, SOCK_STREAM, 0))<0) return -1;
-if (connect (tac_fd, (struct sockaddr *) &tac_port, sizeof tac_port) < 0)
-    return -1;
+
+// get flags
+flags = fcntl(tac_fd, F_GETFL, 0);
+if( flags < 0 ) {
+	//fprintf( stderr, "fcntl: %s\n", strerror(errno) );
+	tac_err = "socket error";
+	return -1;
+}
+
+// set socket to nonblock
+res = fcntl( tac_fd, F_SETFL, flags | O_NONBLOCK );
+if( res < 0 ) {
+	//fprintf( stderr, "fcntl: %s\n", strerror(errno) );
+	tac_err = "socket error";
+	return -1;
+}
+
+// connect
+res = connect (tac_fd, (struct sockaddr *) &tac_port, sizeof tac_port);
+
+// connection not established, but in progress
+if( res < 0 && (errno != EINPROGRESS) ) {
+	tac_err = "connection failed";
+	return -1;
+}
+
+// wait for connection or timeout
+if( res != 0 ) {
+	FD_ZERO(&wset);
+	FD_SET(tac_fd, &wset);
+	tv.tv_sec  = timeout;
+	tv.tv_usec = 0;
+
+	res = select( tac_fd+1, NULL, &wset, NULL, &tv );
+	if( res < 0 ) {
+		tac_err = "select failed";
+		return -1;
+	}
+	else if( res == 0 ) {
+		tac_err = "timeout";
+		return -1;
+	}
+	if( res > 0 ) {
+		// socket is ready for writing. Check if connection was
+		// established successfully
+		len = sizeof(optval);
+		if( getsockopt( tac_fd, SOL_SOCKET, SO_ERROR, (void *)&optval, &len ) > 0 ) {
+			tac_err = "getsockopt failed";
+			return -1;
+		}
+		if( optval != 0 ) {
+			tac_err = "connection failed";
+			return -1;
+		}
+		// optval == 0 --> no error, connection established
+	}
+}
+	
 return tac_fd;
 }
 




More information about the Pkg-perl-cvs-commits mailing list