windows-installer-updates-20050612
authorJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 13 Jun 2005 02:06:57 +0000 (02:06 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 13 Jun 2005 02:06:57 +0000 (02:06 +0000)
Add asetkey.exe

Add uninstall.exe and associated shortcut to Wix

Fix ability to uninstall loopback adapter on non-English Windows versions

====================
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 clean rule

====================

use "uninst" for rule instead of "uninstall"

====================

build wix/uninstall directory

====================

add OpenAFS logo icon

12 files changed:
src/WINNT/install/NSIS/OpenAFS.nsi
src/WINNT/install/loopback/loopbackutils.cpp
src/WINNT/install/wix/Icon/ico_OpenAFS.ico [new file with mode: 0644]
src/WINNT/install/wix/NTMakefile
src/WINNT/install/wix/feature.wxi
src/WINNT/install/wix/files.wxi
src/WINNT/install/wix/lang/en_US/strings.wxl
src/WINNT/install/wix/lang/en_US/ui.wxi
src/WINNT/install/wix/uninstall/NTMakefile [new file with mode: 0644]
src/WINNT/install/wix/uninstall/uninstall.c [new file with mode: 0644]
src/WINNT/install/wix/uninstall/uninstall.rc [new file with mode: 0644]
src/config/NTMakefile

index e7577b2..3fd63f0 100644 (file)
@@ -787,6 +787,7 @@ skipCheck:
   SetOutPath "$INSTDIR\Server\usr\afs\bin"  
   File "${AFS_SERVER_BUILDDIR}\afskill.exe"
   File "${AFS_SERVER_BUILDDIR}\afssvrcfg.exe"
+  File "${AFS_SERVER_BUILDDIR}\asetkey.exe"
   File "${AFS_SERVER_BUILDDIR}\bosctlsvc.exe"
   File "${AFS_SERVER_BUILDDIR}\bosserver.exe"
   File "${AFS_SERVER_BUILDDIR}\buserver.exe"
@@ -1155,6 +1156,7 @@ DoServer:
   SetOutPath "$INSTDIR\Server\usr\afs\bin"  
   File "${AFS_SERVER_BUILDDIR}\afskill.pdb"
   File "${AFS_SERVER_BUILDDIR}\afssvrcfg.pdb"
+  File "${AFS_SERVER_BUILDDIR}\asetkey.pdb"
   File "${AFS_SERVER_BUILDDIR}\bosctlsvc.pdb"
   File "${AFS_SERVER_BUILDDIR}\bosserver.pdb"
   File "${AFS_SERVER_BUILDDIR}\buserver.pdb"
index 72256a5..01248d2 100644 (file)
@@ -57,7 +57,6 @@ extern "C" DWORD UnInstallLoopBack(void)
     GUID netGuid;
     HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;
     SP_DEVINFO_DATA DeviceInfoData;
-    TCHAR* deviceDesc;
     DWORD index = 0;
     BOOL found = FALSE;
     DWORD size = 0;
@@ -74,45 +73,80 @@ extern "C" DWORD UnInstallLoopBack(void)
     if (hDeviceInfo == INVALID_HANDLE_VALUE)
         return GetLastError();
 
-    deviceDesc = (TCHAR *)malloc(MAX_PATH*sizeof(TCHAR));
     // enumerate the driver info list
-    while (SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData))
+    while (TRUE)
     {
+        TCHAR * deviceHwid;
+
+        ok = SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData);
+
+       if(!ok) 
+       {
+         if(GetLastError() == ERROR_NO_MORE_ITEMS)
+             break;
+         else 
+         {
+             index++;
+             continue;
+         }
+       }
+
         // try to get the DeviceDesc registry property
