--------------------- PatchSet 2736 Date: 2001/08/10 12:43:20 Author: kinkie Branch: ntlm Tag: (none) Log: Added code to timeout the authentication. Members: src/auth/ntlm/helpers/NTLMSSP/ntlm_auth.c:1.1.4.19->1.1.4.20 Index: squid/src/auth/ntlm/helpers/NTLMSSP/ntlm_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/helpers/NTLMSSP/Attic/ntlm_auth.c,v retrieving revision 1.1.4.19 retrieving revision 1.1.4.20 diff -u -r1.1.4.19 -r1.1.4.20 --- squid/src/auth/ntlm/helpers/NTLMSSP/ntlm_auth.c 9 Aug 2001 10:43:29 -0000 1.1.4.19 +++ squid/src/auth/ntlm/helpers/NTLMSSP/ntlm_auth.c 10 Aug 2001 12:43:20 -0000 1.1.4.20 @@ -22,6 +22,9 @@ #include "smbval/smblib-common.h" #include "smbval/rfcnb-error.h" +#include +#include + /* these are part of rfcnb-priv.h and smblib-priv.h */ extern int SMB_Get_Error_Msg (int msg, char *msgbuf, int len); extern int SMB_Get_Last_Error (); @@ -60,6 +63,15 @@ char smb_error_buffer[1000]; +/* signal handler to be invoked when the authentication operation + times out */ +static void +timeout_during_auth(int signum) { + fprintf(stderr,"ntlm-auth[%d]: Timeout during authentication.\n", getpid()); + SEND("BH Timeout during authentication"); + dc_disconnect(); +} + /* makes a null-terminated string upper-case. Changes CONTENTS! */ static void uc (char *string) @@ -247,7 +259,6 @@ if (fgets (buf, BUFFER_SIZE, stdin) == NULL) { fprintf (stderr, "fgets() failed! dying..... errno=%d (%s)\n", errno, strerror (errno)); - abort (); exit (1); /* BIIG buffer */ } debug ("managing request\n"); @@ -290,7 +301,11 @@ case NTLM_AUTHENTICATE: /* check against the DC */ plen = strlen (buf) * 3 / 4; /* we only need it here. Optimization */ + signal(SIGALRM,timeout_during_auth); + alarm(30); cred = ntlm_check_auth ((ntlm_authenticate *) decoded, plen); + alarm(0); + signal(SIGALRM,SIG_DFL); if (cred == NULL) { int smblib_err, smb_errorclass, smb_errorcode, nb_error; /* there was an error. We have two errno's to look at.