]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3609: several RADIUS helper improvements
authorAlan Mizrahi <alan@mizrahi.com.ve>
Wed, 29 Aug 2012 13:51:52 +0000 (07:51 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 29 Aug 2012 13:51:52 +0000 (07:51 -0600)
helpers/basic_auth/RADIUS/basic_radius_auth.8
helpers/basic_auth/RADIUS/basic_radius_auth.cc

index 5a9fde7666ad338fd7aa1b97a849fb62ad389553..7d5679489c3a1da1e703d92ae6241b7d4f71980c 100644 (file)
@@ -82,6 +82,10 @@ This directive is optional.
 .if !'po4a'hide' .BI "port " portnumber
 Specifies the port number or service name where the helper should connect.
 .
+.if !'po4a'hide' .TP
+.if !'po4a'hide' .BI "timeout " seconds
+Specifies the RADIUS request timeout.
+.
 .SH AUTHOR
 This program is written by 
 .if !'po4a'hide' .I Marc van Selm <selm@cistron.nl>
index 41b6f2052a15d53cf1eb7d3c4d9c5a25e1752205..3efa8b0562af05415fa3700b1080d9c02c582426 100644 (file)
@@ -116,7 +116,7 @@ static int nasport = 111;
 static int nasporttype = 0;
 static uint32_t nas_ipaddr;
 static uint32_t auth_ipaddr;
-static int retries = 30;
+static int retries = 10;
 
 char progname[] = "basic_radius_auth";
 
@@ -249,6 +249,8 @@ rad_auth_config(const char *cfname)
             sscanf(line, "service %s", svc_name);
         if (!memcmp(line, "port", 4))
             sscanf(line, "port %s", svc_name);
+        if (!memcmp(line, "timeout", 7))
+            sscanf(line, "timeout %d", &retries);
     }
     fclose(cf);
     if (srv && crt)
@@ -280,7 +282,7 @@ urldecode(char *dst, const char *src, int size)
     *dst = '\0';
 }
 
-static int
+static void
 authenticate(int socket_fd, const char *username, const char *passwd)
 {
     AUTH_HDR *auth;
@@ -445,16 +447,20 @@ authenticate(int socket_fd, const char *username, const char *passwd)
                 continue;
 
             rc = result_recv(saremote.sin_addr.s_addr, saremote.sin_port, recv_buffer, len);
-            if (rc == 0)
-                return 1;
-            if (rc == 1)
-                return 0;
+            if (rc == 0) {
+                SEND_OK("");
+                return;
+            }
+            if (rc == 1) {
+                SEND_ERR("");
+                return;
+            }
         }
     }
 
     fprintf(stderr, "%s: No response from RADIUS server\n", progname);
-
-    return 0;
+    SEND_ERR("No response from RADIUS server");
+    return;
 }
 
 int
@@ -596,10 +602,7 @@ main(int argc, char **argv)
             ++ptr;
         urldecode(passwd, ptr, MAXPASS);
 
-        if (authenticate(sockfd, username, passwd))
-            SEND_OK("");
-        else
-            SEND_ERR("");
+        authenticate(sockfd, username, passwd);
     }
     close(sockfd);
     exit(1);