Committer  : entrope
CVSROOT    : /cvsroot/undernet-ircu
Module     : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2006-05-08 01:30:34 UTC

Modified files:
  Tag: u2_10_12_branch
     ChangeLog include/s_auth.h ircd/list.c ircd/s_auth.c

Log message:

Do not let ident or DNS timeouts kill a client.

---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.96 ircu2.10/ChangeLog:1.710.2.97
--- ircu2.10/ChangeLog:1.710.2.96       Sat May  6 16:59:33 2006
+++ ircu2.10/ChangeLog  Sun May  7 18:30:20 2006
@@ -1,3 +1,23 @@
+2006-05-07  Michael Poole <[EMAIL PROTECTED]>
+
+       * include/s_auth.h (destroy_auth_request): Remove second argument.
+
+       * ircd/list.c (free_client): Update to match.
+
+       * ircd/s_auth.c (check_auth_finished): Remove second argument and
+       update call to destroy_auth_request().
+       (send_auth_query): Update call to destroy_auth_request().
+       (destroy_auth_request): Remove second argument.
+       (auth_timeout_callback): Send timeout failure messages here
+       instead.  Update call to check_auth_finished().
+       (auth_dns_callback): Update call to check_auth_finished().
+       (start_auth): Likewise.
+       (auth_set_pong): Likewise.
+       (auth_set_user): Likewise.
+       (auth_set_nick): Likewise.
+       (auth_cap_done): Likewise.
+       (iauth_parse): Likewise.
+
 2006-05-06  Michael Poole <[EMAIL PROTECTED]>
 
        * ircd/s_auth.c (AuthRequestFlag): Add AR_PASSWORD_CHECKED.
Index: ircu2.10/include/s_auth.h
diff -u ircu2.10/include/s_auth.h:1.6.2.1 ircu2.10/include/s_auth.h:1.6.2.2
--- ircu2.10/include/s_auth.h:1.6.2.1   Wed Feb 15 19:49:54 2006
+++ ircu2.10/include/s_auth.h   Sun May  7 18:30:24 2006
@@ -17,7 +17,7 @@
  */
 /** @file
  * @brief Interface for DNS and ident lookups.
- * @version $Id: s_auth.h,v 1.6.2.1 2006/02/16 03:49:54 entrope Exp $
+ * @version $Id: s_auth.h,v 1.6.2.2 2006/05/08 01:30:24 entrope Exp $
  */
 #ifndef INCLUDED_s_auth_h
 #define INCLUDED_s_auth_h
@@ -40,7 +40,7 @@
 extern int auth_set_password(struct AuthRequest *auth, const char *password);
 extern int auth_cap_start(struct AuthRequest *auth);
 extern int auth_cap_done(struct AuthRequest *auth);
-extern void destroy_auth_request(struct AuthRequest *req, int send_reports);
+extern void destroy_auth_request(struct AuthRequest *req);
 
 extern int auth_spawn(int argc, char *argv[]);
 extern void auth_send_exit(struct Client *cptr);
Index: ircu2.10/ircd/list.c
diff -u ircu2.10/ircd/list.c:1.34.2.2 ircu2.10/ircd/list.c:1.34.2.3
--- ircu2.10/ircd/list.c:1.34.2.2       Fri Mar 24 19:46:56 2006
+++ ircu2.10/ircd/list.c        Sun May  7 18:30:24 2006
@@ -19,7 +19,7 @@
  */
 /** @file
  * @brief Singly and doubly linked list manipulation implementation.
- * @version $Id: list.c,v 1.34.2.2 2006/03/25 03:46:56 entrope Exp $
+ * @version $Id: list.c,v 1.34.2.3 2006/05/08 01:30:24 entrope Exp $
  */
 #include "config.h"
 
@@ -269,7 +269,7 @@
         cptr, cli_connect(cptr)));
 
   if (cli_auth(cptr))
-    destroy_auth_request(cli_auth(cptr), 0);
+    destroy_auth_request(cli_auth(cptr));
 
   /* Make sure we didn't magically get re-added to the list */
   assert(cli_next(cptr) == 0);
Index: ircu2.10/ircd/s_auth.c
diff -u ircu2.10/ircd/s_auth.c:1.37.2.9 ircu2.10/ircd/s_auth.c:1.37.2.10
--- ircu2.10/ircd/s_auth.c:1.37.2.9     Sat May  6 16:40:25 2006
+++ ircu2.10/ircd/s_auth.c      Sun May  7 18:30:24 2006
@@ -31,7 +31,7 @@
  */
 /** @file
  * @brief Implementation of DNS and ident lookups.
- * @version $Id: s_auth.c,v 1.37.2.9 2006/05/06 23:40:25 entrope Exp $
+ * @version $Id: s_auth.c,v 1.37.2.10 2006/05/08 01:30:24 entrope Exp $
  */
 #include "config.h"
 
@@ -355,11 +355,9 @@
  * destroy \a auth, clear the password, set the username, and register
  * the client.
  * @param[in] auth Authorization request to check.
- * @param[in] send_reports Passed to destroy_auth_request() if \a auth
- *   is complete.
  * @return Zero if client is kept, CPTR_KILLED if client rejected.
  */
