--------------------- PatchSet 2982 Date: 2001/09/09 09:33:20 Author: serassio Branch: nt-2_3-tolsty Tag: (none) Log: Fixed indent problems Members: auth_modules/MSNT/denyusers.c:1.1.16.1.6.1->1.1.16.1.6.2 auth_modules/MSNT/md4.c:1.1.1.1.62.1->1.1.1.1.62.2 auth_modules/MSNT/rfcnb-common.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/rfcnb-error.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/rfcnb-io.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/rfcnb-io.h:1.1.1.1.62.1->1.1.1.1.62.2 auth_modules/MSNT/rfcnb-priv.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/rfcnb-util.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/rfcnb-util.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/rfcnb.h:1.1.1.1.62.1->1.1.1.1.62.2 auth_modules/MSNT/session.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/smbauth.c:1.1.1.1.4.2.6.1->1.1.1.1.4.2.6.2 auth_modules/MSNT/smbdes.c:1.1.1.1.62.1->1.1.1.1.62.2 auth_modules/MSNT/smbencrypt.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/smblib-common.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/smblib-priv.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/smblib-util.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/smblib.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/smblib.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/std-defines.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/std-includes.h:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/valid.c:1.1.1.1.30.1->1.1.1.1.30.2 auth_modules/MSNT/valid.h:1.1.1.1.62.1->1.1.1.1.62.2 auth_modules/PAM/Makefile.in:1.1.1.1.22.1.2.1->1.1.1.1.22.1.2.2 auth_modules/PAM/pam_auth.c:1.1.1.1.18.1.2.1->1.1.1.1.18.1.2.2 auth_modules/SMB/Makefile.in:1.1.1.1.20.1.2.1->1.1.1.1.20.1.2.2 auth_modules/SMB/smb_auth.c:1.1.1.2.28.1->1.1.1.2.28.2 auth_modules/getpwnam/Makefile.in:1.1.1.2.30.1.2.1->1.1.1.2.30.1.2.2 auth_modules/getpwnam/getpwnam_auth.c:1.1.1.1.72.1->1.1.1.1.72.2 Index: squid/auth_modules/MSNT/denyusers.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/denyusers.c,v retrieving revision 1.1.16.1.6.1 retrieving revision 1.1.16.1.6.2 diff -u -r1.1.16.1.6.1 -r1.1.16.1.6.2 --- squid/auth_modules/MSNT/denyusers.c 27 Aug 2001 21:48:15 -0000 1.1.16.1.6.1 +++ squid/auth_modules/MSNT/denyusers.c 9 Sep 2001 09:33:20 -0000 1.1.16.1.6.2 @@ -1,3 +1,4 @@ + /* * denyusers.c * (C) 2000 Antonino Iannella, Stellar-X Pty Ltd @@ -38,7 +39,7 @@ * Logs any messages to the syslog daemon. */ -int +int Read_denyusers() { FILE *DFile; /* DENYUSER file pointer */ @@ -76,15 +77,13 @@ free(DeniedUsers); if ((DeniedUsers = malloc(sizeof(char) * (DenyUserSize + 1))) == NULL) { - syslog(LOG_USER | LOG_ERR, - "Read_denyusers: malloc(DeniedUsers) failed."); + syslog(LOG_USER | LOG_ERR, "Read_denyusers: malloc(DeniedUsers) failed."); return 1; } /* Open the DENYUSERS file. Report any errors. */ if ((DFile = fopen(DENYUSERS, "r")) == NULL) { - syslog(LOG_USER | LOG_ERR, - "Read_denyusers: Failed to open denied user file."); + syslog(LOG_USER | LOG_ERR, "Read_denyusers: Failed to open denied user file."); syslog(LOG_USER | LOG_ERR, strerror(errno)); return 1; } @@ -112,7 +111,7 @@ * Returns 0 if the user was not found, and 1 if they were. */ -int +int Check_user(char *ConnectingUser) { static char CUBuf[NAMELEN + 1]; @@ -151,7 +150,7 @@ * signal. */ -void +void Checkforchange() { struct stat ChkBuf; /* Stat data buffer */ @@ -177,8 +176,7 @@ * Log a message of its actions. */ if (ChkBuf.st_mtime != LastModTime) { - syslog(LOG_USER | LOG_INFO, - "Checkforchange: Reloading denied user list."); + syslog(LOG_USER | LOG_INFO, "Checkforchange: Reloading denied user list."); Read_denyusers(); } } Index: squid/auth_modules/MSNT/md4.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/md4.c,v retrieving revision 1.1.1.1.62.1 retrieving revision 1.1.1.1.62.2 diff -u -r1.1.1.1.62.1 -r1.1.1.1.62.2 --- squid/auth_modules/MSNT/md4.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.62.1 +++ squid/auth_modules/MSNT/md4.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.62.2 @@ -29,29 +29,25 @@ static uint32 A, B, C, D; -static uint32 -F(uint32 X, uint32 Y, uint32 Z) +static uint32 F(uint32 X, uint32 Y, uint32 Z) { - return (X & Y) | ((~X) & Z); + return (X&Y) | ((~X)&Z); } -static uint32 -G(uint32 X, uint32 Y, uint32 Z) +static uint32 G(uint32 X, uint32 Y, uint32 Z) { - return (X & Y) | (X & Z) | (Y & Z); + return (X&Y) | (X&Z) | (Y&Z); } -static uint32 -H(uint32 X, uint32 Y, uint32 Z) +static uint32 H(uint32 X, uint32 Y, uint32 Z) { - return X ^ Y ^ Z; + return X^Y^Z; } -static uint32 -lshift(uint32 x, int s) +static uint32 lshift(uint32 x, int s) { - x &= 0xFFFFFFFF; - return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); + x &= 0xFFFFFFFF; + return ((x<>(32-s)); } #define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s) @@ -59,151 +55,117 @@ #define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s) /* this applies md4 to 64 byte chunks */ -static void -mdfour64(uint32 * M) +static void mdfour64(uint32 *M) { - int j; - uint32 AA, BB, CC, DD; - uint32 X[16]; - - for (j = 0; j < 16; j++) - X[j] = M[j]; - - AA = A; - BB = B; - CC = C; - DD = D; - - ROUND1(A, B, C, D, 0, 3); - ROUND1(D, A, B, C, 1, 7); - ROUND1(C, D, A, B, 2, 11); - ROUND1(B, C, D, A, 3, 19); - ROUND1(A, B, C, D, 4, 3); - ROUND1(D, A, B, C, 5, 7); - ROUND1(C, D, A, B, 6, 11); - ROUND1(B, C, D, A, 7, 19); - ROUND1(A, B, C, D, 8, 3); - ROUND1(D, A, B, C, 9, 7); - ROUND1(C, D, A, B, 10, 11); - ROUND1(B, C, D, A, 11, 19); - ROUND1(A, B, C, D, 12, 3); - ROUND1(D, A, B, C, 13, 7); - ROUND1(C, D, A, B, 14, 11); - ROUND1(B, C, D, A, 15, 19); - - ROUND2(A, B, C, D, 0, 3); - ROUND2(D, A, B, C, 4, 5); - ROUND2(C, D, A, B, 8, 9); - ROUND2(B, C, D, A, 12, 13); - ROUND2(A, B, C, D, 1, 3); - ROUND2(D, A, B, C, 5, 5); - ROUND2(C, D, A, B, 9, 9); - ROUND2(B, C, D, A, 13, 13); - ROUND2(A, B, C, D, 2, 3); - ROUND2(D, A, B, C, 6, 5); - ROUND2(C, D, A, B, 10, 9); - ROUND2(B, C, D, A, 14, 13); - ROUND2(A, B, C, D, 3, 3); - ROUND2(D, A, B, C, 7, 5); - ROUND2(C, D, A, B, 11, 9); - ROUND2(B, C, D, A, 15, 13); - - ROUND3(A, B, C, D, 0, 3); - ROUND3(D, A, B, C, 8, 9); - ROUND3(C, D, A, B, 4, 11); - ROUND3(B, C, D, A, 12, 15); - ROUND3(A, B, C, D, 2, 3); - ROUND3(D, A, B, C, 10, 9); - ROUND3(C, D, A, B, 6, 11); - ROUND3(B, C, D, A, 14, 15); - ROUND3(A, B, C, D, 1, 3); - ROUND3(D, A, B, C, 9, 9); - ROUND3(C, D, A, B, 5, 11); - ROUND3(B, C, D, A, 13, 15); - ROUND3(A, B, C, D, 3, 3); - ROUND3(D, A, B, C, 11, 9); - ROUND3(C, D, A, B, 7, 11); - ROUND3(B, C, D, A, 15, 15); - - A += AA; - B += BB; - C += CC; - D += DD; - - A &= 0xFFFFFFFF; - B &= 0xFFFFFFFF; - C &= 0xFFFFFFFF; - D &= 0xFFFFFFFF; - - for (j = 0; j < 16; j++) - X[j] = 0; -} - -static void -copy64(uint32 * M, unsigned char *in) -{ - int i; - - for (i = 0; i < 16; i++) - M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) | - (in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0); -} - -static void -copy4(unsigned char *out, uint32 x) -{ - out[0] = x & 0xFF; - out[1] = (x >> 8) & 0xFF; - out[2] = (x >> 16) & 0xFF; - out[3] = (x >> 24) & 0xFF; + int j; + uint32 AA, BB, CC, DD; + uint32 X[16]; + + for (j=0;j<16;j++) + X[j] = M[j]; + + AA = A; BB = B; CC = C; DD = D; + + ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); + ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); + ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); + ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); + ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); + ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); + ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); + ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); + + ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); + ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); + ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); + ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); + ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); + ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); + ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); + ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); + + ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); + ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); + ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); + ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); + ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); + ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); + ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); + ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); + + A += AA; B += BB; C += CC; D += DD; + + A &= 0xFFFFFFFF; B &= 0xFFFFFFFF; + C &= 0xFFFFFFFF; D &= 0xFFFFFFFF; + + for (j=0;j<16;j++) + X[j] = 0; +} + +static void copy64(uint32 *M, unsigned char *in) +{ + int i; + + for (i=0;i<16;i++) + M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | + (in[i*4+1]<<8) | (in[i*4+0]<<0); +} + +static void copy4(unsigned char *out,uint32 x) +{ + out[0] = x&0xFF; + out[1] = (x>>8)&0xFF; + out[2] = (x>>16)&0xFF; + out[3] = (x>>24)&0xFF; } /* produce a md4 message digest from data of length n bytes */ -void -mdfour(unsigned char *out, unsigned char *in, int n) +void mdfour(unsigned char *out, unsigned char *in, int n) { - unsigned char buf[128]; - uint32 M[16]; - uint32 b = n * 8; - int i; - - A = 0x67452301; - B = 0xefcdab89; - C = 0x98badcfe; - D = 0x10325476; - - while (n > 64) { - copy64(M, in); - mdfour64(M); - in += 64; - n -= 64; - } - - for (i = 0; i < 128; i++) - buf[i] = 0; - memcpy(buf, in, n); - buf[n] = 0x80; + unsigned char buf[128]; + uint32 M[16]; + uint32 b = n * 8; + int i; + + A = 0x67452301; + B = 0xefcdab89; + C = 0x98badcfe; + D = 0x10325476; + + while (n > 64) { + copy64(M, in); + mdfour64(M); + in += 64; + n -= 64; + } + + for (i=0;i<128;i++) + buf[i] = 0; + memcpy(buf, in, n); + buf[n] = 0x80; + + if (n <= 55) { + copy4(buf+56, b); + copy64(M, buf); + mdfour64(M); + } else { + copy4(buf+120, b); + copy64(M, buf); + mdfour64(M); + copy64(M, buf+64); + mdfour64(M); + } - if (n <= 55) { - copy4(buf + 56, b); + for (i=0;i<128;i++) + buf[i] = 0; copy64(M, buf); - mdfour64(M); - } else { - copy4(buf + 120, b); - copy64(M, buf); - mdfour64(M); - copy64(M, buf + 64); - mdfour64(M); - } - - for (i = 0; i < 128; i++) - buf[i] = 0; - copy64(M, buf); - - copy4(out, A); - copy4(out + 4, B); - copy4(out + 8, C); - copy4(out + 12, D); - A = B = C = D = 0; + copy4(out, A); + copy4(out+4, B); + copy4(out+8, C); + copy4(out+12, D); + + A = B = C = D = 0; } + + Index: squid/auth_modules/MSNT/rfcnb-common.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-common.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/rfcnb-common.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/rfcnb-common.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB Common Structures etc Defines @@ -24,12 +25,12 @@ /* A data structure we need */ -typedef struct RFCNB_Pkt -{ +typedef struct RFCNB_Pkt { + + char * data; /* The data in this portion */ + int len; + struct RFCNB_Pkt *next; + +} RFCNB_Pkt; - char *data; /* The data in this portion */ - int len; - struct RFCNB_Pkt *next; -} -RFCNB_Pkt; Index: squid/auth_modules/MSNT/rfcnb-error.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-error.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/rfcnb-error.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/rfcnb-error.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB Error Response Defines @@ -24,47 +25,51 @@ /* Error responses */ -#define RFCNBE_Bad -1 /* Bad response */ +#define RFCNBE_Bad -1 /* Bad response */ #define RFCNBE_OK 0 /* these should follow the spec ... is there one ?*/ -#define RFCNBE_NoSpace 1 /* Could not allocate space for a struct */ -#define RFCNBE_BadName 2 /* Could not translate a name */ -#define RFCNBE_BadRead 3 /* Read sys call failed */ -#define RFCNBE_BadWrite 4 /* Write Sys call failed */ -#define RFCNBE_ProtErr 5 /* Protocol Error */ -#define RFCNBE_ConGone 6 /* Connection dropped */ -#define RFCNBE_BadHandle 7 /* Handle passed was bad */ -#define RFCNBE_BadSocket 8 /* Problems creating socket */ -#define RFCNBE_ConnectFailed 9 /* Connect failed */ -#define RFCNBE_CallRejNLOCN 10 /* Call rejected, not listening on CN */ -#define RFCNBE_CallRejNLFCN 11 /* Call rejected, not listening for CN */ -#define RFCNBE_CallRejCNNP 12 /* Call rejected, called name not present */ -#define RFCNBE_CallRejInfRes 13 /* Call rejetced, name ok, no resources */ -#define RFCNBE_CallRejUnSpec 14 /* Call rejected, unspecified error */ -#define RFCNBE_BadParam 15 /* Bad parameters passed ... */ -#define RFCNBE_Timeout 16 /* IO Timed out */ +#define RFCNBE_NoSpace 1 /* Could not allocate space for a struct */ +#define RFCNBE_BadName 2 /* Could not translate a name */ +#define RFCNBE_BadRead 3 /* Read sys call failed */ +#define RFCNBE_BadWrite 4 /* Write Sys call failed */ +#define RFCNBE_ProtErr 5 /* Protocol Error */ +#define RFCNBE_ConGone 6 /* Connection dropped */ +#define RFCNBE_BadHandle 7 /* Handle passed was bad */ +#define RFCNBE_BadSocket 8 /* Problems creating socket */ +#define RFCNBE_ConnectFailed 9 /* Connect failed */ +#define RFCNBE_CallRejNLOCN 10 /* Call rejected, not listening on CN */ +#define RFCNBE_CallRejNLFCN 11 /* Call rejected, not listening for CN */ +#define RFCNBE_CallRejCNNP 12 /* Call rejected, called name not present */ +#define RFCNBE_CallRejInfRes 13/* Call rejetced, name ok, no resources */ +#define RFCNBE_CallRejUnSpec 14/* Call rejected, unspecified error */ +#define RFCNBE_BadParam 15/* Bad parameters passed ... */ +#define RFCNBE_Timeout 16/* IO Timed out */ /* Text strings for the error responses */ static char *RFCNB_Error_Strings[] = { - "RFCNBE_OK: Routine completed successfully.", - "RFCNBE_NoSpace: No space available for a malloc call.", - "RFCNBE_BadName: NetBIOS name could not be translated to IP address.", - "RFCNBE_BadRead: Read system call returned an error. Check errno.", - "RFCNBE_BadWrite: Write system call returned an error. Check errno.", - "RFCNBE_ProtErr: A protocol error has occurred.", - "RFCNBE_ConGone: Connection dropped during a read or write system call.", - "RFCNBE_BadHandle: Bad connection handle passed.", - "RFCNBE_BadSocket: Problems creating socket.", - "RFCNBE_ConnectFailed: Connection failed. See errno.", - "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.", - "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.", - "RFCNBE_CallRejCNNP: Call rejected. Called name not present.", - "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.", - "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.", - "RFCNBE_BadParam: Bad parameters passed to a routine.", - "RFCNBE_Timeout: IO Operation timed out ..." + "RFCNBE_OK: Routine completed successfully.", + "RFCNBE_NoSpace: No space available for a malloc call.", + "RFCNBE_BadName: NetBIOS name could not be translated to IP address.", + "RFCNBE_BadRead: Read system call returned an error. Check errno.", + "RFCNBE_BadWrite: Write system call returned an error. Check errno.", + "RFCNBE_ProtErr: A protocol error has occurred.", + "RFCNBE_ConGone: Connection dropped during a read or write system call.", + "RFCNBE_BadHandle: Bad connection handle passed.", + "RFCNBE_BadSocket: Problems creating socket.", + "RFCNBE_ConnectFailed: Connection failed. See errno.", + "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.", + "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.", + "RFCNBE_CallRejCNNP: Call rejected. Called name not present.", + "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.", + "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.", + "RFCNBE_BadParam: Bad parameters passed to a routine.", + "RFCNBE_Timeout: IO Operation timed out ..." + }; + + + Index: squid/auth_modules/MSNT/rfcnb-io.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-io.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/rfcnb-io.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/rfcnb-io.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NEtBIOS implementation + Version 1.0 RFCNB IO Routines ... @@ -29,109 +30,108 @@ #include #include -int RFCNB_Timeout = 0; /* Timeout in seconds ... */ +int RFCNB_Timeout = 0; /* Timeout in seconds ... */ + +void rfcnb_alarm(int sig) -void -rfcnb_alarm(int sig) { - fprintf(stderr, "IO Timed out ...\n"); + fprintf(stderr, "IO Timed out ...\n"); } /* Set timeout value and setup signal handling */ -int -RFCNB_Set_Timeout(int seconds) +int RFCNB_Set_Timeout(int seconds) + { - int temp; - /* If we are on a Bezerkeley system, use sigvec, else sigaction */ + int temp; + /* If we are on a Bezerkeley system, use sigvec, else sigaction */ #ifndef SA_RESTART - struct sigvec invec, outvec; + struct sigvec invec, outvec; #else - struct sigaction inact, outact; + struct sigaction inact, outact; #endif - RFCNB_Timeout = seconds; + RFCNB_Timeout = seconds; - if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */ + if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */ #ifndef SA_RESTART - invec.sv_handler = (void (*)()) rfcnb_alarm; - invec.sv_mask = 0; - invec.sv_flags = SV_INTERRUPT; + invec.sv_handler = (void (*)())rfcnb_alarm; + invec.sv_mask = 0; + invec.sv_flags = SV_INTERRUPT; - if (sigvec(SIGALRM, &invec, &outvec) < 0) - return (-1); + if (sigvec(SIGALRM, &invec, &outvec) < 0) + return(-1); #else - inact.sa_handler = (void (*)()) rfcnb_alarm; + inact.sa_handler = (void (*)())rfcnb_alarm; #ifdef SOLARIS - /* Solaris seems to have an array of vectors ... */ - inact.sa_mask.__sigbits[0] = 0; - inact.sa_mask.__sigbits[1] = 0; - inact.sa_mask.__sigbits[2] = 0; - inact.sa_mask.__sigbits[3] = 0; + /* Solaris seems to have an array of vectors ... */ + inact.sa_mask.__sigbits[0] = 0; + inact.sa_mask.__sigbits[1] = 0; + inact.sa_mask.__sigbits[2] = 0; + inact.sa_mask.__sigbits[3] = 0; #else #ifdef __GLIBC__ - for (temp = 0; temp < 32; temp++) - inact.sa_mask.__val[temp] = 0; + for (temp = 0 ; temp < 32 ; temp ++) + inact.sa_mask.__val[temp]=0; #else - inact.sa_mask = 0; + inact.sa_mask = 0; #endif #endif - inact.sa_flags = 0; /* Don't restart */ + inact.sa_flags = 0; /* Don't restart */ - if (sigaction(SIGALRM, &inact, &outact) < 0) - return (-1); + if (sigaction(SIGALRM, &inact, &outact) < 0) + return(-1); #endif - } + } - return (0); + return(0); } /* Discard the rest of an incoming packet as we do not have space for it in the buffer we allocated or were passed ... */ -int -RFCNB_Discard_Rest(struct RFCNB_Con *con, int len) -{ - char temp[100]; /* Read into here */ - int rest, this_read, bytes_read; +int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len) - /* len is the amount we should read */ +{ char temp[100]; /* Read into here */ + int rest, this_read, bytes_read; + + /* len is the amount we should read */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Discard_Rest called to discard: %i\n", len); + fprintf(stderr, "Discard_Rest called to discard: %i\n", len); #endif - rest = len; - - while (rest > 0) { - - this_read = (rest > sizeof(temp) ? sizeof(temp) : rest); + rest = len; - bytes_read = read(con->fd, temp, this_read); + while (rest > 0) { - if (bytes_read <= 0) { /* Error so return */ + this_read = (rest > sizeof(temp)?sizeof(temp):rest); - if (bytes_read < 0) - RFCNB_errno = RFCNBE_BadRead; - else - RFCNB_errno = RFCNBE_ConGone; + bytes_read = read(con -> fd, temp, this_read); - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + if (bytes_read <= 0) { /* Error so return */ - } + if (bytes_read < 0) + RFCNB_errno = RFCNBE_BadRead; + else + RFCNB_errno = RFCNBE_ConGone; - rest = rest - bytes_read; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); } + + rest = rest - bytes_read; - return (0); + } + + return(0); } @@ -144,87 +144,85 @@ */ -int -RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) -{ - int len_sent, tot_sent, this_len; - struct RFCNB_Pkt *pkt_ptr; - char *this_data; - int i; - struct iovec io_list[10]; /* We should never have more */ - /* If we do, this will blow up ... */ +int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) - /* Try to send the data ... We only send as many bytes as len claims */ - /* We should try to stuff it into an IOVEC and send as one write */ +{ int len_sent, tot_sent, this_len; + struct RFCNB_Pkt *pkt_ptr; + char *this_data; + int i; + struct iovec io_list[10]; /* We should never have more */ + /* If we do, this will blow up ...*/ + /* Try to send the data ... We only send as many bytes as len claims */ + /* We should try to stuff it into an IOVEC and send as one write */ - pkt_ptr = pkt; - len_sent = tot_sent = 0; /* Nothing sent so far */ - i = 0; - while ((pkt_ptr != NULL) & (i < 10)) { /* Watch that magic number! */ + pkt_ptr = pkt; + len_sent = tot_sent = 0; /* Nothing sent so far */ + i = 0; - this_len = pkt_ptr->len; - this_data = pkt_ptr->data; - if ((tot_sent + this_len) > len) - this_len = len - tot_sent; /* Adjust so we don't send too much */ + while ((pkt_ptr != NULL) & (i < 10)) { /* Watch that magic number! */ - /* Now plug into the iovec ... */ + this_len = pkt_ptr -> len; + this_data = pkt_ptr -> data; + if ((tot_sent + this_len) > len) + this_len = len - tot_sent; /* Adjust so we don't send too much */ - io_list[i].iov_len = this_len; - io_list[i].iov_base = this_data; - i++; + /* Now plug into the iovec ... */ - tot_sent += this_len; + io_list[i].iov_len = this_len; + io_list[i].iov_base = this_data; + i++; - if (tot_sent == len) - break; /* Let's not send too much */ + tot_sent += this_len; - pkt_ptr = pkt_ptr->next; + if (tot_sent == len) break; /* Let's not send too much */ - } + pkt_ptr = pkt_ptr -> next; + + } #ifdef RFCNB_DEBUG - fprintf(stderr, "Frags = %i, tot_sent = %i\n", i, tot_sent); + fprintf(stderr, "Frags = %i, tot_sent = %i\n", i, tot_sent); #endif - /* Set up an alarm if timeouts are set ... */ - - if (RFCNB_Timeout > 0) - alarm(RFCNB_Timeout); + /* Set up an alarm if timeouts are set ... */ - if ((len_sent = writev(con->fd, io_list, i)) < 0) { /* An error */ - - con->rfc_errno = errno; - if (errno == EINTR) /* We were interrupted ... */ - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_BadWrite; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + if (RFCNB_Timeout > 0) + alarm(RFCNB_Timeout); - } + if ((len_sent = writev(con -> fd, io_list, i)) < 0) { /* An error */ - if (len_sent < tot_sent) { /* Less than we wanted */ - if (errno == EINTR) /* We were interrupted */ - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_BadWrite; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); - } + con -> rfc_errno = errno; + if (errno == EINTR) /* We were interrupted ... */ + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_BadWrite; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); + + } + + if (len_sent < tot_sent) { /* Less than we wanted */ + if (errno == EINTR) /* We were interrupted */ + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_BadWrite; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); + } - if (RFCNB_Timeout > 0) - alarm(0); /* Reset that sucker */ + if (RFCNB_Timeout > 0) + alarm(0); /* Reset that sucker */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Len sent = %i ...\n", len_sent); - RFCNB_Print_Pkt(stderr, "sent", pkt, len_sent); /* Print what send ... */ + fprintf(stderr, "Len sent = %i ...\n", len_sent); + RFCNB_Print_Pkt(stderr, "sent", pkt, len_sent); /* Print what send ... */ #endif - return (len_sent); + return(len_sent); } @@ -236,187 +234,188 @@ */ -int -RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) -{ - int read_len, pkt_len; - char hdr[RFCNB_Pkt_Hdr_Len]; /* Local space for the header */ - struct RFCNB_Pkt *pkt_frag; - int more, this_time, offset, frag_len, this_len; - BOOL seen_keep_alive = TRUE; +int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) + +{ int read_len, pkt_len; + char hdr[RFCNB_Pkt_Hdr_Len]; /* Local space for the header */ + struct RFCNB_Pkt *pkt_frag; + int more, this_time, offset, frag_len, this_len; + BOOL seen_keep_alive = TRUE; - /* Read that header straight into the buffer */ + /* Read that header straight into the buffer */ - if (len < RFCNB_Pkt_Hdr_Len) { /* What a bozo */ + if (len < RFCNB_Pkt_Hdr_Len) { /* What a bozo */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Trying to read less than a packet:"); - perror(""); + fprintf(stderr, "Trying to read less than a packet:"); + perror(""); #endif - RFCNB_errno = RFCNBE_BadParam; - return (RFCNBE_Bad); + RFCNB_errno = RFCNBE_BadParam; + return(RFCNBE_Bad); - } + } - /* We discard keep alives here ... */ + /* We discard keep alives here ... */ - if (RFCNB_Timeout > 0) - alarm(RFCNB_Timeout); + if (RFCNB_Timeout > 0) + alarm(RFCNB_Timeout); - while (seen_keep_alive) { + while (seen_keep_alive) { - if ((read_len = read(con->fd, hdr, sizeof(hdr))) < 0) { /* Problems */ + if ((read_len = read(con -> fd, hdr, sizeof(hdr))) < 0) { /* Problems */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Reading the packet, we got:"); - perror(""); + fprintf(stderr, "Reading the packet, we got:"); + perror(""); #endif - if (errno == EINTR) - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_BadRead; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + if (errno == EINTR) + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_BadRead; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); - } + } - /* Now we check out what we got */ + /* Now we check out what we got */ - if (read_len == 0) { /* Connection closed, send back eof? */ + if (read_len == 0) { /* Connection closed, send back eof? */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Connection closed reading\n"); -#endif + fprintf(stderr, "Connection closed reading\n"); +#endif - if (errno == EINTR) - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_ConGone; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + if (errno == EINTR) + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_ConGone; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); - } + } - if (RFCNB_Pkt_Type(hdr) == RFCNB_SESSION_KEEP_ALIVE) { + if (RFCNB_Pkt_Type(hdr) == RFCNB_SESSION_KEEP_ALIVE) { #ifdef RFCNB_DEBUG - fprintf(stderr, "RFCNB KEEP ALIVE received\n"); + fprintf(stderr, "RFCNB KEEP ALIVE received\n"); #endif - - } else { - seen_keep_alive = FALSE; - } - + + } + else { + seen_keep_alive = FALSE; } - /* What if we got less than or equal to a hdr size in bytes? */ + } + + /* What if we got less than or equal to a hdr size in bytes? */ - if (read_len < sizeof(hdr)) { /* We got a small packet */ + if (read_len < sizeof(hdr)) { /* We got a small packet */ - /* Now we need to copy the hdr portion we got into the supplied packet */ + /* Now we need to copy the hdr portion we got into the supplied packet */ - memcpy(pkt->data, hdr, read_len); /*Copy data */ + memcpy(pkt -> data, hdr, read_len); /*Copy data */ #ifdef RFCNB_DEBUG - RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len); + RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len); #endif - return (read_len); + return(read_len); - } + } - /* Now, if we got at least a hdr size, alloc space for rest, if we need it */ + /* Now, if we got at least a hdr size, alloc space for rest, if we need it */ - pkt_len = RFCNB_Pkt_Len(hdr); + pkt_len = RFCNB_Pkt_Len(hdr); #ifdef RFCNB_DEBUG - fprintf(stderr, "Reading Pkt: Length = %i\n", pkt_len); -#endif + fprintf(stderr, "Reading Pkt: Length = %i\n", pkt_len); +#endif - /* Now copy in the hdr */ + /* Now copy in the hdr */ - memcpy(pkt->data, hdr, sizeof(hdr)); + memcpy(pkt -> data, hdr, sizeof(hdr)); - /* Get the rest of the packet ... first figure out how big our buf is? */ - /* And make sure that we handle the fragments properly ... Sure should */ - /* use an iovec ... */ + /* Get the rest of the packet ... first figure out how big our buf is? */ + /* And make sure that we handle the fragments properly ... Sure should */ + /* use an iovec ... */ - if (len < pkt_len) /* Only get as much as we have space for */ - more = len - RFCNB_Pkt_Hdr_Len; - else - more = pkt_len; + if (len < pkt_len) /* Only get as much as we have space for */ + more = len - RFCNB_Pkt_Hdr_Len; + else + more = pkt_len; - this_time = 0; + this_time = 0; - /* We read for each fragment ... */ + /* We read for each fragment ... */ - if (pkt->len == read_len) { /* If this frag was exact size */ - pkt_frag = pkt->next; /* Stick next lot in next frag */ - offset = 0; /* then we start at 0 in next */ - } else { - pkt_frag = pkt; /* Otherwise use rest of this frag */ - offset = RFCNB_Pkt_Hdr_Len; /* Otherwise skip the header */ - } + if (pkt -> len == read_len){ /* If this frag was exact size */ + pkt_frag = pkt -> next; /* Stick next lot in next frag */ + offset = 0; /* then we start at 0 in next */ + } + else { + pkt_frag = pkt; /* Otherwise use rest of this frag */ + offset = RFCNB_Pkt_Hdr_Len; /* Otherwise skip the header */ + } - frag_len = pkt_frag->len; + frag_len = pkt_frag -> len; - if (more <= frag_len) /* If len left to get less than frag space */ - this_len = more; /* Get the rest ... */ - else - this_len = frag_len - offset; + if (more <= frag_len) /* If len left to get less than frag space */ + this_len = more; /* Get the rest ... */ + else + this_len = frag_len - offset; - while (more > 0) { + while (more > 0) { - if ((this_time = read(con->fd, (pkt_frag->data) + offset, this_len)) <= 0) { /* Problems */ + if ((this_time = read(con -> fd, (pkt_frag -> data) + offset, this_len)) <= 0) { /* Problems */ - if (errno == EINTR) { + if (errno == EINTR) { - RFCNB_errno = RFCNB_Timeout; + RFCNB_errno = RFCNB_Timeout; - } else { - if (this_time < 0) - RFCNB_errno = RFCNBE_BadRead; - else - RFCNB_errno = RFCNBE_ConGone; - } + } + else { + if (this_time < 0) + RFCNB_errno = RFCNBE_BadRead; + else + RFCNB_errno = RFCNBE_ConGone; + } - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); + + } - } #ifdef RFCNB_DEBUG - fprintf(stderr, - "Frag_Len = %i, this_time = %i, this_len = %i, more = %i\n", - frag_len, this_time, this_len, more); + fprintf(stderr, "Frag_Len = %i, this_time = %i, this_len = %i, more = %i\n", frag_len, + this_time, this_len, more); #endif - read_len = read_len + this_time; /* How much have we read ... */ + read_len = read_len + this_time; /* How much have we read ... */ - /* Now set up the next part */ + /* Now set up the next part */ - if (pkt_frag->next == NULL) - break; /* That's it here */ + if (pkt_frag -> next == NULL) break; /* That's it here */ - pkt_frag = pkt_frag->next; - this_len = pkt_frag->len; - offset = 0; + pkt_frag = pkt_frag -> next; + this_len = pkt_frag -> len; + offset = 0; - more = more - this_time; + more = more - this_time; - } + } #ifdef RFCNB_DEBUG - fprintf(stderr, "Pkt Len = %i, read_len = %i\n", pkt_len, read_len); - RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len + sizeof(hdr)); + fprintf(stderr,"Pkt Len = %i, read_len = %i\n", pkt_len, read_len); + RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len + sizeof(hdr)); #endif - if (read_len < (pkt_len + sizeof(hdr))) { /* Discard the rest */ + if (read_len < (pkt_len + sizeof(hdr))) { /* Discard the rest */ - return (RFCNB_Discard_Rest(con, (pkt_len + sizeof(hdr)) - read_len)); + return(RFCNB_Discard_Rest(con, (pkt_len + sizeof(hdr)) - read_len)); - } + } - if (RFCNB_Timeout > 0) - alarm(0); /* Reset that sucker */ + if (RFCNB_Timeout > 0) + alarm(0); /* Reset that sucker */ - return (read_len + sizeof(RFCNB_Hdr)); + return(read_len + sizeof(RFCNB_Hdr)); } Index: squid/auth_modules/MSNT/rfcnb-io.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-io.h,v retrieving revision 1.1.1.1.62.1 retrieving revision 1.1.1.1.62.2 diff -u -r1.1.1.1.62.1 -r1.1.1.1.62.2 --- squid/auth_modules/MSNT/rfcnb-io.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.62.1 +++ squid/auth_modules/MSNT/rfcnb-io.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.62.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB IO Routines Defines Index: squid/auth_modules/MSNT/rfcnb-priv.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-priv.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/rfcnb-priv.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/rfcnb-priv.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB Defines @@ -51,33 +52,30 @@ /* Structures */ -typedef struct redirect_addr *redirect_ptr; +typedef struct redirect_addr * redirect_ptr; -struct redirect_addr -{ +struct redirect_addr { - struct in_addr ip_addr; - int port; - redirect_ptr next; + struct in_addr ip_addr; + int port; + redirect_ptr next; }; -typedef struct RFCNB_Con -{ +typedef struct RFCNB_Con { - int fd; /* File descripter for TCP/IP connection */ - int rfc_errno; /* last error */ - int timeout; /* How many milli-secs before IO times out */ - int redirects; /* How many times we were redirected */ - struct redirect_addr *redirect_list; /* First is first address */ - struct redirect_addr *last_addr; - -} -RFCNB_Con; - -typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */ - /* char[0] as the type, char[1] the */ - /* flags, and char[2..3] the length */ + int fd; /* File descripter for TCP/IP connection */ + int rfc_errno; /* last error */ + int timeout; /* How many milli-secs before IO times out */ + int redirects; /* How many times we were redirected */ + struct redirect_addr *redirect_list; /* First is first address */ + struct redirect_addr *last_addr; + +} RFCNB_Con; + +typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */ + /* char[0] as the type, char[1] the */ + /* flags, and char[2..3] the length */ /* Macros to extract things from the header. These are for portability between architecture types where we are worried about byte order */ @@ -88,7 +86,7 @@ #define RFCNB_Pkt_Nack_Len 5 #define RFCNB_Pkt_Type_Offset 0 #define RFCNB_Pkt_Flags_Offset 1 -#define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */ +#define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */ #define RFCNB_Pkt_N1Len_Offset 4 #define RFCNB_Pkt_Called_Offset 5 #define RFCNB_Pkt_N2Len_Offset 38 @@ -149,5 +147,5 @@ #ifndef RFCNB_ERRNO extern int RFCNB_errno; -extern int RFCNB_saved_errno; /* Save this from point of error */ +extern int RFCNB_saved_errno; /* Save this from point of error */ #endif Index: squid/auth_modules/MSNT/rfcnb-util.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-util.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/rfcnb-util.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/rfcnb-util.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB Utility Routines ... @@ -27,40 +28,38 @@ #include "rfcnb-util.h" #include "rfcnb-io.h" -extern void (*Prot_Print_Routine) (); /* Pointer to protocol print routine */ +extern void (*Prot_Print_Routine)(); /* Pointer to protocol print routine */ /* Convert name and pad to 16 chars as needed */ /* Name 1 is a C string with null termination, name 2 may not be */ /* If SysName is true, then put a <00> on end, else space> */ -void -RFCNB_CvtPad_Name(char *name1, char *name2) -{ - char c, c1, c2; - int i, len; +void RFCNB_CvtPad_Name(char *name1, char *name2) - len = strlen(name1); +{ char c, c1, c2; + int i, len; - for (i = 0; i < 16; i++) { + len = strlen(name1); - if (i >= len) { + for (i = 0; i < 16; i++) { - c1 = 'C'; - c2 = 'A'; /* CA is a space */ + if (i >= len) { - } else { + c1 = 'C'; c2 = 'A'; /* CA is a space */ + + } else { - c = name1[i]; - c1 = (char) ((int) c / 16 + (int) 'A'); - c2 = (char) ((int) c % 16 + (int) 'A'); - } + c = name1[i]; + c1 = (char)((int)c/16 + (int)'A'); + c2 = (char)((int)c%16 + (int)'A'); + } - name2[i * 2] = c1; - name2[i * 2 + 1] = c2; + name2[i*2] = c1; + name2[i*2+1] = c2; - } + } - name2[32] = 0; /* Put in the nll ... */ + name2[32] = 0; /* Put in the nll ...*/ } @@ -73,337 +72,327 @@ */ -void -RFCNB_AName_To_NBName(char *AName, char *NBName) -{ - char c, c1, c2; - int i; +void RFCNB_AName_To_NBName(char *AName, char *NBName) - for (i = 0; i < 16; i++) { +{ char c, c1, c2; + int i; - c = AName[i]; + for (i=0; i < 16; i++) { - c1 = (char) ((c >> 4) + 'A'); - c2 = (char) ((c & 0xF) + 'A'); + c = AName[i]; - NBName[i * 2] = c1; - NBName[i * 2 + 1] = c2; - } + c1 = (char)((c >> 4) + 'A'); + c2 = (char)((c & 0xF) + 'A'); + + NBName[i*2] = c1; + NBName[i*2+1] = c2; + } - NBName[32] = 0; /* Put in a null */ + NBName[32] = 0; /* Put in a null */ } /* Do the reverse of the above ... */ -void -RFCNB_NBName_To_AName(char *NBName, char *AName) -{ - char c, c1, c2; - int i; +void RFCNB_NBName_To_AName(char *NBName, char *AName) - for (i = 0; i < 16; i++) { +{ char c, c1, c2; + int i; - c1 = NBName[i * 2]; - c2 = NBName[i * 2 + 1]; + for (i=0; i < 16; i++) { - c = (char) (((int) c1 - (int) 'A') * 16 + ((int) c2 - (int) 'A')); + c1 = NBName[i*2]; + c2 = NBName[i*2+1]; - AName[i] = c; + c = (char)(((int)c1 - (int)'A') * 16 + ((int)c2 - (int)'A')); - } + AName[i] = c; - AName[i] = 0; /* Put a null on the end ... */ + } + + AName[i] = 0; /* Put a null on the end ... */ } /* Print a string of bytes in HEX etc */ -void -RFCNB_Print_Hex(FILE * fd, struct RFCNB_Pkt *pkt, int Offset, int Len) -{ - char c1, c2, outbuf1[33]; - unsigned char c; - int i, j; - struct RFCNB_Pkt *pkt_ptr = pkt; - static char Hex_List[17] = "0123456789ABCDEF"; - - j = 0; +void RFCNB_Print_Hex(FILE *fd, struct RFCNB_Pkt *pkt, int Offset, int Len) - /* We only want to print as much as sepcified in Len */ +{ char c1, c2, outbuf1[33]; + unsigned char c; + int i, j; + struct RFCNB_Pkt *pkt_ptr = pkt; + static char Hex_List[17] = "0123456789ABCDEF"; - while (pkt_ptr != NULL) { + j = 0; - for (i = 0; - i < ((Len > (pkt_ptr->len) ? pkt_ptr->len : Len) - Offset); i++) { + /* We only want to print as much as sepcified in Len */ - c = pkt_ptr->data[i + Offset]; - c1 = Hex_List[c >> 4]; - c2 = Hex_List[c & 0xF]; + while (pkt_ptr != NULL) { - outbuf1[j++] = c1; - outbuf1[j++] = c2; + for (i = 0; + i < ((Len > (pkt_ptr -> len)?pkt_ptr -> len:Len) - Offset); + i++) { - if (j == 32) { /* Print and reset */ - outbuf1[j] = 0; - fprintf(fd, " %s\n", outbuf1); - j = 0; - } + c = pkt_ptr -> data[i + Offset]; + c1 = Hex_List[c >> 4]; + c2 = Hex_List[c & 0xF]; - } + outbuf1[j++] = c1; outbuf1[j++] = c2; - Offset = 0; - Len = Len - pkt_ptr->len; /* Reduce amount by this much */ - pkt_ptr = pkt_ptr->next; + if (j == 32){ /* Print and reset */ + outbuf1[j] = 0; + fprintf(fd, " %s\n", outbuf1); + j = 0; + } } - /* Print last lot in the buffer ... */ + Offset = 0; + Len = Len - pkt_ptr -> len; /* Reduce amount by this much */ + pkt_ptr = pkt_ptr -> next; - if (j > 0) { + } - outbuf1[j] = 0; - fprintf(fd, " %s\n", outbuf1); + /* Print last lot in the buffer ... */ - } + if (j > 0) { + + outbuf1[j] = 0; + fprintf(fd, " %s\n", outbuf1); - fprintf(fd, "\n"); + } + + fprintf(fd, "\n"); } /* Get a packet of size n */ -struct RFCNB_Pkt * -RFCNB_Alloc_Pkt(int n) -{ - RFCNB_Pkt *pkt; +struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n) - if ((pkt = (struct RFCNB_Pkt *) malloc(sizeof(struct RFCNB_Pkt))) == NULL) { +{ RFCNB_Pkt *pkt; - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return (NULL); + if ((pkt = (struct RFCNB_Pkt *)malloc(sizeof(struct RFCNB_Pkt))) == NULL) { - } + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return(NULL); - pkt->next = NULL; - pkt->len = n; + } - if (n == 0) - return (pkt); + pkt -> next = NULL; + pkt -> len = n; - if ((pkt->data = (char *) malloc(n)) == NULL) { + if (n == 0) return(pkt); - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - free(pkt); - return (NULL); + if ((pkt -> data = (char *)malloc(n)) == NULL) { - } + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + free(pkt); + return(NULL); + + } - return (pkt); + return(pkt); } /* Free up a packet */ -int -RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt) -{ - struct RFCNB_Pkt *pkt_next; - char *data_ptr; +int RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt) - while (pkt != NULL) { +{ struct RFCNB_Pkt *pkt_next; char *data_ptr; - pkt_next = pkt->next; + while (pkt != NULL) { - data_ptr = pkt->data; + pkt_next = pkt -> next; - if (data_ptr != NULL) - free(data_ptr); + data_ptr = pkt -> data; - free(pkt); + if (data_ptr != NULL) + free(data_ptr); - pkt = pkt_next; + free(pkt); - } + pkt = pkt_next; + + } } /* Print an RFCNB packet */ -void -RFCNB_Print_Pkt(FILE * fd, char *dirn, struct RFCNB_Pkt *pkt, int len) -{ - char lname[17]; +void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len) - /* We assume that the first fragment is the RFCNB Header */ - /* We should loop through the fragments printing them out */ +{ char lname[17]; - fprintf(fd, "RFCNB Pkt %s:", dirn); + /* We assume that the first fragment is the RFCNB Header */ + /* We should loop through the fragments printing them out */ - switch (RFCNB_Pkt_Type(pkt->data)) { + fprintf(fd, "RFCNB Pkt %s:", dirn); - case RFCNB_SESSION_MESSAGE: + switch (RFCNB_Pkt_Type(pkt -> data)) { - fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt->data)); - RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len, + case RFCNB_SESSION_MESSAGE: + + fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt -> data)); + RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len, #ifdef RFCNB_PRINT_DATA - RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len); + RFCNB_Pkt_Len(pkt -> data) - RFCNB_Pkt_Hdr_Len); #else - 40); + 40); #endif - if (Prot_Print_Routine != 0) { /* Print the rest of the packet */ + if (Prot_Print_Routine != 0) { /* Print the rest of the packet */ + + Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len, + RFCNB_Pkt_Len(pkt -> data) - RFCNB_Pkt_Hdr_Len); - Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len, - RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len); + } - } + break; - break; + case RFCNB_SESSION_REQUEST: - case RFCNB_SESSION_REQUEST: + fprintf(fd, "SESSION REQUEST: Length = %i\n", + RFCNB_Pkt_Len(pkt -> data)); + RFCNB_NBName_To_AName((char *)(pkt -> data + RFCNB_Pkt_Called_Offset), lname); + fprintf(fd, " Called Name: %s\n", lname); + RFCNB_NBName_To_AName((char *)(pkt -> data + RFCNB_Pkt_Calling_Offset), lname); + fprintf(fd, " Calling Name: %s\n", lname); - fprintf(fd, "SESSION REQUEST: Length = %i\n", RFCNB_Pkt_Len(pkt->data)); - RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Called_Offset), - lname); - fprintf(fd, " Called Name: %s\n", lname); - RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Calling_Offset), - lname); - fprintf(fd, " Calling Name: %s\n", lname); + break; - break; + case RFCNB_SESSION_ACK: - case RFCNB_SESSION_ACK: + fprintf(fd, "RFCNB SESSION ACK: Length = %i\n", + RFCNB_Pkt_Len(pkt -> data)); - fprintf(fd, "RFCNB SESSION ACK: Length = %i\n", - RFCNB_Pkt_Len(pkt->data)); + break; - break; + case RFCNB_SESSION_REJ: + fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n", + RFCNB_Pkt_Len(pkt -> data)); - case RFCNB_SESSION_REJ: - fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n", - RFCNB_Pkt_Len(pkt->data)); - - if (RFCNB_Pkt_Len(pkt->data) < 1) { - fprintf(fd, " Protocol Error, short Reject packet!\n"); - } else { - fprintf(fd, " Error = %x\n", CVAL(pkt->data, - RFCNB_Pkt_Error_Offset)); - } + if (RFCNB_Pkt_Len(pkt -> data) < 1) { + fprintf(fd, " Protocol Error, short Reject packet!\n"); + } + else { + fprintf(fd, " Error = %x\n", CVAL(pkt -> data, RFCNB_Pkt_Error_Offset)); + } - break; + break; - case RFCNB_SESSION_RETARGET: + case RFCNB_SESSION_RETARGET: - fprintf(fd, "RFCNB SESSION RETARGET: Length = %i\n", - RFCNB_Pkt_Len(pkt->data)); + fprintf(fd, "RFCNB SESSION RETARGET: Length = %i\n", + RFCNB_Pkt_Len(pkt -> data)); - /* Print out the IP address etc and the port? */ + /* Print out the IP address etc and the port? */ - break; + break; - case RFCNB_SESSION_KEEP_ALIVE: + case RFCNB_SESSION_KEEP_ALIVE: - fprintf(fd, "RFCNB SESSION KEEP ALIVE: Length = %i\n", - RFCNB_Pkt_Len(pkt->data)); - break; + fprintf(fd, "RFCNB SESSION KEEP ALIVE: Length = %i\n", + RFCNB_Pkt_Len(pkt -> data)); + break; default: - break; - } + break; + } } /* Resolve a name into an address */ -int -RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP) -{ - int addr; /* Assumes IP4, 32 bit network addresses */ - struct hostent *hp; - - /* Use inet_addr to try to convert the address */ +int RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP) - if ((addr = inet_addr(host)) == INADDR_NONE) { /* Oh well, a good try :-) */ +{ int addr; /* Assumes IP4, 32 bit network addresses */ + struct hostent *hp; - /* Now try a name look up with gethostbyname */ + /* Use inet_addr to try to convert the address */ - if ((hp = gethostbyname(host)) == NULL) { /* Not in DNS */ + if ((addr = inet_addr(host)) == INADDR_NONE) { /* Oh well, a good try :-) */ - /* Try NetBIOS name lookup, how the hell do we do that? */ + /* Now try a name look up with gethostbyname */ - RFCNB_errno = RFCNBE_BadName; /* Is this right? */ - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + if ((hp = gethostbyname(host)) == NULL) { /* Not in DNS */ - } else { /* We got a name */ + /* Try NetBIOS name lookup, how the hell do we do that? */ - memcpy((void *) Dest_IP, (void *) hp->h_addr_list[0], - sizeof(struct in_addr)); + RFCNB_errno = RFCNBE_BadName; /* Is this right? */ + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); - } - } else { /* It was an IP address */ + } + else { /* We got a name */ - memcpy((void *) Dest_IP, (void *) &addr, sizeof(struct in_addr)); + memcpy((void *)Dest_IP, (void *)hp -> h_addr_list[0], sizeof(struct in_addr)); } + } + else { /* It was an IP address */ + + memcpy((void *)Dest_IP, (void *)&addr, sizeof(struct in_addr)); + + } - return 0; + return 0; } /* Disconnect the TCP connection to the server */ -int -RFCNB_Close(int socket) +int RFCNB_Close(int socket) + { - close(socket); + close(socket); - /* If we want to do error recovery, here is where we put it */ + /* If we want to do error recovery, here is where we put it */ - return 0; + return 0; } /* Connect to the server specified in the IP address. Not sure how to handle socket options etc. */ -int -RFCNB_IP_Connect(struct in_addr Dest_IP, int port) -{ - struct sockaddr_in Socket; - int fd; +int RFCNB_IP_Connect(struct in_addr Dest_IP, int port) - /* Create a socket */ +{ struct sockaddr_in Socket; + int fd; - if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { /* Handle the error */ + /* Create a socket */ - RFCNB_errno = RFCNBE_BadSocket; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); - } + if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { /* Handle the error */ + + RFCNB_errno = RFCNBE_BadSocket; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); + } - bzero((char *) &Socket, sizeof(Socket)); - memcpy((char *) &Socket.sin_addr, (char *) &Dest_IP, sizeof(Dest_IP)); + bzero((char *)&Socket, sizeof(Socket)); + memcpy((char *)&Socket.sin_addr, (char *)&Dest_IP, sizeof(Dest_IP)); - Socket.sin_port = htons(port); - Socket.sin_family = PF_INET; + Socket.sin_port = htons(port); + Socket.sin_family = PF_INET; - /* Now connect to the destination */ + /* Now connect to the destination */ - if (connect(fd, (struct sockaddr *) &Socket, sizeof(Socket)) < 0) { /* Error */ + if (connect(fd, (struct sockaddr *)&Socket, sizeof(Socket)) < 0) { /* Error */ - close(fd); - RFCNB_errno = RFCNBE_ConnectFailed; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + close(fd); + RFCNB_errno = RFCNBE_ConnectFailed; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); } - return (fd); + return(fd); } @@ -412,120 +401,132 @@ */ -int -RFCNB_Session_Req(struct RFCNB_Con *con, - char *Called_Name, - char *Calling_Name, BOOL * redirect, struct in_addr *Dest_IP, int *port) -{ - char *sess_pkt; +int RFCNB_Session_Req(struct RFCNB_Con *con, + char *Called_Name, + char *Calling_Name, + BOOL *redirect, + struct in_addr *Dest_IP, + int * port) - /* Response packet should be no more than 9 bytes, make 16 jic */ +{ char *sess_pkt; - char ln1[16], ln2[16], n1[32], n2[32], resp[16]; - int len; - struct RFCNB_Pkt *pkt, res_pkt; + /* Response packet should be no more than 9 bytes, make 16 jic */ - /* We build and send the session request, then read the response */ + char ln1[16], ln2[16], n1[32], n2[32], resp[16]; + int len; + struct RFCNB_Pkt *pkt, res_pkt; - pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Sess_Len); + /* We build and send the session request, then read the response */ - if (pkt == NULL) { + pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Sess_Len); - return (RFCNBE_Bad); /* Leave the error that RFCNB_Alloc_Pkt gives) */ + if (pkt == NULL) { - } + return(RFCNBE_Bad); /* Leave the error that RFCNB_Alloc_Pkt gives) */ - sess_pkt = pkt->data; /* Get pointer to packet proper */ + } - sess_pkt[RFCNB_Pkt_Type_Offset] = RFCNB_SESSION_REQUEST; - RFCNB_Put_Pkt_Len(sess_pkt, RFCNB_Pkt_Sess_Len - RFCNB_Pkt_Hdr_Len); - sess_pkt[RFCNB_Pkt_N1Len_Offset] = 32; - sess_pkt[RFCNB_Pkt_N2Len_Offset] = 32; + sess_pkt = pkt -> data; /* Get pointer to packet proper */ - RFCNB_CvtPad_Name(Called_Name, (sess_pkt + RFCNB_Pkt_Called_Offset)); - RFCNB_CvtPad_Name(Calling_Name, (sess_pkt + RFCNB_Pkt_Calling_Offset)); + sess_pkt[RFCNB_Pkt_Type_Offset] = RFCNB_SESSION_REQUEST; + RFCNB_Put_Pkt_Len(sess_pkt, RFCNB_Pkt_Sess_Len-RFCNB_Pkt_Hdr_Len); + sess_pkt[RFCNB_Pkt_N1Len_Offset] = 32; + sess_pkt[RFCNB_Pkt_N2Len_Offset] = 32; - /* Now send the packet */ + RFCNB_CvtPad_Name(Called_Name, (sess_pkt + RFCNB_Pkt_Called_Offset)); + RFCNB_CvtPad_Name(Calling_Name, (sess_pkt + RFCNB_Pkt_Calling_Offset)); -#ifdef RFCNB_DEBUG + /* Now send the packet */ - fprintf(stderr, "Sending packet: "); +#ifdef RFCNB_DEBUG + fprintf(stderr, "Sending packet: "); + #endif - if ((len = RFCNB_Put_Pkt(con, pkt, RFCNB_Pkt_Sess_Len)) < 0) { + if ((len = RFCNB_Put_Pkt(con, pkt, RFCNB_Pkt_Sess_Len)) < 0) { - return (RFCNBE_Bad); /* Should be able to write that lot ... */ + return(RFCNBE_Bad); /* Should be able to write that lot ... */ } + #ifdef RFCNB_DEBUG - fprintf(stderr, "Getting packet.\n"); + fprintf(stderr, "Getting packet.\n"); #endif - res_pkt.data = resp; - res_pkt.len = sizeof(resp); - res_pkt.next = NULL; + res_pkt.data = resp; + res_pkt.len = sizeof(resp); + res_pkt.next = NULL; - if ((len = RFCNB_Get_Pkt(con, &res_pkt, sizeof(resp))) < 0) { + if ((len = RFCNB_Get_Pkt(con, &res_pkt, sizeof(resp))) < 0) { - return (RFCNBE_Bad); + return(RFCNBE_Bad); - } - - /* Now analyze the packet ... */ + } - switch (RFCNB_Pkt_Type(resp)) { + /* Now analyze the packet ... */ - case RFCNB_SESSION_REJ: /* Didnt like us ... too bad */ + switch (RFCNB_Pkt_Type(resp)) { - /* Why did we get rejected ? */ + case RFCNB_SESSION_REJ: /* Didnt like us ... too bad */ - switch (CVAL(resp, RFCNB_Pkt_Error_Offset)) { - - case 0x80: - RFCNB_errno = RFCNBE_CallRejNLOCN; - break; - case 0x81: - RFCNB_errno = RFCNBE_CallRejNLFCN; - break; - case 0x82: - RFCNB_errno = RFCNBE_CallRejCNNP; - break; - case 0x83: - RFCNB_errno = RFCNBE_CallRejInfRes; - break; - case 0x8F: - RFCNB_errno = RFCNBE_CallRejUnSpec; - break; - default: - RFCNB_errno = RFCNBE_ProtErr; - break; - } + /* Why did we get rejected ? */ + + switch (CVAL(resp,RFCNB_Pkt_Error_Offset)) { - return (RFCNBE_Bad); + case 0x80: + RFCNB_errno = RFCNBE_CallRejNLOCN; + break; + case 0x81: + RFCNB_errno = RFCNBE_CallRejNLFCN; + break; + case 0x82: + RFCNB_errno = RFCNBE_CallRejCNNP; break; + case 0x83: + RFCNB_errno = RFCNBE_CallRejInfRes; + break; + case 0x8F: + RFCNB_errno = RFCNBE_CallRejUnSpec; + break; + default: + RFCNB_errno = RFCNBE_ProtErr; + break; + } - case RFCNB_SESSION_ACK: /* Got what we wanted ... */ + return(RFCNBE_Bad); + break; - return (0); - break; + case RFCNB_SESSION_ACK: /* Got what we wanted ... */ - case RFCNB_SESSION_RETARGET: /* Go elsewhere */ + return(0); + break; - *redirect = TRUE; /* Copy port and ip addr */ + case RFCNB_SESSION_RETARGET: /* Go elsewhere */ - memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr)); - *port = SVAL(resp, RFCNB_Pkt_Port_Offset); + *redirect = TRUE; /* Copy port and ip addr */ - return (0); - break; + memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr)); + *port = SVAL(resp, RFCNB_Pkt_Port_Offset); - default: /* A protocol error */ + return(0); + break; - RFCNB_errno = RFCNBE_ProtErr; - return (RFCNBE_Bad); - break; + default: /* A protocol error */ + + RFCNB_errno = RFCNBE_ProtErr; + return(RFCNBE_Bad); + break; } } + + + + + + + + + Index: squid/auth_modules/MSNT/rfcnb-util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-util.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/rfcnb-util.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/rfcnb-util.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB Utility Defines @@ -28,11 +29,11 @@ void RFCNB_NBName_To_AName(char *NBName, char *AName); -void RFCNB_Print_Hex(FILE * fd, struct RFCNB_Pkt *pkt, int Offset, int Len); +void RFCNB_Print_Hex(FILE *fd, struct RFCNB_Pkt *pkt, int Offset, int Len); struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n); -void RFCNB_Print_Pkt(FILE * fd, char *dirn, struct RFCNB_Pkt *pkt, int len); +void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len); int RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP); @@ -40,6 +41,10 @@ int RFCNB_IP_Connect(struct in_addr Dest_IP, int port); -int RFCNB_Session_Req(struct RFCNB_Con *con, - char *Called_Name, - char *Calling_Name, BOOL * redirect, struct in_addr *Dest_IP, int *port); +int RFCNB_Session_Req(struct RFCNB_Con *con, + char *Called_Name, + char *Calling_Name, + BOOL *redirect, + struct in_addr *Dest_IP, + int * port); + Index: squid/auth_modules/MSNT/rfcnb.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb.h,v retrieving revision 1.1.1.1.62.1 retrieving revision 1.1.1.1.62.2 diff -u -r1.1.1.1.62.1 -r1.1.1.1.62.2 --- squid/auth_modules/MSNT/rfcnb.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.62.1 +++ squid/auth_modules/MSNT/rfcnb.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.62.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 RFCNB Defines @@ -34,7 +35,7 @@ /* Definition of routines we define */ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, - int port); + int port); int RFCNB_Send(void *Con_Handle, struct RFCNB_Pkt *Data, int Length); Index: squid/auth_modules/MSNT/session.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/session.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/session.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/session.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation + Version 1.0 Session Routines ... @@ -33,7 +34,7 @@ int RFCNB_Stats[RFCNB_MAX_STATS]; -void (*Prot_Print_Routine) () = NULL; /* Pointer to print routine */ +void (*Prot_Print_Routine)() = NULL; /* Pointer to print routine */ /* Set up a session with a remote name. We are passed Called_Name as a string which we convert to a NetBIOS name, ie space terminated, up to @@ -42,128 +43,123 @@ Address can be a DNS based name, or a TCP/IP address ... */ -void * -RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, - int port) +void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, + int port) -{ - struct RFCNB_Con *con; - struct in_addr Dest_IP; - int Client; - BOOL redirect; - struct redirect_addr *redir_addr; - char *Service_Address; +{ struct RFCNB_Con *con; + struct in_addr Dest_IP; + int Client; + BOOL redirect; struct redirect_addr *redir_addr; + char *Service_Address; - /* Now, we really should look up the port in /etc/services ... */ + /* Now, we really should look up the port in /etc/services ... */ - if (port == 0) - port = RFCNB_Default_Port; + if (port == 0) port = RFCNB_Default_Port; - /* Create a connection structure first */ + /* Create a connection structure first */ - if ((con = (struct RFCNB_Con *) malloc(sizeof(struct RFCNB_Con))) == NULL) { /* Error in size */ + if ((con = (struct RFCNB_Con *)malloc(sizeof(struct RFCNB_Con))) == NULL) { /* Error in size */ - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return (NULL); + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return(NULL); } + + con -> fd = -0; /* no descriptor yet */ + con -> rfc_errno = 0; /* no error yet */ + con -> timeout = 0; /* no timeout */ + con -> redirects = 0; + con -> redirect_list = NULL; /* Fix bug still in version 0.50 */ - con->fd = -0; /* no descriptor yet */ - con->rfc_errno = 0; /* no error yet */ - con->timeout = 0; /* no timeout */ - con->redirects = 0; - con->redirect_list = NULL; /* Fix bug still in version 0.50 */ - - /* Resolve that name into an IP address */ - - Service_Address = Called_Name; - if (strcmp(Called_Address, "") != 0) { /* If the Called Address = "" */ - Service_Address = Called_Address; - } + /* Resolve that name into an IP address */ - if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) { /* Error */ + Service_Address = Called_Name; + if (strcmp(Called_Address, "") != 0) { /* If the Called Address = "" */ + Service_Address = Called_Address; + } - /* No need to modify RFCNB_errno as it was done by RFCNB_Name_To_IP */ + if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) { /* Error */ - return (NULL); + /* No need to modify RFCNB_errno as it was done by RFCNB_Name_To_IP */ - } + return(NULL); - /* Now connect to the remote end */ + } - redirect = TRUE; /* Fudge this one so we go once through */ + /* Now connect to the remote end */ - while (redirect) { /* Connect and get session info etc */ + redirect = TRUE; /* Fudge this one so we go once through */ - redirect = FALSE; /* Assume all OK */ + while (redirect) { /* Connect and get session info etc */ - /* Build the redirect info. First one is first addr called */ - /* And tack it onto the list of addresses we called */ + redirect = FALSE; /* Assume all OK */ - if ((redir_addr = - (struct redirect_addr *) malloc(sizeof(struct redirect_addr))) - == NULL) { /* Could not get space */ + /* Build the redirect info. First one is first addr called */ + /* And tack it onto the list of addresses we called */ - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return (NULL); + if ((redir_addr = (struct redirect_addr *)malloc(sizeof(struct redirect_addr))) == NULL) { /* Could not get space */ + + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return(NULL); - } + } - memcpy((char *) &(redir_addr->ip_addr), (char *) &Dest_IP, - sizeof(Dest_IP)); - redir_addr->port = port; - redir_addr->next = NULL; + memcpy((char *)&(redir_addr -> ip_addr), (char *)&Dest_IP, sizeof(Dest_IP)); + redir_addr -> port = port; + redir_addr -> next = NULL; - if (con->redirect_list == NULL) { /* Stick on head */ + if (con -> redirect_list == NULL) { /* Stick on head */ - con->redirect_list = con->last_addr = redir_addr; + con -> redirect_list = con -> last_addr = redir_addr; - } else { + } else { - con->last_addr->next = redir_addr; - con->last_addr = redir_addr; + con -> last_addr -> next = redir_addr; + con -> last_addr = redir_addr; - } + } - /* Now, make that connection */ + /* Now, make that connection */ - if ((Client = RFCNB_IP_Connect(Dest_IP, port)) < 0) { /* Error */ + if ((Client = RFCNB_IP_Connect(Dest_IP, port)) < 0) { /* Error */ - /* No need to modify RFCNB_errno as it was done by RFCNB_IP_Connect */ + /* No need to modify RFCNB_errno as it was done by RFCNB_IP_Connect */ - return (NULL); + return(NULL); - } + } - con->fd = Client; + con -> fd = Client; - /* Now send and handle the RFCNB session request */ - /* If we get a redirect, we will comeback with redirect true - * and a new IP address in DEST_IP */ + /* Now send and handle the RFCNB session request */ + /* If we get a redirect, we will comeback with redirect true + and a new IP address in DEST_IP */ - if ((errno = RFCNB_Session_Req(con, - Called_Name, Calling_Name, &redirect, &Dest_IP, &port)) < 0) { + if ((errno = RFCNB_Session_Req(con, + Called_Name, + Calling_Name, + &redirect, &Dest_IP, &port)) < 0) { - /* No need to modify RFCNB_errno as it was done by RFCNB_Session.. */ + /* No need to modify RFCNB_errno as it was done by RFCNB_Session.. */ - return (NULL); + return(NULL); - } + } - if (redirect) { + if (redirect) { - /* We have to close the connection, and then try again */ + /* We have to close the connection, and then try again */ - (con->redirects)++; + (con -> redirects)++; - RFCNB_Close(con->fd); /* Close it */ + RFCNB_Close(con -> fd); /* Close it */ - } + } } - return (con); + return(con); } @@ -171,138 +167,133 @@ data as a series of pointers to blocks of data ... we should check the length ... */ -int -RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length) -{ - struct RFCNB_Pkt *pkt; - char *hdr; - int len; +int RFCNB_Send(struct RFCNB_Con *Con_Handle, struct RFCNB_Pkt *udata, int Length) - /* Plug in the header and send the data */ +{ struct RFCNB_Pkt *pkt; char *hdr; + int len; - pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Hdr_Len); + /* Plug in the header and send the data */ - if (pkt == NULL) { + pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Hdr_Len); - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + if (pkt == NULL) { - } + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); - pkt->next = udata; /* The user data we want to send */ + } - hdr = pkt->data; + pkt -> next = udata; /* The user data we want to send */ - /* Following crap is for portability across multiple UNIX machines */ + hdr = pkt -> data; - *(hdr + RFCNB_Pkt_Type_Offset) = RFCNB_SESSION_MESSAGE; - RFCNB_Put_Pkt_Len(hdr, Length); + /* Following crap is for portability across multiple UNIX machines */ -#ifdef RFCNB_DEBUG + *(hdr + RFCNB_Pkt_Type_Offset) = RFCNB_SESSION_MESSAGE; + RFCNB_Put_Pkt_Len(hdr, Length); - fprintf(stderr, "Sending packet: "); +#ifdef RFCNB_DEBUG + fprintf(stderr, "Sending packet: "); + #endif - if ((len = RFCNB_Put_Pkt(Con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) { + if ((len = RFCNB_Put_Pkt(Con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) { - /* No need to change RFCNB_errno as it was done by put_pkt ... */ + /* No need to change RFCNB_errno as it was done by put_pkt ... */ - return (RFCNBE_Bad); /* Should be able to write that lot ... */ + return(RFCNBE_Bad); /* Should be able to write that lot ... */ + + } - } - - /* Now we have sent that lot, let's get rid of the RFCNB Header and return */ + /* Now we have sent that lot, let's get rid of the RFCNB Header and return */ - pkt->next = NULL; + pkt -> next = NULL; - RFCNB_Free_Pkt(pkt); + RFCNB_Free_Pkt(pkt); - return (len); + return(len); } /* We pick up a message from the internet ... We have to worry about non-message packets ... */ -int -RFCNB_Recv(void *con_Handle, struct RFCNB_Pkt *Data, int Length) -{ - struct RFCNB_Pkt *pkt; - struct RFCNB_Hdr *hdr; - int ret_len; - - if (con_Handle == NULL) { - - RFCNB_errno = RFCNBE_BadHandle; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); +int RFCNB_Recv(void *con_Handle, struct RFCNB_Pkt *Data, int Length) - } +{ struct RFCNB_Pkt *pkt; struct RFCNB_Hdr *hdr; + int ret_len; - /* Now get a packet from below. We allocate a header first */ + if (con_Handle == NULL){ - /* Plug in the header and send the data */ + RFCNB_errno = RFCNBE_BadHandle; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); - pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Hdr_Len); + } - if (pkt == NULL) { + /* Now get a packet from below. We allocate a header first */ - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return (RFCNBE_Bad); + /* Plug in the header and send the data */ - } + pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Hdr_Len); + + if (pkt == NULL) { + + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return(RFCNBE_Bad); + + } - pkt->next = Data; /* Plug in the data portion */ + pkt -> next = Data; /* Plug in the data portion */ - if ((ret_len = - RFCNB_Get_Pkt(con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) { + if ((ret_len = RFCNB_Get_Pkt(con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) { #ifdef RFCNB_DEBUG - fprintf(stderr, "Bad packet return in RFCNB_Recv... \n"); + fprintf(stderr, "Bad packet return in RFCNB_Recv... \n"); #endif - return (RFCNBE_Bad); + return(RFCNBE_Bad); - } + } - /* We should check that we go a message and not a keep alive */ + /* We should check that we go a message and not a keep alive */ - pkt->next = NULL; + pkt -> next = NULL; - RFCNB_Free_Pkt(pkt); + RFCNB_Free_Pkt(pkt); - return (ret_len); + return(ret_len); } /* We just disconnect from the other end, as there is nothing in the RFCNB */ /* protocol that specifies any exchange as far as I can see */ -int -RFCNB_Hangup(struct RFCNB_Con *con_Handle) +int RFCNB_Hangup(struct RFCNB_Con *con_Handle) + { - if (con_Handle != NULL) { - RFCNB_Close(con_Handle->fd); /* Could this fail? */ - free(con_Handle); - } + if (con_Handle != NULL) { + RFCNB_Close(con_Handle -> fd); /* Could this fail? */ + free(con_Handle); + } - return 0; + return 0; } /* Set TCP_NODELAY on the socket */ -int -RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, BOOL yn) +int RFCNB_Set_Sock_NoDelay(struct RFCNB_Con *con_Handle, BOOL yn) + { - return (setsockopt(con_Handle->fd, IPPROTO_TCP, TCP_NODELAY, - (char *) &yn, sizeof(yn))); + return(setsockopt(con_Handle -> fd, IPPROTO_TCP, TCP_NODELAY, + (char *)&yn, sizeof(yn))); } @@ -310,8 +301,8 @@ /* Listen for a connection on a port???, when */ /* the connection comes in, we return with the connection */ -void * -RFCNB_Listen() +void *RFCNB_Listen() + { } @@ -319,55 +310,56 @@ /* Pick up the last error response as a string, hmmm, this routine should */ /* have been different ... */ -void -RFCNB_Get_Error(char *buffer, int buf_len) +void RFCNB_Get_Error(char *buffer, int buf_len) + { - if (RFCNB_saved_errno <= 0) { - sprintf(buffer, "%s", RFCNB_Error_Strings[RFCNB_errno]); - } else { - sprintf(buffer, "%s\n\terrno:%s", RFCNB_Error_Strings[RFCNB_errno], + if (RFCNB_saved_errno <= 0) { + sprintf(buffer, "%s", RFCNB_Error_Strings[RFCNB_errno]); + } + else { + sprintf(buffer, "%s\n\terrno:%s", RFCNB_Error_Strings[RFCNB_errno], strerror(RFCNB_saved_errno)); - } + } } /* Pick up the last error response and returns as a code */ -int -RFCNB_Get_Last_Error() +int RFCNB_Get_Last_Error() + { - return (RFCNB_errno); + return(RFCNB_errno); } /* Pick up saved errno as well */ -int -RFCNB_Get_Last_Errno() +int RFCNB_Get_Last_Errno() + { - return (RFCNB_saved_errno); + return(RFCNB_saved_errno); } /* Pick up the last error response and return in string ... */ -int -RFCNB_Get_Error_Msg(int code, char *msg_buf, int len) +int RFCNB_Get_Error_Msg(int code, char *msg_buf, int len) + { - strncpy(msg_buf, RFCNB_Error_Strings[abs(code)], len); + strncpy(msg_buf, RFCNB_Error_Strings[abs(code)], len); } /* Register a higher level protocol print routine */ -void -RFCNB_Register_Print_Routine(void (*fn) ()) +void RFCNB_Register_Print_Routine(void (*fn)()) + { - Prot_Print_Routine = fn; + Prot_Print_Routine = fn; } Index: squid/auth_modules/MSNT/smbauth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smbauth.c,v retrieving revision 1.1.1.1.4.2.6.1 retrieving revision 1.1.1.1.4.2.6.2 diff -u -r1.1.1.1.4.2.6.1 -r1.1.1.1.4.2.6.2 --- squid/auth_modules/MSNT/smbauth.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.4.2.6.1 +++ squid/auth_modules/MSNT/smbauth.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.4.2.6.2 @@ -1,5 +1,7 @@ + /* msntauth + Modified to act as a Squid authenticator module. Removed all Pike stuff. Returns OK for a successful authentication, or ERR upon error. @@ -34,75 +36,78 @@ #include #include "sitedef.h" -extern void Checkforchange(); /* For signal() to find the function */ +extern void Checkforchange(); /* For signal() to find the function */ /* Main program for simple authentication. Reads the denied user file. Sets alarm timer. Scans and checks for Squid input, and attempts to validate the user. */ -int -main() +int main() { - char username[256]; - char password[256]; - char wstr[256]; - struct itimerval TimeOut; - - /* Read denied user file. If it fails there is a serious problem. - * Check syslog messages. Deny all users while in this state. - * The process should then be killed. */ - - if (Read_denyusers() == 1) { - while (1) { - fgets(wstr, 255, stdin); - puts("ERR"); - fflush(stdout); - } + char username[256]; + char password[256]; + char wstr[256]; + struct itimerval TimeOut; + + /* Read denied user file. If it fails there is a serious problem. + Check syslog messages. Deny all users while in this state. + The process should then be killed. */ + + if (Read_denyusers() == 1) + { + while (1) + { + fgets(wstr, 255, stdin); + puts("ERR"); + fflush(stdout); + } + } + + /* An alarm timer is used to check the denied user file for changes + every minute. Reload the file if it has changed. */ + + TimeOut.it_interval.tv_sec = 60; + TimeOut.it_interval.tv_usec = 0; + TimeOut.it_value.tv_sec = 60; + TimeOut.it_value.tv_usec = 0; + setitimer(ITIMER_REAL, &TimeOut, 0); + signal(SIGALRM, Checkforchange); + signal(SIGHUP, Checkforchange); + + while (1) + { + /* Read whole line from standard input. Terminate on break. */ + if (fgets(wstr, 255, stdin) == NULL) + break; + + /* Clear any current settings */ + username[0] = '\0'; + password[0] = '\0'; + sscanf(wstr, "%s %s", username, password); /* Extract parameters */ + + /* Check for invalid or blank entries */ + if ((username[0] == '\0') || (password[0] == '\0')) + { + puts("ERR"); + fflush(stdout); + continue; } - /* An alarm timer is used to check the denied user file for changes - * every minute. Reload the file if it has changed. */ - - TimeOut.it_interval.tv_sec = 60; - TimeOut.it_interval.tv_usec = 0; - TimeOut.it_value.tv_sec = 60; - TimeOut.it_value.tv_usec = 0; - setitimer(ITIMER_REAL, &TimeOut, 0); - signal(SIGALRM, Checkforchange); - signal(SIGHUP, Checkforchange); - - while (1) { - /* Read whole line from standard input. Terminate on break. */ - if (fgets(wstr, 255, stdin) == NULL) - break; - - /* Clear any current settings */ - username[0] = '\0'; - password[0] = '\0'; - sscanf(wstr, "%s %s", username, password); /* Extract parameters */ - - /* Check for invalid or blank entries */ - if ((username[0] == '\0') || (password[0] == '\0')) { - puts("ERR"); - fflush(stdout); - continue; - } - - if (Check_user(username) == 1) /* Check if user is denied */ - puts("ERR"); - else { - if (Valid_User(username, password, PRIMARY_DC, BACKUP_DC, - NTDOMAIN) == 0) - puts("OK"); - else - puts("ERR"); - } - - fflush(stdout); - } - - return 0; + if (Check_user(username) == 1) /* Check if user is denied */ + puts("ERR"); + else + { + if (Valid_User(username, password, PRIMARY_DC, BACKUP_DC, NTDOMAIN) == 0) + puts("OK"); + else + puts("ERR"); + } + + fflush(stdout); + } + + return 0; } /* Valid_User return codes - @@ -112,3 +117,4 @@ 2 - Protocol error. 3 - Logon error; Incorrect password or username given. */ + Index: squid/auth_modules/MSNT/smbdes.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smbdes.c,v retrieving revision 1.1.1.1.62.1 retrieving revision 1.1.1.1.62.2 diff -u -r1.1.1.1.62.1 -r1.1.1.1.62.2 --- squid/auth_modules/MSNT/smbdes.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.62.1 +++ squid/auth_modules/MSNT/smbdes.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.62.2 @@ -47,308 +47,291 @@ -static int perm1[56] = { 57, 49, 41, 33, 25, 17, 9, - 1, 58, 50, 42, 34, 26, 18, - 10, 2, 59, 51, 43, 35, 27, - 19, 11, 3, 60, 52, 44, 36, - 63, 55, 47, 39, 31, 23, 15, - 7, 62, 54, 46, 38, 30, 22, - 14, 6, 61, 53, 45, 37, 29, - 21, 13, 5, 28, 20, 12, 4 -}; - -static int perm2[48] = { 14, 17, 11, 24, 1, 5, - 3, 28, 15, 6, 21, 10, - 23, 19, 12, 4, 26, 8, - 16, 7, 27, 20, 13, 2, - 41, 52, 31, 37, 47, 55, - 30, 40, 51, 45, 33, 48, - 44, 49, 39, 56, 34, 53, - 46, 42, 50, 36, 29, 32 -}; - -static int perm3[64] = { 58, 50, 42, 34, 26, 18, 10, 2, - 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, - 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, - 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, - 63, 55, 47, 39, 31, 23, 15, 7 -}; - -static int perm4[48] = { 32, 1, 2, 3, 4, 5, - 4, 5, 6, 7, 8, 9, - 8, 9, 10, 11, 12, 13, - 12, 13, 14, 15, 16, 17, - 16, 17, 18, 19, 20, 21, - 20, 21, 22, 23, 24, 25, - 24, 25, 26, 27, 28, 29, - 28, 29, 30, 31, 32, 1 -}; - -static int perm5[32] = { 16, 7, 20, 21, - 29, 12, 28, 17, - 1, 15, 23, 26, - 5, 18, 31, 10, - 2, 8, 24, 14, - 32, 27, 3, 9, - 19, 13, 30, 6, - 22, 11, 4, 25 -}; - - -static int perm6[64] = { 40, 8, 48, 16, 56, 24, 64, 32, - 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, - 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, - 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, - 33, 1, 41, 9, 49, 17, 57, 25 -}; +static int perm1[56] = {57, 49, 41, 33, 25, 17, 9, + 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, + 19, 11, 3, 60, 52, 44, 36, + 63, 55, 47, 39, 31, 23, 15, + 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, + 21, 13, 5, 28, 20, 12, 4}; + +static int perm2[48] = {14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32}; + +static int perm3[64] = {58, 50, 42, 34, 26, 18, 10, 2, + 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, + 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, + 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, + 63, 55, 47, 39, 31, 23, 15, 7}; + +static int perm4[48] = { 32, 1, 2, 3, 4, 5, + 4, 5, 6, 7, 8, 9, + 8, 9, 10, 11, 12, 13, + 12, 13, 14, 15, 16, 17, + 16, 17, 18, 19, 20, 21, + 20, 21, 22, 23, 24, 25, + 24, 25, 26, 27, 28, 29, + 28, 29, 30, 31, 32, 1}; + +static int perm5[32] = { 16, 7, 20, 21, + 29, 12, 28, 17, + 1, 15, 23, 26, + 5, 18, 31, 10, + 2, 8, 24, 14, + 32, 27, 3, 9, + 19, 13, 30, 6, + 22, 11, 4, 25}; + + +static int perm6[64] ={ 40, 8, 48, 16, 56, 24, 64, 32, + 39, 7, 47, 15, 55, 23, 63, 31, + 38, 6, 46, 14, 54, 22, 62, 30, + 37, 5, 45, 13, 53, 21, 61, 29, + 36, 4, 44, 12, 52, 20, 60, 28, + 35, 3, 43, 11, 51, 19, 59, 27, + 34, 2, 42, 10, 50, 18, 58, 26, + 33, 1, 41, 9, 49, 17, 57, 25}; -static int sc[16] = { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 }; +static int sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1}; static int sbox[8][4][16] = { - {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, - {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, - {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, - {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}}, - - {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, - {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, - {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, - {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}}, - - {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, - {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, - {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, - {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}}, - - {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, - {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, - {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, - {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}}, - - {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, - {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, - {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, - {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}}, - - {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, - {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, - {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, - {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}}, - - {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, - {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, - {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, - {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}}, - - {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, - {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, - {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, - {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}} -}; - -static void -permute(char *out, char *in, int *p, int n) -{ - int i; - for (i = 0; i < n; i++) - out[i] = in[p[i] - 1]; -} - -static void -lshift(char *d, int count, int n) -{ - char out[64]; - int i; - for (i = 0; i < n; i++) - out[i] = d[(i + count) % n]; - for (i = 0; i < n; i++) - d[i] = out[i]; -} - -static void -concat(char *out, char *in1, char *in2, int l1, int l2) -{ - while (l1--) - *out++ = *in1++; - while (l2--) - *out++ = *in2++; -} - -static void -xor(char *out, char *in1, char *in2, int n) -{ - int i; - for (i = 0; i < n; i++) - out[i] = in1[i] ^ in2[i]; -} - -static void -dohash(char *out, char *in, char *key) -{ - int i, j, k; - char pk1[56]; - char c[28]; - char d[28]; - char cd[56]; - char ki[16][48]; - char pd1[64]; - char l[32], r[32]; - char rl[64]; - - permute(pk1, key, perm1, 56); - - for (i = 0; i < 28; i++) - c[i] = pk1[i]; - for (i = 0; i < 28; i++) - d[i] = pk1[i + 28]; - - for (i = 0; i < 16; i++) { - lshift(c, sc[i], 28); - lshift(d, sc[i], 28); - - concat(cd, c, d, 28, 28); - permute(ki[i], cd, perm2, 48); - } - - permute(pd1, in, perm3, 64); - - for (j = 0; j < 32; j++) { - l[j] = pd1[j]; - r[j] = pd1[j + 32]; - } - - for (i = 0; i < 16; i++) { - char er[48]; - char erk[48]; - char b[8][6]; - char cb[32]; - char pcb[32]; - char r2[32]; - - permute(er, r, perm4, 48); - - xor(erk, er, ki[i], 48); - - for (j = 0; j < 8; j++) - for (k = 0; k < 6; k++) - b[j][k] = erk[j * 6 + k]; - - for (j = 0; j < 8; j++) { - int m, n; - m = (b[j][0] << 1) | b[j][5]; + {{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7}, + {0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8}, + {4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0}, + {15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}}, - n = (b[j][1] << 3) | (b[j][2] << 2) | (b[j][3] << 1) | b[j][4]; + {{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10}, + {3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5}, + {0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15}, + {13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}}, - for (k = 0; k < 4; k++) - b[j][k] = (sbox[j][m][n] & (1 << (3 - k))) ? 1 : 0; - } + {{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8}, + {13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1}, + {13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7}, + {1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}}, - for (j = 0; j < 8; j++) - for (k = 0; k < 4; k++) - cb[j * 4 + k] = b[j][k]; - permute(pcb, cb, perm5, 32); + {{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15}, + {13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9}, + {10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4}, + {3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}}, - xor(r2, l, pcb, 32); + {{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9}, + {14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6}, + {4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14}, + {11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}}, - for (j = 0; j < 32; j++) - l[j] = r[j]; + {{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11}, + {10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8}, + {9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6}, + {4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}}, - for (j = 0; j < 32; j++) - r[j] = r2[j]; - } + {{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1}, + {13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6}, + {1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2}, + {6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}}, - concat(rl, r, l, 32, 32); + {{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7}, + {1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2}, + {7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8}, + {2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}}}; - permute(out, rl, perm6, 64); +static void permute(char *out, char *in, int *p, int n) +{ + int i; + for (i=0;i> 1; - key[1] = ((str[0] & 0x01) << 6) | (str[1] >> 2); - key[2] = ((str[1] & 0x03) << 5) | (str[2] >> 3); - key[3] = ((str[2] & 0x07) << 4) | (str[3] >> 4); - key[4] = ((str[3] & 0x0F) << 3) | (str[4] >> 5); - key[5] = ((str[4] & 0x1F) << 2) | (str[5] >> 6); - key[6] = ((str[5] & 0x3F) << 1) | (str[6] >> 7); - key[7] = str[6] & 0x7F; - for (i = 0; i < 8; i++) { - key[i] = (key[i] << 1); - } +static void concat(char *out, char *in1, char *in2, int l1, int l2) +{ + while (l1--) + *out++ = *in1++; + while (l2--) + *out++ = *in2++; } +static void xor(char *out, char *in1, char *in2, int n) +{ + int i; + for (i=0;i>1; + key[1] = ((str[0]&0x01)<<6) | (str[1]>>2); + key[2] = ((str[1]&0x03)<<5) | (str[2]>>3); + key[3] = ((str[2]&0x07)<<4) | (str[3]>>4); + key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5); + key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6); + key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7); + key[7] = str[6]&0x7F; + for (i=0;i<8;i++) { + key[i] = (key[i]<<1); + } } -void -E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24) + +static void smbhash(unsigned char *out, unsigned char *in, unsigned char *key) { - smbhash(p24, c8, p21); - smbhash(p24 + 8, c8, p21 + 7); - smbhash(p24 + 16, c8, p21 + 14); + int i; + char outb[64]; + char inb[64]; + char keyb[64]; + unsigned char key2[8]; + + str_to_key(key, key2); + + for (i=0;i<64;i++) { + inb[i] = (in[i/8] & (1<<(7-(i%8)))) ? 1 : 0; + keyb[i] = (key2[i/8] & (1<<(7-(i%8)))) ? 1 : 0; + outb[i] = 0; + } + + dohash(outb, inb, keyb); + + for (i=0;i<8;i++) { + out[i] = 0; + } + + for (i=0;i<64;i++) { + if (outb[i]) + out[i/8] |= (1<<(7-(i%8))); + } } -void -cred_hash1(unsigned char *out, unsigned char *in, unsigned char *key) +void E_P16(unsigned char *p14,unsigned char *p16) { - unsigned char buf[8]; + unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; + smbhash(p16, sp8, p14); + smbhash(p16+8, sp8, p14+7); +} - smbhash(buf, in, key); - smbhash(out, buf, key + 9); +void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24) +{ + smbhash(p24, c8, p21); + smbhash(p24+8, c8, p21+7); + smbhash(p24+16, c8, p21+14); } -void -cred_hash2(unsigned char *out, unsigned char *in, unsigned char *key) +void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key) { - unsigned char buf[8]; - static unsigned char key2[8]; + unsigned char buf[8]; - smbhash(buf, in, key); - key2[0] = key[7]; - smbhash(out, buf, key2); + smbhash(buf, in, key); + smbhash(out, buf, key+9); } + +void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key) +{ + unsigned char buf[8]; + static unsigned char key2[8]; + + smbhash(buf, in, key); + key2[0] = key[7]; + smbhash(out, buf, key2); +} + Index: squid/auth_modules/MSNT/smbencrypt.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smbencrypt.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/smbencrypt.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/smbencrypt.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -33,35 +33,33 @@ #include "byteorder.h" -char *StrnCpy(char *dest, char *src, int n); +char *StrnCpy(char *dest,char *src,int n); void strupper(char *s); /* This implements the X/Open SMB password encryption It takes a password, a 8 byte "crypt key" and puts 24 bytes of encrypted password into p24 */ -void -SMBencrypt(uchar * passwd, uchar * c8, uchar * p24) +void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24) { - uchar p14[15], p21[21]; + uchar p14[15], p21[21]; - memset(p21, '\0', 21); - memset(p14, '\0', 14); - StrnCpy((char *) p14, (char *) passwd, 14); - - strupper((char *) p14); - E_P16(p14, p21); - E_P24(p21, c8, p24); + memset(p21,'\0',21); + memset(p14,'\0',14); + StrnCpy((char *)p14,(char *)passwd,14); + + strupper((char *)p14); + E_P16(p14, p21); + E_P24(p21, c8, p24); } /* Routines for Windows NT MD4 Hash functions. */ -static int -_my_wcslen(int16 * str) +static int _my_wcslen(int16 *str) { - int len = 0; - while (*str++ != 0) - len++; - return len; + int len = 0; + while(*str++ != 0) + len++; + return len; } /* @@ -70,135 +68,129 @@ * this must be in intel (little-endian) * format. */ - -static int -_my_mbstowcs(int16 * dst, uchar * src, int len) + +static int _my_mbstowcs(int16 *dst, uchar *src, int len) { - int i; - int16 val; - - for (i = 0; i < len; i++) { - val = *src; - SSVAL(dst, 0, val); - dst++; - src++; - if (val == 0) - break; - } - return i; + int i; + int16 val; + + for(i = 0; i < len; i++) { + val = *src; + SSVAL(dst,0,val); + dst++; + src++; + if(val == 0) + break; + } + return i; } /* * Creates the MD4 Hash of the users password in NT UNICODE. */ - -void -E_md4hash(uchar * passwd, uchar * p16) + +void E_md4hash(uchar *passwd, uchar *p16) { - int len; - int16 wpwd[129]; + int len; + int16 wpwd[129]; + + /* Password cannot be longer than 128 characters */ + len = strlen((char *)passwd); + if(len > 128) + len = 128; + /* Password must be converted to NT unicode */ + _my_mbstowcs(wpwd, passwd, len); + wpwd[len] = 0; /* Ensure string is null terminated */ + /* Calculate length in bytes */ + len = _my_wcslen(wpwd) * sizeof(int16); - /* Password cannot be longer than 128 characters */ - len = strlen((char *) passwd); - if (len > 128) - len = 128; - /* Password must be converted to NT unicode */ - _my_mbstowcs(wpwd, passwd, len); - wpwd[len] = 0; /* Ensure string is null terminated */ - /* Calculate length in bytes */ - len = _my_wcslen(wpwd) * sizeof(int16); - - mdfour(p16, (unsigned char *) wpwd, len); + mdfour(p16, (unsigned char *)wpwd, len); } /* Does the NT MD4 hash then des encryption. */ - -void -SMBNTencrypt(uchar * passwd, uchar * c8, uchar * p24) + +void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24) { - uchar p21[21]; - - memset(p21, '\0', 21); - - E_md4hash(passwd, p21); - E_P24(p21, c8, p24); + uchar p21[21]; + + memset(p21,'\0',21); + + E_md4hash(passwd, p21); + E_P24(p21, c8, p24); } /* Does both the NT and LM owfs of a user's password */ -void -nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16) +void nt_lm_owf_gen(char *pwd, char *nt_p16, char *p16) { - char passwd[130]; - StrnCpy(passwd, pwd, sizeof(passwd) - 1); + char passwd[130]; + StrnCpy(passwd, pwd, sizeof(passwd)-1); - /* Calculate the MD4 hash (NT compatible) of the password */ - memset(nt_p16, '\0', 16); - E_md4hash((uchar *) passwd, (uchar *) nt_p16); + /* Calculate the MD4 hash (NT compatible) of the password */ + memset(nt_p16, '\0', 16); + E_md4hash((uchar *)passwd, (uchar *)nt_p16); - /* Mangle the passwords into Lanman format */ - passwd[14] = '\0'; - strupper(passwd); + /* Mangle the passwords into Lanman format */ + passwd[14] = '\0'; + strupper(passwd); - /* Calculate the SMB (lanman) hash functions of the password */ + /* Calculate the SMB (lanman) hash functions of the password */ - memset(p16, '\0', 16); - E_P16((uchar *) passwd, (uchar *) p16); + memset(p16, '\0', 16); + E_P16((uchar *) passwd, (uchar *)p16); - /* clear out local copy of user's password (just being paranoid). */ - bzero(passwd, sizeof(passwd)); + /* clear out local copy of user's password (just being paranoid). */ + bzero(passwd, sizeof(passwd)); } /**************************************************************************** line strncpy but always null terminates. Make sure there is room! ****************************************************************************/ -char * -StrnCpy(char *dest, char *src, int n) +char *StrnCpy(char *dest,char *src,int n) { - char *d = dest; - if (!dest) - return (NULL); - if (!src) { - *dest = 0; - return (dest); + char *d = dest; + if (!dest) return(NULL); + if (!src) { + *dest = 0; + return(dest); + } + while (n-- && (*d++ = *src++)) ; + *d = 0; + return(dest); +} + +void strupper(char *s) +{ + while (*s) + { + /* +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + + if (is_shift_jis (*s)) + { + if (is_sj_lower (s[0], s[1])) + s[1] = sj_toupper2 (s[1]); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (islower(*s)) + *s = toupper(*s); + s++; + } } - while (n-- && (*d++ = *src++)); - *d = 0; - return (dest); -} - -void -strupper(char *s) -{ - while (*s) { - /* - * #if !defined(KANJI_WIN95_COMPATIBILITY) - * if(lp_client_code_page() == KANJI_CODEPAGE) - * { - * - * if (is_shift_jis (*s)) - * { - * if (is_sj_lower (s[0], s[1])) - * s[1] = sj_toupper2 (s[1]); - * s += 2; - * } - * else if (is_kana (*s)) - * { - * s++; - * } - * else - * { - * if (islower(*s)) - * *s = toupper(*s); - * s++; - * } - * } - * else - * #endif *//* KANJI_WIN95_COMPATIBILITY */ - { - if (islower(*s)) - *s = toupper(*s); - s++; - } + else +#endif */ /* KANJI_WIN95_COMPATIBILITY */ + { + if (islower(*s)) + *s = toupper(*s); + s++; } -} + } +} Index: squid/auth_modules/MSNT/smblib-common.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smblib-common.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/smblib-common.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/smblib-common.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX SMBlib NetBIOS implementation + Version 1.0 SMBlib Common Defines @@ -72,7 +73,7 @@ /* Server errors ... */ -#define SMBV_error 0x01 /* Generic error */ +#define SMBV_error 0x01 /* Generic error */ #define SMBV_badpw 0x02 #define SMBV_badtype 0x03 #define SMBV_access 0x04 @@ -137,12 +138,12 @@ /* Define the protocol types ... */ -#define SMB_P_Unknown -1 /* Hmmm, is this smart? */ +#define SMB_P_Unknown -1 /* Hmmm, is this smart? */ #define SMB_P_Core 0 #define SMB_P_CorePlus 1 #define SMB_P_DOSLanMan1 2 #define SMB_P_LanMan1 3 -#define SMB_P_DOSLanMan2 4 +#define SMB_P_DOSLanMan2 4 #define SMB_P_LanMan2 5 #define SMB_P_DOSLanMan2_1 6 #define SMB_P_LanMan2_1 7 @@ -157,29 +158,27 @@ /* SMBlibE_ values >1 indicate local from SMBlib code errors? */ #define SMBlibE_Success 0 -#define SMBlibE_Remote 1 /* Remote error, get more info from con */ +#define SMBlibE_Remote 1 /* Remote error, get more info from con */ #define SMBlibE_BAD -1 -#define SMBlibE_LowerLayer 2 /* Lower layer error */ -#define SMBlibE_NotImpl 3 /* Function not yet implemented */ -#define SMBlibE_ProtLow 4 /* Protocol negotiated does not support req */ -#define SMBlibE_NoSpace 5 /* No space to allocate a structure */ -#define SMBlibE_BadParam 6 /* Bad parameters */ -#define SMBlibE_NegNoProt 7 /* None of our protocols was liked */ -#define SMBlibE_SendFailed 8 /* Sending an SMB failed */ -#define SMBlibE_RecvFailed 9 /* Receiving an SMB failed */ -#define SMBlibE_GuestOnly 10 /* Logged in as guest */ -#define SMBlibE_CallFailed 11 /* Call remote end failed */ -#define SMBlibE_ProtUnknown 12 /* Protocol unknown */ -#define SMBlibE_NoSuchMsg 13 /* Keep this up to date */ - -typedef struct -{ /* A structure for a Dirent */ - - unsigned char resume_key[21]; /* Don't touch this */ - unsigned char file_attributes; /* Attributes of file */ - unsigned int date_time; /* date and time of last mod */ - unsigned int size; - char filename[13]; /* The name of the file */ +#define SMBlibE_LowerLayer 2 /* Lower layer error */ +#define SMBlibE_NotImpl 3 /* Function not yet implemented */ +#define SMBlibE_ProtLow 4 /* Protocol negotiated does not support req */ +#define SMBlibE_NoSpace 5 /* No space to allocate a structure */ +#define SMBlibE_BadParam 6 /* Bad parameters */ +#define SMBlibE_NegNoProt 7 /* None of our protocols was liked */ +#define SMBlibE_SendFailed 8 /* Sending an SMB failed */ +#define SMBlibE_RecvFailed 9 /* Receiving an SMB failed */ +#define SMBlibE_GuestOnly 10 /* Logged in as guest */ +#define SMBlibE_CallFailed 11 /* Call remote end failed */ +#define SMBlibE_ProtUnknown 12 /* Protocol unknown */ +#define SMBlibE_NoSuchMsg 13 /* Keep this up to date */ + +typedef struct { /* A structure for a Dirent */ + + unsigned char resume_key[21]; /* Don't touch this */ + unsigned char file_attributes; /* Attributes of file */ + unsigned int date_time; /* date and time of last mod */ + unsigned int size; + char filename[13]; /* The name of the file */ -} -SMB_CP_dirent; +} SMB_CP_dirent; Index: squid/auth_modules/MSNT/smblib-priv.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smblib-priv.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/smblib-priv.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/smblib-priv.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX SMBlib NetBIOS implementation + Version 1.0 SMBlib private Defines @@ -28,106 +29,106 @@ #include typedef unsigned short uint16; -typedef unsigned int uint32; +typedef unsigned int uint32; -#include "byteorder.h" /* Hmmm ... hot good */ +#include "byteorder.h" /* Hmmm ... hot good */ #define max(a,b) (a < b ? b : a) -#define SMB_DEF_IDF 0x424D53FF /* "\377SMB" */ - +#define SMB_DEF_IDF 0x424D53FF /* "\377SMB" */ + /* Core protocol commands */ -#define SMBmkdir 0x00 /* create directory */ -#define SMBrmdir 0x01 /* delete directory */ -#define SMBopen 0x02 /* open file */ -#define SMBcreate 0x03 /* create file */ -#define SMBclose 0x04 /* close file */ -#define SMBflush 0x05 /* flush file */ -#define SMBunlink 0x06 /* delete file */ -#define SMBmv 0x07 /* rename file */ -#define SMBgetatr 0x08 /* get file attributes */ -#define SMBsetatr 0x09 /* set file attributes */ -#define SMBread 0x0A /* read from file */ -#define SMBwrite 0x0B /* write to file */ -#define SMBlock 0x0C /* lock byte range */ -#define SMBunlock 0x0D /* unlock byte range */ -#define SMBctemp 0x0E /* create temporary file */ -#define SMBmknew 0x0F /* make new file */ -#define SMBchkpth 0x10 /* check directory path */ -#define SMBexit 0x11 /* process exit */ -#define SMBlseek 0x12 /* seek */ -#define SMBtcon 0x70 /* tree connect */ -#define SMBtdis 0x71 /* tree disconnect */ -#define SMBnegprot 0x72 /* negotiate protocol */ -#define SMBdskattr 0x80 /* get disk attributes */ -#define SMBsearch 0x81 /* search directory */ -#define SMBsplopen 0xC0 /* open print spool file */ -#define SMBsplwr 0xC1 /* write to print spool file */ -#define SMBsplclose 0xC2 /* close print spool file */ -#define SMBsplretq 0xC3 /* return print queue */ -#define SMBsends 0xD0 /* send single block message */ -#define SMBsendb 0xD1 /* send broadcast message */ -#define SMBfwdname 0xD2 /* forward user name */ -#define SMBcancelf 0xD3 /* cancel forward */ -#define SMBgetmac 0xD4 /* get machine name */ -#define SMBsendstrt 0xD5 /* send start of multi-block message */ -#define SMBsendend 0xD6 /* send end of multi-block message */ -#define SMBsendtxt 0xD7 /* send text of multi-block message */ +#define SMBmkdir 0x00 /* create directory */ +#define SMBrmdir 0x01 /* delete directory */ +#define SMBopen 0x02 /* open file */ +#define SMBcreate 0x03 /* create file */ +#define SMBclose 0x04 /* close file */ +#define SMBflush 0x05 /* flush file */ +#define SMBunlink 0x06 /* delete file */ +#define SMBmv 0x07 /* rename file */ +#define SMBgetatr 0x08 /* get file attributes */ +#define SMBsetatr 0x09 /* set file attributes */ +#define SMBread 0x0A /* read from file */ +#define SMBwrite 0x0B /* write to file */ +#define SMBlock 0x0C /* lock byte range */ +#define SMBunlock 0x0D /* unlock byte range */ +#define SMBctemp 0x0E /* create temporary file */ +#define SMBmknew 0x0F /* make new file */ +#define SMBchkpth 0x10 /* check directory path */ +#define SMBexit 0x11 /* process exit */ +#define SMBlseek 0x12 /* seek */ +#define SMBtcon 0x70 /* tree connect */ +#define SMBtdis 0x71 /* tree disconnect */ +#define SMBnegprot 0x72 /* negotiate protocol */ +#define SMBdskattr 0x80 /* get disk attributes */ +#define SMBsearch 0x81 /* search directory */ +#define SMBsplopen 0xC0 /* open print spool file */ +#define SMBsplwr 0xC1 /* write to print spool file */ +#define SMBsplclose 0xC2 /* close print spool file */ +#define SMBsplretq 0xC3 /* return print queue */ +#define SMBsends 0xD0 /* send single block message */ +#define SMBsendb 0xD1 /* send broadcast message */ +#define SMBfwdname 0xD2 /* forward user name */ +#define SMBcancelf 0xD3 /* cancel forward */ +#define SMBgetmac 0xD4 /* get machine name */ +#define SMBsendstrt 0xD5 /* send start of multi-block message */ +#define SMBsendend 0xD6 /* send end of multi-block message */ +#define SMBsendtxt 0xD7 /* send text of multi-block message */ /* CorePlus protocol */ -#define SMBlockread 0x13 /* Lock a range and read it */ -#define SMBwriteunlock 0x14 /* Unlock a range and then write */ -#define SMBreadbraw 0x1a /* read a block of data without smb header ohead */ -#define SMBwritebraw 0x1d /* write a block of data without smb header ohead */ -#define SMBwritec 0x20 /* secondary write request */ -#define SMBwriteclose 0x2c /* write a file and then close it */ +#define SMBlockread 0x13 /* Lock a range and read it */ +#define SMBwriteunlock 0x14 /* Unlock a range and then write */ +#define SMBreadbraw 0x1a /* read a block of data without smb header ohead*/ +#define SMBwritebraw 0x1d /* write a block of data without smb header ohead*/ +#define SMBwritec 0x20 /* secondary write request */ +#define SMBwriteclose 0x2c /* write a file and then close it */ /* DOS Extended Protocol */ -#define SMBreadBraw 0x1A /* read block raw */ -#define SMBreadBmpx 0x1B /* read block multiplexed */ -#define SMBreadBs 0x1C /* read block (secondary response) */ -#define SMBwriteBraw 0x1D /* write block raw */ -#define SMBwriteBmpx 0x1E /* write block multiplexed */ -#define SMBwriteBs 0x1F /* write block (secondary request) */ -#define SMBwriteC 0x20 /* write complete response */ -#define SMBsetattrE 0x22 /* set file attributes expanded */ -#define SMBgetattrE 0x23 /* get file attributes expanded */ -#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */ -#define SMBtrans 0x25 /* transaction - name, bytes in/out */ -#define SMBtranss 0x26 /* transaction (secondary request/response) */ -#define SMBioctl 0x27 /* IOCTL */ -#define SMBioctls 0x28 /* IOCTL (secondary request/response) */ -#define SMBcopy 0x29 /* copy */ -#define SMBmove 0x2A /* move */ -#define SMBecho 0x2B /* echo */ -#define SMBopenX 0x2D /* open and X */ -#define SMBreadX 0x2E /* read and X */ -#define SMBwriteX 0x2F /* write and X */ -#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */ -#define SMBtconX 0x75 /* tree connect and X */ -#define SMBffirst 0x82 /* find first */ -#define SMBfunique 0x83 /* find unique */ -#define SMBfclose 0x84 /* find close */ -#define SMBinvalid 0xFE /* invalid command */ +#define SMBreadBraw 0x1A /* read block raw */ +#define SMBreadBmpx 0x1B /* read block multiplexed */ +#define SMBreadBs 0x1C /* read block (secondary response) */ +#define SMBwriteBraw 0x1D /* write block raw */ +#define SMBwriteBmpx 0x1E /* write block multiplexed */ +#define SMBwriteBs 0x1F /* write block (secondary request) */ +#define SMBwriteC 0x20 /* write complete response */ +#define SMBsetattrE 0x22 /* set file attributes expanded */ +#define SMBgetattrE 0x23 /* get file attributes expanded */ +#define SMBlockingX 0x24 /* lock/unlock byte ranges and X */ +#define SMBtrans 0x25 /* transaction - name, bytes in/out */ +#define SMBtranss 0x26 /* transaction (secondary request/response) */ +#define SMBioctl 0x27 /* IOCTL */ +#define SMBioctls 0x28 /* IOCTL (secondary request/response) */ +#define SMBcopy 0x29 /* copy */ +#define SMBmove 0x2A /* move */ +#define SMBecho 0x2B /* echo */ +#define SMBopenX 0x2D /* open and X */ +#define SMBreadX 0x2E /* read and X */ +#define SMBwriteX 0x2F /* write and X */ +#define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */ +#define SMBtconX 0x75 /* tree connect and X */ +#define SMBffirst 0x82 /* find first */ +#define SMBfunique 0x83 /* find unique */ +#define SMBfclose 0x84 /* find close */ +#define SMBinvalid 0xFE /* invalid command */ /* Any more ? */ -#define SMBdatablockID 0x01 /* A data block identifier */ -#define SMBdialectID 0x02 /* A dialect id */ -#define SMBpathnameID 0x03 /* A pathname ID */ -#define SMBasciiID 0x04 /* An ascii string ID */ -#define SMBvariableblockID 0x05 /* A variable block ID */ +#define SMBdatablockID 0x01 /* A data block identifier */ +#define SMBdialectID 0x02 /* A dialect id */ +#define SMBpathnameID 0x03 /* A pathname ID */ +#define SMBasciiID 0x04 /* An ascii string ID */ +#define SMBvariableblockID 0x05 /* A variable block ID */ /* some other defines we need */ /* Flags defines ... */ -#define SMB_FLG2_NON_DOS 0x01 /* We know non dos names */ -#define SMB_FLG2_EXT_ATR 0x02 /* We know about Extended Attributes */ -#define SMB_FLG2_LNG_NAM 0x04 /* Long names ? */ +#define SMB_FLG2_NON_DOS 0x01 /* We know non dos names */ +#define SMB_FLG2_EXT_ATR 0x02 /* We know about Extended Attributes */ +#define SMB_FLG2_LNG_NAM 0x04 /* Long names ? */ typedef unsigned short WORD; typedef unsigned short UWORD; @@ -161,17 +162,17 @@ /* the data that follows in the SMB packet, so the code will have to */ /* take that into account. */ -#define SMB_hdr_idf_offset 0 /* 0xFF,'SMB' 0-3 */ -#define SMB_hdr_com_offset 4 /* BYTE 4 */ -#define SMB_hdr_rcls_offset 5 /* BYTE 5 */ -#define SMB_hdr_reh_offset 6 /* BYTE 6 */ -#define SMB_hdr_err_offset 7 /* WORD 7 */ -#define SMB_hdr_reb_offset 9 /* BYTE 9 */ -#define SMB_hdr_flg_offset 9 /* same as reb ... */ -#define SMB_hdr_res_offset 10 /* 7 WORDs 10 */ -#define SMB_hdr_res0_offset 10 /* WORD 10 */ -#define SMB_hdr_flg2_offset 10 /* WORD */ -#define SMB_hdr_res1_offset 12 /* WORD 12 */ +#define SMB_hdr_idf_offset 0 /* 0xFF,'SMB' 0-3 */ +#define SMB_hdr_com_offset 4 /* BYTE 4 */ +#define SMB_hdr_rcls_offset 5 /* BYTE 5 */ +#define SMB_hdr_reh_offset 6 /* BYTE 6 */ +#define SMB_hdr_err_offset 7 /* WORD 7 */ +#define SMB_hdr_reb_offset 9 /* BYTE 9 */ +#define SMB_hdr_flg_offset 9 /* same as reb ...*/ +#define SMB_hdr_res_offset 10 /* 7 WORDs 10 */ +#define SMB_hdr_res0_offset 10 /* WORD 10 */ +#define SMB_hdr_flg2_offset 10 /* WORD */ +#define SMB_hdr_res1_offset 12 /* WORD 12 */ #define SMB_hdr_res2_offset 14 #define SMB_hdr_res3_offset 16 #define SMB_hdr_res4_offset 18 @@ -183,275 +184,275 @@ #define SMB_hdr_mid_offset 30 #define SMB_hdr_wct_offset 32 -#define SMB_hdr_len 33 /* 33 byte header? */ +#define SMB_hdr_len 33 /* 33 byte header? */ -#define SMB_hdr_axc_offset 33 /* AndX Command */ -#define SMB_hdr_axr_offset 34 /* AndX Reserved */ -#define SMB_hdr_axo_offset 35 /* Offset from start to WCT of AndX cmd */ +#define SMB_hdr_axc_offset 33 /* AndX Command */ +#define SMB_hdr_axr_offset 34 /* AndX Reserved */ +#define SMB_hdr_axo_offset 35 /* Offset from start to WCT of AndX cmd */ /* Format of the Negotiate Protocol SMB */ #define SMB_negp_bcc_offset 33 -#define SMB_negp_buf_offset 35 /* Where the buffer starts */ -#define SMB_negp_len 35 /* plus the data */ +#define SMB_negp_buf_offset 35 /* Where the buffer starts */ +#define SMB_negp_len 35 /* plus the data */ /* Format of the Negotiate Response SMB, for CoreProtocol, LM1.2 and */ /* NT LM 0.12. wct will be 1 for CoreProtocol, 13 for LM 1.2, and 17 */ /* for NT LM 0.12 */ -#define SMB_negrCP_idx_offset 33 /* Response to the neg req */ +#define SMB_negrCP_idx_offset 33 /* Response to the neg req */ #define SMB_negrCP_bcc_offset 35 -#define SMB_negrLM_idx_offset 33 /* dialect index */ -#define SMB_negrLM_sec_offset 35 /* Security mode */ -#define SMB_sec_user_mask 0x01 /* 0 = share, 1 = user */ -#define SMB_sec_encrypt_mask 0x02 /* pick out encrypt */ -#define SMB_negrLM_mbs_offset 37 /* max buffer size */ -#define SMB_negrLM_mmc_offset 39 /* max mpx count */ -#define SMB_negrLM_mnv_offset 41 /* max number of VCs */ -#define SMB_negrLM_rm_offset 43 /* raw mode support bit vec */ +#define SMB_negrLM_idx_offset 33 /* dialect index */ +#define SMB_negrLM_sec_offset 35 /* Security mode */ +#define SMB_sec_user_mask 0x01 /* 0 = share, 1 = user */ +#define SMB_sec_encrypt_mask 0x02 /* pick out encrypt */ +#define SMB_negrLM_mbs_offset 37 /* max buffer size */ +#define SMB_negrLM_mmc_offset 39 /* max mpx count */ +#define SMB_negrLM_mnv_offset 41 /* max number of VCs */ +#define SMB_negrLM_rm_offset 43 /* raw mode support bit vec*/ #define SMB_read_raw_mask 0x01 #define SMB_write_raw_mask 0x02 -#define SMB_negrLM_sk_offset 45 /* session key, 32 bits */ -#define SMB_negrLM_st_offset 49 /* Current server time */ -#define SMB_negrLM_sd_offset 51 /* Current server date */ -#define SMB_negrLM_stz_offset 53 /* Server Time Zone */ -#define SMB_negrLM_ekl_offset 55 /* encryption key length */ -#define SMB_negrLM_res_offset 57 /* reserved */ -#define SMB_negrLM_bcc_offset 59 /* bcc */ -#define SMB_negrLM_len 61 /* 61 bytes ? */ -#define SMB_negrLM_buf_offset 61 /* Where the fun begins */ - -#define SMB_negrNTLM_idx_offset 33 /* Selected protocol */ -#define SMB_negrNTLM_sec_offset 35 /* Security more */ -#define SMB_negrNTLM_mmc_offset 36 /* Different format above */ -#define SMB_negrNTLM_mnv_offset 38 /* Max VCs */ -#define SMB_negrNTLM_mbs_offset 40 /* MBS now a long */ -#define SMB_negrNTLM_mrs_offset 44 /* Max raw size */ -#define SMB_negrNTLM_sk_offset 48 /* Session Key */ -#define SMB_negrNTLM_cap_offset 52 /* Capabilities */ -#define SMB_negrNTLM_stl_offset 56 /* Server time low */ -#define SMB_negrNTLM_sth_offset 60 /* Server time high */ -#define SMB_negrNTLM_stz_offset 64 /* Server time zone */ -#define SMB_negrNTLM_ekl_offset 66 /* Encrypt key len */ -#define SMB_negrNTLM_bcc_offset 67 /* Bcc */ +#define SMB_negrLM_sk_offset 45 /* session key, 32 bits */ +#define SMB_negrLM_st_offset 49 /* Current server time */ +#define SMB_negrLM_sd_offset 51 /* Current server date */ +#define SMB_negrLM_stz_offset 53 /* Server Time Zone */ +#define SMB_negrLM_ekl_offset 55 /* encryption key length */ +#define SMB_negrLM_res_offset 57 /* reserved */ +#define SMB_negrLM_bcc_offset 59 /* bcc */ +#define SMB_negrLM_len 61 /* 61 bytes ? */ +#define SMB_negrLM_buf_offset 61 /* Where the fun begins */ + +#define SMB_negrNTLM_idx_offset 33 /* Selected protocol */ +#define SMB_negrNTLM_sec_offset 35 /* Security more */ +#define SMB_negrNTLM_mmc_offset 36 /* Different format above */ +#define SMB_negrNTLM_mnv_offset 38 /* Max VCs */ +#define SMB_negrNTLM_mbs_offset 40 /* MBS now a long */ +#define SMB_negrNTLM_mrs_offset 44 /* Max raw size */ +#define SMB_negrNTLM_sk_offset 48 /* Session Key */ +#define SMB_negrNTLM_cap_offset 52 /* Capabilities */ +#define SMB_negrNTLM_stl_offset 56 /* Server time low */ +#define SMB_negrNTLM_sth_offset 60 /* Server time high */ +#define SMB_negrNTLM_stz_offset 64 /* Server time zone */ +#define SMB_negrNTLM_ekl_offset 66 /* Encrypt key len */ +#define SMB_negrNTLM_bcc_offset 67 /* Bcc */ #define SMB_negrNTLM_len 69 #define SMB_negrNTLM_buf_offset 69 /* Offsets related to Tree Connect */ #define SMB_tcon_bcc_offset 33 -#define SMB_tcon_buf_offset 35 /* where the data is for tcon */ -#define SMB_tcon_len 35 /* plus the data */ +#define SMB_tcon_buf_offset 35 /* where the data is for tcon */ +#define SMB_tcon_len 35 /* plus the data */ -#define SMB_tconr_mbs_offset 33 /* max buffer size */ -#define SMB_tconr_tid_offset 35 /* returned tree id */ -#define SMB_tconr_bcc_offset 37 -#define SMB_tconr_len 39 - -#define SMB_tconx_axc_offset 33 /* And X Command */ -#define SMB_tconx_axr_offset 34 /* reserved */ -#define SMB_tconx_axo_offset 35 /* Next command offset */ -#define SMB_tconx_flg_offset 37 /* Flags, bit0=1 means disc TID */ -#define SMB_tconx_pwl_offset 39 /* Password length */ -#define SMB_tconx_bcc_offset 41 /* bcc */ -#define SMB_tconx_buf_offset 43 /* buffer */ -#define SMB_tconx_len 43 /* up to data ... */ - -#define SMB_tconxr_axc_offset 33 /* Where the AndX Command is */ -#define SMB_tconxr_axr_offset 34 /* Reserved */ -#define SMB_tconxr_axo_offset 35 /* AndX offset location */ +#define SMB_tconr_mbs_offset 33 /* max buffer size */ +#define SMB_tconr_tid_offset 35 /* returned tree id */ +#define SMB_tconr_bcc_offset 37 +#define SMB_tconr_len 39 + +#define SMB_tconx_axc_offset 33 /* And X Command */ +#define SMB_tconx_axr_offset 34 /* reserved */ +#define SMB_tconx_axo_offset 35 /* Next command offset */ +#define SMB_tconx_flg_offset 37 /* Flags, bit0=1 means disc TID */ +#define SMB_tconx_pwl_offset 39 /* Password length */ +#define SMB_tconx_bcc_offset 41 /* bcc */ +#define SMB_tconx_buf_offset 43 /* buffer */ +#define SMB_tconx_len 43 /* up to data ... */ + +#define SMB_tconxr_axc_offset 33 /* Where the AndX Command is */ +#define SMB_tconxr_axr_offset 34 /* Reserved */ +#define SMB_tconxr_axo_offset 35 /* AndX offset location */ /* Offsets related to tree_disconnect */ -#define SMB_tdis_bcc_offset 33 /* bcc */ -#define SMB_tdis_len 35 /* total len */ +#define SMB_tdis_bcc_offset 33 /* bcc */ +#define SMB_tdis_len 35 /* total len */ -#define SMB_tdisr_bcc_offset 33 /* bcc */ +#define SMB_tdisr_bcc_offset 33 /* bcc */ #define SMB_tdisr_len 35 /* Offsets related to Open Request */ -#define SMB_open_mod_offset 33 /* Mode to open with */ -#define SMB_open_atr_offset 35 /* Attributes of file */ -#define SMB_open_bcc_offset 37 /* bcc */ -#define SMB_open_buf_offset 39 /* File name */ -#define SMB_open_len 39 /* Plus the file name */ - -#define SMB_openx_axc_offset 33 /* Next command */ -#define SMB_openx_axr_offset 34 /* Reserved */ -#define SMB_openx_axo_offset 35 /* offset of next wct */ -#define SMB_openx_flg_offset 37 /* Flags, bit0 = need more info */ - /* bit1 = exclusive oplock */ - /* bit2 = batch oplock */ -#define SMB_openx_mod_offset 39 /* mode to open with */ -#define SMB_openx_atr_offset 41 /* search attributes */ -#define SMB_openx_fat_offset 43 /* File attributes */ -#define SMB_openx_tim_offset 45 /* time and date of creat */ -#define SMB_openx_ofn_offset 49 /* Open function */ -#define SMB_openx_als_offset 51 /* Space to allocate on */ -#define SMB_openx_res_offset 55 /* reserved */ -#define SMB_openx_bcc_offset 63 /* bcc */ -#define SMB_openx_buf_offset 65 /* Where file name goes */ +#define SMB_open_mod_offset 33 /* Mode to open with */ +#define SMB_open_atr_offset 35 /* Attributes of file */ +#define SMB_open_bcc_offset 37 /* bcc */ +#define SMB_open_buf_offset 39 /* File name */ +#define SMB_open_len 39 /* Plus the file name */ + +#define SMB_openx_axc_offset 33 /* Next command */ +#define SMB_openx_axr_offset 34 /* Reserved */ +#define SMB_openx_axo_offset 35 /* offset of next wct */ +#define SMB_openx_flg_offset 37 /* Flags, bit0 = need more info */ + /* bit1 = exclusive oplock */ + /* bit2 = batch oplock */ +#define SMB_openx_mod_offset 39 /* mode to open with */ +#define SMB_openx_atr_offset 41 /* search attributes */ +#define SMB_openx_fat_offset 43 /* File attributes */ +#define SMB_openx_tim_offset 45 /* time and date of creat */ +#define SMB_openx_ofn_offset 49 /* Open function */ +#define SMB_openx_als_offset 51 /* Space to allocate on */ +#define SMB_openx_res_offset 55 /* reserved */ +#define SMB_openx_bcc_offset 63 /* bcc */ +#define SMB_openx_buf_offset 65 /* Where file name goes */ #define SMB_openx_len 65 -#define SMB_openr_fid_offset 33 /* FID returned */ -#define SMB_openr_atr_offset 35 /* Attributes opened with */ -#define SMB_openr_tim_offset 37 /* Last mod time of file */ -#define SMB_openr_fsz_offset 41 /* File size 4 bytes */ -#define SMB_openr_acc_offset 45 /* Access allowed */ +#define SMB_openr_fid_offset 33 /* FID returned */ +#define SMB_openr_atr_offset 35 /* Attributes opened with */ +#define SMB_openr_tim_offset 37 /* Last mod time of file */ +#define SMB_openr_fsz_offset 41 /* File size 4 bytes */ +#define SMB_openr_acc_offset 45 /* Access allowed */ #define SMB_openr_bcc_offset 47 #define SMB_openr_len 49 -#define SMB_openxr_axc_offset 33 /* And X command */ -#define SMB_openxr_axr_offset 34 /* reserved */ -#define SMB_openxr_axo_offset 35 /* offset to next command */ -#define SMB_openxr_fid_offset 37 /* FID returned */ -#define SMB_openxr_fat_offset 39 /* File attributes returned */ -#define SMB_openxr_tim_offset 41 /* File creation date etc */ -#define SMB_openxr_fsz_offset 45 /* Size of file */ -#define SMB_openxr_acc_offset 49 /* Access granted */ - -#define SMB_clos_fid_offset 33 /* FID to close */ -#define SMB_clos_tim_offset 35 /* Last mod time */ -#define SMB_clos_bcc_offset 39 /* bcc */ +#define SMB_openxr_axc_offset 33 /* And X command */ +#define SMB_openxr_axr_offset 34 /* reserved */ +#define SMB_openxr_axo_offset 35 /* offset to next command */ +#define SMB_openxr_fid_offset 37 /* FID returned */ +#define SMB_openxr_fat_offset 39 /* File attributes returned*/ +#define SMB_openxr_tim_offset 41 /* File creation date etc */ +#define SMB_openxr_fsz_offset 45 /* Size of file */ +#define SMB_openxr_acc_offset 49 /* Access granted */ + +#define SMB_clos_fid_offset 33 /* FID to close */ +#define SMB_clos_tim_offset 35 /* Last mod time */ +#define SMB_clos_bcc_offset 39 /* bcc */ #define SMB_clos_len 41 /* Offsets related to Write requests */ -#define SMB_write_fid_offset 33 /* FID to write */ -#define SMB_write_cnt_offset 35 /* bytes to write */ -#define SMB_write_ofs_offset 37 /* location to write to */ -#define SMB_write_clf_offset 41 /* advisory count left */ -#define SMB_write_bcc_offset 43 /* bcc = data bytes + 3 */ -#define SMB_write_buf_offset 45 /* Data=0x01, len, data */ -#define SMB_write_len 45 /* plus the data ... */ +#define SMB_write_fid_offset 33 /* FID to write */ +#define SMB_write_cnt_offset 35 /* bytes to write */ +#define SMB_write_ofs_offset 37 /* location to write to */ +#define SMB_write_clf_offset 41 /* advisory count left */ +#define SMB_write_bcc_offset 43 /* bcc = data bytes + 3 */ +#define SMB_write_buf_offset 45 /* Data=0x01, len, data */ +#define SMB_write_len 45 /* plus the data ... */ -#define SMB_writr_cnt_offset 33 /* Count of bytes written */ -#define SMB_writr_bcc_offset 35 /* bcc */ +#define SMB_writr_cnt_offset 33 /* Count of bytes written */ +#define SMB_writr_bcc_offset 35 /* bcc */ #define SMB_writr_len 37 /* Offsets related to read requests */ -#define SMB_read_fid_offset 33 /* FID of file to read */ -#define SMB_read_cnt_offset 35 /* count of words to read */ -#define SMB_read_ofs_offset 37 /* Where to read from */ -#define SMB_read_clf_offset 41 /* Advisory count to go */ +#define SMB_read_fid_offset 33 /* FID of file to read */ +#define SMB_read_cnt_offset 35 /* count of words to read */ +#define SMB_read_ofs_offset 37 /* Where to read from */ +#define SMB_read_clf_offset 41 /* Advisory count to go */ #define SMB_read_bcc_offset 43 #define SMB_read_len 45 -#define SMB_readr_cnt_offset 33 /* Count of bytes returned */ -#define SMB_readr_res_offset 35 /* 4 shorts reserved, 8 bytes */ -#define SMB_readr_bcc_offset 43 /* bcc */ -#define SMB_readr_bff_offset 45 /* buffer format char = 0x01 */ -#define SMB_readr_len_offset 46 /* buffer len */ -#define SMB_readr_len 45 /* length of the readr before data */ +#define SMB_readr_cnt_offset 33 /* Count of bytes returned */ +#define SMB_readr_res_offset 35 /* 4 shorts reserved, 8 bytes */ +#define SMB_readr_bcc_offset 43 /* bcc */ +#define SMB_readr_bff_offset 45 /* buffer format char = 0x01 */ +#define SMB_readr_len_offset 46 /* buffer len */ +#define SMB_readr_len 45 /* length of the readr before data */ /* Offsets for Create file */ -#define SMB_creat_atr_offset 33 /* Attributes of new file ... */ -#define SMB_creat_tim_offset 35 /* Time of creation */ -#define SMB_creat_dat_offset 37 /* 4004BCE :-) */ -#define SMB_creat_bcc_offset 39 /* bcc */ +#define SMB_creat_atr_offset 33 /* Attributes of new file ... */ +#define SMB_creat_tim_offset 35 /* Time of creation */ +#define SMB_creat_dat_offset 37 /* 4004BCE :-) */ +#define SMB_creat_bcc_offset 39 /* bcc */ #define SMB_creat_buf_offset 41 -#define SMB_creat_len 41 /* Before the data */ +#define SMB_creat_len 41 /* Before the data */ -#define SMB_creatr_fid_offset 33 /* FID of created file */ +#define SMB_creatr_fid_offset 33 /* FID of created file */ /* Offsets for Delete file */ -#define SMB_delet_sat_offset 33 /* search attribites */ -#define SMB_delet_bcc_offset 35 /* bcc */ +#define SMB_delet_sat_offset 33 /* search attribites */ +#define SMB_delet_bcc_offset 35 /* bcc */ #define SMB_delet_buf_offset 37 #define SMB_delet_len 37 /* Offsets for SESSION_SETUP_ANDX for both LM and NT LM protocols */ -#define SMB_ssetpLM_mbs_offset 37 /* Max buffer Size, allow for AndX */ -#define SMB_ssetpLM_mmc_offset 39 /* max multiplex count */ -#define SMB_ssetpLM_vcn_offset 41 /* VC number if new VC */ -#define SMB_ssetpLM_snk_offset 43 /* Session Key */ -#define SMB_ssetpLM_pwl_offset 47 /* password length */ -#define SMB_ssetpLM_res_offset 49 /* reserved */ -#define SMB_ssetpLM_bcc_offset 53 /* bcc */ -#define SMB_ssetpLM_len 55 /* before data ... */ +#define SMB_ssetpLM_mbs_offset 37 /* Max buffer Size, allow for AndX */ +#define SMB_ssetpLM_mmc_offset 39 /* max multiplex count */ +#define SMB_ssetpLM_vcn_offset 41 /* VC number if new VC */ +#define SMB_ssetpLM_snk_offset 43 /* Session Key */ +#define SMB_ssetpLM_pwl_offset 47 /* password length */ +#define SMB_ssetpLM_res_offset 49 /* reserved */ +#define SMB_ssetpLM_bcc_offset 53 /* bcc */ +#define SMB_ssetpLM_len 55 /* before data ... */ #define SMB_ssetpLM_buf_offset 55 -#define SMB_ssetpNTLM_mbs_offset 37 /* Max Buffer Size for NT LM 0.12 */ - /* and above */ -#define SMB_ssetpNTLM_mmc_offset 39 /* Max Multiplex count */ -#define SMB_ssetpNTLM_vcn_offset 41 /* VC Number */ -#define SMB_ssetpNTLM_snk_offset 43 /* Session key */ -#define SMB_ssetpNTLM_cipl_offset 47 /* Case Insensitive PW Len */ -#define SMB_ssetpNTLM_cspl_offset 49 /* Unicode pw len */ -#define SMB_ssetpNTLM_res_offset 51 /* reserved */ -#define SMB_ssetpNTLM_cap_offset 55 /* server capabilities */ -#define SMB_ssetpNTLM_bcc_offset 59 /* bcc */ -#define SMB_ssetpNTLM_len 61 /* before data */ +#define SMB_ssetpNTLM_mbs_offset 37 /* Max Buffer Size for NT LM 0.12 */ + /* and above */ +#define SMB_ssetpNTLM_mmc_offset 39 /* Max Multiplex count */ +#define SMB_ssetpNTLM_vcn_offset 41 /* VC Number */ +#define SMB_ssetpNTLM_snk_offset 43 /* Session key */ +#define SMB_ssetpNTLM_cipl_offset 47 /* Case Insensitive PW Len */ +#define SMB_ssetpNTLM_cspl_offset 49 /* Unicode pw len */ +#define SMB_ssetpNTLM_res_offset 51 /* reserved */ +#define SMB_ssetpNTLM_cap_offset 55 /* server capabilities */ +#define SMB_ssetpNTLM_bcc_offset 59 /* bcc */ +#define SMB_ssetpNTLM_len 61 /* before data */ #define SMB_ssetpNTLM_buf_offset 61 -#define SMB_ssetpr_axo_offset 35 /* Offset of next response ... */ -#define SMB_ssetpr_act_offset 37 /* action, bit 0 = 1 => guest */ -#define SMB_ssetpr_bcc_offset 39 /* bcc */ -#define SMB_ssetpr_buf_offset 41 /* Native OS etc */ +#define SMB_ssetpr_axo_offset 35 /* Offset of next response ... */ +#define SMB_ssetpr_act_offset 37 /* action, bit 0 = 1 => guest */ +#define SMB_ssetpr_bcc_offset 39 /* bcc */ +#define SMB_ssetpr_buf_offset 41 /* Native OS etc */ /* Offsets for SMB create directory */ -#define SMB_creatdir_bcc_offset 33 /* only a bcc here */ -#define SMB_creatdir_buf_offset 35 /* Where things start */ +#define SMB_creatdir_bcc_offset 33 /* only a bcc here */ +#define SMB_creatdir_buf_offset 35 /* Where things start */ #define SMB_creatdir_len 35 /* Offsets for SMB delete directory */ -#define SMB_deletdir_bcc_offset 33 /* only a bcc here */ -#define SMB_deletdir_buf_offset 35 /* where things start */ +#define SMB_deletdir_bcc_offset 33 /* only a bcc here */ +#define SMB_deletdir_buf_offset 35 /* where things start */ #define SMB_deletdir_len 35 /* Offsets for SMB check directory */ -#define SMB_checkdir_bcc_offset 33 /* Only a bcc here */ -#define SMB_checkdir_buf_offset 35 /* where things start */ +#define SMB_checkdir_bcc_offset 33 /* Only a bcc here */ +#define SMB_checkdir_buf_offset 35 /* where things start */ #define SMB_checkdir_len 35 /* Offsets for SMB search */ -#define SMB_search_mdc_offset 33 /* Max Dir ents to return */ -#define SMB_search_atr_offset 35 /* Search attributes */ -#define SMB_search_bcc_offset 37 /* bcc */ -#define SMB_search_buf_offset 39 /* where the action is */ +#define SMB_search_mdc_offset 33 /* Max Dir ents to return */ +#define SMB_search_atr_offset 35 /* Search attributes */ +#define SMB_search_bcc_offset 37 /* bcc */ +#define SMB_search_buf_offset 39 /* where the action is */ #define SMB_search_len 39 -#define SMB_searchr_dec_offset 33 /* Dir ents returned */ -#define SMB_searchr_bcc_offset 35 /* bcc */ -#define SMB_searchr_buf_offset 37 /* Where the action starts */ -#define SMB_searchr_len 37 /* before the dir ents */ +#define SMB_searchr_dec_offset 33 /* Dir ents returned */ +#define SMB_searchr_bcc_offset 35 /* bcc */ +#define SMB_searchr_buf_offset 37 /* Where the action starts */ +#define SMB_searchr_len 37 /* before the dir ents */ -#define SMB_searchr_dirent_len 43 /* 53 bytes */ +#define SMB_searchr_dirent_len 43 /* 53 bytes */ /* Defines for SMB transact and transact2 calls */ -#define SMB_trans_tpc_offset 33 /* Total param count */ -#define SMB_trans_tdc_offset 35 /* total Data count */ -#define SMB_trans_mpc_offset 37 /* Max params bytes to return */ -#define SMB_trans_mdc_offset 39 /* Max data bytes to return */ -#define SMB_trans_msc_offset 41 /* Max setup words to return */ -#define SMB_trans_rs1_offset 42 /* Reserved byte */ -#define SMB_trans_flg_offset 43 /* flags */ -#define SMB_trans_tmo_offset 45 /* Timeout, long */ -#define SMB_trans_rs2_offset 49 /* Next reserved */ -#define SMB_trans_pbc_offset 51 /* Param Byte count in buf */ -#define SMB_trans_pbo_offset 53 /* Offset to param bytes */ -#define SMB_trans_dbc_offset 55 /* Data byte count in buf */ -#define SMB_trans_dbo_offset 57 /* Data byte offset */ -#define SMB_trans_suc_offset 59 /* Setup count - byte */ -#define SMB_trans_rs3_offset 60 /* Reserved to pad ... */ -#define SMB_trans_len 61 /* Up to setup, still need bcc */ +#define SMB_trans_tpc_offset 33 /* Total param count */ +#define SMB_trans_tdc_offset 35 /* total Data count */ +#define SMB_trans_mpc_offset 37 /* Max params bytes to return */ +#define SMB_trans_mdc_offset 39 /* Max data bytes to return */ +#define SMB_trans_msc_offset 41 /* Max setup words to return */ +#define SMB_trans_rs1_offset 42 /* Reserved byte */ +#define SMB_trans_flg_offset 43 /* flags */ +#define SMB_trans_tmo_offset 45 /* Timeout, long */ +#define SMB_trans_rs2_offset 49 /* Next reserved */ +#define SMB_trans_pbc_offset 51 /* Param Byte count in buf */ +#define SMB_trans_pbo_offset 53 /* Offset to param bytes */ +#define SMB_trans_dbc_offset 55 /* Data byte count in buf */ +#define SMB_trans_dbo_offset 57 /* Data byte offset */ +#define SMB_trans_suc_offset 59 /* Setup count - byte */ +#define SMB_trans_rs3_offset 60 /* Reserved to pad ... */ +#define SMB_trans_len 61 /* Up to setup, still need bcc */ -#define SMB_transr_tpc_offset 33 /* Total param bytes returned */ +#define SMB_transr_tpc_offset 33 /* Total param bytes returned */ #define SMB_transr_tdc_offset 35 #define SMB_transr_rs1_offset 37 #define SMB_transr_pbc_offset 39 #define SMB_transr_pbo_offset 41 -#define SMB_transr_pdi_offset 43 /* parameter displacement */ +#define SMB_transr_pdi_offset 43 /* parameter displacement */ #define SMB_transr_dbc_offset 45 #define SMB_transr_dbo_offset 47 #define SMB_transr_ddi_offset 49 @@ -476,118 +477,102 @@ #define SMB_LMapi_SetUserInfo 0x0072 #define SMB_LMapi_UserPasswordSet 0x0073 - + /* Structures and defines we use in the client interface */ /* The protocols we might support. Perhaps a bit ambitious, as only RFCNB */ /* has any support so far 0(sometimes called NBT) */ -typedef enum -{ SMB_RFCNB, SMB_IPXNB, SMB_NETBEUI, SMB_X25 } -SMB_Transport_Types; - -typedef enum -{ SMB_Con_FShare, SMB_Con_PShare, SMB_Con_IPC } -SMB_Con_Types; - -typedef enum -{ SMB_State_NoState, SMB_State_Stopped, SMB_State_Started } -SMB_State_Types; - -/* The following two arrays need to be in step! */ -/* We must make it possible for callers to specify these ... */ +typedef enum {SMB_RFCNB, SMB_IPXNB, SMB_NETBEUI, SMB_X25} SMB_Transport_Types; +typedef enum {SMB_Con_FShare, SMB_Con_PShare, SMB_Con_IPC} SMB_Con_Types; -static char *SMB_Prots[] = { "PC NETWORK PROGRAM 1.0", - "MICROSOFT NETWORKS 1.03", - "MICROSOFT NETWORKS 3.0", - "DOS LANMAN1.0", - "LANMAN1.0", - "DOS LM1.2X002", - "LM1.2X002", - "DOS LANMAN2.1", - "LANMAN2.1", - "Samba", - "NT LM 0.12", - "NT LANMAN 1.0", - NULL -}; +typedef enum {SMB_State_NoState, SMB_State_Stopped, SMB_State_Started} SMB_State_Types; -static int SMB_Types[] = { SMB_P_Core, - SMB_P_CorePlus, - SMB_P_DOSLanMan1, - SMB_P_DOSLanMan1, - SMB_P_LanMan1, - SMB_P_DOSLanMan2, - SMB_P_LanMan2, - SMB_P_LanMan2_1, - SMB_P_LanMan2_1, - SMB_P_NT1, - SMB_P_NT1, - SMB_P_NT1, - -1 -}; +/* The following two arrays need to be in step! */ +/* We must make it possible for callers to specify these ... */ -typedef struct SMB_Status -{ - union - { - struct - { - unsigned char ErrorClass; - unsigned char Reserved; - unsigned short Error; - } - DosError; - unsigned int NtStatus; - } - status; -} -SMB_Status; - -typedef struct SMB_Tree_Structure *SMB_Tree_Handle; - -typedef struct SMB_Connect_Def *SMB_Handle_Type; - -struct SMB_Connect_Def -{ - - SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */ - int protocol; /* What is the protocol */ - int prot_IDX; /* And what is the index */ - void *Trans_Connect; /* The connection */ - - /* All these strings should be malloc'd */ - - char service[80], username[80], password[80], desthost[80], - sock_options[80]; - char address[80], myname[80]; - - SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */ - - int gid; /* Group ID, do we need it? */ - int mid; /* Multiplex ID? We might need one per con */ - int pid; /* Process ID */ - - int uid; /* Authenticated user id. */ - - /* It is pretty clear that we need to bust some of */ - /* these out into a per TCon record, as there may */ - /* be multiple TCon's per server, etc ... later */ - - int port; /* port to use in case not default, this is a TCPism! */ - - int max_xmit; /* Max xmit permitted by server */ - int Security; /* 0 = share, 1 = user */ - int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */ - BOOL encrypt_passwords; /* FALSE = don't */ - int MaxMPX, MaxVC, MaxRaw; - unsigned int SessionKey, Capabilities; - int SvrTZ; /* Server Time Zone */ - int Encrypt_Key_Len; - char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40]; - char Svr_OS[80], Svr_LMType[80], Svr_PDom[80]; +static char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0", + "MICROSOFT NETWORKS 1.03", + "MICROSOFT NETWORKS 3.0", + "DOS LANMAN1.0", + "LANMAN1.0", + "DOS LM1.2X002", + "LM1.2X002", + "DOS LANMAN2.1", + "LANMAN2.1", + "Samba", + "NT LM 0.12", + "NT LANMAN 1.0", + NULL}; + +static int SMB_Types[] = {SMB_P_Core, + SMB_P_CorePlus, + SMB_P_DOSLanMan1, + SMB_P_DOSLanMan1, + SMB_P_LanMan1, + SMB_P_DOSLanMan2, + SMB_P_LanMan2, + SMB_P_LanMan2_1, + SMB_P_LanMan2_1, + SMB_P_NT1, + SMB_P_NT1, + SMB_P_NT1, + -1}; + +typedef struct SMB_Status { + + union { + struct { + unsigned char ErrorClass; + unsigned char Reserved; + unsigned short Error; + } DosError; + unsigned int NtStatus; + } status; +} SMB_Status; + +typedef struct SMB_Tree_Structure * SMB_Tree_Handle; + +typedef struct SMB_Connect_Def * SMB_Handle_Type; + +struct SMB_Connect_Def { + + SMB_Handle_Type Next_Con, Prev_Con; /* Next and previous conn */ + int protocol; /* What is the protocol */ + int prot_IDX; /* And what is the index */ + void *Trans_Connect; /* The connection */ + + /* All these strings should be malloc'd */ + + char service[80], username[80], password[80], desthost[80], sock_options[80]; + char address[80], myname[80]; + + SMB_Tree_Handle first_tree, last_tree; /* List of trees on this server */ + + int gid; /* Group ID, do we need it? */ + int mid; /* Multiplex ID? We might need one per con */ + int pid; /* Process ID */ + + int uid; /* Authenticated user id. */ + + /* It is pretty clear that we need to bust some of */ + /* these out into a per TCon record, as there may */ + /* be multiple TCon's per server, etc ... later */ + + int port; /* port to use in case not default, this is a TCPism! */ + + int max_xmit; /* Max xmit permitted by server */ + int Security; /* 0 = share, 1 = user */ + int Raw_Support; /* bit 0 = 1 = Read Raw supported, 1 = 1 Write raw */ + BOOL encrypt_passwords; /* FALSE = don't */ + int MaxMPX, MaxVC, MaxRaw; + unsigned int SessionKey, Capabilities; + int SvrTZ; /* Server Time Zone */ + int Encrypt_Key_Len; + char Encrypt_Key[80], Domain[80], PDomain[80], OSName[80], LMType[40]; + char Svr_OS[80], Svr_LMType[80], Svr_PDom[80]; }; @@ -601,30 +586,28 @@ /* A Tree_Structure */ -struct SMB_Tree_Structure -{ +struct SMB_Tree_Structure { - SMB_Tree_Handle next, prev; - SMB_Handle_Type con; - char path[129]; - char device_type[20]; - int mbs; /* Local MBS */ - int tid; + SMB_Tree_Handle next, prev; + SMB_Handle_Type con; + char path[129]; + char device_type[20]; + int mbs; /* Local MBS */ + int tid; }; typedef struct SMB_File_Def SMB_File; -struct SMB_File_Def -{ +struct SMB_File_Def { - SMB_Tree_Handle tree; - char filename[256]; /* We should malloc this ... */ - UWORD fid; - unsigned int lastmod; - unsigned int size; /* Could blow up if 64bit files supported */ - UWORD access; - off_t fileloc; + SMB_Tree_Handle tree; + char filename[256]; /* We should malloc this ... */ + UWORD fid; + unsigned int lastmod; + unsigned int size; /* Could blow up if 64bit files supported */ + UWORD access; + off_t fileloc; }; @@ -634,8 +617,8 @@ #ifndef SMBLIB_ERRNO extern int SMBlib_errno; -extern int SMBlib_SMB_Error; /* last Error */ +extern int SMBlib_SMB_Error; /* last Error */ #endif SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type con, SMB_Tree_Handle tree, - char *path, char *password, char *dev); + char *path, char *password, char *dev); Index: squid/auth_modules/MSNT/smblib-util.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smblib-util.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/smblib-util.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/smblib-util.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX SMBlib NetBIOS implementation + Version 1.0 SMBlib Utility Routines @@ -28,45 +29,44 @@ /* Print out an SMB pkt in all its gory detail ... */ -void -SMB_Print_Pkt(FILE fd, RFCNB_Pkt * pkt, BOOL command, int Offset, int Len) +void SMB_Print_Pkt(FILE fd, RFCNB_Pkt *pkt, BOOL command, int Offset, int Len) + { - /* Well, just how do we do this ... print it I suppose */ + /* Well, just how do we do this ... print it I suppose */ - /* Print out the SMB header ... */ + /* Print out the SMB header ... */ - /* Print the command */ + /* Print the command */ - /* Print the other bits in the header */ + /* Print the other bits in the header */ - /* etc */ + /* etc */ } /* Convert a DOS Date_Time to a local host type date time for printing */ -char * -SMB_DOSTimToStr(int DOS_time) -{ - static char SMB_Time_Temp[48]; - int DOS_sec, DOS_min, DOS_hour, DOS_day, DOS_month, DOS_year; +char *SMB_DOSTimToStr(int DOS_time) - SMB_Time_Temp[0] = 0; +{ static char SMB_Time_Temp[48]; + int DOS_sec, DOS_min, DOS_hour, DOS_day, DOS_month, DOS_year; - DOS_sec = (DOS_time & 0x001F) * 2; - DOS_min = (DOS_time & 0x07E0) >> 5; - DOS_hour = ((DOS_time & 0xF800) >> 11); + SMB_Time_Temp[0] = 0; - DOS_day = (DOS_time & 0x001F0000) >> 16; - DOS_month = (DOS_time & 0x01E00000) >> 21; - DOS_year = ((DOS_time & 0xFE000000) >> 25) + 80; + DOS_sec = (DOS_time & 0x001F) * 2; + DOS_min = (DOS_time & 0x07E0) >> 5; + DOS_hour = ((DOS_time & 0xF800) >> 11); - sprintf(SMB_Time_Temp, "%2d/%02d/%2d %2d:%02d:%02d", DOS_day, DOS_month, - DOS_year, DOS_hour, DOS_min, DOS_sec); + DOS_day = (DOS_time & 0x001F0000) >> 16; + DOS_month = (DOS_time & 0x01E00000) >> 21; + DOS_year = ((DOS_time & 0xFE000000) >> 25) + 80; - return (SMB_Time_Temp); + sprintf(SMB_Time_Temp, "%2d/%02d/%2d %2d:%02d:%02d", DOS_day, DOS_month, + DOS_year, DOS_hour, DOS_min, DOS_sec); + + return(SMB_Time_Temp); } @@ -74,82 +74,85 @@ to a static string which we guarantee is long enough. If verbose is true, we print out long form of strings ... */ -char * -SMB_AtrToStr(int attribs, BOOL verbose) -{ - static char SMB_Attrib_Temp[128]; +char *SMB_AtrToStr(int attribs, BOOL verbose) - SMB_Attrib_Temp[0] = 0; +{ static char SMB_Attrib_Temp[128]; - if (attribs & SMB_FA_ROF) - strcat(SMB_Attrib_Temp, (verbose ? "Read Only " : "R")); + SMB_Attrib_Temp[0] = 0; - if (attribs & SMB_FA_HID) - strcat(SMB_Attrib_Temp, (verbose ? "Hidden " : "H")); + if (attribs & SMB_FA_ROF) + strcat(SMB_Attrib_Temp, (verbose?"Read Only ":"R")); - if (attribs & SMB_FA_SYS) - strcat(SMB_Attrib_Temp, (verbose ? "System " : "S")); + if (attribs & SMB_FA_HID) + strcat(SMB_Attrib_Temp, (verbose?"Hidden ":"H")); - if (attribs & SMB_FA_VOL) - strcat(SMB_Attrib_Temp, (verbose ? "Volume " : "V")); + if (attribs & SMB_FA_SYS) + strcat(SMB_Attrib_Temp, (verbose?"System ":"S")); - if (attribs & SMB_FA_DIR) - strcat(SMB_Attrib_Temp, (verbose ? "Directory " : "D")); + if (attribs & SMB_FA_VOL) + strcat(SMB_Attrib_Temp, (verbose?"Volume ":"V")); - if (attribs & SMB_FA_ARC) - strcat(SMB_Attrib_Temp, (verbose ? "Archive " : "A")); + if (attribs & SMB_FA_DIR) + strcat(SMB_Attrib_Temp, (verbose?"Directory ":"D")); - return (SMB_Attrib_Temp); + if (attribs & SMB_FA_ARC) + strcat(SMB_Attrib_Temp, (verbose?"Archive ":"A")); + + return(SMB_Attrib_Temp); } /* Pick up the Max Buffer Size from the Tree Structure ... */ -int -SMB_Get_Tree_MBS(SMB_Tree_Handle tree) +int SMB_Get_Tree_MBS(SMB_Tree_Handle tree) + { - if (tree != NULL) { - return (tree->mbs); - } else { - return (SMBlibE_BAD); - } + if (tree != NULL) { + return(tree -> mbs); + } + else { + return(SMBlibE_BAD); + } } /* Pick up the Max buffer size */ -int -SMB_Get_Max_Buf_Siz(SMB_Handle_Type Con_Handle) +int SMB_Get_Max_Buf_Siz(SMB_Handle_Type Con_Handle) + { - if (Con_Handle != NULL) { - return (Con_Handle->max_xmit); - } else { - return (SMBlibE_BAD); - } + if (Con_Handle != NULL) { + return(Con_Handle -> max_xmit); + } + else { + return(SMBlibE_BAD); + } } /* Pickup the protocol index from the connection structure */ -int -SMB_Get_Protocol_IDX(SMB_Handle_Type Con_Handle) +int SMB_Get_Protocol_IDX(SMB_Handle_Type Con_Handle) + { - if (Con_Handle != NULL) { - return (Con_Handle->prot_IDX); - } else { - return (0xFFFF); /* Invalid protocol */ - } + if (Con_Handle != NULL) { + return(Con_Handle -> prot_IDX); + } + else { + return(0xFFFF); /* Invalid protocol */ + } } /* Pick up the protocol from the connection structure */ -int -SMB_Get_Protocol(SMB_Handle_Type Con_Handle) +int SMB_Get_Protocol(SMB_Handle_Type Con_Handle) + { - if (Con_Handle != NULL) { - return (Con_Handle->protocol); - } else { - return (0xFFFF); /* Invalid protocol */ - } + if (Con_Handle != NULL) { + return(Con_Handle -> protocol); + } + else { + return(0xFFFF); /* Invalid protocol */ + } } @@ -157,32 +160,32 @@ /* We offered, and the index back from the server. We allow for a user */ /* supplied list, and assume that it is a subset of our list */ -int -SMB_Figure_Protocol(char *dialects[], int prot_index) -{ - int i; +int SMB_Figure_Protocol(char *dialects[], int prot_index) + +{ int i; - if (dialects == SMB_Prots) { /* The jobs is easy, just index into table */ + if (dialects == SMB_Prots) { /* The jobs is easy, just index into table */ - return (SMB_Types[prot_index]); - } else { /* Search through SMB_Prots looking for a match */ + return(SMB_Types[prot_index]); + } + else { /* Search through SMB_Prots looking for a match */ - for (i = 0; SMB_Prots[i] != NULL; i++) { + for (i = 0; SMB_Prots[i] != NULL; i++) { - if (strcmp(dialects[prot_index], SMB_Prots[i]) == 0) { /* A match */ + if (strcmp(dialects[prot_index], SMB_Prots[i]) == 0) { /* A match */ - return (SMB_Types[i]); + return(SMB_Types[i]); - } + } - } + } - /* If we got here, then we are in trouble, because the protocol was not */ - /* One we understand ... */ + /* If we got here, then we are in trouble, because the protocol was not */ + /* One we understand ... */ - return (SMB_P_Unknown); + return(SMB_P_Unknown); - } + } } @@ -191,546 +194,538 @@ /* we return the index of the accepted protocol in NegProt, -1 indicates */ /* none acceptible, and our return value is 0 if ok, <0 if problems */ -int -SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[]) -{ - struct SMB_Neg_Prot_Def *prot_pkt; - struct SMB_Neg_Prot_Resp_Def *resp_pkt; - struct RFCNB_Pkt *pkt; - int prots_len, i, pkt_len, prot, alloc_len; - char *p; +int SMB_Negotiate(SMB_Handle_Type Con_Handle, char *Prots[]) - /* Figure out how long the prot list will be and allocate space for it */ +{ struct SMB_Neg_Prot_Def *prot_pkt; + struct SMB_Neg_Prot_Resp_Def *resp_pkt; + struct RFCNB_Pkt *pkt; + int prots_len, i, pkt_len, prot, alloc_len; + char *p; - prots_len = 0; + /* Figure out how long the prot list will be and allocate space for it */ - for (i = 0; Prots[i] != NULL; i++) { + prots_len = 0; - prots_len = prots_len + strlen(Prots[i]) + 2; /* Account for null etc */ + for (i = 0; Prots[i] != NULL; i++) { - } + prots_len = prots_len + strlen(Prots[i]) + 2; /* Account for null etc */ - /* The -1 accounts for the one byte smb_buf we have because some systems */ - /* don't like char msg_buf[] */ + } - pkt_len = SMB_negp_len + prots_len; + /* The -1 accounts for the one byte smb_buf we have because some systems */ + /* don't like char msg_buf[] */ - /* Make sure that the pkt len is long enough for the max response ... */ - /* Which is a problem, because the encryption key len eec may be long */ + pkt_len = SMB_negp_len + prots_len; - if (pkt_len < (SMB_hdr_wct_offset + (19 * 2) + 40)) { + /* Make sure that the pkt len is long enough for the max response ... */ + /* Which is a problem, because the encryption key len eec may be long */ - alloc_len = SMB_hdr_wct_offset + (19 * 2) + 40; + if (pkt_len < (SMB_hdr_wct_offset + (19 * 2) + 40)) { - } else { + alloc_len = SMB_hdr_wct_offset + (19 * 2) + 40; - alloc_len = pkt_len; + } + else { - } + alloc_len = pkt_len; - pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(alloc_len); + } - if (pkt == NULL) { + pkt = (struct RFCNB_Pkt *)RFCNB_Alloc_Pkt(alloc_len); - SMBlib_errno = SMBlibE_NoSpace; - return (SMBlibE_BAD); + if (pkt == NULL) { - } + SMBlib_errno = SMBlibE_NoSpace; + return(SMBlibE_BAD); - /* Now plug in the bits we need */ + } - bzero(SMB_Hdr(pkt), SMB_negp_len); - SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ - *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBnegprot; - SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle->pid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid); - *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0; + /* Now plug in the bits we need */ - SSVAL(SMB_Hdr(pkt), SMB_negp_bcc_offset, prots_len); + bzero(SMB_Hdr(pkt), SMB_negp_len); + SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ + *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBnegprot; + SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle -> pid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle -> mid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle -> uid); + *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0; - /* Now copy the prot strings in with the right stuff */ + SSVAL(SMB_Hdr(pkt), SMB_negp_bcc_offset, prots_len); - p = (char *) (SMB_Hdr(pkt) + SMB_negp_buf_offset); + /* Now copy the prot strings in with the right stuff */ - for (i = 0; Prots[i] != NULL; i++) { + p = (char *)(SMB_Hdr(pkt) + SMB_negp_buf_offset); - *p = SMBdialectID; - strcpy(p + 1, Prots[i]); - p = p + strlen(Prots[i]) + 2; /* Adjust len of p for null plus dialectID */ + for (i = 0; Prots[i] != NULL; i++) { - } + *p = SMBdialectID; + strcpy(p + 1, Prots[i]); + p = p + strlen(Prots[i]) + 2; /* Adjust len of p for null plus dialectID */ - /* Now send the packet and sit back ... */ + } - if (RFCNB_Send(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) { + /* Now send the packet and sit back ... */ + + if (RFCNB_Send(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0){ #ifdef DEBUG - fprintf(stderr, "Error sending negotiate protocol\n"); + fprintf(stderr, "Error sending negotiate protocol\n"); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = -SMBlibE_SendFailed; /* Failed, check lower layer errno */ - return (SMBlibE_BAD); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = -SMBlibE_SendFailed; /* Failed, check lower layer errno */ + return(SMBlibE_BAD); - } + } - /* Now get the response ... */ + /* Now get the response ... */ - if (RFCNB_Recv(Con_Handle->Trans_Connect, pkt, alloc_len) < 0) { + if (RFCNB_Recv(Con_Handle -> Trans_Connect, pkt, alloc_len) < 0) { #ifdef DEBUG - fprintf(stderr, "Error receiving response to negotiate\n"); + fprintf(stderr, "Error receiving response to negotiate\n"); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = -SMBlibE_RecvFailed; /* Failed, check lower layer errno */ - return (SMBlibE_BAD); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = -SMBlibE_RecvFailed; /* Failed, check lower layer errno */ + return(SMBlibE_BAD); - } + } - if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ + if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ #ifdef DEBUG - fprintf(stderr, - "SMB_Negotiate failed with errorclass = %i, Error Code = %i\n", - CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), SVAL(SMB_Hdr(pkt), - SMB_hdr_err_offset)); + fprintf(stderr, "SMB_Negotiate failed with errorclass = %i, Error Code = %i\n", + CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), + SVAL(SMB_Hdr(pkt), SMB_hdr_err_offset)); #endif - SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_Remote; - return (SMBlibE_BAD); - - } + SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_Remote; + return(SMBlibE_BAD); - if (SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset) == 0xFFFF) { + } + + if (SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset) == 0xFFFF) { #ifdef DEBUG - fprintf(stderr, "None of our protocols was accepted ... "); + fprintf(stderr, "None of our protocols was accepted ... "); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_NegNoProt; - return (SMBlibE_BAD); - - } - - /* Now, unpack the info from the response, if any and evaluate the proto */ - /* selected. We must make sure it is one we like ... */ + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_NegNoProt; + return(SMBlibE_BAD); - Con_Handle->prot_IDX = prot = SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset); - Con_Handle->protocol = SMB_Figure_Protocol(Prots, prot); + } - if (Con_Handle->protocol == SMB_P_Unknown) { /* No good ... */ + /* Now, unpack the info from the response, if any and evaluate the proto */ + /* selected. We must make sure it is one we like ... */ - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_ProtUnknown; - return (SMBlibE_BAD); + Con_Handle -> prot_IDX = prot = SVAL(SMB_Hdr(pkt), SMB_negrCP_idx_offset); + Con_Handle -> protocol = SMB_Figure_Protocol(Prots, prot); - } + if (Con_Handle -> protocol == SMB_P_Unknown) { /* No good ... */ - switch (CVAL(SMB_Hdr(pkt), SMB_hdr_wct_offset)) { + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_ProtUnknown; + return(SMBlibE_BAD); - case 0x01: /* No more info ... */ + } + + switch (CVAL(SMB_Hdr(pkt), SMB_hdr_wct_offset)) { - break; + case 0x01: /* No more info ... */ - case 13: /* Up to and including LanMan 2.1 */ + break; - Con_Handle->Security = SVAL(SMB_Hdr(pkt), SMB_negrLM_sec_offset); - Con_Handle->encrypt_passwords = - ((Con_Handle->Security & SMB_sec_encrypt_mask) != 0x00); - Con_Handle->Security = Con_Handle->Security & SMB_sec_user_mask; + case 13: /* Up to and including LanMan 2.1 */ - Con_Handle->max_xmit = SVAL(SMB_Hdr(pkt), SMB_negrLM_mbs_offset); - Con_Handle->MaxMPX = SVAL(SMB_Hdr(pkt), SMB_negrLM_mmc_offset); - Con_Handle->MaxVC = SVAL(SMB_Hdr(pkt), SMB_negrLM_mnv_offset); - Con_Handle->Raw_Support = SVAL(SMB_Hdr(pkt), SMB_negrLM_rm_offset); - Con_Handle->SessionKey = IVAL(SMB_Hdr(pkt), SMB_negrLM_sk_offset); - Con_Handle->SvrTZ = SVAL(SMB_Hdr(pkt), SMB_negrLM_stz_offset); - Con_Handle->Encrypt_Key_Len = SVAL(SMB_Hdr(pkt), SMB_negrLM_ekl_offset); + Con_Handle -> Security = SVAL(SMB_Hdr(pkt), SMB_negrLM_sec_offset); + Con_Handle -> encrypt_passwords = ((Con_Handle -> Security & SMB_sec_encrypt_mask) != 0x00); + Con_Handle -> Security = Con_Handle -> Security & SMB_sec_user_mask; - p = (SMB_Hdr(pkt) + SMB_negrLM_buf_offset); - fprintf(stderr, "%d", (char *) (SMB_Hdr(pkt) + SMB_negrLM_buf_offset)); - memcpy(Con_Handle->Encrypt_Key, p, 8); + Con_Handle -> max_xmit = SVAL(SMB_Hdr(pkt), SMB_negrLM_mbs_offset); + Con_Handle -> MaxMPX = SVAL(SMB_Hdr(pkt), SMB_negrLM_mmc_offset); + Con_Handle -> MaxVC = SVAL(SMB_Hdr(pkt), SMB_negrLM_mnv_offset); + Con_Handle -> Raw_Support = SVAL(SMB_Hdr(pkt), SMB_negrLM_rm_offset); + Con_Handle -> SessionKey = IVAL(SMB_Hdr(pkt), SMB_negrLM_sk_offset); + Con_Handle -> SvrTZ = SVAL(SMB_Hdr(pkt), SMB_negrLM_stz_offset); + Con_Handle -> Encrypt_Key_Len = SVAL(SMB_Hdr(pkt), SMB_negrLM_ekl_offset); + + p = (SMB_Hdr(pkt) + SMB_negrLM_buf_offset); + fprintf(stderr, "%d", (char *)(SMB_Hdr(pkt) + SMB_negrLM_buf_offset)); + memcpy(Con_Handle->Encrypt_Key, p, 8); - p = - (SMB_Hdr(pkt) + SMB_negrLM_buf_offset + - Con_Handle->Encrypt_Key_Len); + p = (SMB_Hdr(pkt) + SMB_negrLM_buf_offset + Con_Handle -> Encrypt_Key_Len); - strncpy(p, Con_Handle->Svr_PDom, sizeof(Con_Handle->Svr_PDom) - 1); + strncpy(p, Con_Handle -> Svr_PDom, sizeof(Con_Handle -> Svr_PDom) - 1); - break; + break; - case 17: /* NT LM 0.12 and LN LM 1.0 */ + case 17: /* NT LM 0.12 and LN LM 1.0 */ - Con_Handle->Security = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_sec_offset); - Con_Handle->encrypt_passwords = - ((Con_Handle->Security & SMB_sec_encrypt_mask) != 0x00); - Con_Handle->Security = Con_Handle->Security & SMB_sec_user_mask; + Con_Handle -> Security = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_sec_offset); + Con_Handle -> encrypt_passwords = ((Con_Handle -> Security & SMB_sec_encrypt_mask) != 0x00); + Con_Handle -> Security = Con_Handle -> Security & SMB_sec_user_mask; - Con_Handle->max_xmit = IVAL(SMB_Hdr(pkt), SMB_negrNTLM_mbs_offset); - Con_Handle->MaxMPX = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_mmc_offset); - Con_Handle->MaxVC = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_mnv_offset); - Con_Handle->MaxRaw = IVAL(SMB_Hdr(pkt), SMB_negrNTLM_mrs_offset); - Con_Handle->SessionKey = IVAL(SMB_Hdr(pkt), SMB_negrNTLM_sk_offset); - Con_Handle->SvrTZ = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_stz_offset); - Con_Handle->Encrypt_Key_Len = - CVAL(SMB_Hdr(pkt), SMB_negrNTLM_ekl_offset); + Con_Handle -> max_xmit = IVAL(SMB_Hdr(pkt), SMB_negrNTLM_mbs_offset); + Con_Handle -> MaxMPX = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_mmc_offset); + Con_Handle -> MaxVC = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_mnv_offset); + Con_Handle -> MaxRaw = IVAL(SMB_Hdr(pkt), SMB_negrNTLM_mrs_offset); + Con_Handle -> SessionKey = IVAL(SMB_Hdr(pkt), SMB_negrNTLM_sk_offset); + Con_Handle -> SvrTZ = SVAL(SMB_Hdr(pkt), SMB_negrNTLM_stz_offset); + Con_Handle -> Encrypt_Key_Len = CVAL(SMB_Hdr(pkt), SMB_negrNTLM_ekl_offset); - p = (SMB_Hdr(pkt) + SMB_negrNTLM_buf_offset); - memcpy(Con_Handle->Encrypt_Key, p, 8); - p = - (SMB_Hdr(pkt) + SMB_negrNTLM_buf_offset + - Con_Handle->Encrypt_Key_Len); + p = (SMB_Hdr(pkt) + SMB_negrNTLM_buf_offset ); + memcpy(Con_Handle -> Encrypt_Key, p, 8); + p = (SMB_Hdr(pkt) + SMB_negrNTLM_buf_offset + Con_Handle -> Encrypt_Key_Len); - strncpy(p, Con_Handle->Svr_PDom, sizeof(Con_Handle->Svr_PDom) - 1); + strncpy(p, Con_Handle -> Svr_PDom, sizeof(Con_Handle -> Svr_PDom) - 1); - break; + break; - default: + default: #ifdef DEBUG - fprintf(stderr, "Unknown NegProt response format ... Ignored\n"); - fprintf(stderr, " wct = %i\n", CVAL(SMB_Hdr(pkt), SMB_hdr_wct_offset)); + fprintf(stderr, "Unknown NegProt response format ... Ignored\n"); + fprintf(stderr, " wct = %i\n", CVAL(SMB_Hdr(pkt), SMB_hdr_wct_offset)); #endif - break; - } + break; + } #ifdef DEBUG - fprintf(stderr, "Protocol selected is: %i:%s\n", prot, Prots[prot]); + fprintf(stderr, "Protocol selected is: %i:%s\n", prot, Prots[prot]); #endif - RFCNB_Free_Pkt(pkt); - return (0); + RFCNB_Free_Pkt(pkt); + return(0); } /* Get our hostname */ -void -SMB_Get_My_Name(char *name, int len) -{ - int loc; +void SMB_Get_My_Name(char *name, int len) + +{ int loc; - if (gethostname(name, len) < 0) { /* Error getting name */ + if (gethostname(name, len) < 0) { /* Error getting name */ - strncpy(name, "unknown", len); + strncpy(name, "unknown", len); - /* Should check the error */ + /* Should check the error */ #ifdef DEBUG - fprintf(stderr, "gethostname in SMB_Get_My_Name returned error:"); - perror(""); + fprintf(stderr, "gethostname in SMB_Get_My_Name returned error:"); + perror(""); #endif - } + } - /* only keep the portion up to the first "." */ + /* only keep the portion up to the first "." */ } /* Send a TCON to the remote server ... */ -SMB_Tree_Handle -SMB_TreeConnect(SMB_Handle_Type Con_Handle, -SMB_Tree_Handle Tree_Handle, char *path, char *password, char *device) -{ - struct RFCNB_Pkt *pkt; - int param_len, i, pkt_len; - char *p; - SMB_Tree_Handle tree; +SMB_Tree_Handle SMB_TreeConnect(SMB_Handle_Type Con_Handle, + SMB_Tree_Handle Tree_Handle, + char *path, + char *password, + char *device) - /* Figure out how much space is needed for path, password, dev ... */ +{ struct RFCNB_Pkt *pkt; + int param_len, i, pkt_len; + char *p; + SMB_Tree_Handle tree; - if (path == NULL | password == NULL | device == NULL) { + /* Figure out how much space is needed for path, password, dev ... */ + + if (path == NULL | password == NULL | device == NULL) { #ifdef DEBUG - fprintf(stderr, "Bad parameter passed to SMB_TreeConnect\n"); + fprintf(stderr, "Bad parameter passed to SMB_TreeConnect\n"); #endif - SMBlib_errno = SMBlibE_BadParam; - return (NULL); - - } - - /* The + 2 is because of the \0 and the marker ... */ + SMBlib_errno = SMBlibE_BadParam; + return(NULL); - param_len = strlen(path) + 2 + strlen(password) + 2 + strlen(device) + 2; + } - /* The -1 accounts for the one byte smb_buf we have because some systems */ - /* don't like char msg_buf[] */ + /* The + 2 is because of the \0 and the marker ... */ - pkt_len = SMB_tcon_len + param_len; + param_len = strlen(path) + 2 + strlen(password) + 2 + strlen(device) + 2; - pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(pkt_len); + /* The -1 accounts for the one byte smb_buf we have because some systems */ + /* don't like char msg_buf[] */ - if (pkt == NULL) { + pkt_len = SMB_tcon_len + param_len; - SMBlib_errno = SMBlibE_NoSpace; - return (NULL); /* Should handle the error */ + pkt = (struct RFCNB_Pkt *)RFCNB_Alloc_Pkt(pkt_len); - } + if (pkt == NULL) { - /* Now allocate a tree for this to go into ... */ + SMBlib_errno = SMBlibE_NoSpace; + return(NULL); /* Should handle the error */ - if (Tree_Handle == NULL) { + } - tree = (SMB_Tree_Handle) malloc(sizeof(struct SMB_Tree_Structure)); + /* Now allocate a tree for this to go into ... */ - if (tree == NULL) { + if (Tree_Handle == NULL) { - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_NoSpace; - return (NULL); + tree = (SMB_Tree_Handle)malloc(sizeof(struct SMB_Tree_Structure)); - } - } else { + if (tree == NULL) { + + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_NoSpace; + return(NULL); + + } + } + else { - tree = Tree_Handle; + tree = Tree_Handle; - } + } - tree->next = tree->prev = NULL; - tree->con = Con_Handle; - strncpy(tree->path, path, sizeof(tree->path)); - strncpy(tree->device_type, device, sizeof(tree->device_type)); + tree -> next = tree -> prev = NULL; + tree -> con = Con_Handle; + strncpy(tree -> path, path, sizeof(tree -> path)); + strncpy(tree -> device_type, device, sizeof(tree -> device_type)); - /* Now plug in the values ... */ + /* Now plug in the values ... */ - bzero(SMB_Hdr(pkt), SMB_tcon_len); - SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ - *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBtcon; - SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle->pid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid); - *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0; + bzero(SMB_Hdr(pkt), SMB_tcon_len); + SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ + *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBtcon; + SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle -> pid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle -> mid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle -> uid); + *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0; - SSVAL(SMB_Hdr(pkt), SMB_tcon_bcc_offset, param_len); + SSVAL(SMB_Hdr(pkt), SMB_tcon_bcc_offset, param_len); - /* Now copy the param strings in with the right stuff */ + /* Now copy the param strings in with the right stuff */ - p = (char *) (SMB_Hdr(pkt) + SMB_tcon_buf_offset); - *p = SMBasciiID; - strcpy(p + 1, path); - p = p + strlen(path) + 2; - *p = SMBasciiID; - strcpy(p + 1, password); - p = p + strlen(password) + 2; - *p = SMBasciiID; - strcpy(p + 1, device); + p = (char *)(SMB_Hdr(pkt) + SMB_tcon_buf_offset); + *p = SMBasciiID; + strcpy(p + 1, path); + p = p + strlen(path) + 2; + *p = SMBasciiID; + strcpy(p + 1, password); + p = p + strlen(password) + 2; + *p = SMBasciiID; + strcpy(p + 1, device); - /* Now send the packet and sit back ... */ + /* Now send the packet and sit back ... */ - if (RFCNB_Send(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) { + if (RFCNB_Send(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0){ #ifdef DEBUG - fprintf(stderr, "Error sending TCon request\n"); + fprintf(stderr, "Error sending TCon request\n"); #endif - if (Tree_Handle == NULL) - free(tree); - RFCNB_Free_Pkt(pkt); - SMBlib_errno = -SMBlibE_SendFailed; - return (NULL); + if (Tree_Handle == NULL) + free(tree); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = -SMBlibE_SendFailed; + return(NULL); - } + } - /* Now get the response ... */ + /* Now get the response ... */ - if (RFCNB_Recv(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) { + if (RFCNB_Recv(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0) { #ifdef DEBUG - fprintf(stderr, "Error receiving response to TCon\n"); + fprintf(stderr, "Error receiving response to TCon\n"); #endif - if (Tree_Handle == NULL) - free(tree); - RFCNB_Free_Pkt(pkt); - SMBlib_errno = -SMBlibE_RecvFailed; - return (NULL); + if (Tree_Handle == NULL) + free(tree); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = -SMBlibE_RecvFailed; + return(NULL); - } + } - /* Check out the response type ... */ + /* Check out the response type ... */ - if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ + if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ #ifdef DEBUG - fprintf(stderr, - "SMB_TCon failed with errorclass = %i, Error Code = %i\n", - CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), SVAL(SMB_Hdr(pkt), - SMB_hdr_err_offset)); + fprintf(stderr, "SMB_TCon failed with errorclass = %i, Error Code = %i\n", + CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), + SVAL(SMB_Hdr(pkt), SMB_hdr_err_offset)); #endif - if (Tree_Handle == NULL) - free(tree); - SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_Remote; - return (NULL); + if (Tree_Handle == NULL) + free(tree); + SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_Remote; + return(NULL); - } + } - tree->tid = SVAL(SMB_Hdr(pkt), SMB_tconr_tid_offset); - tree->mbs = SVAL(SMB_Hdr(pkt), SMB_tconr_mbs_offset); + tree -> tid = SVAL(SMB_Hdr(pkt), SMB_tconr_tid_offset); + tree -> mbs = SVAL(SMB_Hdr(pkt), SMB_tconr_mbs_offset); #ifdef DEBUG - fprintf(stderr, "TConn succeeded, with TID=%i, Max Xmit=%i\n", - tree->tid, tree->mbs); + fprintf(stderr, "TConn succeeded, with TID=%i, Max Xmit=%i\n", + tree -> tid, tree -> mbs); #endif - /* Now link the Tree to the Server Structure ... */ + /* Now link the Tree to the Server Structure ... */ - if (Con_Handle->first_tree == NULL) { + if (Con_Handle -> first_tree == NULL) { - Con_Handle->first_tree == tree; - Con_Handle->last_tree == tree; + Con_Handle -> first_tree == tree; + Con_Handle -> last_tree == tree; - } else { + } + else { - Con_Handle->last_tree->next = tree; - tree->prev = Con_Handle->last_tree; - Con_Handle->last_tree = tree; + Con_Handle -> last_tree -> next = tree; + tree -> prev = Con_Handle -> last_tree; + Con_Handle -> last_tree = tree; - } + } - RFCNB_Free_Pkt(pkt); - return (tree); + RFCNB_Free_Pkt(pkt); + return(tree); } -int -SMB_TreeDisconnect(SMB_Tree_Handle Tree_Handle, BOOL discard) -{ - struct RFCNB_Pkt *pkt; - int pkt_len; +int SMB_TreeDisconnect(SMB_Tree_Handle Tree_Handle, BOOL discard) - pkt_len = SMB_tdis_len; +{ struct RFCNB_Pkt *pkt; + int pkt_len; - pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(pkt_len); + pkt_len = SMB_tdis_len; - if (pkt == NULL) { + pkt = (struct RFCNB_Pkt *)RFCNB_Alloc_Pkt(pkt_len); - SMBlib_errno = SMBlibE_NoSpace; - return (SMBlibE_BAD); /* Should handle the error */ + if (pkt == NULL) { - } + SMBlib_errno = SMBlibE_NoSpace; + return(SMBlibE_BAD); /* Should handle the error */ + + } - /* Now plug in the values ... */ + /* Now plug in the values ... */ - bzero(SMB_Hdr(pkt), SMB_tdis_len); - SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ - *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBtdis; - SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Tree_Handle->con->pid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Tree_Handle->con->mid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Tree_Handle->con->uid); - *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0; + bzero(SMB_Hdr(pkt), SMB_tdis_len); + SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ + *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBtdis; + SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Tree_Handle -> con -> pid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Tree_Handle -> con -> mid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Tree_Handle -> con -> uid); + *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 0; - SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, Tree_Handle->tid); - SSVAL(SMB_Hdr(pkt), SMB_tcon_bcc_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, Tree_Handle -> tid); + SSVAL(SMB_Hdr(pkt), SMB_tcon_bcc_offset, 0); - /* Now send the packet and sit back ... */ + /* Now send the packet and sit back ... */ - if (RFCNB_Send(Tree_Handle->con->Trans_Connect, pkt, pkt_len) < 0) { + if (RFCNB_Send(Tree_Handle -> con -> Trans_Connect, pkt, pkt_len) < 0){ #ifdef DEBUG - fprintf(stderr, "Error sending TDis request\n"); + fprintf(stderr, "Error sending TDis request\n"); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = -SMBlibE_SendFailed; - return (SMBlibE_BAD); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = -SMBlibE_SendFailed; + return(SMBlibE_BAD); - } + } - /* Now get the response ... */ + /* Now get the response ... */ - if (RFCNB_Recv(Tree_Handle->con->Trans_Connect, pkt, pkt_len) < 0) { + if (RFCNB_Recv(Tree_Handle -> con -> Trans_Connect, pkt, pkt_len) < 0) { #ifdef DEBUG - fprintf(stderr, "Error receiving response to TCon\n"); + fprintf(stderr, "Error receiving response to TCon\n"); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = -SMBlibE_RecvFailed; - return (SMBlibE_BAD); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = -SMBlibE_RecvFailed; + return(SMBlibE_BAD); - } + } - /* Check out the response type ... */ + /* Check out the response type ... */ - if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ + if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ #ifdef DEBUG - fprintf(stderr, - "SMB_TDis failed with errorclass = %i, Error Code = %i\n", - CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), SVAL(SMB_Hdr(pkt), - SMB_hdr_err_offset)); + fprintf(stderr, "SMB_TDis failed with errorclass = %i, Error Code = %i\n", + CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), + SVAL(SMB_Hdr(pkt), SMB_hdr_err_offset)); #endif - SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_Remote; - return (SMBlibE_BAD); + SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_Remote; + return(SMBlibE_BAD); - } + } - Tree_Handle->tid = 0xFFFF; /* Invalid TID */ - Tree_Handle->mbs = 0; /* Invalid */ + Tree_Handle -> tid = 0xFFFF; /* Invalid TID */ + Tree_Handle -> mbs = 0; /* Invalid */ #ifdef DEBUG - fprintf(stderr, "Tree disconnect successful ...\n"); + fprintf(stderr, "Tree disconnect successful ...\n"); #endif - /* What about the tree handle ? */ + /* What about the tree handle ? */ - if (discard == TRUE) { /* Unlink it and free it ... */ + if (discard == TRUE) { /* Unlink it and free it ... */ - if (Tree_Handle->next == NULL) - Tree_Handle->con->first_tree = Tree_Handle->prev; - else - Tree_Handle->next->prev = Tree_Handle->prev; + if (Tree_Handle -> next == NULL) + Tree_Handle -> con -> first_tree = Tree_Handle -> prev; + else + Tree_Handle -> next -> prev = Tree_Handle -> prev; - if (Tree_Handle->prev == NULL) - Tree_Handle->con->last_tree = Tree_Handle->next; - else - Tree_Handle->prev->next = Tree_Handle->next; + if (Tree_Handle -> prev == NULL) + Tree_Handle -> con -> last_tree = Tree_Handle -> next; + else + Tree_Handle -> prev -> next = Tree_Handle -> next; - } + } - RFCNB_Free_Pkt(pkt); - return (0); + RFCNB_Free_Pkt(pkt); + return(0); } /* Pick up the last LMBlib error ... */ -int -SMB_Get_Last_Error() +int SMB_Get_Last_Error() + { - return (SMBlib_errno); + return(SMBlib_errno); } /* Pick up the last error returned in an SMB packet */ /* We will need macros to extract error class and error code */ -int -SMB_Get_Last_SMB_Err() +int SMB_Get_Last_SMB_Err() + { - return (SMBlib_SMB_Error); + return(SMBlib_SMB_Error); } @@ -740,55 +735,55 @@ static char *SMBlib_Error_Messages[] = { - "Request completed sucessfully.", - "Server returned a non-zero SMB Error Class and Code.", - "A lower layer protocol error occurred.", - "Function not yet implemented.", - "The protocol negotiated does not support the request.", - "No space available for operation.", - "One or more bad parameters passed.", - "None of the protocols we offered were accepted.", - "The attempt to send an SMB request failed. See protocol error info.", - "The attempt to get an SMB response failed. See protocol error info.", - "The logon request failed, but you were logged in as guest.", - "The attempt to call the remote server failed. See protocol error info.", - "The protocol dialect specified in a NegProt and accepted by the server is unknown.", - /* This next one simplifies error handling */ - "No such error code.", - NULL -}; + "Request completed sucessfully.", + "Server returned a non-zero SMB Error Class and Code.", + "A lower layer protocol error occurred.", + "Function not yet implemented.", + "The protocol negotiated does not support the request.", + "No space available for operation.", + "One or more bad parameters passed.", + "None of the protocols we offered were accepted.", + "The attempt to send an SMB request failed. See protocol error info.", + "The attempt to get an SMB response failed. See protocol error info.", + "The logon request failed, but you were logged in as guest.", + "The attempt to call the remote server failed. See protocol error info.", + "The protocol dialect specified in a NegProt and accepted by the server is unknown.", + /* This next one simplifies error handling */ + "No such error code.", + NULL}; + +int SMB_Get_Error_Msg(int msg, char *msgbuf, int len) -int -SMB_Get_Error_Msg(int msg, char *msgbuf, int len) { - if (msg >= 0) { + if (msg >= 0) { - strncpy(msgbuf, - SMBlib_Error_Messages[msg > - SMBlibE_NoSuchMsg ? SMBlibE_NoSuchMsg : msg], len - 1); - msgbuf[len - 1] = 0; /* Make sure it is a string */ - } else { /* Add the lower layer message ... */ + strncpy(msgbuf, + SMBlib_Error_Messages[msg>SMBlibE_NoSuchMsg?SMBlibE_NoSuchMsg:msg], + len - 1); + msgbuf[len - 1] = 0; /* Make sure it is a string */ + } + else { /* Add the lower layer message ... */ - char prot_msg[1024]; + char prot_msg[1024]; - msg = -msg; /* Make it positive */ + msg = -msg; /* Make it positive */ - strncpy(msgbuf, - SMBlib_Error_Messages[msg > - SMBlibE_NoSuchMsg ? SMBlibE_NoSuchMsg : msg], len - 1); + strncpy(msgbuf, + SMBlib_Error_Messages[msg>SMBlibE_NoSuchMsg?SMBlibE_NoSuchMsg:msg], + len - 1); - msgbuf[len - 1] = 0; /* make sure it is a string */ + msgbuf[len - 1] = 0; /* make sure it is a string */ - if (strlen(msgbuf) < len) { /* If there is space, put rest in */ + if (strlen(msgbuf) < len) { /* If there is space, put rest in */ - strncat(msgbuf, "\n\t", len - strlen(msgbuf)); + strncat(msgbuf, "\n\t", len - strlen(msgbuf)); - RFCNB_Get_Error(prot_msg, sizeof(prot_msg) - 1); + RFCNB_Get_Error(prot_msg, sizeof(prot_msg) - 1); - strncat(msgbuf, prot_msg, len - strlen(msgbuf)); + strncat(msgbuf, prot_msg, len - strlen(msgbuf)); - } } + } } Index: squid/auth_modules/MSNT/smblib.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smblib.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/smblib.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/smblib.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX SMBlib NetBIOS implementation + Version 1.0 SMBlib Routines @@ -36,36 +37,36 @@ /* Initialize the SMBlib package */ -int -SMB_Init() +int SMB_Init() + { - SMBlib_State = SMB_State_Started; + SMBlib_State = SMB_State_Started; - signal(SIGPIPE, SIG_IGN); /* Ignore these ... */ + signal(SIGPIPE, SIG_IGN); /* Ignore these ... */ /* If SMBLIB_Instrument is defines, turn on the instrumentation stuff */ #ifdef SMBLIB_INSTRUMENT - SMBlib_Instrument_Init(); + SMBlib_Instrument_Init(); #endif - return 0; + return 0; } -int -SMB_Term() +int SMB_Term() + { #ifdef SMBLIB_INSTRUMENT - SMBlib_Instrument_Term(); /* Clean up and print results */ + SMBlib_Instrument_Term(); /* Clean up and print results */ #endif - return 0; + return 0; } @@ -73,117 +74,118 @@ /* We have other helper routines to set variables */ SMB_Handle_Type SMB_Create_Con_Handle() + { - SMBlib_errno = SMBlibE_NotImpl; - return (NULL); + SMBlib_errno = SMBlibE_NotImpl; + return(NULL); } -int -SMBlib_Set_Sock_NoDelay(SMB_Handle_Type Con_Handle, BOOL yn) +int SMBlib_Set_Sock_NoDelay(SMB_Handle_Type Con_Handle, BOOL yn) + { - if (RFCNB_Set_Sock_NoDelay(Con_Handle->Trans_Connect, yn) < 0) { + if (RFCNB_Set_Sock_NoDelay(Con_Handle -> Trans_Connect, yn) < 0) { #ifdef DEBUG #endif - fprintf(stderr, "Setting no-delay on TCP socket failed ...\n"); + fprintf(stderr, "Setting no-delay on TCP socket failed ...\n"); - } + } - return (0); + return(0); } /* SMB_Connect_Server: Connect to a server, but don't negotiate protocol */ /* or anything else ... */ -SMB_Handle_Type -SMB_Connect_Server(SMB_Handle_Type Con_Handle, char *server, char *NTdomain) -{ - SMB_Handle_Type con; - char temp[80], called[80], calling[80], *address; - int i; +SMB_Handle_Type SMB_Connect_Server(SMB_Handle_Type Con_Handle, + char *server, char *NTdomain) - /* Get a connection structure if one does not exist */ +{ SMB_Handle_Type con; + char temp[80], called[80], calling[80], *address; + int i; - con = Con_Handle; + /* Get a connection structure if one does not exist */ - if (Con_Handle == NULL) { + con = Con_Handle; - if ((con = - (struct SMB_Connect_Def *) malloc(sizeof(struct - SMB_Connect_Def))) == NULL) { + if (Con_Handle == NULL) { + if ((con = (struct SMB_Connect_Def *)malloc(sizeof(struct SMB_Connect_Def))) == NULL) { - SMBlib_errno = SMBlibE_NoSpace; - return NULL; - } + SMBlib_errno = SMBlibE_NoSpace; + return NULL; } - /* Init some things ... */ - - strcpy(con->service, ""); - strcpy(con->username, ""); - strcpy(con->password, ""); - strcpy(con->sock_options, ""); - strcpy(con->address, ""); - strcpy(con->desthost, server); - strcpy(con->PDomain, NTdomain); - strcpy(con->OSName, SMBLIB_DEFAULT_OSNAME); - strcpy(con->LMType, SMBLIB_DEFAULT_LMTYPE); - con->first_tree = con->last_tree = NULL; + } - SMB_Get_My_Name(con->myname, sizeof(con->myname)); + /* Init some things ... */ - con->port = 0; /* No port selected */ + strcpy(con -> service, ""); + strcpy(con -> username, ""); + strcpy(con -> password, ""); + strcpy(con -> sock_options, ""); + strcpy(con -> address, ""); + strcpy(con -> desthost, server); + strcpy(con -> PDomain, NTdomain); + strcpy(con -> OSName, SMBLIB_DEFAULT_OSNAME); + strcpy(con -> LMType, SMBLIB_DEFAULT_LMTYPE); + con -> first_tree = con -> last_tree = NULL; - /* Get some things we need for the SMB Header */ + SMB_Get_My_Name(con -> myname, sizeof(con -> myname)); - con->pid = getpid(); - con->mid = con->pid; /* This will do for now ... */ - con->uid = 0; /* Until we have done a logon, no uid ... */ - con->gid = getgid(); + con -> port = 0; /* No port selected */ - /* Now connect to the remote end, but first upper case the name of the - * service we are going to call, sine some servers want it in uppercase */ + /* Get some things we need for the SMB Header */ - for (i = 0; i < strlen(server); i++) - called[i] = toupper(server[i]); + con -> pid = getpid(); + con -> mid = con -> pid; /* This will do for now ... */ + con -> uid = 0; /* Until we have done a logon, no uid ... */ + con -> gid = getgid(); - called[strlen(server)] = 0; /* Make it a string */ + /* Now connect to the remote end, but first upper case the name of the + service we are going to call, sine some servers want it in uppercase */ - for (i = 0; i < strlen(con->myname); i++) - calling[i] = toupper(con->myname[i]); + for (i=0; i < strlen(server); i++) + called[i] = toupper(server[i]); + + called[strlen(server)] = 0; /* Make it a string */ - calling[strlen(con->myname)] = 0; /* Make it a string */ + for (i=0; i < strlen(con -> myname); i++) + calling[i] = toupper(con -> myname[i]); + + calling[strlen(con -> myname)] = 0; /* Make it a string */ - if (strcmp(con->address, "") == 0) - address = con->desthost; - else - address = con->address; + if (strcmp(con -> address, "") == 0) + address = con -> desthost; + else + address = con -> address; - con->Trans_Connect = RFCNB_Call(called, calling, address, /* Protocol specific */ - con->port); + con -> Trans_Connect = RFCNB_Call(called, + calling, + address, /* Protocol specific */ + con -> port); - /* Did we get one? */ + /* Did we get one? */ - if (con->Trans_Connect == NULL) { - - if (Con_Handle == NULL) { - Con_Handle = NULL; - free(con); - } - SMBlib_errno = -SMBlibE_CallFailed; - return NULL; + if (con -> Trans_Connect == NULL) { + if (Con_Handle == NULL) { + Con_Handle = NULL; + free(con); } + SMBlib_errno = -SMBlibE_CallFailed; + return NULL; + + } - return (con); + return(con); } @@ -191,361 +193,366 @@ /* If Con_Handle == NULL then create a handle and connect, otherwise */ /* use the handle passed */ -char *SMB_Prots_Restrict[] = { "PC NETWORK PROGRAM 1.0", - NULL -}; - - -SMB_Handle_Type -SMB_Connect(SMB_Handle_Type Con_Handle, -SMB_Tree_Handle * tree, char *service, char *username, char *password) - { - SMB_Handle_Type con; - char *host, *address; - char temp[80], called[80], calling[80]; - int i; +char *SMB_Prots_Restrict[] = {"PC NETWORK PROGRAM 1.0", + NULL}; - /* Get a connection structure if one does not exist */ - con = Con_Handle; +SMB_Handle_Type SMB_Connect(SMB_Handle_Type Con_Handle, + SMB_Tree_Handle *tree, + char *service, + char *username, + char *password) - if (Con_Handle == NULL) { +{ SMB_Handle_Type con; + char *host, *address; + char temp[80], called[80], calling[80]; + int i; - if ((con = - (struct SMB_Connect_Def *) malloc(sizeof(struct - SMB_Connect_Def))) == NULL) { - - SMBlib_errno = SMBlibE_NoSpace; - return NULL; - } + /* Get a connection structure if one does not exist */ - } + con = Con_Handle; - /* Init some things ... */ + if (Con_Handle == NULL) { - strcpy(con->service, service); - strcpy(con->username, username); - strcpy(con->password, password); - strcpy(con->sock_options, ""); - strcpy(con->address, ""); - strcpy(con->PDomain, SMBLIB_DEFAULT_DOMAIN); - strcpy(con->OSName, SMBLIB_DEFAULT_OSNAME); - strcpy(con->LMType, SMBLIB_DEFAULT_LMTYPE); - con->first_tree = con->last_tree = NULL; + if ((con = (struct SMB_Connect_Def *)malloc(sizeof(struct SMB_Connect_Def))) == NULL) { - SMB_Get_My_Name(con->myname, sizeof(con->myname)); + SMBlib_errno = SMBlibE_NoSpace; + return NULL; + } + + } - con->port = 0; /* No port selected */ + /* Init some things ... */ - /* Get some things we need for the SMB Header */ + strcpy(con -> service, service); + strcpy(con -> username, username); + strcpy(con -> password, password); + strcpy(con -> sock_options, ""); + strcpy(con -> address, ""); + strcpy(con -> PDomain, SMBLIB_DEFAULT_DOMAIN); + strcpy(con -> OSName, SMBLIB_DEFAULT_OSNAME); + strcpy(con -> LMType, SMBLIB_DEFAULT_LMTYPE); + con -> first_tree = con -> last_tree = NULL; - con->pid = getpid(); - con->mid = con->pid; /* This will do for now ... */ - con->uid = 0; /* Until we have done a logon, no uid */ - con->gid = getgid(); + SMB_Get_My_Name(con -> myname, sizeof(con -> myname)); - /* Now figure out the host portion of the service */ + con -> port = 0; /* No port selected */ - strcpy(temp, service); - host = strtok(temp, "/\\"); /* Separate host name portion */ - strcpy(con->desthost, host); + /* Get some things we need for the SMB Header */ - /* Now connect to the remote end, but first upper case the name of the - * service we are going to call, sine some servers want it in uppercase */ + con -> pid = getpid(); + con -> mid = con -> pid; /* This will do for now ... */ + con -> uid = 0; /* Until we have done a logon, no uid */ + con -> gid = getgid(); - for (i = 0; i < strlen(host); i++) - called[i] = toupper(host[i]); + /* Now figure out the host portion of the service */ - called[strlen(host)] = 0; /* Make it a string */ + strcpy(temp, service); + host = strtok(temp, "/\\"); /* Separate host name portion */ + strcpy(con -> desthost, host); - for (i = 0; i < strlen(con->myname); i++) - calling[i] = toupper(con->myname[i]); + /* Now connect to the remote end, but first upper case the name of the + service we are going to call, sine some servers want it in uppercase */ - calling[strlen(con->myname)] = 0; /* Make it a string */ + for (i=0; i < strlen(host); i++) + called[i] = toupper(host[i]); + + called[strlen(host)] = 0; /* Make it a string */ - if (strcmp(con->address, "") == 0) - address = con->desthost; - else - address = con->address; + for (i=0; i < strlen(con -> myname); i++) + calling[i] = toupper(con -> myname[i]); + + calling[strlen(con -> myname)] = 0; /* Make it a string */ - con->Trans_Connect = RFCNB_Call(called, calling, address, /* Protocol specific */ - con->port); + if (strcmp(con -> address, "") == 0) + address = con -> desthost; + else + address = con -> address; - /* Did we get one? */ + con -> Trans_Connect = RFCNB_Call(called, + calling, + address, /* Protocol specific */ + con -> port); - if (con->Trans_Connect == NULL) { + /* Did we get one? */ - if (Con_Handle == NULL) { - free(con); - Con_Handle = NULL; - } - SMBlib_errno = -SMBlibE_CallFailed; - return NULL; + if (con -> Trans_Connect == NULL) { + if (Con_Handle == NULL) { + free(con); + Con_Handle = NULL; } + SMBlib_errno = -SMBlibE_CallFailed; + return NULL; - /* Now, negotiate the protocol */ + } - if (SMB_Negotiate(con, SMB_Prots_Restrict) < 0) { + /* Now, negotiate the protocol */ - /* Hmmm what should we do here ... We have a connection, but could not - * negotiate ... */ + if (SMB_Negotiate(con, SMB_Prots_Restrict) < 0) { - return NULL; + /* Hmmm what should we do here ... We have a connection, but could not + negotiate ... */ - } + return NULL; - /* Now connect to the service ... */ + } - if ((*tree = SMB_TreeConnect(con, NULL, service, password, "A:")) == NULL) { + /* Now connect to the service ... */ - return NULL; + if ((*tree = SMB_TreeConnect(con, NULL, service, password, "A:")) == NULL) { - } + return NULL; + + } - return (con); + return(con); } /* Logon to the server. That is, do a session setup if we can. We do not do */ /* Unicode yet! */ -int -SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName, char *PassWord) -{ - struct RFCNB_Pkt *pkt; - int param_len, i, pkt_len, pass_len, a; - char *p, pword[128]; - - /* First we need a packet etc ... but we need to know what protocol has */ - /* been negotiated to figure out if we can do it and what SMB format to */ - /* use ... */ +int SMB_Logon_Server(SMB_Handle_Type Con_Handle, char *UserName, + char *PassWord) - if (Con_Handle->protocol < SMB_P_LanMan1) { +{ struct RFCNB_Pkt *pkt; + int param_len, i, pkt_len, pass_len,a; + char *p, pword[128]; - SMBlib_errno = SMBlibE_ProtLow; - return (SMBlibE_BAD); + /* First we need a packet etc ... but we need to know what protocol has */ + /* been negotiated to figure out if we can do it and what SMB format to */ + /* use ... */ - } + if (Con_Handle -> protocol < SMB_P_LanMan1) { + + SMBlib_errno = SMBlibE_ProtLow; + return(SMBlibE_BAD); - strcpy(pword, PassWord); + } + + strcpy(pword, PassWord); #ifdef PAM_SMB_ENC_PASS - if (Con_Handle->encrypt_passwords) { - pass_len = 24; - SMBencrypt((uchar *) PassWord, (uchar *) Con_Handle->Encrypt_Key, - (uchar *) pword); - } else + if (Con_Handle -> encrypt_passwords) + { + pass_len=24; + SMBencrypt((uchar *) PassWord, (uchar *)Con_Handle -> Encrypt_Key,(uchar *)pword); + } + else #endif - pass_len = strlen(pword); + pass_len=strlen(pword); - /* Now build the correct structure */ + /* Now build the correct structure */ - if (Con_Handle->protocol < SMB_P_NT1) { + if (Con_Handle -> protocol < SMB_P_NT1) { - param_len = strlen(UserName) + 1 + pass_len + 1 + - strlen(Con_Handle->PDomain) + 1 + strlen(Con_Handle->OSName) + 1; + param_len = strlen(UserName) + 1 + pass_len + 1 + + strlen(Con_Handle -> PDomain) + 1 + + strlen(Con_Handle -> OSName) + 1; - pkt_len = SMB_ssetpLM_len + param_len; + pkt_len = SMB_ssetpLM_len + param_len; - pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(pkt_len); + pkt = (struct RFCNB_Pkt *)RFCNB_Alloc_Pkt(pkt_len); - if (pkt == NULL) { + if (pkt == NULL) { - SMBlib_errno = SMBlibE_NoSpace; - return (SMBlibE_BAD); /* Should handle the error */ + SMBlib_errno = SMBlibE_NoSpace; + return(SMBlibE_BAD); /* Should handle the error */ - } + } - bzero(SMB_Hdr(pkt), SMB_ssetpLM_len); - SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ - *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBsesssetupX; - SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle->pid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid); - *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 10; - *(SMB_Hdr(pkt) + SMB_hdr_axc_offset) = 0xFF; /* No extra command */ - SSVAL(SMB_Hdr(pkt), SMB_hdr_axo_offset, 0); + bzero(SMB_Hdr(pkt), SMB_ssetpLM_len); + SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ + *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBsesssetupX; + SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle -> pid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle -> mid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle -> uid); + *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 10; + *(SMB_Hdr(pkt) + SMB_hdr_axc_offset) = 0xFF; /* No extra command */ + SSVAL(SMB_Hdr(pkt), SMB_hdr_axo_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_mbs_offset, SMBLIB_MAX_XMIT); - SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_mmc_offset, 2); - SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_vcn_offset, Con_Handle->pid); - SIVAL(SMB_Hdr(pkt), SMB_ssetpLM_snk_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_pwl_offset, pass_len + 1); - SIVAL(SMB_Hdr(pkt), SMB_ssetpLM_res_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_bcc_offset, param_len); + SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_mbs_offset, SMBLIB_MAX_XMIT); + SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_mmc_offset, 2); + SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_vcn_offset, Con_Handle -> pid); + SIVAL(SMB_Hdr(pkt), SMB_ssetpLM_snk_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_pwl_offset, pass_len + 1); + SIVAL(SMB_Hdr(pkt), SMB_ssetpLM_res_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_ssetpLM_bcc_offset, param_len); - /* Now copy the param strings in with the right stuff */ + /* Now copy the param strings in with the right stuff */ - p = (char *) (SMB_Hdr(pkt) + SMB_ssetpLM_buf_offset); + p = (char *)(SMB_Hdr(pkt) + SMB_ssetpLM_buf_offset); - /* Copy in password, then the rest. Password has a null at end */ + /* Copy in password, then the rest. Password has a null at end */ - memcpy(p, pword, pass_len); + memcpy(p, pword, pass_len); - p = p + pass_len + 1; + p = p + pass_len + 1; - strcpy(p, UserName); - p = p + strlen(UserName); - *p = 0; + strcpy(p, UserName); + p = p + strlen(UserName); + *p = 0; - p = p + 1; + p = p + 1; - strcpy(p, Con_Handle->PDomain); - p = p + strlen(Con_Handle->PDomain); - *p = 0; - p = p + 1; + strcpy(p, Con_Handle -> PDomain); + p = p + strlen(Con_Handle -> PDomain); + *p = 0; + p = p + 1; - strcpy(p, Con_Handle->OSName); - p = p + strlen(Con_Handle->OSName); - *p = 0; + strcpy(p, Con_Handle -> OSName); + p = p + strlen(Con_Handle -> OSName); + *p = 0; - } else { + } + else { - /* We don't admit to UNICODE support ... */ + /* We don't admit to UNICODE support ... */ - param_len = strlen(UserName) + 1 + pass_len + - strlen(Con_Handle->PDomain) + 1 + - strlen(Con_Handle->OSName) + 1 + strlen(Con_Handle->LMType) + 1; + param_len = strlen(UserName) + 1 + pass_len + + strlen(Con_Handle -> PDomain) + 1 + + strlen(Con_Handle -> OSName) + 1 + + strlen(Con_Handle -> LMType) + 1; - pkt_len = SMB_ssetpNTLM_len + param_len; + pkt_len = SMB_ssetpNTLM_len + param_len; - pkt = (struct RFCNB_Pkt *) RFCNB_Alloc_Pkt(pkt_len); + pkt = (struct RFCNB_Pkt *)RFCNB_Alloc_Pkt(pkt_len); - if (pkt == NULL) { + if (pkt == NULL) { - SMBlib_errno = SMBlibE_NoSpace; - return (-1); /* Should handle the error */ + SMBlib_errno = SMBlibE_NoSpace; + return(-1); /* Should handle the error */ - } + } - bzero(SMB_Hdr(pkt), SMB_ssetpNTLM_len); - SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ - *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBsesssetupX; - SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle->pid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle->mid); - SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle->uid); - *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 13; - *(SMB_Hdr(pkt) + SMB_hdr_axc_offset) = 0xFF; /* No extra command */ - SSVAL(SMB_Hdr(pkt), SMB_hdr_axo_offset, 0); + bzero(SMB_Hdr(pkt), SMB_ssetpNTLM_len); + SIVAL(SMB_Hdr(pkt), SMB_hdr_idf_offset, SMB_DEF_IDF); /* Plunk in IDF */ + *(SMB_Hdr(pkt) + SMB_hdr_com_offset) = SMBsesssetupX; + SSVAL(SMB_Hdr(pkt), SMB_hdr_pid_offset, Con_Handle -> pid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_tid_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_hdr_mid_offset, Con_Handle -> mid); + SSVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset, Con_Handle -> uid); + *(SMB_Hdr(pkt) + SMB_hdr_wct_offset) = 13; + *(SMB_Hdr(pkt) + SMB_hdr_axc_offset) = 0xFF; /* No extra command */ + SSVAL(SMB_Hdr(pkt), SMB_hdr_axo_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_mbs_offset, SMBLIB_MAX_XMIT); - SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_mmc_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_vcn_offset, 0); - SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_snk_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cipl_offset, pass_len); - SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cspl_offset, 0); - SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_res_offset, 0); - SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cap_offset, 0); - SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_bcc_offset, param_len); + SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_mbs_offset, SMBLIB_MAX_XMIT); + SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_mmc_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_vcn_offset, 0); + SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_snk_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cipl_offset, pass_len); + SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cspl_offset, 0); + SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_res_offset, 0); + SIVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_cap_offset, 0); + SSVAL(SMB_Hdr(pkt), SMB_ssetpNTLM_bcc_offset, param_len); - /* Now copy the param strings in with the right stuff */ + /* Now copy the param strings in with the right stuff */ - p = (char *) (SMB_Hdr(pkt) + SMB_ssetpNTLM_buf_offset); + p = (char *)(SMB_Hdr(pkt) + SMB_ssetpNTLM_buf_offset); - /* Copy in password, then the rest. Password has no null at end */ + /* Copy in password, then the rest. Password has no null at end */ - memcpy(p, pword, pass_len); + memcpy(p, pword, pass_len); - p = p + pass_len; + p = p + pass_len; - strcpy(p, UserName); - p = p + strlen(UserName); - *p = 0; + strcpy(p, UserName); + p = p + strlen(UserName); + *p = 0; - p = p + 1; + p = p + 1; - strcpy(p, Con_Handle->PDomain); - p = p + strlen(Con_Handle->PDomain); - *p = 0; - p = p + 1; + strcpy(p, Con_Handle -> PDomain); + p = p + strlen(Con_Handle -> PDomain); + *p = 0; + p = p + 1; - strcpy(p, Con_Handle->OSName); - p = p + strlen(Con_Handle->OSName); - *p = 0; - p = p + 1; + strcpy(p, Con_Handle -> OSName); + p = p + strlen(Con_Handle -> OSName); + *p = 0; + p = p + 1; - strcpy(p, Con_Handle->LMType); - p = p + strlen(Con_Handle->LMType); - *p = 0; + strcpy(p, Con_Handle -> LMType); + p = p + strlen(Con_Handle -> LMType); + *p = 0; - } + } - /* Now send it and get a response */ + /* Now send it and get a response */ - if (RFCNB_Send(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) { + if (RFCNB_Send(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0){ #ifdef DEBUG - fprintf(stderr, "Error sending SessSetupX request\n"); + fprintf(stderr, "Error sending SessSetupX request\n"); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_SendFailed; - return (SMBlibE_BAD); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_SendFailed; + return(SMBlibE_BAD); - } + } - /* Now get the response ... */ + /* Now get the response ... */ - if (RFCNB_Recv(Con_Handle->Trans_Connect, pkt, pkt_len) < 0) { + if (RFCNB_Recv(Con_Handle -> Trans_Connect, pkt, pkt_len) < 0) { #ifdef DEBUG - fprintf(stderr, "Error receiving response to SessSetupAndX\n"); + fprintf(stderr, "Error receiving response to SessSetupAndX\n"); #endif - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_RecvFailed; - return (SMBlibE_BAD); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_RecvFailed; + return(SMBlibE_BAD); - } + } - /* Check out the response type ... */ + /* Check out the response type ... */ - if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ + if (CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset) != SMBC_SUCCESS) { /* Process error */ #ifdef DEBUG - fprintf(stderr, - "SMB_SessSetupAndX failed with errorclass = %i, Error Code = %i\n", - CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), SVAL(SMB_Hdr(pkt), - SMB_hdr_err_offset)); + fprintf(stderr, "SMB_SessSetupAndX failed with errorclass = %i, Error Code = %i\n", + CVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset), + SVAL(SMB_Hdr(pkt), SMB_hdr_err_offset)); #endif - SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); - RFCNB_Free_Pkt(pkt); - SMBlib_errno = SMBlibE_Remote; - return (SMBlibE_BAD); + SMBlib_SMB_Error = IVAL(SMB_Hdr(pkt), SMB_hdr_rcls_offset); + RFCNB_Free_Pkt(pkt); + SMBlib_errno = SMBlibE_Remote; + return(SMBlibE_BAD); + + } - } #ifdef DEBUG - fprintf(stderr, "SessSetupAndX response. Action = %i\n", - SVAL(SMB_Hdr(pkt), SMB_ssetpr_act_offset)); + fprintf(stderr, "SessSetupAndX response. Action = %i\n", + SVAL(SMB_Hdr(pkt), SMB_ssetpr_act_offset)); #endif - /* Now pick up the UID for future reference ... */ + /* Now pick up the UID for future reference ... */ - Con_Handle->uid = SVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset); - RFCNB_Free_Pkt(pkt); + Con_Handle -> uid = SVAL(SMB_Hdr(pkt), SMB_hdr_uid_offset); + RFCNB_Free_Pkt(pkt); - return (0); + return(0); } /* Disconnect from the server, and disconnect all tree connects */ -int -SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle) +int SMB_Discon(SMB_Handle_Type Con_Handle, BOOL KeepHandle) + { - /* We just disconnect the connection for now ... */ + /* We just disconnect the connection for now ... */ - RFCNB_Hangup(Con_Handle->Trans_Connect); + RFCNB_Hangup(Con_Handle -> Trans_Connect); - if (!KeepHandle) - free(Con_Handle); + if (!KeepHandle) + free(Con_Handle); - return (0); + return(0); } Index: squid/auth_modules/MSNT/smblib.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/smblib.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/smblib.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/smblib.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,4 +1,5 @@ /* UNIX SMBlib NetBIOS implementation + Version 1.0 SMBlib Defines @@ -38,8 +39,8 @@ /* Connect to a server and give us back a handle. If Con == NULL, create */ /* The handle and populate it with defaults */ -void *SMB_Connect(void *Con, void **tree, - char *name, char *User, char *Password); +void *SMB_Connect(void *Con, void **tree, + char *name, char *User, char *Password); /* Negotiate a protocol */ @@ -47,8 +48,8 @@ /* Connect to a tree ... */ -void *SMB_TreeConnect(void *con_handle, void *tree_handle, - char *path, char *password, char *dev); +void *SMB_TreeConnect(void *con_handle, void *tree_handle, + char *path, char *password, char *dev); /* Disconnect a tree ... */ @@ -57,8 +58,10 @@ /* Open a file */ void *SMB_Open(void *tree_handle, - void *file_handle, - char *file_name, unsigned short mode, unsigned short search); + void *file_handle, + char *file_name, + unsigned short mode, + unsigned short search); /* Close a file */ @@ -70,7 +73,9 @@ int SMB_Discon(void *Con, BOOL KeepHandle); void *SMB_Create(void *Tree_Handle, - void *File_Handle, char *file_name, short search); + void *File_Handle, + char *file_name, + short search); int SMB_Delete(void *tree, char *file_name, short search); @@ -87,6 +92,6 @@ int SMB_Get_Error_Msg(int msg, char *msgbuf, int len); void *SMB_Logon_And_TCon(void *con, void *tree, char *user, char *pass, - char *service, char *st); + char *service, char *st); #define SMBLIB_DEFAULT_DOMAIN "anydom" Index: squid/auth_modules/MSNT/std-defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/std-defines.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/std-defines.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/std-defines.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,5 +1,6 @@ /* RFCNB Standard includes ... */ /* + SMBlib Standard Includes Copyright (C) 1996, Richard Sharpe Index: squid/auth_modules/MSNT/std-includes.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/std-includes.h,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/std-includes.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/std-includes.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -1,5 +1,6 @@ /* RFCNB Standard includes ... */ /* + RFCNB Standard Includes Copyright (C) 1996, Richard Sharpe Index: squid/auth_modules/MSNT/valid.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/valid.c,v retrieving revision 1.1.1.1.30.1 retrieving revision 1.1.1.1.30.2 diff -u -r1.1.1.1.30.1 -r1.1.1.1.30.2 --- squid/auth_modules/MSNT/valid.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.30.1 +++ squid/auth_modules/MSNT/valid.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.30.2 @@ -4,39 +4,36 @@ #include "smblib.h" #include "valid.h" -int -Valid_User(char *USERNAME, char *PASSWORD, char *SERVER, char *BACKUP, - char *DOMAIN) +int Valid_User(char *USERNAME,char *PASSWORD,char *SERVER,char *BACKUP, char *DOMAIN) { - char *SMB_Prots[] = { "PC NETWORK PROGRAM 1.0", - "MICROSOFT NETWORKS 1.03", - "MICROSOFT NETWORKS 3.0", - "LANMAN1.0", - "LM1.2X002", - "Samba", - "NT LM 0.12", - "NT LANMAN 1.0", - NULL - }; - void *con; + char *SMB_Prots[] = {"PC NETWORK PROGRAM 1.0", + "MICROSOFT NETWORKS 1.03", + "MICROSOFT NETWORKS 3.0", + "LANMAN1.0", + "LM1.2X002", + "Samba", + "NT LM 0.12", + "NT LANMAN 1.0", + NULL}; + void *con; - SMB_Init(); - con = SMB_Connect_Server(NULL, SERVER, DOMAIN); - if (con == NULL) { /* Error ... */ - con = SMB_Connect_Server(NULL, BACKUP, DOMAIN); - if (con == NULL) { - return (NTV_SERVER_ERROR); - } - } - if (SMB_Negotiate(con, SMB_Prots) < 0) { /* An error */ - SMB_Discon(con, 0); - return (NTV_PROTOCOL_ERROR); - } - if (SMB_Logon_Server(con, USERNAME, PASSWORD) < 0) { - SMB_Discon(con, 0); - return (NTV_LOGON_ERROR); - } - - SMB_Discon(con, 0); - return (NTV_NO_ERROR); + SMB_Init(); + con = SMB_Connect_Server(NULL, SERVER, DOMAIN); + if (con == NULL) { /* Error ... */ + con = SMB_Connect_Server(NULL, BACKUP, DOMAIN); + if (con == NULL) { + return(NTV_SERVER_ERROR); + } + } + if (SMB_Negotiate(con, SMB_Prots) < 0) { /* An error */ + SMB_Discon(con,0); + return(NTV_PROTOCOL_ERROR); + } + if (SMB_Logon_Server(con, USERNAME, PASSWORD) < 0) { + SMB_Discon(con,0); + return(NTV_LOGON_ERROR); + } + + SMB_Discon(con,0); + return(NTV_NO_ERROR); } Index: squid/auth_modules/MSNT/valid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/valid.h,v retrieving revision 1.1.1.1.62.1 retrieving revision 1.1.1.1.62.2 diff -u -r1.1.1.1.62.1 -r1.1.1.1.62.2 --- squid/auth_modules/MSNT/valid.h 27 Aug 2001 21:48:15 -0000 1.1.1.1.62.1 +++ squid/auth_modules/MSNT/valid.h 9 Sep 2001 09:33:20 -0000 1.1.1.1.62.2 @@ -7,7 +7,6 @@ #define NTV_PROTOCOL_ERROR 2 #define NTV_LOGON_ERROR 3 -int Valid_User(char *USERNAME, char *PASSWORD, char *SERVER, char *BACKUP, - char *DOMAIN); +int Valid_User(char *USERNAME,char *PASSWORD,char *SERVER, char *BACKUP, char *DOMAIN); #endif Index: squid/auth_modules/PAM/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/PAM/Attic/Makefile.in,v retrieving revision 1.1.1.1.22.1.2.1 retrieving revision 1.1.1.1.22.1.2.2 diff -u -r1.1.1.1.22.1.2.1 -r1.1.1.1.22.1.2.2 --- squid/auth_modules/PAM/Makefile.in 27 Aug 2001 21:48:15 -0000 1.1.1.1.22.1.2.1 +++ squid/auth_modules/PAM/Makefile.in 9 Sep 2001 09:33:20 -0000 1.1.1.1.22.1.2.2 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.1.1.1.22.1.2.1 2001/08/27 21:48:15 tolsty Exp $ +# $Id: Makefile.in,v 1.1.1.1.22.1.2.2 2001/09/09 09:33:20 serassio Exp $ # # Uncomment and customize the following to suit your needs: # Index: squid/auth_modules/PAM/pam_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/PAM/Attic/pam_auth.c,v retrieving revision 1.1.1.1.18.1.2.1 retrieving revision 1.1.1.1.18.1.2.2 diff -u -r1.1.1.1.18.1.2.1 -r1.1.1.1.18.1.2.2 --- squid/auth_modules/PAM/pam_auth.c 27 Aug 2001 21:48:15 -0000 1.1.1.1.18.1.2.1 +++ squid/auth_modules/PAM/pam_auth.c 9 Sep 2001 09:33:20 -0000 1.1.1.1.18.1.2.2 @@ -1,5 +1,5 @@ /* - * $Id: pam_auth.c,v 1.1.1.1.18.1.2.1 2001/08/27 21:48:15 tolsty Exp $ + * $Id: pam_auth.c,v 1.1.1.1.18.1.2.2 2001/09/09 09:33:20 serassio Exp $ * * PAM authenticator module for Squid. * Copyright (C) 1999 Henrik Nordstrom @@ -71,12 +71,10 @@ * expects a single converstation message of type PAM_PROMPT_ECHO_OFF. */ static int -password_conversation(int num_msg, const struct pam_message **msg, - struct pam_response **resp, void *appdata_ptr) +password_conversation(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { if (num_msg != 1 || msg[0]->msg_style != PAM_PROMPT_ECHO_OFF) { - fprintf(stderr, "ERROR: Unexpected PAM converstaion '%d/%s'\n", - msg[0]->msg_style, msg[0]->msg); + fprintf(stderr, "ERROR: Unexpected PAM converstaion '%d/%s'\n", msg[0]->msg_style, msg[0]->msg); return PAM_CONV_ERR; } if (!appdata_ptr) { @@ -86,8 +84,7 @@ appdata_ptr = password; } if (!appdata_ptr) { - fprintf(stderr, - "ERROR: No password available to password_converstation!\n"); + fprintf(stderr, "ERROR: No password available to password_converstation!\n"); return PAM_CONV_ERR; } *resp = calloc(num_msg, sizeof(struct pam_response)); @@ -101,7 +98,8 @@ return ((*resp)[0].resp ? PAM_SUCCESS : PAM_CONV_ERR); } -static struct pam_conv conv = { +static struct pam_conv conv = +{ &password_conversation, NULL }; Index: squid/auth_modules/SMB/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/SMB/Attic/Makefile.in,v retrieving revision 1.1.1.1.20.1.2.1 retrieving revision 1.1.1.1.20.1.2.2 diff -u -r1.1.1.1.20.1.2.1 -r1.1.1.1.20.1.2.2 --- squid/auth_modules/SMB/Makefile.in 27 Aug 2001 21:48:15 -0000 1.1.1.1.20.1.2.1 +++ squid/auth_modules/SMB/Makefile.in 9 Sep 2001 09:33:21 -0000 1.1.1.1.20.1.2.2 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.1.1.1.20.1.2.1 2001/08/27 21:48:15 tolsty Exp $ +# $Id: Makefile.in,v 1.1.1.1.20.1.2.2 2001/09/09 09:33:21 serassio Exp $ # # Uncomment and customize the following to suit your needs: # Index: squid/auth_modules/SMB/smb_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/SMB/Attic/smb_auth.c,v retrieving revision 1.1.1.2.28.1 retrieving revision 1.1.1.2.28.2 diff -u -r1.1.1.2.28.1 -r1.1.1.2.28.2 --- squid/auth_modules/SMB/smb_auth.c 27 Aug 2001 21:48:15 -0000 1.1.1.2.28.1 +++ squid/auth_modules/SMB/smb_auth.c 9 Sep 2001 09:33:21 -0000 1.1.1.2.28.2 @@ -27,14 +27,14 @@ struct SMBDOMAIN { - char *name; /* domain name */ - char *sname; /* match this with user input */ - char *passthrough; /* pass-through authentication */ - char *nmbaddr; /* name service address */ - int nmbcast; /* broadcast or unicast */ - char *authshare; /* share name of auth file */ - char *authfile; /* pathname of auth file */ - struct SMBDOMAIN *next; /* linked list */ + char *name; /* domain name */ + char *sname; /* match this with user input */ + char *passthrough; /* pass-through authentication */ + char *nmbaddr; /* name service address */ + int nmbcast; /* broadcast or unicast */ + char *authshare; /* share name of auth file */ + char *authfile; /* pathname of auth file */ + struct SMBDOMAIN *next; /* linked list */ }; struct SMBDOMAIN *firstdom = NULL; @@ -45,199 +45,217 @@ * to the read command of the bourne shell. */ -void -print_esc(FILE * p, char *s) +void print_esc(FILE *p, char *s) { - char buf[256]; - char *t; - int i = 0; - - for (t = s; *t != '\0'; t++) { - if (i > 250) { - buf[i] = '\0'; - (void) fputs(buf, p); - i = 0; - } + char buf[256]; + char *t; + int i = 0; + + for (t = s; *t != '\0'; t++) + { + if (i > 250) + { + buf[i] = '\0'; + (void) fputs(buf, p); + i = 0; + } - if (*t == '\\') - buf[i++] = '\\'; + if (*t == '\\') + buf[i++] = '\\'; - buf[i++] = *t; - } + buf[i++] = *t; + } - if (i > 0) { - buf[i] = '\0'; - (void) fputs(buf, p); - } + if (i > 0) + { + buf[i] = '\0'; + (void) fputs(buf, p); + } } -void -main(int argc, char *argv[]) +void main(int argc, char *argv[]) { - int i; - char buf[BUFSIZE]; - struct SMBDOMAIN *dom; - char *s; - char *user; - char *pass; - char *domname; - FILE *p; - int debug = 0; - char *shcmd; - - /* make standard output line buffered */ - if (setvbuf(stdout, NULL, _IOLBF, 0) != 0) - return; - - /* parse command line arguments */ - for (i = 1; i < argc; i++) { - if (strcmp(argv[i], "-d") == 0) { - debug = 1; - continue; - } + int i; + char buf[BUFSIZE]; + struct SMBDOMAIN *dom; + char *s; + char *user; + char *pass; + char *domname; + FILE *p; + int debug = 0; + char *shcmd; + + /* make standard output line buffered */ + if (setvbuf(stdout, NULL, _IOLBF, 0) != 0) + return; + + /* parse command line arguments */ + for (i = 1; i < argc; i++) + { + if (strcmp(argv[i], "-d") == 0) + { + debug = 1; + continue; + } - /* the next options require an argument */ - if (i + 1 == argc) - break; - - if (strcmp(argv[i], "-W") == 0) { - if ((dom = - (struct SMBDOMAIN *) malloc(sizeof(struct SMBDOMAIN))) == - NULL) return; - - dom->name = dom->sname = argv[++i]; - dom->passthrough = ""; - dom->nmbaddr = ""; - dom->nmbcast = NMB_BROADCAST; - dom->authshare = "NETLOGON"; - dom->authfile = "proxyauth"; - dom->next = NULL; - - /* append to linked list */ - if (lastdom != NULL) - lastdom->next = dom; - else - firstdom = dom; + /* the next options require an argument */ + if (i + 1 == argc) + break; + + if (strcmp(argv[i], "-W") == 0) + { + if ((dom = (struct SMBDOMAIN *) malloc(sizeof(struct SMBDOMAIN))) == NULL) + return; + + dom->name = dom->sname = argv[++i]; + dom->passthrough = ""; + dom->nmbaddr = ""; + dom->nmbcast = NMB_BROADCAST; + dom->authshare = "NETLOGON"; + dom->authfile = "proxyauth"; + dom->next = NULL; + + /* append to linked list */ + if (lastdom != NULL) + lastdom->next = dom; + else + firstdom = dom; - lastdom = dom; - continue; - } + lastdom = dom; + continue; + } - if (strcmp(argv[i], "-w") == 0) { - if (lastdom != NULL) - lastdom->sname = argv[++i]; - continue; - } + if (strcmp(argv[i], "-w") == 0) + { + if (lastdom != NULL) + lastdom->sname = argv[++i]; + continue; + } - if (strcmp(argv[i], "-P") == 0) { - if (lastdom != NULL) - lastdom->passthrough = argv[++i]; - continue; - } + if (strcmp(argv[i], "-P") == 0) + { + if (lastdom != NULL) + lastdom->passthrough = argv[++i]; + continue; + } - if (strcmp(argv[i], "-B") == 0) { - if (lastdom != NULL) { - lastdom->nmbaddr = argv[++i]; - lastdom->nmbcast = NMB_BROADCAST; - } - continue; - } + if (strcmp(argv[i], "-B") == 0) + { + if (lastdom != NULL) + { + lastdom->nmbaddr = argv[++i]; + lastdom->nmbcast = NMB_BROADCAST; + } + continue; + } - if (strcmp(argv[i], "-U") == 0) { - if (lastdom != NULL) { - lastdom->nmbaddr = argv[++i]; - lastdom->nmbcast = NMB_UNICAST; - } - continue; - } + if (strcmp(argv[i], "-U") == 0) + { + if (lastdom != NULL) + { + lastdom->nmbaddr = argv[++i]; + lastdom->nmbcast = NMB_UNICAST; + } + continue; + } - if (strcmp(argv[i], "-S") == 0) { - if (lastdom != NULL) { - if ((lastdom->authshare = strdup(argv[++i])) == NULL) - return; - - /* convert backslashes to forward slashes */ - for (s = lastdom->authshare; *s != '\0'; s++) - if (*s == '\\') - *s = '/'; - - /* strip leading forward slash from share name */ - if (*lastdom->authshare == '/') - lastdom->authshare++; - - if ((s = strchr(lastdom->authshare, '/')) != NULL) { - *s = '\0'; - lastdom->authfile = s + 1; + if (strcmp(argv[i], "-S") == 0) + { + if (lastdom != NULL) + { + if ((lastdom->authshare = strdup(argv[++i])) == NULL) + return; + + /* convert backslashes to forward slashes */ + for (s = lastdom->authshare; *s != '\0'; s++) + if (*s == '\\') + *s = '/'; + + /* strip leading forward slash from share name */ + if (*lastdom->authshare == '/') + lastdom->authshare++; + + if ((s = strchr(lastdom->authshare, '/')) != NULL) + { + *s = '\0'; + lastdom->authfile = s + 1; + } + } + continue; } - } - continue; } - } - shcmd = debug ? HELPERSCRIPT : HELPERSCRIPT " > /dev/null 2>&1"; + shcmd = debug ? HELPERSCRIPT : HELPERSCRIPT " > /dev/null 2>&1"; - /* pass to helper script */ + /* pass to helper script */ if (putenv("SAMBAPREFIX=" SAMBAPREFIX) != 0) - return; + return; - while (1) { - if (fgets(buf, BUFSIZE, stdin) == NULL) - break; - - if ((s = strchr(buf, '\n')) == NULL) - continue; - *s = '\0'; - - if ((s = strchr(buf, ' ')) == NULL) { - (void) printf("ERR\n"); - continue; - } - *s = '\0'; + while (1) + { + if (fgets(buf, BUFSIZE, stdin) == NULL) + break; + + if ((s = strchr(buf, '\n')) == NULL) + continue; + *s = '\0'; + + if ((s = strchr(buf, ' ')) == NULL) + { + (void) printf("ERR\n"); + continue; + } + *s = '\0'; - user = buf; - pass = s + 1; - domname = NULL; - - if ((s = strchr(user, '\\')) != NULL) { - *s = '\0'; - domname = user; - user = s + 1; - } + user = buf; + pass = s + 1; + domname = NULL; + + if ((s = strchr(user, '\\')) != NULL) + { + *s = '\0'; + domname = user; + user = s + 1; + } - /* match domname with linked list */ - if (domname != NULL && strlen(domname) > 0) { - for (dom = firstdom; dom != NULL; dom = dom->next) - if (strcasecmp(dom->sname, domname) == 0) - break; - } else - dom = firstdom; - - if (dom == NULL) { - (void) printf("ERR\n"); - continue; - } + /* match domname with linked list */ + if (domname != NULL && strlen(domname) > 0) + { + for (dom = firstdom; dom != NULL; dom = dom->next) + if (strcasecmp(dom->sname, domname) == 0) + break; + } else + dom = firstdom; + + if (dom == NULL) + { + (void) printf("ERR\n"); + continue; + } - if ((p = popen(shcmd, "w")) == NULL) { - (void) printf("ERR\n"); - continue; - } + if ((p = popen(shcmd, "w")) == NULL) + { + (void) printf("ERR\n"); + continue; + } - (void) fprintf(p, "%s\n", dom->name); - (void) fprintf(p, "%s\n", dom->passthrough); - (void) fprintf(p, "%s\n", dom->nmbaddr); - (void) fprintf(p, "%d\n", dom->nmbcast); - (void) fprintf(p, "%s\n", dom->authshare); - (void) fprintf(p, "%s\n", dom->authfile); - (void) fprintf(p, "%s\n", user); - /* the password can contain special characters */ - print_esc(p, pass); - (void) fputc('\n', p); - (void) fflush(p); - - if (pclose(p) == 0) - (void) printf("OK\n"); - else - (void) printf("ERR\n"); + (void) fprintf(p, "%s\n", dom->name); + (void) fprintf(p, "%s\n", dom->passthrough); + (void) fprintf(p, "%s\n", dom->nmbaddr); + (void) fprintf(p, "%d\n", dom->nmbcast); + (void) fprintf(p, "%s\n", dom->authshare); + (void) fprintf(p, "%s\n", dom->authfile); + (void) fprintf(p, "%s\n", user); + /* the password can contain special characters */ + print_esc(p, pass); + (void) fputc('\n', p); + (void) fflush(p); + + if (pclose(p) == 0) + (void) printf("OK\n"); + else + (void) printf("ERR\n"); - } /* while (1) */ + } /* while (1) */ } Index: squid/auth_modules/getpwnam/Makefile.in =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/getpwnam/Attic/Makefile.in,v retrieving revision 1.1.1.2.30.1.2.1 retrieving revision 1.1.1.2.30.1.2.2 diff -u -r1.1.1.2.30.1.2.1 -r1.1.1.2.30.1.2.2 --- squid/auth_modules/getpwnam/Makefile.in 27 Aug 2001 21:48:16 -0000 1.1.1.2.30.1.2.1 +++ squid/auth_modules/getpwnam/Makefile.in 9 Sep 2001 09:33:21 -0000 1.1.1.2.30.1.2.2 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.1.1.2.30.1.2.1 2001/08/27 21:48:16 tolsty Exp $ +# $Id: Makefile.in,v 1.1.1.2.30.1.2.2 2001/09/09 09:33:21 serassio Exp $ # # Uncomment and customize the following to suit your needs: # Index: squid/auth_modules/getpwnam/getpwnam_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/getpwnam/Attic/getpwnam_auth.c,v retrieving revision 1.1.1.1.72.1 retrieving revision 1.1.1.1.72.2 diff -u -r1.1.1.1.72.1 -r1.1.1.1.72.2 --- squid/auth_modules/getpwnam/getpwnam_auth.c 27 Aug 2001 21:48:16 -0000 1.1.1.1.72.1 +++ squid/auth_modules/getpwnam/getpwnam_auth.c 9 Sep 2001 09:33:21 -0000 1.1.1.1.72.2 @@ -44,7 +44,7 @@ #define ERR "ERR\n" #define OK "OK\n" -int +int main() { char buf[256];