From b0ba6348441e330509e444d77753d44940da19dd Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 16 Mar 2004 16:21:42 +0000 Subject: [PATCH] registry-20040316 Fix the DependsOnGroup NetworkProvider key to ensure it is placed in the correct location Change the location of the ShowTrayIcon key so that we no longer store user data in the HKLM Transarc tree ==================== 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. ==================== Move the locations of the ShowTrayIcon and cell name based expiration reminder keys out of the HKLM\SOFTWARE\Transarc... key and into the {HKCU,HKLM}\SOFTWARE\OpenAFS\... tree. This is safe to do because these keys are transient in nature (created by afscreds.exe) and really do belong to the user and not to the machine. --- src/WINNT/client_creds/afscreds.h | 3 ++- src/WINNT/client_creds/main.cpp | 11 +++++++++-- src/WINNT/client_creds/misc.cpp | 4 ++-- src/WINNT/client_creds/shortcut.cpp | 6 ++---- src/WINNT/client_creds/window.cpp | 38 ++++++++++++++++++++++--------------- src/WINNT/install/NSIS/OpenAFS.nsi | 4 ++-- 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/WINNT/client_creds/afscreds.h b/src/WINNT/client_creds/afscreds.h index 90d9489..a5aad5b 100644 --- a/src/WINNT/client_creds/afscreds.h +++ b/src/WINNT/client_creds/afscreds.h @@ -52,9 +52,10 @@ extern "C" { * */ -#define REGSTR_BASE HKEY_LOCAL_MACHINE #define REGSTR_PATH_AFS TEXT("Software\\TransarcCorporation\\AFS Client\\CurrentVersion") #define REGSTR_PATH_AFSCREDS TEXT("Software\\TransarcCorporation\\AFS Client\\AfsCreds") +#define REGSTR_PATH_OPENAFS_CLIENT TEXT("SOFTWARE\\OpenAFS\\Client") +#define REGSTR_PATH_OPENAFS_CLIENT_REMIND TEXT("SOFTWARE\\OpenAFS\\Client\\Reminders") #define REGVAL_AFS_TITLE TEXT("Title") #define REGVAL_AFS_VERSION TEXT("VersionString") diff --git a/src/WINNT/client_creds/main.cpp b/src/WINNT/client_creds/main.cpp index f7a66b6..6a977c5 100644 --- a/src/WINNT/client_creds/main.cpp +++ b/src/WINNT/client_creds/main.cpp @@ -171,7 +171,7 @@ BOOL InitApp (LPSTR pszCmdLineA) if (fInstall) { HKEY hk; - if (RegCreateKey (HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"), &hk) == 0) + if (RegCreateKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; @@ -211,7 +211,14 @@ BOOL InitApp (LPSTR pszCmdLineA) g.fStartup = TRUE; HKEY hk; - if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"), &hk) == 0) + if (RegOpenKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0) + { + DWORD dwSize = sizeof(g.fStartup); + DWORD dwType = REG_DWORD; + RegQueryValueEx (hk, TEXT("ShowTrayIcon"), NULL, &dwType, (PBYTE)&g.fStartup, &dwSize); + RegCloseKey (hk); + } + else if (RegOpenKey (HKEY_LOCAL_MACHINE, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0) { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; diff --git a/src/WINNT/client_creds/misc.cpp b/src/WINNT/client_creds/misc.cpp index 5251e9b..b06ece5 100644 --- a/src/WINNT/client_creds/misc.cpp +++ b/src/WINNT/client_creds/misc.cpp @@ -57,7 +57,7 @@ void LoadRemind (size_t iCreds) g.aCreds[ iCreds ].fRemind = TRUE; HKEY hk; - if (RegOpenKey (REGSTR_BASE, REGSTR_PATH_AFSCREDS, &hk) == 0) + if (RegOpenKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT_REMIND, &hk) == 0) { DWORD dwValue = 1; DWORD dwSize = sizeof(dwValue); @@ -72,7 +72,7 @@ void LoadRemind (size_t iCreds) void SaveRemind (size_t iCreds) { HKEY hk; - if (RegCreateKey (REGSTR_BASE, REGSTR_PATH_AFSCREDS, &hk) == 0) + if (RegCreateKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT_REMIND, &hk) == 0) { DWORD dwValue = g.aCreds[ iCreds ].fRemind; RegSetValueEx (hk, g.aCreds[ iCreds ].szCell, NULL, REG_DWORD, (PBYTE)&dwValue, sizeof(DWORD)); diff --git a/src/WINNT/client_creds/shortcut.cpp b/src/WINNT/client_creds/shortcut.cpp index 9508dd2..6bce0c7 100644 --- a/src/WINNT/client_creds/shortcut.cpp +++ b/src/WINNT/client_creds/shortcut.cpp @@ -41,8 +41,6 @@ void Shortcut_Exit (void) CoUninitialize(); } -static char OpenAFSConfigKeyName[] = "SOFTWARE\\OpenAFS\\Client"; - BOOL Shortcut_Create (LPTSTR pszTarget, LPCTSTR pszSource, LPTSTR pszDesc, LPTSTR pszArgs) { IShellLink *psl; @@ -115,10 +113,10 @@ void Shortcut_FixStartup (LPCTSTR pszLinkName, BOOL fAutoStart) DWORD code, len, type; TCHAR szParams[ 64 ] = TEXT(AFSCREDS_SHORTCUT_OPTIONS); - code = RegOpenKeyEx(HKEY_CURRENT_USER, OpenAFSConfigKeyName, + code = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT, 0, KEY_QUERY_VALUE, &hk); if (code != ERROR_SUCCESS) - code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, OpenAFSConfigKeyName, + code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGSTR_PATH_OPENAFS_CLIENT, 0, KEY_QUERY_VALUE, &hk); if (code == ERROR_SUCCESS) { len = sizeof(szParams); diff --git a/src/WINNT/client_creds/window.cpp b/src/WINNT/client_creds/window.cpp index 0a2cb14..e80b0b3 100644 --- a/src/WINNT/client_creds/window.cpp +++ b/src/WINNT/client_creds/window.cpp @@ -397,19 +397,27 @@ void Main_OnSelectTab (void) void Main_OnCheckTerminate (void) { - HKEY hk; - if (RegOpenKey (HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"), &hk) == 0) - { + HKEY hk; + + if (RegOpenKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0) + { + DWORD dwSize = sizeof(g.fStartup); + DWORD dwType = REG_DWORD; + RegQueryValueEx (hk, TEXT("ShowTrayIcon"), NULL, &dwType, (PBYTE)&g.fStartup, &dwSize); + RegCloseKey (hk); + } + else if (RegOpenKey (HKEY_LOCAL_MACHINE, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0) + { DWORD dwSize = sizeof(g.fStartup); DWORD dwType = REG_DWORD; RegQueryValueEx (hk, TEXT("ShowTrayIcon"), NULL, &dwType, (PBYTE)&g.fStartup, &dwSize); RegCloseKey (hk); - } + } - Shortcut_FixStartup (cszSHORTCUT_NAME, g.fStartup); + Shortcut_FixStartup (cszSHORTCUT_NAME, g.fStartup); - if (!g.fStartup) - Quit(); + if (!g.fStartup) + Quit(); } @@ -716,14 +724,14 @@ void Terminate_OnOK (HWND hDlg) g.fStartup = IsDlgButtonChecked (hDlg, IDC_STARTUP); - HKEY hk; - if (RegCreateKey (HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"), &hk) == 0) - { - DWORD dwSize = sizeof(g.fStartup); - DWORD dwType = REG_DWORD; - RegSetValueEx (hk, TEXT("ShowTrayIcon"), NULL, dwType, (PBYTE)&g.fStartup, dwSize); - RegCloseKey (hk); - } + HKEY hk; + if (RegCreateKey (HKEY_CURRENT_USER, REGSTR_PATH_OPENAFS_CLIENT, &hk) == 0) + { + DWORD dwSize = sizeof(g.fStartup); + DWORD dwType = REG_DWORD; + RegSetValueEx (hk, TEXT("ShowTrayIcon"), NULL, dwType, (PBYTE)&g.fStartup, dwSize); + RegCloseKey (hk); + } Shortcut_FixStartup (cszSHORTCUT_NAME, g.fStartup); diff --git a/src/WINNT/install/NSIS/OpenAFS.nsi b/src/WINNT/install/NSIS/OpenAFS.nsi index a1de9c8..0c68667 100644 --- a/src/WINNT/install/NSIS/OpenAFS.nsi +++ b/src/WINNT/install/NSIS/OpenAFS.nsi @@ -642,7 +642,7 @@ skipremove: ReadINIStr $R0 $1 "Field 2" "State" WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "Cell" $R0 ReadINIStr $R0 $1 "Field 3" "State" - WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "ShowTrayIcon" 1 + WriteRegDWORD HKLM "SOFTWARE\OpenAFS\Client" "ShowTrayIcon" 1 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel" $R0 ReadINIStr $R0 $1 "Field 5" "State" WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "FreelanceClient" $R0 @@ -657,7 +657,7 @@ skipremove: WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NoFindLanaByName" 1 !ENDIF - strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon" + strcpy $REG_SUB_KEY "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" strcpy $REG_VALUE "DependOnGroup" strcpy $REG_DATA_1 "PNP_TDI" strcpy $REG_DATA_2 "" -- 1.9.4