-        ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, &DeviceInfoData,
-                                              SPDRP_DEVICEDESC,
-                                              NULL, (PBYTE)deviceDesc,
-                                              MAX_PATH * sizeof(TCHAR), &size);
+        ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, 
+                                             &DeviceInfoData,
+                                              SPDRP_HARDWAREID,
+                                              NULL,
+                                             NULL,
+                                              0, 
+                                             &size);
         if (!ok)
         {
             ret = GetLastError();
-            if (ret != ERROR_INSUFFICIENT_BUFFER)
-                break;
-            // if the buffer is too small, reallocate
-            free(deviceDesc);
-            deviceDesc = (TCHAR *)malloc(size);
+            if (ret != ERROR_INSUFFICIENT_BUFFER) {
+                index++;
+                continue;
+           }
+
+            deviceHwid = (TCHAR *)malloc(size);
             ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo,
                                                   &DeviceInfoData,
-                                                  SPDRP_DEVICEDESC,
-                                                  NULL, (PBYTE)deviceDesc,
-                                                  size, NULL);
-            if (!ok)
-                break;
-        }
+                                                  SPDRP_HARDWAREID,
+                                                  NULL, 
+                                                 (PBYTE)deviceHwid,
+                                                  size, 
+                                                 NULL);
+            if (!ok) {
+               free(deviceHwid);
+               deviceHwid = NULL;
+               index++;
+               continue;
+           }
+        } else {
+           // something is wrong.  This shouldn't have worked with a NULL buffer
+           ReportMessage(0, "GetDeviceRegistryProperty succeeded with a NULL buffer", NULL,  NULL, 0);
+           index++;
+           continue;
+       }
 
-        // case insensitive comparison
-        _tcslwr(deviceDesc);
-        if( _tcsstr(deviceDesc, DRIVER))
-        {
-            found = TRUE;
-            break;
-        }
+       for (TCHAR *t = deviceHwid; t && *t && t < &deviceHwid[size / sizeof(TCHAR)]; t += _tcslen(t) + 1)
+       {
+           if(!_tcsicmp(DRIVERHWID, t)) {
+               found = TRUE;
+               break;
+           }
+       }
+
+       if (deviceHwid) {
+           free(deviceHwid);
+           deviceHwid = NULL;
+       }
 
+       if (found)
+            break;
+       
         index++;
     }
 
-    free(deviceDesc);
-    
     if (found == FALSE)
     {
         ret = GetLastError();
@@ -126,6 +160,7 @@ extern "C" DWORD UnInstallLoopBack(void)
         ret = GetLastError();
         goto cleanup;
     }
+
     ok = SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData);
     if (!ok)
     {
@@ -133,6 +168,8 @@ extern "C" DWORD UnInstallLoopBack(void)
         goto cleanup;
     }
 
+    ret = 0;
+
 cleanup:
     // clean up the device info set
     if (hDeviceInfo != INVALID_HANDLE_VALUE)
@@ -143,7 +180,6 @@ cleanup:
 
 BOOL IsLoopbackInstalled(void)
 {
-    TCHAR * hwid = _T("*MSLOOP");
     HDEVINFO DeviceInfoSet;
     SP_DEVINFO_DATA DeviceInfoData;
     DWORD i,err;
@@ -163,11 +199,21 @@ BOOL IsLoopbackInstalled(void)
     //
     found = FALSE;
     DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
-    for (i=0; SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData); i++)
+    for (i=0; ;i++)
     {
+        BOOL ok;
         DWORD DataT;
         TCHAR *p, *buffer = NULL;
         DWORD buffersize = 0;
+
+       ok = SetupDiEnumDeviceInfo(DeviceInfoSet, i, &DeviceInfoData);
+
+       if(!ok) {
+         if(GetLastError() == ERROR_NO_MORE_ITEMS)
+           break;
+         else
+           continue;
+       }
         
         //
         // We won't know the size of the HardwareID buffer until we call
@@ -175,7 +221,13 @@ BOOL IsLoopbackInstalled(void)
         // use the required buffer size to Alloc the nessicary space.
         // Keep calling we have success or an unknown failure.
         //
-        while (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,&DeviceInfoData,SPDRP_HARDWAREID,&DataT,(PBYTE)buffer,buffersize,&buffersize))
+        while (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
+                                                &DeviceInfoData,
+                                                SPDRP_HARDWAREID,
+                                                &DataT,
+                                                (PBYTE)buffer,
+                                                buffersize,
+                                                &buffersize))
         {
             if (GetLastError() == ERROR_INVALID_DATA)
             {
@@ -191,25 +243,32 @@ BOOL IsLoopbackInstalled(void)
             }
             else
             {
+               if (buffer)
+                    LocalFree(buffer);
                 goto cleanup_DeviceInfo;
-            }            
+            }
         }
         
-        if (GetLastError() == ERROR_INVALID_DATA) 
+        if (GetLastError() == ERROR_INVALID_DATA) {
+           if (buffer)
+                LocalFree(buffer);
             continue;
+       }
         
         // Compare each entry in the buffer multi-sz list with our hwid.
         for (p=buffer; *p && (p < &buffer[buffersize]); p += _tcslen(p)+1)
         {
-            if (!_tcsicmp(hwid,p))
+            if (!_tcsicmp(DRIVERHWID,p))
             {
                 found = TRUE;
                 break;
             }
         }
         
