////////////////////////////////////////////////////////////////////
//
//
-// E V E N T L O G G I N G F U N C T I O N S
+// E V E N T L O G G I N G F U N C T I O N S
//
//
////////////////////////////////////////////////////////////////////
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <roken.h>
+
#include <windows.h>
#include <stdarg.h>
#include <string.h>
#include <WINNT/afsreg.h>
#include "afsd.h"
#include "afsd_eventlog.h"
+#define AFS_VERSION_STRINGS
+#include "afs_component_version_number.h"
static BOOL GetServicePath(LPTSTR lpPathBuf, PDWORD pdwPathBufSize);
static BOOL AddEventSource(void);
static BOOL
GetServicePath(LPTSTR lpPathBuf, PDWORD pdwPathBufSize)
{
- HKEY hKey = NULL;
+ HKEY hKey = NULL;
DWORD dwData = 0;
BOOL bRet = TRUE;
do {
// Open key
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_SUBKEY, 0, KEY_QUERY_VALUE, &hKey ) )
- {
+ {
bRet = FALSE;
break;
}
NULL, // type buffer
(LPBYTE) lpPathBuf, // data buffer
&dwData)) // size of data buffer
- {
+ {
bRet = FALSE;
break;
}
-
+
*pdwPathBufSize = dwData;
} while (0);
-
+
if (hKey != NULL)
- RegCloseKey(hKey);
+ RegCloseKey(hKey);
return bRet;
-}
+}
//
// Ensure name for message file is in proper location in Registry.
static BOOL
AddEventSource()
{
- HKEY hKey = NULL, hLogKey;
- UCHAR szBuf[MAX_PATH] = "afsd_service.exe";
- DWORD dwData, dwDisposition;
+ HKEY hKey = NULL, hLogKey;
+ UCHAR szBuf[MAX_PATH] = "afsd_service.exe";
+ DWORD dwData, dwDisposition;
static BOOL bRet = TRUE;
static BOOL bOnce = TRUE;
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, AFSREG_APPLOG_SUBKEY, 0,
KEY_SET_VALUE, &hLogKey ) )
- {
- // nope - create it
+ {
+ // nope - create it
if ( RegCreateKeyEx(HKEY_LOCAL_MACHINE, AFSREG_APPLOG_SUBKEY, 0,
NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hLogKey,
- &dwDisposition))
- {
+ &dwDisposition))
+ {
bRet = FALSE;
goto done;
}
}
- // Let's see if key already exists as a subkey under the
+ // Let's see if key already exists as a subkey under the
// Application key in the EventLog registry key. If not,
// create it.
if ( RegOpenKeyEx( hLogKey, AFSREG_CLT_APPLOG_SUBKEY, 0,
KEY_SET_VALUE, &hKey ) )
- {
- // nope - create it
+ {
+ // nope - create it
if ( RegCreateKeyEx(hLogKey, AFSREG_CLT_APPLOG_SUBKEY, 0,
NULL, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &hKey,
- &dwDisposition))
- {
+ &dwDisposition))
+ {
bRet = FALSE;
goto done;
}
}
- // Add the name to the EventMessageFile subkey.
- if ( RegSetValueEx( hKey, // subkey handle
- AFSREG_APPLOG_MSGFILE_VALUE, // value name
- 0, // must be zero
- REG_SZ, // value type
- (LPBYTE) szBuf, // pointer to value data
+ // Add the name to the EventMessageFile subkey.
+ if ( RegSetValueEx( hKey, // subkey handle
+ AFSREG_APPLOG_MSGFILE_VALUE, // value name
+ 0, // must be zero
+ REG_SZ, // value type
+ (LPBYTE) szBuf, // pointer to value data
(DWORD)strlen(szBuf) + 1)) // length of value data
- {
+ {
bRet = FALSE;
goto done;
}
- // Set the supported event types in the TypesSupported subkey.
- dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
- EVENTLOG_INFORMATION_TYPE;
+ // Set the supported event types in the TypesSupported subkey.
+ dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
+ EVENTLOG_INFORMATION_TYPE;
- if ( RegSetValueEx( hKey, // subkey handle
- AFSREG_APPLOG_MSGTYPE_VALUE, // value name
- 0, // must be zero
- REG_DWORD, // value type
- (LPBYTE) &dwData, // pointer to value data
+ if ( RegSetValueEx( hKey, // subkey handle
+ AFSREG_APPLOG_MSGTYPE_VALUE, // value name
+ 0, // must be zero
+ REG_DWORD, // value type
+ (LPBYTE) &dwData, // pointer to value data
sizeof(DWORD))) // length of value data
- {
+ {
bRet = FALSE;
goto done;
}
-
+
done:
if (hKey != NULL)
- RegCloseKey(hKey);
+ RegCloseKey(hKey);
if (hLogKey != NULL)
- RegCloseKey(hLogKey);
+ RegCloseKey(hLogKey);
return bRet;
-}
+}
// Log an event with a formatted system message as the (only) substitution
// string, from the given message ID.
case MSG_FLUSH_UNEXPECTED_EVENT:
case MSG_UNHANDLED_EXCEPTION:
case MSG_SMB_ZERO_TRANSACTION_COUNT:
- case MSG_SERVICE_START_PENDING:
case MSG_SERVICE_INCORRECT_VERSIONS:
- case MSG_SERVICE_RUNNING:
case MSG_SERVICE_STOPPING:
+ case MSG_SERVICE_STOPPED:
case MSG_SERVICE_ERROR_STOP:
case MSG_CRYPT_OFF:
case MSG_CRYPT_ON:
break;
+ case MSG_SERVICE_START_PENDING:
+ wNumArgs = 1;
+ lpArgs[0] = AFSVersion;
+ break;
+ case MSG_SERVICE_RUNNING:
+ wNumArgs = 1;
+ if (smb_Enabled && RDR_Initialized)
+ lpArgs[0] = "SMB and RDR interfaces";
+ else if (smb_Enabled)
+ lpArgs[0] = "SMB interface";
+ else if (RDR_Initialized)
+ lpArgs[0] = "RDR interface";
+ else
+ lpArgs[0] = "No active interface";
+ break;
case MSG_FLUSH_BAD_SHARE_NAME:
case MSG_FLUSH_OPEN_ENUM_ERROR:
case MSG_FLUSH_ENUM_ERROR:
case MSG_SMB_SEND_PACKET_FAILURE:
case MSG_UNEXPECTED_SMB_SESSION_CLOSE:
case MSG_RX_MSGSIZE_EXCEEDED:
+ case MSG_RX_BUSY_CALL_CHANNEL:
wNumArgs = 1;
lpArgs[0] = va_arg(listArgs, LPTSTR);
break;
case MSG_SERVER_REPORTS_VIO:
case MSG_SERVER_REPORTS_VBUSY:
case MSG_SERVER_REPORTS_VRESTARTING:
+ wNumArgs = 3;
+ lpArgs[0] = va_arg(listArgs, LPTSTR);
+ StringCbPrintf(lpStrings[1],STRLEN,"%d",va_arg(listArgs,afs_int32));
+ lpArgs[1] = lpStrings[1];
+ lpArgs[2] = va_arg(listArgs, LPTSTR);
+ break;
case MSG_ALL_SERVERS_BUSY:
case MSG_ALL_SERVERS_OFFLINE:
case MSG_ALL_SERVERS_DOWN:
CloseHandle(hMutex);
DeregisterEventSource(hEventSource);
-}
+}