mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 23:40:13 +00:00
STABLE14-windows-misc-20040907
replace QWORD with DWORD
====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================
add expanded registry string support to Submounts
====================
Correct a 64-bit time_t error
(cherry picked from commit f31658317a
)
This commit is contained in:
parent
8660663e6a
commit
e0e9832c9b
@ -28,7 +28,7 @@ Variable: LANadapter
|
||||
name will be 'AFS'.
|
||||
|
||||
Value : CacheSize
|
||||
Type : QWORD
|
||||
Type : DWORD
|
||||
Default : 20480 (CM_CONFIGDEFAULT_CACHESIZE)
|
||||
Variable: cm_initParams.cacheSize
|
||||
|
||||
@ -58,7 +58,7 @@ Variable: numSvThreads
|
||||
smb_Server in smb.c).
|
||||
|
||||
Value : Stats
|
||||
Type : QWORD
|
||||
Type : DWORD
|
||||
Default : 1000 (CM_CONFIGDEFAULT_STATS)
|
||||
Variable: cm_initParams.nStatCaches
|
||||
|
||||
@ -76,7 +76,7 @@ Variable: smb_LogoffTokenTransfer
|
||||
that the tokens remain valid until the profile save is complete.
|
||||
|
||||
Value : LogoffTokenTransferTimeout
|
||||
Type : QWORD
|
||||
Type : DWORD
|
||||
Default : 10
|
||||
Variable: smb_LogoffTokenTransferTimeout
|
||||
|
||||
@ -165,7 +165,7 @@ Variable: reportSessionStartups
|
||||
or various error types to be logged.
|
||||
|
||||
Value : TraceBufferSize
|
||||
Type : QWORD
|
||||
Type : DWORD
|
||||
Default : 5000 (CM_CONFIGDEFAULT_TRACEBUFSIZE)
|
||||
Variable: traceBufSize
|
||||
|
||||
|
@ -590,7 +590,7 @@ int afsd_InitCM(char **reasonP)
|
||||
code = RegQueryValueEx(parmKey, "CachePath", NULL, ®Type,
|
||||
buf, &dummyLen);
|
||||
if (code == ERROR_SUCCESS && buf[0]) {
|
||||
if(regType == REG_EXPAND_SZ) {
|
||||
if (regType == REG_EXPAND_SZ) {
|
||||
dummyLen = ExpandEnvironmentStrings(buf, cm_CachePath, sizeof(cm_CachePath));
|
||||
if(dummyLen > sizeof(cm_CachePath)) {
|
||||
afsi_log("Cache path [%s] longer than %d after expanding env strings", buf, sizeof(cm_CachePath));
|
||||
|
@ -65,7 +65,7 @@ main(int argc, char **argv) {
|
||||
else
|
||||
mountstring = argv[2];
|
||||
|
||||
if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_SZ, mountstring, strlen(mountstring)+1)) {
|
||||
if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_EXPAND_SZ, mountstring, strlen(mountstring)+1)) {
|
||||
fprintf(stderr,"Submount Set failure for [%s]: %lX",
|
||||
argv[1], GetLastError());
|
||||
RegCloseKey(hkSubmounts);
|
||||
|
@ -39,6 +39,7 @@
|
||||
#endif
|
||||
|
||||
#include "cm_rpc.h"
|
||||
#include <strsafe.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <crtdbg.h>
|
||||
@ -2044,7 +2045,7 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
|
||||
* leading "/afs" when writing out the submount.
|
||||
*/
|
||||
RegSetValueEx( hkSubmounts, submountreqp, 0,
|
||||
REG_SZ,
|
||||
REG_EXPAND_SZ,
|
||||
(strlen(&afspath[strlen(cm_mountRoot)])) ?
|
||||
&afspath[strlen(cm_mountRoot)]:"/",
|
||||
(strlen(&afspath[strlen(cm_mountRoot)])) ?
|
||||
@ -2098,14 +2099,21 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
|
||||
char submountPathNormalized[MAX_PATH];
|
||||
char submountPath[MAX_PATH] = "";
|
||||
DWORD submountPathLen = sizeof(submountPath);
|
||||
char submountName[256];
|
||||
char submountName[MAX_PATH];
|
||||
DWORD submountNameLen = sizeof(submountName);
|
||||
|
||||
dwType = 0;
|
||||
RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
|
||||
&dwType, submountPath, &submountPathLen);
|
||||
if (dwType == REG_EXPAND_SZ) {
|
||||
char buf[MAX_PATH];
|
||||
StringCbCopyA(buf, MAX_PATH, submountPath);
|
||||
submountPathLen = ExpandEnvironmentStrings(buf, submountPath, MAX_PATH);
|
||||
if (submountPathLen > MAX_PATH)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If this is an Auto### submount, remember its ### value */
|
||||
|
||||
if ((!strnicmp (submountName, "auto", 4)) &&
|
||||
(isdigit (submountName[strlen("auto")]))) {
|
||||
int thisAutoSubmount;
|
||||
@ -2145,7 +2153,7 @@ long cm_IoctlMakeSubmount(smb_ioctl_t *ioctlp, cm_user_t *userp)
|
||||
RegSetValueEx( hkSubmounts,
|
||||
ioctlp->outDatap,
|
||||
0,
|
||||
REG_SZ,
|
||||
REG_EXPAND_SZ,
|
||||
(strlen(&afspath[strlen(cm_mountRoot)])) ?
|
||||
&afspath[strlen(cm_mountRoot)]:"/",
|
||||
(strlen(&afspath[strlen(cm_mountRoot)])) ?
|
||||
|
@ -26,6 +26,7 @@ extern "C" {
|
||||
#endif
|
||||
#include <osilog.h>
|
||||
#include <lanahelper.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
extern void Config_GetLanAdapter (ULONG *pnLanAdapter);
|
||||
|
||||
@ -75,6 +76,28 @@ WriteRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs)
|
||||
return (status == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
WriteExpandedRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs)
|
||||
{
|
||||
HKEY hkSub = NULL;
|
||||
RegCreateKeyEx( key,
|
||||
subkey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&hkSub,
|
||||
NULL);
|
||||
|
||||
DWORD status = RegSetValueEx( hkSub, lhs, 0, REG_EXPAND_SZ, (const BYTE *)rhs, strlen(rhs)+1 );
|
||||
|
||||
if ( hkSub )
|
||||
RegCloseKey( hkSub );
|
||||
|
||||
return (status == ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
ReadRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs, DWORD * size)
|
||||
{
|
||||
@ -89,8 +112,19 @@ ReadRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs, LPTSTR rhs, DWORD * siz
|
||||
&hkSub,
|
||||
NULL);
|
||||
|
||||
DWORD dwType;
|
||||
DWORD status = RegQueryValueEx( hkSub, lhs, 0, &dwType, (LPBYTE)rhs, size );
|
||||
DWORD dwType = 0;
|
||||
DWORD localSize = *size;
|
||||
|
||||
DWORD status = RegQueryValueEx( hkSub, lhs, 0, &dwType, (LPBYTE)rhs, &localSize);
|
||||
if (status == 0 && dwType == REG_EXPAND_SZ) {
|
||||
TCHAR * buf = (TCHAR *)malloc((*size) * sizeof(TCHAR));
|
||||
memcpy(buf, rhs, (*size) * sizeof(TCHAR));
|
||||
localSize = ExpandEnvironmentStrings(buf, rhs, *size);
|
||||
free(buf);
|
||||
if ( localSize > *size )
|
||||
status = !ERROR_SUCCESS;
|
||||
}
|
||||
*size = localSize;
|
||||
|
||||
if ( hkSub )
|
||||
RegCloseKey( hkSub );
|
||||
@ -112,7 +146,6 @@ DeleteRegistryString(HKEY key, TCHAR * subkey, LPTSTR lhs)
|
||||
&hkSub,
|
||||
NULL);
|
||||
|
||||
DWORD dwType;
|
||||
DWORD status = RegDeleteValue( hkSub, lhs );
|
||||
|
||||
if ( hkSub )
|
||||
@ -385,7 +418,7 @@ void QueryDriveMapList_ReadSubmounts (PDRIVEMAPLIST pList)
|
||||
HKEY hkSubmounts;
|
||||
|
||||
RegCreateKeyEx( HKEY_LOCAL_MACHINE,
|
||||
"SOFTWARE\\OpenAFS\\Client\\Submounts",
|
||||
cszSECTION_SUBMOUNTS,
|
||||
0,
|
||||
"AFS",
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
@ -414,11 +447,19 @@ void QueryDriveMapList_ReadSubmounts (PDRIVEMAPLIST pList)
|
||||
DWORD submountPathLen = MAX_PATH;
|
||||
TCHAR submountName[MAX_PATH];
|
||||
DWORD submountNameLen = MAX_PATH;
|
||||
DWORD dwType;
|
||||
DWORD dwType = 0;
|
||||
|
||||
RegEnumValue( hkSubmounts, dwIndex, submountName, &submountNameLen, NULL,
|
||||
&dwType, (LPBYTE)submountPath, &submountPathLen);
|
||||
|
||||
if (dwType == REG_EXPAND_SZ) {
|
||||
char buf[MAX_PATH];
|
||||
StringCbCopyA(buf, MAX_PATH, submountPath);
|
||||
submountPathLen = ExpandEnvironmentStrings(buf, submountPath, MAX_PATH);
|
||||
if (submountPathLen > MAX_PATH)
|
||||
continue;
|
||||
}
|
||||
|
||||
SUBMOUNT Submount;
|
||||
memset (&Submount, 0x00, sizeof(SUBMOUNT));
|
||||
lstrcpy (Submount.szSubmount, submountName);
|
||||
@ -805,7 +846,7 @@ void AddSubMount (LPTSTR pszSubmount, LPTSTR pszMapping)
|
||||
if (!szRHS[0])
|
||||
lstrcpy (szRHS, TEXT("/"));
|
||||
|
||||
WriteRegistryString(HKEY_LOCAL_MACHINE, cszSECTION_SUBMOUNTS, pszSubmount, szRHS);
|
||||
WriteExpandedRegistryString(HKEY_LOCAL_MACHINE, cszSECTION_SUBMOUNTS, pszSubmount, szRHS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -304,13 +304,13 @@ ObtainTokensFromUserIfNeeded(HWND hWnd)
|
||||
strcpy(aserver.name, "afs");
|
||||
strcpy(aserver.cell, rootcell);
|
||||
|
||||
rc = ktc_GetToken(&aserver, &atoken, sizeof(atoken), &aclient);
|
||||
if ( rc == 0 ) {
|
||||
GetLocalTime (&stNow);
|
||||
SystemTimeToFileTime (&stNow, &ftNow);
|
||||
llNow = (((LONGLONG)ftNow.dwHighDateTime) << 32) + (LONGLONG)(ftNow.dwLowDateTime);
|
||||
llNow /= c100ns1SECOND;
|
||||
|
||||
rc = ktc_GetToken(&aserver, &atoken, sizeof(atoken), &aclient);
|
||||
if ( rc == 0 ) {
|
||||
TimeToSystemTime (&stExpires, atoken.endTime);
|
||||
SystemTimeToFileTime (&stExpires, &ftExpires);
|
||||
llExpires = (((LONGLONG)ftExpires.dwHighDateTime) << 32) + (LONGLONG)(ftExpires.dwLowDateTime);
|
||||
@ -371,15 +371,16 @@ ObtainTokensFromUserIfNeeded(HWND hWnd)
|
||||
KFW_AFS_renew_token_for_cell(rootcell);
|
||||
|
||||
rc = ktc_GetToken(&aserver, &atoken, sizeof(atoken), &aclient);
|
||||
|
||||
if ( rc == 0 ) {
|
||||
TimeToSystemTime (&stExpires, atoken.endTime);
|
||||
SystemTimeToFileTime (&stExpires, &ftExpires);
|
||||
llExpires = (((LONGLONG)ftExpires.dwHighDateTime) << 32) + (LONGLONG)(ftExpires.dwLowDateTime);
|
||||
llExpires /= c100ns1SECOND;
|
||||
|
||||
if (!rc && (llNow < llExpires))
|
||||
if (llNow < llExpires)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage(hWnd, WM_OBTAIN_TOKENS, FALSE, (long)rootcell);
|
||||
rootcell = NULL; // rootcell freed by message receiver
|
||||
|
Loading…
Reference in New Issue
Block a user