-        if (buffer) LocalFree(buffer);
-        if (found) break;
+        if (buffer)
+           LocalFree(buffer);
+        if (found) 
+           break;
     }
     
     //  Cleanup.
@@ -323,16 +382,28 @@ extern "C" DWORD InstallLoopBack(LPCTSTR pConnectionName, LPCTSTR ip, LPCTSTR ma
 
        // if we successfully find the hardware ID and it turns out to
        // be the one for the loopback driver, then we are done.
-       if(SetupDiGetDriverInfoDetail(hDeviceInfo,
+       if (SetupDiGetDriverInfoDetail(hDeviceInfo,
                                      &DeviceInfoData,
                                      &DriverInfoData,
                                      pDriverInfoDetail,
                                      sizeof(detailBuf),
-                                     NULL) &&
-          !_tcsicmp(pDriverInfoDetail->HardwareID, DRIVERHWID)) {
-
-         found = TRUE;
-         break;
+                                     NULL)) {
+            TCHAR * t;
+
+           // pDriverInfoDetail->HardwareID is a MULTISZ string.  Go through the
+           // whole list and see if there is a match somewhere.
+           t = pDriverInfoDetail->HardwareID;
+           while (t && *t && t < (TCHAR *) &detailBuf[sizeof(detailBuf)/sizeof(detailBuf[0])]) {
+             if (!_tcsicmp(t, DRIVERHWID))
+               break;
+
+             t += _tcslen(t) + 1;
+           }
+
+           if (t && *t && t < (TCHAR *) &detailBuf[sizeof(detailBuf)/sizeof(detailBuf[0])]) {
+             found = TRUE;
+             break;
+           }
        }
 
         index++;
diff --git a/src/WINNT/install/wix/Icon/ico_OpenAFS.ico b/src/WINNT/install/wix/Icon/ico_OpenAFS.ico
new file mode 100644 (file)
index 0000000..3c434f1
Binary files /dev/null and b/src/WINNT/install/wix/Icon/ico_OpenAFS.ico differ
index b335a43..d8868af 100644 (file)
@@ -1,3 +1,10 @@
+# Copyright 2004, OpenAFS.ORG and others.
+# All Rights Reserved.
+#
+# This software has been released under the terms of the IBM Public
+# License.  For details, see the LICENSE file in the top-level source
+# directory or online at http://www.openafs.org/dl/license10.html
+
 RELDIR=WINNT\install\wix
 !INCLUDE ..\..\..\config\NTMakefile.$(SYS_NAME)
 !INCLUDE ..\..\..\config\NTMakefile.version
@@ -32,12 +39,17 @@ languages:
 
 lang:: lang_clean $(MSIFILE)
 
+uninst: 
+        $(CD) uninstall
+        $(MAKE) /f NTMakefile /nologo install
+        $(CD) ..
+
 customactions:
        $(CD) custom
        $(MAKE) /f NTMakefile /nologo install
        $(CD) ..
 
-install: customactions languages
+install: uninst customactions languages 
 
 $(MSIFILE): $(WIXOBJ)
        light -nologo -out $(MSIFILE) \
@@ -67,6 +79,9 @@ clean::
        $(CD) custom
        $(MAKE) /f NTMakefile /nologo clean
        $(CD) ..
+       $(CD) uninstall
+       $(MAKE) /f NTMakefile /nologo clean
+       $(CD) ..
        
 lang_clean:
        -$(DEL) $(WIXOBJ)
index 7d647ce..1c4302b 100644 (file)
@@ -5,6 +5,7 @@
             Title="OpenAFS">
            <ComponentRef Id="efl_desktop_INI" />
            <ComponentRef Id="efl_replace_afs_CMD" />
+           <ComponentRef Id="efl_uninstall_EXE" />
             <Feature Id="feaClient" AllowAdvertise="no" Description="$(loc.StrAFSClientLongDesc)" Display="expand"
                 InstallDefault="followParent" Level="30" Title="$(loc.StrAFSClientDesc)">
                 
                 <ComponentRef Id="cmf_volserver_EXE" />
                 <ComponentRef Id="cmf_afskill_EXE" />
                 <ComponentRef Id="cmf_afssvrcfg_EXE" />
+                <ComponentRef Id="cmf_asetkey_EXE" />
                 <ComponentRef Id="cmf_bosctlsvc_EXE" />
                 <ComponentRef Id="cmf_bosserver_EXE" />
                 <ComponentRef Id="cmf_buserver_EXE" />
index de2f811..7acc16c 100644 (file)
             <Component Id="efl_replace_afs_CMD" Guid="C9C93F3E-EEBA-4056-9669-5EF78D748D50">
                <File Id="filreplace_afs_CMD" Name="replafs.cmd" LongName="replace_afs.cmd" KeyPath="yes" DiskId="1" src="$(var.SrcDir)\WINNT\install\wix\replace_afs.cmd" />
             </Component>
+           <Component Id="efl_uninstall_EXE" Guid="8B99B979-03F4-4AB5-9CE8-1DA97DB6613A">
+               <File Id="filuninstall_EXE" Name="uninst.exe" LongName="uninstall.exe" KeyPath="yes" DiskId="1" src="$(var.ClientDir)\uninstall.exe">
+                       <Shortcut Id="scUninstall" Directory="dirShortCut" Name="Uninst.lnk" LongName="Uninstall OpenAFS.lnk" Description="$(loc.StrUninstallDesc)" Icon="ico_OpenAFS" IconIndex="0" Show="normal" />
+                </File>
+           </Component>
             <Directory Id="dirCommon" Name="Common">
                 <Component Id="cmp_CommonDir" Guid="C86B03A1-AE97-48B1-A77B-1B2395F1E117" KeyPath="yes">
                     <Environment Id="envCommon" Name="PATH" Action="create" System="yes" Permanent="no" Part="last" Separator=";" Value="[AFSDIR]Common" />
                                                                        <Shortcut Id="scSvrCfgWizard" Directory="dirShortCut" Name="SvrCfgWz.lnk" LongName="Server Configuration Wizard.lnk" Description="$(loc.StrCfgWzdDesc)" Arguments="/wizard" Icon="ico_afssvrcfg" IconIndex="0" Show="normal" WorkingDirectory="dirCommon" />
                                 </File>
                             </Component>
+                            <Component Id="cmf_asetkey_EXE" Guid="9B7694A2-DCAE-4DBA-84F2-09DC796C20B2">
+                                <File Id="fileasetkey_EXE" Name="asetk.exe" LongName="asetkey.exe" KeyPath="yes" DiskId="1" />
+                            </Component>
                             <Component Id="cmf_bosctlsvc_EXE" Guid="8F6F62A8-BB6D-46C1-BA80-4F207AA24F0D">
                                 <File Id="filebosctlsvc_EXE" Name="bosct.exe" LongName="bosctlsvc.exe" KeyPath="yes" DiskId="1" />
                                 <ServiceControl Id="TransarcAFSServer" Name="TransarcAFSServer" Stop="both" Remove="both" Wait="yes" />
                                 <File Id="filevolserver_PDB" Name="volse.pdb" LongName="volserver.pdb" DiskId="1" />
                                 <File Id="fileafskill_PDB" Name="afski.pdb" LongName="afskill.pdb" DiskId="1" />
                                 <File Id="fileafssvrcfg_PDB" Name="afssv.pdb" LongName="afssvrcfg.pdb" DiskId="1" />
+                                <File Id="fileasetkey_PDB" Name="asetk.pdb" LongName="asetkey.pdb" DiskId="1" />
                                 <File Id="filebosctlsvc_PDB" Name="bosct.pdb" LongName="bosctlsvc.pdb" DiskId="1" />
                                 <File Id="filebosserver_PDB" Name="bosse.pdb" LongName="bosserver.pdb" DiskId="1" />
                                 <File Id="filebuserver_PDB" Name="buser.pdb" LongName="buserver.pdb" DiskId="1" />
index 45c1273..dab8cee 100644 (file)
@@ -54,5 +54,5 @@
        <String Id="ActRemoveNsisInstallation">Removing existing installation of OpenAFS</String>
        
        <String Id="StrNsisAbortReason">Installation of OpenAFS for Windows was prematurely terminated because OpenAFS [NSISVERSION] was already installed.</String>
-       
+       <String Id="StrUninstallDesc">Uninstall OpenAFS from the local machine.</String>
 </WixLocalization>
index 4e458dc..98555f4 100644 (file)
     <Icon Id="ico_Help" src="Icon\ico_Help.ico" />
     <Icon Id="ico_ServerManager" src="Icon\ico_ServerManager.ico" />
     <Icon Id="ico_afssvrcfg" src="Icon\ico_afssvrcfg.ico" />
+    <Icon Id="ico_OpenAFS" src="Icon\ico_OpenAFS.ico" />
 </Include>
diff --git a/src/WINNT/install/wix/uninstall/NTMakefile b/src/WINNT/install/wix/uninstall/NTMakefile
new file mode 100644 (file)
index 0000000..ff266cd
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright 2004, OpenAFS.ORG and others.
+# All Rights Reserved.
+#
+# This software has been released under the terms of the IBM Public
+# License.  For details, see the LICENSE file in the top-level source
+# directory or online at http://www.openafs.org/dl/license10.html
+
+RELDIR=WINNT\install\wix\uninstall
+!INCLUDE ..\..\..\..\config\NTMakefile.$(SYS_NAME)
+!INCLUDE ..\..\..\..\config\NTMakefile.version
+
+UNINSTALL = $(DESTDIR)\root.client\usr\vice\etc\uninstall.exe
+
+OBJECTS = $(OUT)\uninstall.obj
+
+$(OBJECTS): $$(@B).c
+        $(C2OBJ) $**
+
+$(OUT)\uninstall.res: uninstall.rc AFS_component_version_number.h
+
+$(UNINSTALL): $(OBJECTS) $(OUT)\uninstall.res
+  $(EXECONLINK) msi.lib
+  $(EXEPREP)
+
+install: $(UNINSTALL)
+
+# Cleanup
+clean::
+        -$(DEL) AFS_component_version_number.h
+        -$(DEL) $(OUT)\uninstall.obj
+        -$(DEL) $(OUT)\uninstall.res
+        -$(DEL) $(UNINSTALL)
diff --git a/src/WINNT/install/wix/uninstall/uninstall.c b/src/WINNT/install/wix/uninstall/uninstall.c
new file mode 100644 (file)
index 0000000..4295a97
--- /dev/null
@@ -0,0 +1,23 @@
+#define _WIN32_MSI 200
+#include <windows.h>
+#include <msi.h>
+
+#define OAFW_UPGRADE_CODE TEXT("{6823EEDD-84FC-4204-ABB3-A80D25779833}")
+int main(void)
+{
+    UINT rc = ERROR_SUCCESS;
+    DWORD iProduct = 0;
+    CHAR  szProductCode[39];
+
+    MsiSetInternalUI(INSTALLUILEVEL_PROGRESSONLY, NULL);
+    
+    do {
+        rc = MsiEnumRelatedProducts(OAFW_UPGRADE_CODE, 0, iProduct, szProductCode);
+        if ( rc == ERROR_SUCCESS ) {
+            MsiConfigureProduct(szProductCode, 0 /* ignored */, INSTALLSTATE_ABSENT);
+            iProduct++;
+        }
+    } while ( rc == ERROR_SUCCESS );
+
+    return (rc == ERROR_NO_MORE_ITEMS ? 0 : 1);
+}
diff --git a/src/WINNT/install/wix/uninstall/uninstall.rc b/src/WINNT/install/wix/uninstall/uninstall.rc
new file mode 100644 (file)
index 0000000..d846dfd
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ * 
+ * This software has been released under the terms of the IBM Public
+ * License.  For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+
+/* Define VERSIONINFO resource */
+
+#define  AFS_VERINFO_FILE_DESCRIPTION "AFS Uninstall Command"
+#define AFS_VERINFO_NAME "uninstall"
+#define AFS_VERINFO_FILENAME "uninstall.exe"
+
+#include "AFS_component_version_number.h"
+#include "..\..\..\..\config\NTVersioninfo.rc"
+
+100                ICON    DISCARDABLE     "..\Icon\ico_OpenAFS.ico"
\ No newline at end of file
index 57fa76c..f90a4ba 100644 (file)
@@ -359,6 +359,9 @@ idirs: doclink
 !      IF (!EXIST($(OJT)\WINNT\install\wix\custom))
                $(MKDIR) $(OJT)\WINNT\install\wix\custom
 !      ENDIF
+!      IF (!EXIST($(OJT)\WINNT\install\wix\uninstall))
+               $(MKDIR) $(OJT)\WINNT\install\wix\uninstall
+!      ENDIF
 !      IF (!EXIST($(OJT)\WINNT\install\Win9x))
                $(MKDIR) $(OJT)\WINNT\install\Win9x
 !      ENDIF