[pubcookie-dev] WEBISO CVS update: ryanc; PubCookieFilter.h,1.1.2.7,1.1.2.8 PubCookieFilter.opt,1.1.2.10,1.1.2.11

Ryan Campbell ryanc at cac.washington.edu
Fri Mar 28 13:48:28 PST 2003


Update of /usr/local/cvsroot/webiso/pubcookie/src/Win32
 In directory webiso-cvs.cac.washington.edu:/var/tmp/cvs-serv13062/Win32
 
 Modified Files:
       Tag: uwash-stable
 	PubCookieFilter.cpp PubCookieFilter.h PubCookieFilter.opt 
 Log Message:
 2.7.8
 Added pubcookie username to IIS log
 This required using pFC->Allocmem, may have performance issue
 



Index: webiso/pubcookie/src/Win32/PubCookieFilter.cpp
diff -c webiso/pubcookie/src/Win32/PubCookieFilter.cpp:1.2.2.9 webiso/pubcookie/src/Win32/PubCookieFilter.cpp:1.2.2.10
*** webiso/pubcookie/src/Win32/PubCookieFilter.cpp:1.2.2.9	Fri Dec 20 13:26:18 2002
--- webiso/pubcookie/src/Win32/PubCookieFilter.cpp	Fri Mar 28 13:48:26 2003
***************
*** 1499,1505 ****
  					  SF_NOTIFY_NONSECURE_PORT      |
  //					  SF_NOTIFY_READ_RAW_DATA       | // Only for Global Filters
  					  SF_NOTIFY_PREPROC_HEADERS     | // ** Needed
! 					  SF_NOTIFY_URL_MAP             |
  					  SF_NOTIFY_AUTHENTICATION      | // ** Needed
  					  SF_NOTIFY_ACCESS_DENIED       |
  					  SF_NOTIFY_SEND_RESPONSE       |
--- 1499,1505 ----
  					  SF_NOTIFY_NONSECURE_PORT      |
  //					  SF_NOTIFY_READ_RAW_DATA       | // Only for Global Filters
  					  SF_NOTIFY_PREPROC_HEADERS     | // ** Needed
! //					  SF_NOTIFY_URL_MAP             |
  					  SF_NOTIFY_AUTHENTICATION      | // ** Needed
  					  SF_NOTIFY_ACCESS_DENIED       |
  					  SF_NOTIFY_SEND_RESPONSE       |
***************
*** 1576,1583 ****
  		return SF_STATUS_REQ_FINISHED;
  	}
  
! 	pFC->pFilterContext = pbc_malloc(sizeof(pubcookie_dir_rec));
! 	//		(VOID*) pFC->AllocMem(pFC,sizeof(pubcookie_dir_rec),0);
  
  	if (!pFC->pFilterContext) {
  		sprintf(szBuff,"[PBC_OnPreprocHeaders] Error allocating memory");
--- 1576,1583 ----
  		return SF_STATUS_REQ_FINISHED;
  	}
  
! 	//pFC->pFilterContext = pbc_malloc(sizeof(pubcookie_dir_rec));
! 	pFC->pFilterContext = (pubcookie_dir_rec *)pFC->AllocMem(pFC,sizeof(pubcookie_dir_rec),0);
  
  	if (!pFC->pFilterContext) {
  		sprintf(szBuff,"[PBC_OnPreprocHeaders] Error allocating memory");
***************
*** 1888,1919 ****
  		DebugMsg((DEST,"PBC_OnEndOfRequest\n"));
  	}
  			
- 	// OnEndOfNetSession is not called consistantly for each request,
- 	// free here instead.
- 	// Assumes we don't need this structure in OnLog below
- 	
- 	pbc_free(pFC->pFilterContext);
- 
- 	pFC->pFilterContext = NULL;   // Force to Null so we don't try to free twice
  
  	return SF_STATUS_REQ_NEXT_NOTIFICATION;
  
  }  /* OnEndOfRequest */
  
  
  DWORD OnLog (HTTP_FILTER_CONTEXT* pFC, 
  		  	 HTTP_FILTER_LOG* pLogInfo)
  {
  	char szBuff[1024];
  	DWORD dwBuffSize;
  
  	DebugMsg((DEST,"PBC_OnLog\n"));
  
! 	szBuff[0]= NULL; dwBuffSize=1024;
  	pFC->GetServerVariable(pFC, "INSTANCE_ID",
  							szBuff, &dwBuffSize);
  	DebugMsg((DEST,"  Instance ID   : %s\n",szBuff));
  
  	DebugMsg((DEST,"  ClientHostName: %s\n",pLogInfo->pszClientHostName));
  	DebugMsg((DEST,"  ClientUserName: %s\n",pLogInfo->pszClientUserName));
  	DebugMsg((DEST,"  ServerName    : %s\n",pLogInfo->pszServerName));
--- 1888,1950 ----
  		DebugMsg((DEST,"PBC_OnEndOfRequest\n"));
  	}
  			
  
  	return SF_STATUS_REQ_NEXT_NOTIFICATION;
  
  }  /* OnEndOfRequest */
  
