From 2743691b770268ba0584369aa960ef2f656759b4 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 22 Jul 2004 10:23:52 +0000 Subject: [PATCH] misc-cleanups-20040721 * Cleanup debug logging. In particular, allow the TraceOptions registry value to be used as a bit flag as it was intended. Give each type of debugging its own value instead of having each module test for the zero bit. * Modify the handling of the afsd_init.log file. This file originally was replaced on each start. However, with auto-restart this causes any error information from the previous halt to be lost. So it was changed quite a while back to append forever. The problem with this is that the file gets unreasonably large. Solution: add a new registry value, MaxLogSize, which determins how large the file should be allowed to become before truncation. The default is 100K. The magic value 0 means grow indefinitely. * Update afslogon.dll. Cleanup logging. Fix some errors. Remove unused variables. AND do not Forget Tokens on Logoff if the profile is located in AFS space. * Fix a bug introduced yesterday in cellconfig.c which caused problems accessing the CellServDB file * Update the NSIS installer to replace the CRTL DLLs instead of overwrite them. * Add new Startup Winlogon handler to initialize the TraceOption. --- src/WINNT/afsd/afsd_init.c | 32 +++++- src/WINNT/afsd/afslogon.c | 153 ++++++++++++++++++++-------- src/WINNT/afsd/afslogon.def | 1 + src/WINNT/afsd/afslogon.h | 3 +- src/WINNT/afsd/cm_config.c | 55 ++++++++-- src/WINNT/afsd/libafsconf.def | 1 + src/WINNT/afsd/logon_ad.cpp | 145 +++++++++++++------------- src/WINNT/client_config/drivemap.cpp | 2 + src/WINNT/install/NSIS/OpenAFS.nsi | 192 +++++++++++------------------------ src/WINNT/install/wix/files.wxi | 1 + src/auth/cellconfig.c | 8 +- 11 files changed, 328 insertions(+), 265 deletions(-) diff --git a/src/WINNT/afsd/afsd_init.c b/src/WINNT/afsd/afsd_init.c index 1588d82..ed66bc6 100644 --- a/src/WINNT/afsd/afsd_init.c +++ b/src/WINNT/afsd/afsd_init.c @@ -84,6 +84,8 @@ char *cm_sysName = 0; int cm_sysNameCount = 0; char *cm_sysNameList[MAXNUMSYSNAMES]; +DWORD TraceOption = 0; + /* * AFSD Initialization Log * @@ -113,6 +115,10 @@ afsi_start() char t[100], u[100], *p, *path; int zilch; int code; + DWORD dwLow, dwHigh; + HKEY parmKey; + DWORD dummyLen; + DWORD maxLogSize = 100 * 1024; afsi_file = INVALID_HANDLE_VALUE; if (getenv("TEMP")) @@ -128,6 +134,25 @@ afsi_start() GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t)); afsi_file = CreateFile(wd, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL); + + code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, + 0, KEY_QUERY_VALUE, &parmKey); + if (code == ERROR_SUCCESS) { + dummyLen = sizeof(maxLogSize); + code = RegQueryValueEx(parmKey, "MaxLogSize", NULL, NULL, + (BYTE *) &maxLogSize, &dummyLen); + RegCloseKey (parmKey); + } + + if (maxLogSize) { + dwLow = GetFileSize( afsi_file, &dwHigh ); + if ( dwHigh > 0 || dwLow >= maxLogSize ) { + CloseHandle(afsi_file); + afsi_file = CreateFile( wd, GENERIC_WRITE, FILE_SHARE_READ, NULL, + CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL); + } + } + SetFilePointer(afsi_file, 0, NULL, FILE_END); GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, u, sizeof(u)); StringCbCatA(t, sizeof(t), ": Create log file\n"); @@ -431,6 +456,11 @@ int afsd_InitCM(char **reasonP) } } + dummyLen = sizeof(TraceOption); + code = RegQueryValueEx(parmKey, "TraceOption", NULL, NULL, + (BYTE *) &TraceOption, &dummyLen); + afsi_log("Event Log Tracing = %lX", TraceOption); + dummyLen = sizeof(traceBufSize); code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL, (BYTE *) &traceBufSize, &dummyLen); @@ -544,7 +574,7 @@ int afsd_InitCM(char **reasonP) } cm_mountRootLen = sizeof(cm_mountRoot); - code = RegQueryValueEx(parmKey, "Mountroot", NULL, NULL, + code = RegQueryValueEx(parmKey, "MountRoot", NULL, NULL, cm_mountRoot, &cm_mountRootLen); if (code == ERROR_SUCCESS) { afsi_log("Mount root %s", cm_mountRoot); diff --git a/src/WINNT/afsd/afslogon.c b/src/WINNT/afsd/afslogon.c index a08ea52..5f73ceb 100644 --- a/src/WINNT/afsd/afslogon.c +++ b/src/WINNT/afsd/afslogon.c @@ -26,25 +26,26 @@ #include "krb.h" #include "afskfw.h" -DWORD LogonOption,TraceOption; +DWORD TraceOption = 0; HANDLE hDLL; WSADATA WSAjunk; +#define AFS_LOGON_EVENT_NAME TEXT("AFS Logon") void DebugEvent0(char *a) { HANDLE h; char *ptbuf[1]; if (!ISLOGONTRACE(TraceOption)) return; - h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME); + h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME); ptbuf[0] = a; ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL); DeregisterEventSource(h); } -#define MAXBUF_ 131 -void DebugEvent(char *a,char *b,...) +#define MAXBUF_ 512 +void DebugEvent(char *b,...) { HANDLE h; char *ptbuf[1],buf[MAXBUF_+1]; va_list marker; @@ -52,9 +53,7 @@ void DebugEvent(char *a,char *b,...) if (!ISLOGONTRACE(TraceOption)) return; - /*if(!a) */ - a = AFS_DAEMON_EVENT_NAME; - h = RegisterEventSource(NULL, a); + h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME); va_start(marker,b); StringCbVPrintf(buf, MAXBUF_+1,b,marker); buf[MAXBUF_] = '\0'; @@ -212,21 +211,21 @@ BOOL IsServiceRunning (void) if(hkDom) { \ dwSize = sizeof(v); \ rv = RegQueryValueEx(hkDom, n, 0, &dwType, (LPBYTE) &(v), &dwSize); \ - if(rv == ERROR_SUCCESS) DebugEvent(NULL, #v " found in hkDom with type [%d]", dwType); \ + if(rv == ERROR_SUCCESS) DebugEvent(#v " found in hkDom with type [%d]", dwType); \ } \ if(hkDoms && (rv != ERROR_SUCCESS || dwType != t)) { \ dwSize = sizeof(v); \ rv = RegQueryValueEx(hkDoms, n, 0, &dwType, (LPBYTE) &(v), &dwSize); \ - if(rv == ERROR_SUCCESS) DebugEvent(NULL, #v " found in hkDoms with type [%d]", dwType); \ + if(rv == ERROR_SUCCESS) DebugEvent(#v " found in hkDoms with type [%d]", dwType); \ } \ if(hkNp && (rv != ERROR_SUCCESS || dwType != t)) { \ dwSize = sizeof(v); \ rv = RegQueryValueEx(hkNp, n, 0, &dwType, (LPBYTE) &(v), &dwSize); \ - if(rv == ERROR_SUCCESS) DebugEvent(NULL, #v " found in hkNp with type [%d]", dwType); \ + if(rv == ERROR_SUCCESS) DebugEvent(#v " found in hkNp with type [%d]", dwType); \ } \ if(rv != ERROR_SUCCESS || dwType != t) { \ v = d; \ - DebugEvent(NULL, #v " being set to default"); \ + DebugEvent(#v " being set to default"); \ } \ } while(0) @@ -246,7 +245,7 @@ void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, Log char computerName[MAX_COMPUTERNAME_LENGTH + 1]; char *effDomain; - DebugEvent(NULL,"In GetDomainLogonOptions for user [%s] in domain [%s]", username, domain); + DebugEvent("In GetDomainLogonOptions for user [%s] in domain [%s]", username, domain); /* If the domain is the same as the Netbios computer name, we use the LOCALHOST domain name*/ opt->flags = LOGON_FLAG_REMOTE; if(domain) { @@ -265,20 +264,20 @@ void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, Log rv = RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY, 0, KEY_READ, &hkParm ); if(rv != ERROR_SUCCESS) { hkParm = NULL; - DebugEvent(NULL, "GetDomainLogonOption: Can't open parms key [%d]", rv); + DebugEvent("GetDomainLogonOption: Can't open parms key [%d]", rv); } rv = RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_CLIENT_PROVIDER_KEY, 0, KEY_READ, &hkNp ); if(rv != ERROR_SUCCESS) { hkNp = NULL; - DebugEvent(NULL, "GetDomainLogonOptions: Can't open NP key [%d]", rv); + DebugEvent("GetDomainLogonOptions: Can't open NP key [%d]", rv); } if(hkNp) { rv = RegOpenKeyEx( hkNp, REG_CLIENT_DOMAINS_SUBKEY, 0, KEY_READ, &hkDoms ); if( rv != ERROR_SUCCESS ) { hkDoms = NULL; - DebugEvent(NULL, "GetDomainLogonOptions: Can't open Domains key [%d]", rv); + DebugEvent("GetDomainLogonOptions: Can't open Domains key [%d]", rv); } } @@ -286,13 +285,13 @@ void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, Log rv = RegOpenKeyEx( hkDoms, effDomain, 0, KEY_READ, &hkDom ); if( rv != ERROR_SUCCESS ) { hkDom = NULL; - DebugEvent( NULL, "GetDomainLogonOptions: Can't open domain key for [%s] [%d]", effDomain, rv); + DebugEvent("GetDomainLogonOptions: Can't open domain key for [%s] [%d]", effDomain, rv); /* If none of the domains match, we shouldn't use the domain key either */ RegCloseKey(hkDoms); hkDoms = NULL; } } else - DebugEvent( NULL, "Not opening domain key for [%s]", effDomain); + DebugEvent("Not opening domain key for [%s]", effDomain); /* Each individual can either be specified on the domain key, the domains key or in the net provider key. They fail over in that order. If none is found, we just use the @@ -338,7 +337,7 @@ void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, Log UnicodeStringToANSI(plsd->UserName, lsaUsername, MAX_USERNAME_LENGTH); UnicodeStringToANSI(plsd->LogonDomain, lsaDomain, MAX_DOMAIN_LENGTH); - DebugEvent(NULL,"PLSD username[%s] domain[%s]",lsaUsername,lsaDomain); + DebugEvent("PLSD username[%s] domain[%s]",lsaUsername,lsaDomain); if(SUCCEEDED(StringCbLength(lsaUsername, MAX_USERNAME_LENGTH, &tlen))) len = tlen; @@ -364,7 +363,7 @@ bad_strings: LsaFreeReturnBuffer(plsd); } - DebugEvent(NULL,"Looking up logon script"); + DebugEvent("Looking up logon script"); /* Logon script */ /* First find out where the key is */ hkTemp = NULL; @@ -374,20 +373,20 @@ bad_strings: rv = RegQueryValueExW(hkDom, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, NULL, &dwSize); if(rv == ERROR_SUCCESS && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) { hkTemp = hkDom; - DebugEvent(NULL,"Located logon script in hkDom"); + DebugEvent("Located logon script in hkDom"); } else if(hkDoms) rv = RegQueryValueExW(hkDoms, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, NULL, &dwSize); if(rv == ERROR_SUCCESS && !hkTemp && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) { hkTemp = hkDoms; - DebugEvent(NULL,"Located logon script in hkDoms"); + DebugEvent("Located logon script in hkDoms"); } /* Note that the LogonScript in the NP key is only used if we are doing high security. */ else if(hkNp && ISHIGHSECURITY(opt->LogonOption)) rv = RegQueryValueExW(hkNp, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, NULL, &dwSize); if(rv == ERROR_SUCCESS && !hkTemp && (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) { hkTemp = hkNp; - DebugEvent(NULL,"Located logon script in hkNp"); + DebugEvent("Located logon script in hkNp"); } if(hkTemp) { @@ -405,17 +404,17 @@ bad_strings: wuname = malloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP,0,opt->smbName,-1,wuname,len*sizeof(WCHAR)); - DebugEvent(NULL,"Username is set for [%S]", wuname); + DebugEvent("Username is set for [%S]", wuname); /* dwSize still has the size of the required buffer in bytes. */ regscript = malloc(dwSize); rv = RegQueryValueExW(hkTemp, REG_CLIENT_LOGON_SCRIPT_PARMW, 0, &dwType, (LPBYTE) regscript, &dwSize); if(rv != ERROR_SUCCESS) {/* what the ..? */ - DebugEvent(NULL,"Can't look up logon script [%d]",rv); + DebugEvent("Can't look up logon script [%d]",rv); goto doneLogonScript; } - DebugEvent(NULL,"Found logon script [%S]", regscript); + DebugEvent("Found logon script [%S]", regscript); if(dwType == REG_EXPAND_SZ) { DWORD dwReq; @@ -427,12 +426,12 @@ bad_strings: regscript = regexscript; regexscript = NULL; if(dwReq > (dwSize / sizeof(WCHAR))) { - DebugEvent(NULL,"Overflow while expanding environment strings."); + DebugEvent("Overflow while expanding environment strings."); goto doneLogonScript; } } - DebugEvent(NULL,"After expanding env strings [%S]", regscript); + DebugEvent("After expanding env strings [%S]", regscript); if(wcsstr(regscript, L"%s")) { dwSize += len * sizeof(WCHAR); /* make room for username expansion */ @@ -443,7 +442,7 @@ bad_strings: hr = StringCbCopyW(regexuscript, dwSize, regscript); } - DebugEvent(NULL,"After expanding username [%S]", regexuscript); + DebugEvent("After expanding username [%S]", regexuscript); if(hr == S_OK) opt->logonScript = regexuscript; @@ -566,9 +565,9 @@ DWORD APIENTRY NPLogonNotify( /* Convert from Unicode to ANSI */ /*TODO: Use SecureZeroMemory to erase passwords */ - UnicodeStringToANSI(IL->UserName, uname, 256); - UnicodeStringToANSI(IL->Password, password, 256); - UnicodeStringToANSI(IL->LogonDomainName, logonDomain, 256); + UnicodeStringToANSI(IL->UserName, uname, MAX_USERNAME_LENGTH); + UnicodeStringToANSI(IL->Password, password, MAX_PASSWORD_LENGTH); + UnicodeStringToANSI(IL->LogonDomainName, logonDomain, MAX_DOMAIN_LENGTH); /* Make sure AD-DOMANS sent from login that is sent to us is striped */ ctemp = strchr(uname, '@'); @@ -599,16 +598,17 @@ DWORD APIENTRY NPLogonNotify( sleepInterval = opt.sleepInterval; *lpLogonScript = opt.logonScript; - DebugEvent(NULL,"Got logon script: %S",opt.logonScript); + DebugEvent("Got logon script: %S",opt.logonScript); afsWillAutoStart = AFSWillAutoStart(); - DebugEvent("AFS AfsLogon - NPLogonNotify","LogonOption[%x], Service AutoStart[%d]", + DebugEvent("LogonOption[%x], Service AutoStart[%d]", opt.LogonOption,afsWillAutoStart); /* Check for zero length password if integrated logon*/ if ( ISLOGONINTEGRATED(opt.LogonOption) ) { if ( password[0] == 0 ) { + DebugEvent("Password is the empty string"); code = GT_PW_NULL; reason = "zero length password is illegal"; code=0; @@ -617,26 +617,35 @@ DWORD APIENTRY NPLogonNotify( /* Get cell name if doing integrated logon. We might overwrite this if we are logging into an AD realm and we find out that the user's home dir is in some other cell. */ + DebugEvent("About to call cm_GetRootCellName(%s)",cell); code = cm_GetRootCellName(cell); if (code < 0) { + DebugEvent("Unable to obtain Root Cell"); code = KTC_NOCELL; reason = "unknown cell"; code=0; - } + } else { + DebugEvent("Cell is %s",cell); + } /* We get the user's home directory path, if applicable, though we can't lookup the cell right away because the client service may not have started yet. This call also sets the AD_REALM flag in opt.flags if applicable. */ - if(ISREMOTE(opt.flags)) + if(ISREMOTE(opt.flags)) { + DebugEvent("Is Remote"); GetAdHomePath(homePath,MAX_PATH,lpLogonId,&opt); + } } /* loop until AFS is started. */ while (TRUE) { - if(ISADREALM(opt.flags)) { + DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]", + opt.LogonOption,afsWillAutoStart); + + if(ISADREALM(opt.flags)) { code = GetFileCellName(homePath,cell,256); if(!code) { - DebugEvent(NULL,"profile path [%s] is in cell [%s]",homePath,cell); + DebugEvent("profile path [%s] is in cell [%s]",homePath,cell); } /* Don't bail out if GetFileCellName failed. * The home dir may not be in AFS after all. @@ -649,7 +658,7 @@ DWORD APIENTRY NPLogonNotify( { if ( KFW_is_available() ) { code = KFW_AFS_get_cred(uname, cell, password, 0, opt.smbName, &reason); - DebugEvent(NULL,"KFW_AFS_get_cred uname=[%s] smbname=[%s] cell=[%s] code=[%d]",uname,opt.smbName,cell,code); + DebugEvent("KFW_AFS_get_cred uname=[%s] smbname=[%s] cell=[%s] code=[%d]",uname,opt.smbName,cell,code); } else { code = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON, @@ -713,6 +722,7 @@ DWORD APIENTRY NPLogonNotify( retryInterval -= sleepInterval; } + DebugEvent("while loop exited"); /* remove any kerberos 5 tickets currently held by the SYSTEM account */ if ( KFW_is_available() ) KFW_AFS_destroy_tickets_for_cell(cell); @@ -728,7 +738,7 @@ DWORD APIENTRY NPLogonNotify( HANDLE h; char *ptbuf[1]; - h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME); + h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME); ptbuf[0] = msg; ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1008, NULL, 1, 0, ptbuf, NULL); @@ -737,7 +747,7 @@ DWORD APIENTRY NPLogonNotify( code = MapAuthError(code); SetLastError(code); - if (ISLOGONINTEGRATED(LogonOption) && (code!=0)) + if (ISLOGONINTEGRATED(opt.LogonOption) && (code!=0)) { if (*lpLogonScript) LocalFree(*lpLogonScript); @@ -788,20 +798,75 @@ BOOL IsPathInAfs(const CHAR *strPath) return TRUE; } +#ifdef COMMENT +typedef struct _WLX_NOTIFICATION_INFO { + ULONG Size; + ULONG Flags; + PWSTR UserName; + PWSTR Domain; + PWSTR WindowStation; + HANDLE hToken; + HDESK hDesktop; + PFNMSGECALLBACK pStatusCallback; +} WLX_NOTIFICATION_INFO, *PWLX_NOTIFICATION_INFO; +#endif + +VOID AFS_Startup_Event( PWLX_NOTIFICATION_INFO pInfo ) +{ + DWORD LSPtype, LSPsize; + HKEY NPKey; + + (void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY, + 0, KEY_QUERY_VALUE, &NPKey); + LSPsize=sizeof(TraceOption); + RegQueryValueEx(NPKey, REG_CLIENT_TRACE_OPTION_PARM, NULL, + &LSPtype, (LPBYTE)&TraceOption, &LSPsize); + + RegCloseKey (NPKey); + DebugEvent0("AFS_Startup_Event"); +} + VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo ) { DWORD code; TCHAR profileDir[256] = TEXT(""); DWORD len = 256; + PTOKEN_USER tokenUser = NULL; + DWORD retLen; + HANDLE hToken; + + DebugEvent0("AFS_Logoff_Event - Starting"); - if ( GetUserProfileDirectory(pInfo->hToken, profileDir, &len) ) { + if (!GetTokenInformation(pInfo->hToken, TokenUser, NULL, 0, &retLen)) + { + if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER ) { + tokenUser = (PTOKEN_USER) LocalAlloc(LPTR, retLen); + + if (!GetTokenInformation(pInfo->hToken, TokenUser, tokenUser, retLen, &retLen)) + { + DebugEvent("GetTokenInformation failed: GLE = %lX", GetLastError()); + } + } + } + + if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid)) + GetUserProfileDirectory(pInfo->hToken, profileDir, &len); + + if (strlen(profileDir)) { + DebugEvent("Profile Directory: %s", profileDir); if (!IsPathInAfs(profileDir)) { if (code = ktc_ForgetAllTokens()) - DebugEvent(NULL,"AFS AfsLogon - AFS_Logoff_Event - ForgetAllTokens failed [%lX]",code); + DebugEvent("AFS_Logoff_Event - ForgetAllTokens failed [%lX]",code); else - DebugEvent0("AFS AfsLogon - AFS_Logoff_Event - ForgetAllTokens succeeded"); + DebugEvent0("AFS_Logoff_Event - ForgetAllTokens succeeded"); } else { - DebugEvent0("AFS AfsLogon - AFS_Logoff_Event - Tokens left in place; profile in AFS"); + DebugEvent0("AFS_Logoff_Event - Tokens left in place; profile in AFS"); } + } else { + DebugEvent0("AFS_Logoff_Event - Unable to load profile"); } + + if ( tokenUser ) + LocalFree(tokenUser); } + diff --git a/src/WINNT/afsd/afslogon.def b/src/WINNT/afsd/afslogon.def index 2c9c304..28cafc5 100644 --- a/src/WINNT/afsd/afslogon.def +++ b/src/WINNT/afsd/afslogon.def @@ -8,6 +8,7 @@ EXPORTS NPGetCaps NPLogonNotify NPPasswordChangeNotify + AFS_Startup_Event AFS_Logoff_Event diff --git a/src/WINNT/afsd/afslogon.h b/src/WINNT/afsd/afslogon.h index 108768b..24565e1 100644 --- a/src/WINNT/afsd/afslogon.h +++ b/src/WINNT/afsd/afslogon.h @@ -104,7 +104,7 @@ extern "C" { #endif void DebugEvent0(char *a); -void DebugEvent(char *a,char *b,...); +void DebugEvent(char *b,...); CHAR *GenRandomName(CHAR *pbuf); @@ -119,6 +119,7 @@ static BOOL WINAPI UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOu void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt ); DWORD GetFileCellName(char * path, char * cell, size_t cellLen); DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonOptions_t * opt); +DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid); #ifdef __cplusplus } diff --git a/src/WINNT/afsd/cm_config.c b/src/WINNT/afsd/cm_config.c index a02dbc2..9498503 100644 --- a/src/WINNT/afsd/cm_config.c +++ b/src/WINNT/afsd/cm_config.c @@ -52,16 +52,17 @@ extern int errno; #define AFS_CELLSERVDB AFS_CELLSERVDB_UNIX #endif /* DJGPP || WIN95 */ -#ifdef DEBUG -DWORD TraceOption=1; +static DWORD TraceOption = 0; + +/* This really needs to be initialized at DLL Init */ +#define TRACE_OPTION_EVENT 4 -#define TRACE_OPTION_EVENT 1 -#define ISLOGONTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT) +#define ISCONFIGTRACE(v) ( ((v) & TRACE_OPTION_EVENT)==TRACE_OPTION_EVENT) void DebugEvent0_local(char *a) { HANDLE h; char *ptbuf[1]; - if (!ISLOGONTRACE(TraceOption)) + if (!ISCONFIGTRACE(TraceOption)) return; h = RegisterEventSource(NULL, a); ptbuf[0] = a; @@ -75,7 +76,7 @@ void DebugEvent_local(char *a,char *b,...) { HANDLE h; char *ptbuf[1],buf[MAXBUF_+1]; va_list marker; - if (!ISLOGONTRACE(TraceOption)) + if (!ISCONFIGTRACE(TraceOption)) return; h = RegisterEventSource(NULL, a); va_start(marker,b); @@ -85,7 +86,45 @@ void DebugEvent_local(char *a,char *b,...) DeregisterEventSource(h); va_end(marker); } -#endif /* DEBUG */ + +#define REG_CLIENT_PARMS_KEY TEXT("SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters") +#define REG_CLIENT_TRACE_OPTION_PARM TEXT("TraceOption") + +#ifdef COMMENT +BOOL WINAPI DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: { + DWORD LSPtype, LSPsize; + HKEY NPKey; + + (void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, REG_CLIENT_PARMS_KEY, + 0, KEY_QUERY_VALUE, &NPKey); + LSPsize=sizeof(TraceOption); + RegQueryValueEx(NPKey, REG_CLIENT_TRACE_OPTION_PARM, NULL, + &LSPtype, (LPBYTE)&TraceOption, &LSPsize); + + RegCloseKey (NPKey); + break; + } + + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + + case DLL_PROCESS_DETACH: + break; + + default: + return FALSE; + } + + return TRUE; // successful DLL_PROCESS_ATTACH +} +#endif /* COMMENT */ static long cm_ParsePair(char *lineBufferp, char *leftp, char *rightp) { @@ -483,7 +522,6 @@ long cm_GetRootCellName(char *cellNamep) cm_configFile_t *cm_CommonOpen(char *namep, char *rwp) { char wdir[256]; - long code; long tlen; FILE *tfilep; @@ -701,7 +739,6 @@ long cm_CloseCellFile(cm_configFile_t *filep) void cm_GetConfigDir(char *dir) { char wdir[256]; - int code; int tlen; #ifdef AFS_WIN95_ENV char *afsconf_path; diff --git a/src/WINNT/afsd/libafsconf.def b/src/WINNT/afsd/libafsconf.def index 08c2d1e..79a756a 100644 --- a/src/WINNT/afsd/libafsconf.def +++ b/src/WINNT/afsd/libafsconf.def @@ -21,3 +21,4 @@ EXPORTS getAFSServer @14 cm_InitDNS @15 cm_GetConfigDir @16 + \ No newline at end of file diff --git a/src/WINNT/afsd/logon_ad.cpp b/src/WINNT/afsd/logon_ad.cpp index 7122be0..39a9741 100644 --- a/src/WINNT/afsd/logon_ad.cpp +++ b/src/WINNT/afsd/logon_ad.cpp @@ -94,7 +94,7 @@ DWORD LogonSSP(PLUID lpLogonId, PCtxtHandle outCtx) { &expiry); if(status != SEC_E_OK) { - DebugEvent(NULL,"AcquireCredentialsHandle failed: %lX", status); + DebugEvent("AcquireCredentialsHandle failed: %lX", status); goto ghp_0; } @@ -130,7 +130,7 @@ DWORD LogonSSP(PLUID lpLogonId, PCtxtHandle outCtx) { &expiry ); - DebugEvent(NULL,"InitializeSecurityContext returns status[%lX](%s)",status,_get_sec_err_text(status)); + DebugEvent("InitializeSecurityContext returns status[%lX](%s)",status,_get_sec_err_text(status)); if(!first) FreeContextBuffer(stoks.pvBuffer); @@ -143,7 +143,7 @@ DWORD LogonSSP(PLUID lpLogonId, PCtxtHandle outCtx) { } if(!stokc.cbBuffer && !cont) { - DebugEvent(NULL,"Breaking out after InitializeSecurityContext"); + DebugEvent("Breaking out after InitializeSecurityContext"); break; } @@ -158,7 +158,7 @@ DWORD LogonSSP(PLUID lpLogonId, PCtxtHandle outCtx) { &sattrs, &expiry); - DebugEvent(NULL,"AcceptSecurityContext returns status[%lX](%s)", status, _get_sec_err_text(status)); + DebugEvent("AcceptSecurityContext returns status[%lX](%s)", status, _get_sec_err_text(status)); FreeContextBuffer(stokc.pvBuffer); @@ -178,31 +178,25 @@ DWORD LogonSSP(PLUID lpLogonId, PCtxtHandle outCtx) { } while(cont && iters); if(sattrs & ASC_RET_DELEGATE) { - DebugEvent(NULL,"Received delegate context"); + DebugEvent("Received delegate context"); *outCtx = ctxserver; code = 0; } else { - DebugEvent(NULL,"Didn't receive delegate context"); + DebugEvent("Didn't receive delegate context"); outCtx->dwLower = 0; outCtx->dwUpper = 0; DeleteSecurityContext(&ctxserver); } -ghp_2: DeleteSecurityContext(&ctxclient); -ghp_1: FreeCredentialsHandle(&creds); ghp_0: return code; } -DWORD QueryAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId) { +DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid) { DWORD code = 1; /* default is failure */ - - PSECURITY_LOGON_SESSION_DATA plsd; NTSTATUS rv = 0; - DWORD size1,size2; - SID_NAME_USE snu; HRESULT hr = S_OK; LPWSTR p = NULL; WCHAR adsPath[MAX_PATH] = L""; @@ -210,54 +204,47 @@ DWORD QueryAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId) { homePath[0] = '\0'; - rv = LsaGetLogonSessionData(lpLogonId, &plsd); - if(rv == 0){ - if(ConvertSidToStringSidW(plsd->Sid,&p)) { - IADsNameTranslate *pNto; - - DebugEvent(NULL, "Got SID string [%S]", p); - - hr = CoInitialize(NULL); - if(SUCCEEDED(hr)) - coInitialized = TRUE; - - hr = CoCreateInstance(CLSID_NameTranslate, - NULL, - CLSCTX_INPROC_SERVER, - IID_IADsNameTranslate, - (void**)&pNto); - - if(FAILED(hr)) { DebugEvent(NULL,"Can't create nametranslate object"); } - else { - hr = pNto->Init(ADS_NAME_INITTYPE_GC,L""); //,clientUpn/*IL->UserName.Buffer*/,IL->LogonDomainName.Buffer,IL->Password.Buffer); - if (FAILED(hr)) { - DebugEvent(NULL,"NameTranslate Init failed [%ld]", hr); - } - else { - hr = pNto->Set(ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME, p); - if(FAILED(hr)) { DebugEvent(NULL,"Can't set sid string"); } - else { - BSTR bstr; - - hr = pNto->Get(ADS_NAME_TYPE_1779, &bstr); - wcscpy(adsPath, bstr); - - SysFreeString(bstr); - } - } - pNto->Release(); - } - - LocalFree(p); + if(ConvertSidToStringSidW(psid,&p)) { + IADsNameTranslate *pNto; - } else { - DebugEvent(NULL, "Can't convert sid to string"); - } + DebugEvent("Got SID string [%S]", p); - LsaFreeReturnBuffer(plsd); - } else { - DebugEvent(NULL, "LsaGetLogonSessionData failed"); - } + hr = CoInitialize(NULL); + if(SUCCEEDED(hr)) + coInitialized = TRUE; + + hr = CoCreateInstance( CLSID_NameTranslate, + NULL, + CLSCTX_INPROC_SERVER, + IID_IADsNameTranslate, + (void**)&pNto); + + if(FAILED(hr)) { DebugEvent("Can't create nametranslate object"); } + else { + hr = pNto->Init(ADS_NAME_INITTYPE_GC,L""); //,clientUpn/*IL->UserName.Buffer*/,IL->LogonDomainName.Buffer,IL->Password.Buffer); + if (FAILED(hr)) { + DebugEvent("NameTranslate Init failed [%ld]", hr); + } + else { + hr = pNto->Set(ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME, p); + if(FAILED(hr)) { DebugEvent("Can't set sid string"); } + else { + BSTR bstr; + + hr = pNto->Get(ADS_NAME_TYPE_1779, &bstr); + wcscpy(adsPath, bstr); + + SysFreeString(bstr); + } + } + pNto->Release(); + } + + LocalFree(p); + + } else { + DebugEvent("Can't convert sid to string"); + } if(adsPath[0]) { WCHAR fAdsPath[MAX_PATH]; @@ -266,27 +253,27 @@ DWORD QueryAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId) { hr = StringCchPrintfW(fAdsPath, MAX_PATH, L"LDAP://%s", adsPath); if(hr != S_OK) { - DebugEvent(NULL, "Can't format full adspath"); + DebugEvent("Can't format full adspath"); goto cleanup; } - DebugEvent(NULL, "Trying adsPath=[%S]", fAdsPath); + DebugEvent("Trying adsPath=[%S]", fAdsPath); hr = ADsGetObject( fAdsPath, IID_IADsUser, (LPVOID *) &pAdsUser); if(hr != S_OK) { - DebugEvent(NULL, "Can't open IADs object"); + DebugEvent("Can't open IADs object"); goto cleanup; } hr = pAdsUser->get_Profile(&bstHomeDir); if(hr != S_OK) { - DebugEvent(NULL, "Can't get profile directory"); + DebugEvent("Can't get profile directory"); goto cleanup_homedir_section; } wcstombs(homePath, bstHomeDir, homePathLen); - DebugEvent(NULL, "Got homepath [%s]", homePath); + DebugEvent("Got homepath [%s]", homePath); SysFreeString(bstHomeDir); @@ -313,22 +300,32 @@ DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonO homePath[0] = '\0'; - if(LogonSSP(lpLogonId,&ctx)) + if(LogonSSP(lpLogonId,&ctx)) { + DebugEvent("Failed LogonSSP"); return 1; - else { + } else { status = ImpersonateSecurityContext(&ctx); if(status == SEC_E_OK) { - if(!QueryAdHomePath(homePath,homePathLen,lpLogonId)) { - DebugEvent(NULL,"Returned home path [%s]",homePath); - opt->flags |= LOGON_FLAG_AD_REALM; - } - RevertSecurityContext(&ctx); + PSECURITY_LOGON_SESSION_DATA plsd; + NTSTATUS rv; + + rv = LsaGetLogonSessionData(lpLogonId, &plsd); + if(rv == 0) { + if(!QueryAdHomePathFromSid(homePath,homePathLen,plsd->Sid)) { + DebugEvent("Returned home path [%s]",homePath); + opt->flags |= LOGON_FLAG_AD_REALM; + } + LsaFreeReturnBuffer(plsd); + } else { + DebugEvent("LsaGetLogonSessionData failed [%lX]", rv); + } + RevertSecurityContext(&ctx); } else { - DebugEvent(NULL,"Can't impersonate context [%lX]",status); + DebugEvent("Can't impersonate context [%lX]",status); code = 1; } -ghp_0: - DeleteSecurityContext(&ctx); + + DeleteSecurityContext(&ctx); return code; } } diff --git a/src/WINNT/client_config/drivemap.cpp b/src/WINNT/client_config/drivemap.cpp index 8d6fcfb..166461a 100644 --- a/src/WINNT/client_config/drivemap.cpp +++ b/src/WINNT/client_config/drivemap.cpp @@ -21,7 +21,9 @@ extern "C" { #include "drivemap.h" #include #include +#ifdef DEBUG #define DEBUG_VERBOSE +#endif #include #include diff --git a/src/WINNT/install/NSIS/OpenAFS.nsi b/src/WINNT/install/NSIS/OpenAFS.nsi index b00da5a..b36e204 100644 --- a/src/WINNT/install/NSIS/OpenAFS.nsi +++ b/src/WINNT/install/NSIS/OpenAFS.nsi @@ -711,6 +711,7 @@ skipremove: WriteRegDWORD HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Impersonate" 1 WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "DLLName" "afslogon.dll" WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Logoff" "AFS_Logoff_Event" + WriteRegStr HKLM "Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" "Startup" "AFS_Startup_Event" SetRebootFlag true @@ -875,76 +876,6 @@ Section "AFS Control Center" secControl Call AFSLangFiles SetOutPath "$INSTDIR\Common" - SetOutPath "$INSTDIR\Common" -!IFDEF DEBUG -!IFDEF CL_1310 - File "${SYSTEMDIR}\msvcr71d.dll" - File "${SYSTEMDIR}\msvcp71d.dll" - File "${SYSTEMDIR}\mfc71d.dll" - File "${SYSTEMDIR}\MFC71CHS.DLL" - File "${SYSTEMDIR}\MFC71CHT.DLL" - File "${SYSTEMDIR}\MFC71DEU.DLL" - File "${SYSTEMDIR}\MFC71ENU.DLL" - File "${SYSTEMDIR}\MFC71ESP.DLL" - File "${SYSTEMDIR}\MFC71FRA.DLL" - File "${SYSTEMDIR}\MFC71ITA.DLL" - File "${SYSTEMDIR}\MFC71JPN.DLL" - File "${SYSTEMDIR}\MFC71KOR.DLL" -!ELSE -!IFDEF CL_1300 - File "${SYSTEMDIR}\msvcr70d.dll" - File "${SYSTEMDIR}\msvcp70d.dll" - File "${SYSTEMDIR}\mfc70d.dll" - File "${SYSTEMDIR}\MFC70CHS.DLL" - File "${SYSTEMDIR}\MFC70CHT.DLL" - File "${SYSTEMDIR}\MFC70DEU.DLL" - File "${SYSTEMDIR}\MFC70ENU.DLL" - File "${SYSTEMDIR}\MFC70ESP.DLL" - File "${SYSTEMDIR}\MFC70FRA.DLL" - File "${SYSTEMDIR}\MFC70ITA.DLL" - File "${SYSTEMDIR}\MFC70JPN.DLL" - File "${SYSTEMDIR}\MFC70KOR.DLL" -!ELSE - File "${SYSTEMDIR}\mfc42d.dll" - File "${SYSTEMDIR}\msvcp60d.dll" - File "${SYSTEMDIR}\msvcrtd.dll" -!ENDIF -!ENDIF -!ELSE -!IFDEF CL_1310 - File "${SYSTEMDIR}\mfc71.dll" - File "${SYSTEMDIR}\msvcr71.dll" - File "${SYSTEMDIR}\msvcp71.dll" - File "${SYSTEMDIR}\MFC71CHS.DLL" - File "${SYSTEMDIR}\MFC71CHT.DLL" - File "${SYSTEMDIR}\MFC71DEU.DLL" - File "${SYSTEMDIR}\MFC71ENU.DLL" - File "${SYSTEMDIR}\MFC71ESP.DLL" - File "${SYSTEMDIR}\MFC71FRA.DLL" - File "${SYSTEMDIR}\MFC71ITA.DLL" - File "${SYSTEMDIR}\MFC71JPN.DLL" - File "${SYSTEMDIR}\MFC71KOR.DLL" -!ELSE -!IFDEF CL_1300 - File "${SYSTEMDIR}\mfc70.dll" - File "${SYSTEMDIR}\msvcr70.dll" - File "${SYSTEMDIR}\msvcp70.dll" - File "${SYSTEMDIR}\MFC70CHS.DLL" - File "${SYSTEMDIR}\MFC70CHT.DLL" - File "${SYSTEMDIR}\MFC70DEU.DLL" - File "${SYSTEMDIR}\MFC70ENU.DLL" - File "${SYSTEMDIR}\MFC70ESP.DLL" - File "${SYSTEMDIR}\MFC70FRA.DLL" - File "${SYSTEMDIR}\MFC70ITA.DLL" - File "${SYSTEMDIR}\MFC70JPN.DLL" - File "${SYSTEMDIR}\MFC70KOR.DLL" -!ELSE - File "${SYSTEMDIR}\mfc42.dll" - File "${SYSTEMDIR}\msvcp60.dll" - File "${SYSTEMDIR}\msvcrt.dll" -!ENDIF -!ENDIF -!ENDIF ;Store install folder WriteRegStr HKCU "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "PathName" $INSTDIR WriteRegStr HKLM "${AFS_REGKEY_ROOT}\AFS Control Center\CurrentVersion" "VersionString" ${AFS_VERSION} @@ -2652,84 +2583,77 @@ Function AFSLangFiles File "${AFS_SERVER_BUILDDIR}\afskasadmin.dll" File "${AFS_SERVER_BUILDDIR}\afsptsadmin.dll" + SetOutPath "$INSTDIR\Common" + !IFDEF DEBUG !IFDEF CL_1310 - File "${SYSTEMDIR}\msvcr71d.dll" - File "${SYSTEMDIR}\msvcr71d.pdb" - File "${SYSTEMDIR}\msvcp71d.dll" - File "${SYSTEMDIR}\msvcp71d.pdb" - File "${SYSTEMDIR}\mfc71d.dll" - File "${SYSTEMDIR}\mfc71d.pdb" - File "${SYSTEMDIR}\MFC71CHS.DLL" - File "${SYSTEMDIR}\MFC71CHT.DLL" - File "${SYSTEMDIR}\MFC71DEU.DLL" - File "${SYSTEMDIR}\MFC71ENU.DLL" - File "${SYSTEMDIR}\MFC71ESP.DLL" - File "${SYSTEMDIR}\MFC71FRA.DLL" - File "${SYSTEMDIR}\MFC71ITA.DLL" - File "${SYSTEMDIR}\MFC71JPN.DLL" - File "${SYSTEMDIR}\MFC71KOR.DLL" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr71d.dll" "$INSTDIR\Common\msvcr71d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp71d.dll" "$INSTDIR\Common\msvcp71d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc71d.dll" "$INSTDIR\Common\mfc71d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHS.DLL" "$INSTDIR\Common\MFC71CHS.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHT.DLL" "$INSTDIR\Common\MFC71CHT.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71DEU.DLL" "$INSTDIR\Common\MFC71DEU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ENU.DLL" "$INSTDIR\Common\MFC71ENU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ESP.DLL" "$INSTDIR\Common\MFC71ESP.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71FRA.DLL" "$INSTDIR\Common\MFC71FRA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ITA.DLL" "$INSTDIR\Common\MFC71ITA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71JPN.DLL" "$INSTDIR\Common\MFC71JPN.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71KOR.DLL" "$INSTDIR\Common\MFC71KOR.DLL" "$INSTDIR" !ELSE !IFDEF CL_1300 - File "${SYSTEMDIR}\msvcr70d.dll" - File "${SYSTEMDIR}\msvcr70d.pdb" - File "${SYSTEMDIR}\msvcp70d.dll" - File "${SYSTEMDIR}\msvcp70d.pdb" - File "${SYSTEMDIR}\mfc70d.dll" - File "${SYSTEMDIR}\mfc70d.pdb" - File "${SYSTEMDIR}\MFC70CHS.DLL" - File "${SYSTEMDIR}\MFC70CHT.DLL" - File "${SYSTEMDIR}\MFC70DEU.DLL" - File "${SYSTEMDIR}\MFC70ENU.DLL" - File "${SYSTEMDIR}\MFC70ESP.DLL" - File "${SYSTEMDIR}\MFC70FRA.DLL" - File "${SYSTEMDIR}\MFC70ITA.DLL" - File "${SYSTEMDIR}\MFC70JPN.DLL" - File "${SYSTEMDIR}\MFC70KOR.DLL" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr70d.dll" "$INSTDIR\Common\msvcr70d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp70d.dll" "$INSTDIR\Common\msvcp70d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc70d.dll" "$INSTDIR\Common\mfc70d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHS.DLL" "$INSTDIR\Common\MFC70CHS.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHT.DLL" "$INSTDIR\Common\MFC70CHT.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70DEU.DLL" "$INSTDIR\Common\MFC70DEU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ENU.DLL" "$INSTDIR\Common\MFC70ENU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ESP.DLL" "$INSTDIR\Common\MFC70ESP.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70FRA.DLL" "$INSTDIR\Common\MFC70FRA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ITA.DLL" "$INSTDIR\Common\MFC70ITA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70JPN.DLL" "$INSTDIR\Common\MFC70JPN.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70KOR.DLL" "$INSTDIR\Common\MFC70KOR.DLL" "$INSTDIR" !ELSE - File "${SYSTEMDIR}\mfc42d.dll" - File "${SYSTEMDIR}\mfc42d.pdb" - File "${SYSTEMDIR}\msvcp60d.dll" - File "${SYSTEMDIR}\msvcp60d.pdb" - File "${SYSTEMDIR}\msvcrtd.dll" - File "${SYSTEMDIR}\msvcrtd.pdb" + !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc42d.dll" "$INSTDIR\Common\mfc42d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp60d.dll" "$INSTDIR\Common\msvcp60d.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcrtd.dll" "$INSTDIR\Common\msvcrtd.dll" "$INSTDIR" !ENDIF !ENDIF !ELSE !IFDEF CL_1310 - File "${SYSTEMDIR}\mfc71.dll" - File "${SYSTEMDIR}\msvcr71.dll" - File "${SYSTEMDIR}\msvcp71.dll" - File "${SYSTEMDIR}\MFC71CHS.DLL" - File "${SYSTEMDIR}\MFC71CHT.DLL" - File "${SYSTEMDIR}\MFC71DEU.DLL" - File "${SYSTEMDIR}\MFC71ENU.DLL" - File "${SYSTEMDIR}\MFC71ESP.DLL" - File "${SYSTEMDIR}\MFC71FRA.DLL" - File "${SYSTEMDIR}\MFC71ITA.DLL" - File "${SYSTEMDIR}\MFC71JPN.DLL" - File "${SYSTEMDIR}\MFC71KOR.DLL" + !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc71.dll" "$INSTDIR\Common\mfc71.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr71.dll" "$INSTDIR\Common\msvcr71.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp71.dll" "$INSTDIR\Common\msvcp71.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHS.DLL" "$INSTDIR\Common\MFC71CHS.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71CHT.DLL" "$INSTDIR\Common\MFC71CHT.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71DEU.DLL" "$INSTDIR\Common\MFC71DEU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ENU.DLL" "$INSTDIR\Common\MFC71ENU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ESP.DLL" "$INSTDIR\Common\MFC71ESP.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71FRA.DLL" "$INSTDIR\Common\MFC71FRA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71ITA.DLL" "$INSTDIR\Common\MFC71ITA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71JPN.DLL" "$INSTDIR\Common\MFC71JPN.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC71KOR.DLL" "$INSTDIR\Common\MFC71KOR.DLL" "$INSTDIR" !ELSE !IFDEF CL_1300 - File "${SYSTEMDIR}\mfc70.dll" - File "${SYSTEMDIR}\msvcr70.dll" - File "${SYSTEMDIR}\msvcp70.dll" - File "${SYSTEMDIR}\MFC70CHS.DLL" - File "${SYSTEMDIR}\MFC70CHT.DLL" - File "${SYSTEMDIR}\MFC70DEU.DLL" - File "${SYSTEMDIR}\MFC70ENU.DLL" - File "${SYSTEMDIR}\MFC70ESP.DLL" - File "${SYSTEMDIR}\MFC70FRA.DLL" - File "${SYSTEMDIR}\MFC70ITA.DLL" - File "${SYSTEMDIR}\MFC70JPN.DLL" - File "${SYSTEMDIR}\MFC70KOR.DLL" + !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc70.dll" "$INSTDIR\Common\mfc70.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcr70.dll" "$INSTDIR\Common\msvcr70.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp70.dll" "$INSTDIR\Common\msvcp70.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHS.DLL" "$INSTDIR\Common\MFC70CHS.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70CHT.DLL" "$INSTDIR\Common\MFC70CHT.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70DEU.DLL" "$INSTDIR\Common\MFC70DEU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ENU.DLL" "$INSTDIR\Common\MFC70ENU.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ESP.DLL" "$INSTDIR\Common\MFC70ESP.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70FRA.DLL" "$INSTDIR\Common\MFC70FRA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70ITA.DLL" "$INSTDIR\Common\MFC70ITA.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70JPN.DLL" "$INSTDIR\Common\MFC70JPN.DLL" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\MFC70KOR.DLL" "$INSTDIR\Common\MFC70KOR.DLL" "$INSTDIR" !ELSE - File "${SYSTEMDIR}\mfc42.dll" - File "${SYSTEMDIR}\msvcp60.dll" - File "${SYSTEMDIR}\msvcrt.dll" -!ENDIF + !insertmacro ReplaceDLL "${SYSTEMDIR}\mfc42.dll" "$INSTDIR\Common\mfc42.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcp60.dll" "$INSTDIR\Common\msvcp60.dll" "$INSTDIR" + !insertmacro ReplaceDLL "${SYSTEMDIR}\msvcrt.dll" "$INSTDIR\Common\msvcrt.dll" "$INSTDIR" !ENDIF !ENDIF +!ENDIF StrCmp $LANGUAGE ${LANG_ENGLISH} DoEnglish StrCmp $LANGUAGE ${LANG_GERMAN} DoGerman diff --git a/src/WINNT/install/wix/files.wxi b/src/WINNT/install/wix/files.wxi index c4f5fc5..8d251de 100644 --- a/src/WINNT/install/wix/files.wxi +++ b/src/WINNT/install/wix/files.wxi @@ -11,6 +11,7 @@ + diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index 864309d..5a06002 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -215,7 +215,9 @@ afsconf_Check(register struct afsconf_dir *adir) strcompose(tbuffer, sizeof(tbuffer), adir->name, "/", AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); } else { - int len = strlen(tbuffer); + int len; + strncpy(tbuffer, adir->name, sizeof(tbuffer)); + len = strlen(tbuffer); if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) { strncat(tbuffer, "\\", sizeof(tbuffer)); } @@ -434,7 +436,9 @@ afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell, strcompose(tbuffer, sizeof(tbuffer), adir->name, "/", AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); } else { - int len = strlen(tbuffer); + int len; + strncpy(tbuffer, adir->name, sizeof(tbuffer)); + len = strlen(tbuffer); if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) { strncat(tbuffer, "\\", sizeof(tbuffer)); } -- 1.9.4