--------------------- PatchSet 2729 Date: 2001/08/09 10:41:36 Author: kinkie Branch: ntlm Tag: (none) Log: Ran through indent. Members: src/auth/ntlm/helpers/NTLMSSP/libntlmssp.c:1.1.4.8->1.1.4.9 Index: squid/src/auth/ntlm/helpers/NTLMSSP/libntlmssp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/helpers/NTLMSSP/Attic/libntlmssp.c,v retrieving revision 1.1.4.8 retrieving revision 1.1.4.9 diff -u -r1.1.4.8 -r1.1.4.9 --- squid/src/auth/ntlm/helpers/NTLMSSP/libntlmssp.c 20 Jul 2001 12:32:19 -0000 1.1.4.8 +++ squid/src/auth/ntlm/helpers/NTLMSSP/libntlmssp.c 9 Aug 2001 10:41:36 -0000 1.1.4.9 @@ -29,19 +29,19 @@ #endif /* 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(); -extern int RFCNB_Get_Last_Errno(); +extern int SMB_Get_Error_Msg (int msg, char *msgbuf, int len); +extern int SMB_Get_Last_Error (); +extern int RFCNB_Get_Last_Errno (); #include "smblib-priv.h" /* for SMB_Handle_Type */ /* a few forward-declarations. Hackish, but I don't care right now */ -SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, char *server, char *NTdomain); +SMB_Handle_Type SMB_Connect_Server (SMB_Handle_Type Con_Handle, char *server, + char *NTdomain); /* this one is reallllly haackiish. We really should be using anything from smblib-priv.h */ -static char *SMB_Prots[] = -{"PC NETWORK PROGRAM 1.0", +static char *SMB_Prots[] = { "PC NETWORK PROGRAM 1.0", "MICROSOFT NETWORKS 1.03", "MICROSOFT NETWORKS 3.0", "DOS LANMAN1.0", @@ -57,9 +57,10 @@ }; #if 0 -int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle); -int SMB_Negotiate(void *Con_Handle, char *Prots[]); -int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName, char *PassWord, char *Domain, int precrypted); +int SMB_Discon (SMB_Handle_Type Con_Handle, BOOL KeepHandle); +int SMB_Negotiate (void *Con_Handle, char *Prots[]); +int SMB_Logon_Server (SMB_Handle_Type Con_Handle, char *UserName, + char *PassWord, char *Domain, int precrypted); #endif #ifdef DEBUG @@ -75,15 +76,15 @@ /* Disconnects from the DC. A reconnection will be done upon the next request */ void -dc_disconnect() +dc_disconnect () { if (handle != NULL) - SMB_Discon(handle, 0); + SMB_Discon (handle, 0); handle = NULL; } int -connectedp() +connectedp () { return (handle != NULL); } @@ -91,19 +92,19 @@ /* Tries to connect to a DC. Returns 0 on failure, 1 on OK */ int -is_dc_ok(char *domain, char *domain_controller) +is_dc_ok (char *domain, char *domain_controller) { - SMB_Handle_Type h = SMB_Connect_Server(NULL, domain_controller, domain); + SMB_Handle_Type h = SMB_Connect_Server (NULL, domain_controller, domain); if (h == NULL) return 0; - SMB_Discon(h, 0); + SMB_Discon (h, 0); return 1; } /* returns 0 on success, > 0 on failure */ static int -init_challenge(char *domain, char *domain_controller) +init_challenge (char *domain, char *domain_controller) { int smberr; char errstr[100]; @@ -111,39 +112,41 @@ if (handle != NULL) { return 0; } - debug("Connecting to server %s domain %s\n", domain_controller, domain); - handle = SMB_Connect_Server(NULL, domain_controller, domain); - smberr = SMB_Get_Last_Error(); - SMB_Get_Error_Msg(smberr, errstr, 100); + debug ("Connecting to server %s domain %s\n", domain_controller, domain); + handle = SMB_Connect_Server (NULL, domain_controller, domain); + smberr = SMB_Get_Last_Error (); + SMB_Get_Error_Msg (smberr, errstr, 100); if (handle == NULL) { /* couldn't connect */ - debug("Couldn't connect to SMB Server. Error:%s\n", errstr); + debug ("Couldn't connect to SMB Server. Error:%s\n", errstr); return 1; } - if (SMB_Negotiate(handle, SMB_Prots) < 0) { /* An error */ - debug("Error negotiating protocol with SMB Server\n"); - SMB_Discon(handle, 0); + if (SMB_Negotiate (handle, SMB_Prots) < 0) { /* An error */ + debug ("Error negotiating protocol with SMB Server\n"); + SMB_Discon (handle, 0); handle = NULL; return 2; } if (handle->Security == 0) { /* share-level security, unuseable */ - debug("SMB Server uses share-level security .. we need user sercurity.\n"); - SMB_Discon(handle, 0); + debug + ("SMB Server uses share-level security .. we need user sercurity.\n"); + SMB_Discon (handle, 0); handle = NULL; return 3; } - memcpy(challenge, handle->Encrypt_Key, NONCE_LEN); + memcpy (challenge, handle->Encrypt_Key, NONCE_LEN); return 0; } const char * -make_challenge(char *domain, char *domain_controller) +make_challenge (char *domain, char *domain_controller) { - if (init_challenge(domain, domain_controller) > 0) { + if (init_challenge (domain, domain_controller) > 0) { return NULL; } - return ntlm_make_challenge(domain, domain_controller, challenge, NONCE_LEN); + return ntlm_make_challenge (domain, domain_controller, challenge, + NONCE_LEN); } #define min(A,B) (Adomain); + tmp = ntlm_fetch_string ((char *) auth, auth_length, &auth->domain); if (tmp.str == NULL) return NULL; - memcpy(p, tmp.str, tmp.l); + memcpy (p, tmp.str, tmp.l); p += tmp.l; *p++ = '\\'; - tmp = ntlm_fetch_string((char *) auth, auth_length, &auth->user); + tmp = ntlm_fetch_string ((char *) auth, auth_length, &auth->user); if (tmp.str == NULL) return NULL; *(p + tmp.l) = '\0'; @@ -181,7 +184,7 @@ * codes defined in ntlm.h */ char * -ntlm_check_auth(ntlm_authenticate * auth, int auth_length) +ntlm_check_auth (ntlm_authenticate * auth, int auth_length) { int rv; char pass[25]; @@ -190,45 +193,46 @@ lstring tmp; if (handle == NULL) { /*if null we aren't connected, but it shouldn't happen */ - debug("Weird, we've been disconnected\n"); + debug ("Weird, we've been disconnected\n"); ntlm_errno = NTLM_NOT_CONNECTED; return NULL; } /* Authenticating against the NT response doesn't seem to work... */ - tmp = ntlm_fetch_string((char *) auth, auth_length, &auth->lmresponse); + tmp = ntlm_fetch_string ((char *) auth, auth_length, &auth->lmresponse); if (tmp.str == NULL) { - fprintf(stderr, "No auth at all. Returning no-auth\n"); + fprintf (stderr, "No auth at all. Returning no-auth\n"); ntlm_errno = NTLM_LOGON_ERROR; return NULL; } - memcpy(pass, tmp.str, tmp.l); + memcpy (pass, tmp.str, tmp.l); pass[25] = '\0'; /* debug("fetching domain\n"); */ - tmp = ntlm_fetch_string((char *) auth, auth_length, &auth->domain); + tmp = ntlm_fetch_string ((char *) auth, auth_length, &auth->domain); if (tmp.str == NULL) { - debug("No domain supplied. Returning no-auth\n"); + debug ("No domain supplied. Returning no-auth\n"); ntlm_errno = NTLM_LOGON_ERROR; return NULL; } - memcpy(domain, tmp.str, tmp.l); + memcpy (domain, tmp.str, tmp.l); user = domain + tmp.l; *user++ = '\0'; /* debug("fetching user name\n"); */ - tmp = ntlm_fetch_string((char *) auth, auth_length, &auth->user); + tmp = ntlm_fetch_string ((char *) auth, auth_length, &auth->user); if (tmp.str == NULL) { - debug("No username supplied. Returning no-auth\n"); + debug ("No username supplied. Returning no-auth\n"); ntlm_errno = NTLM_LOGON_ERROR; return NULL; } - memcpy(user, tmp.str, tmp.l); + memcpy (user, tmp.str, tmp.l); *(user + tmp.l) = '\0'; - debug("checking domain: '%s', user: '%s', pass='%s'\n", domain, user, pass); + debug ("checking domain: '%s', user: '%s', pass='%s'\n", domain, user, + pass); - rv = SMB_Logon_Server(handle, user, pass, domain, 1); - debug("Login attempt had result %d\n", rv); + rv = SMB_Logon_Server (handle, user, pass, domain, 1); + debug ("Login attempt had result %d\n", rv); if (rv != NTV_NO_ERROR) { /* failed */ ntlm_errno = rv; @@ -236,6 +240,6 @@ } *(user - 1) = '\\'; /* hack. Performing, but ugly. */ - debug("credentials: %s\n", credentials); + debug ("credentials: %s\n", credentials); return credentials; }