+ VOID ReplaceToken(const char *token,const char *data, char *psztarget, int targetsize)
+ {
+ 	char *l1;
+ 	char *szbuff=NULL;
+ 
+ 	while (l1=strstr(psztarget,token)) {
+ 		szbuff = (char *)realloc(szbuff,sizeof(char) * (strlen(psztarget) + strlen(data) - strlen(token) + 1));
+ 		szbuff[0] = 0;
+ 		strncat(szbuff,psztarget,l1-psztarget);
+ 		strcat(szbuff,data);
+ 		strcat(szbuff,l1+strlen(token));
+ 		strncpy(psztarget,szbuff,targetsize);
+ 	}
+ 
+ 	free(szbuff);
+ 
+ }
  
  DWORD OnLog (HTTP_FILTER_CONTEXT* pFC, 
  		  	 HTTP_FILTER_LOG* pLogInfo)
  {
  	char szBuff[1024];
  	DWORD dwBuffSize;
+ 	char *pszNewClient;
+ 	pubcookie_dir_rec* dcfg;
+ 	dcfg = (pubcookie_dir_rec *)pFC->pFilterContext;
  
  	DebugMsg((DEST,"PBC_OnLog\n"));
  
! 	szBuff[0]= NULL;
! 	dwBuffSize=1024;
! 
  	pFC->GetServerVariable(pFC, "INSTANCE_ID",
  							szBuff, &dwBuffSize);
  	DebugMsg((DEST,"  Instance ID   : %s\n",szBuff));
  
+ 	if ( dcfg ) {
+ 		if (strlen(dcfg->user) > 0) {
+ 			dwBuffSize=1024;
+ 			pszNewClient = (char *)pFC->AllocMem(pFC,dwBuffSize,0);
+ 			strncpy(pszNewClient,PBC_CLIENT_LOG_FMT, dwBuffSize);
+ 			DebugMsg((DEST,"  Modified user : %s\n",PBC_CLIENT_LOG_FMT));
+ 			DebugMsg((DEST,"  Modified user : %s\n",pszNewClient));
+ 			ReplaceToken("%w",pLogInfo->pszClientUserName,pszNewClient, dwBuffSize);
+ 						DebugMsg((DEST,"  Modified user : %s\n",pszNewClient));
+ 
+ 			ReplaceToken("%p",dcfg->user, pszNewClient, dwBuffSize);
+ 			DebugMsg((DEST,"  Modified user : %s\n",pszNewClient));
+ 			pLogInfo->pszClientUserName = pszNewClient;
+ 		}
+ 		
+ 	}
  	DebugMsg((DEST,"  ClientHostName: %s\n",pLogInfo->pszClientHostName));
  	DebugMsg((DEST,"  ClientUserName: %s\n",pLogInfo->pszClientUserName));
  	DebugMsg((DEST,"  ServerName    : %s\n",pLogInfo->pszServerName));
***************
*** 1938,1943 ****
--- 1969,1981 ----
  	if ( pLogInfo->dwBytesRecvd > Max_Bytes_Recvd )
  		Max_Bytes_Recvd = pLogInfo->dwBytesRecvd;
  
+ 	// OnEndOfNetSession is not called consistantly for each request,
+ 	// Neither is OnLog.  Must use pFC->AllocMem instead.
+ 	
+ 	/*pbc_free(pFC->pFilterContext);
+ 
+ 	pFC->pFilterContext = NULL;   // Force to Null so we don't try to free twice*/
+ 
  	return SF_STATUS_REQ_NEXT_NOTIFICATION;
  
  }  /* OnLog */
***************
*** 1956,1962 ****
  			
  	// Free pFilterContext here if allocated via malloc
  	// However this routine is not to be called consistantly due to keep alives
- 	// Use EndOfRequest instead
  
  	return SF_STATUS_REQ_NEXT_NOTIFICATION;
  
--- 1994,1999 ----


Index: webiso/pubcookie/src/Win32/PubCookieFilter.h
diff -c webiso/pubcookie/src/Win32/PubCookieFilter.h:1.1.2.7 webiso/pubcookie/src/Win32/PubCookieFilter.h:1.1.2.8
*** webiso/pubcookie/src/Win32/PubCookieFilter.h:1.1.2.7	Fri Dec 20 13:26:18 2002
--- webiso/pubcookie/src/Win32/PubCookieFilter.h	Fri Mar 28 13:48:26 2003
***************
*** 1,5 ****
  
! #define Pubcookie_Version "Pubcookie ISAPI Filter, 2.7.7"
  
  
  char Instance[3];
--- 1,5 ----
  
! #define Pubcookie_Version "Pubcookie ISAPI Filter, 2.7.8"
  
  
  char Instance[3];


Index: webiso/pubcookie/src/Win32/PubCookieFilter.opt



end of message


More information about the pubcookie-dev mailing list