-static int check_auth_finished(struct AuthRequest *auth, int send_reports)
+static int check_auth_finished(struct AuthRequest *auth)
 {
   enum AuthRequestFlag flag;
   int res;
@@ -423,7 +421,7 @@
   else
     FlagSet(&auth->flags, AR_IAUTH_HURRY);
 
-  destroy_auth_request(auth, send_reports);
+  destroy_auth_request(auth);
   if (!IsUserPort(auth->client))
     return 0;
   memset(cli_passwd(auth->client), 0, sizeof(cli_passwd(auth->client)));
@@ -526,7 +524,7 @@
     if (IsUserPort(auth->client))
       sendheader(auth->client, REPORT_FAIL_ID);
     FlagClr(&auth->flags, AR_AUTH_PENDING);
-    check_auth_finished(auth, 0);
+    check_auth_finished(auth);
   }
 }
 
@@ -658,7 +656,7 @@
   }
 
   FlagClr(&auth->flags, AR_AUTH_PENDING);
-  check_auth_finished(auth, 0);
+  check_auth_finished(auth);
 }
 
 /** Handle socket I/O activity.
@@ -700,21 +698,13 @@
 
 /** Stop an auth request completely.
  * @param[in] auth The struct AuthRequest to cancel.
- * @param[in] send_reports If non-zero, report the failure to the user.
  */
-void destroy_auth_request(struct AuthRequest* auth, int send_reports)
+void destroy_auth_request(struct AuthRequest* auth)
 {
   Debug((DEBUG_INFO, "Deleting auth request for %p", auth->client));
 
-  if (FlagHas(&auth->flags, AR_AUTH_PENDING)) {
-    if (send_reports && IsUserPort(auth->client))
-      sendheader(auth->client, REPORT_FAIL_ID);
-  }
-
   if (FlagHas(&auth->flags, AR_DNS_PENDING)) {
     delete_resolver_queries(auth);
-    if (send_reports && IsUserPort(auth->client))
-      sendheader(auth->client, REPORT_FAIL_DNS);
   }
 
   if (-1 < s_fd(&auth->socket)) {
@@ -745,6 +735,7 @@
     /* Report the timeout in the log. */
     log_write(LS_RESOLVER, L_INFO, 0, "Registration timeout %s",
               get_client_name(auth->client, HIDE_IP));
+
     /* Tell iauth if we will let the client on. */
     if (FlagHas(&auth->flags, AR_IAUTH_PENDING)
         && !IAuthHas(iauth, IAUTH_REQUIRED))
@@ -752,8 +743,23 @@
       sendto_iauth(auth->client, "T");
       FlagClr(&auth->flags , AR_IAUTH_PENDING);
     }
+
+    /* Notify client if ident lookup failed. */
+    if (FlagHas(&auth->flags, AR_AUTH_PENDING)) {
+      FlagClr(&auth->flags, AR_AUTH_PENDING);
+      if (IsUserPort(auth->client))
+        sendheader(auth->client, REPORT_FAIL_ID);
+    }
+
+    /* Likewise if dns lookup failed. */
+    if (FlagHas(&auth->flags, AR_DNS_PENDING)) {
+      delete_resolver_queries(auth);
+      if (IsUserPort(auth->client))
+        sendheader(auth->client, REPORT_FAIL_DNS);
+    }
+
     /* Try to register the client. */
-    check_auth_finished(auth, 1);
+    check_auth_finished(auth);
   }
 }
 
@@ -803,7 +809,7 @@
     ircd_strncpy(cli_sockhost(auth->client), h_name, HOSTLEN);
     sendto_iauth(auth->client, "N %s", h_name);
   }
-  check_auth_finished(auth, 0);
+  check_auth_finished(auth);
 }
 
 /** Flag the client to show an attempt to contact the ident server on
@@ -956,7 +962,7 @@
   add_client_to_list(client);
 
   /* Check which auth events remain pending. */
-  check_auth_finished(auth, 0);
+  check_auth_finished(auth);
 }
 
 /** Mark that a user has PONGed while unregistered.
@@ -976,7 +982,7 @@
     return 0;
   }
   FlagClr(&auth->flags, AR_NEEDS_PONG);
-  return check_auth_finished(auth, 0);
+  return check_auth_finished(auth);
 }
 
 /** Record a user's claimed username and userinfo.
@@ -1001,7 +1007,7 @@
     sendto_iauth(cptr, "U %s :%s", username, userinfo);
   else if (IAuthHas(iauth, IAUTH_ADDLINFO))
     sendto_iauth(cptr, "U %s", username);
-  return check_auth_finished(auth, 0);
+  return check_auth_finished(auth);
 }
 
 /** Handle authorization-related aspects of initial nickname selection.
@@ -1027,7 +1033,7 @@
   }
   if (IAuthHas(iauth, IAUTH_UNDERNET))
     sendto_iauth(auth->client, "n %s", nickname);
-  return check_auth_finished(auth, 0);
+  return check_auth_finished(auth);
 }
 
 /** Record a user's password.
@@ -1072,7 +1078,7 @@
 {
   assert(auth != NULL);
   FlagClr(&auth->flags, AR_CAP_PENDING);
-  return check_auth_finished(auth, 0);
+  return check_auth_finished(auth);
 }
 
 /** Attempt to spawn the process for an IAuth instance.
@@ -1950,7 +1956,7 @@
                     ircd_ntoa(&cli_ip(cli)));
       else if (handler(iauth, cli, parc - 3, params + 3))
        /* Handler indicated a possible state change. */
-       check_auth_finished(auth, 0);
+       check_auth_finished(auth);
     }
   }
 }
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches

Reply via email to