From c9aa3bdd830831be7652b83b9458f83ac2d2f944 Mon Sep 17 00:00:00 2001 From: "ssu%netscape.com" Date: Fri, 18 May 2001 10:22:54 +0000 Subject: [PATCH] bug 4933 - new image for the download/xpinstall dialog. bug 80237 - "destination directory" title is gone... bug 77244 - Installers need to create Win32 Reg. key schema that Gecko Embedding browsers can follow bug 78318 - crash with installer if you go back to change the directory selected bug 56538 - Installer fails with error 5 installing on my Win2K box bug 68053 - Win32 installer needs to log the installation process. bug 81081 - Xpinstall dialog in the win32 installer requires touch up sr=dveditz --- xpinstall/packager/windows/browser.jst | 217 ++++++++----- xpinstall/packager/windows/config.it | 177 ++--------- xpinstall/packager/windows/mail.jst | 84 +++-- xpinstall/packager/windows/xpcom.jst | 83 +++-- xpinstall/src/nsInstall.cpp | 9 +- xpinstall/src/nsInstall.h | 8 +- xpinstall/src/nsJSInstall.cpp | 18 +- xpinstall/src/nsJSWinReg.cpp | 125 +++++++- xpinstall/src/nsWinReg.cpp | 291 +++++++++++++++++- xpinstall/src/nsWinReg.h | 13 + xpinstall/src/nsWinRegItem.cpp | 36 ++- xpinstall/wizard/windows/setup/dialogs.c | 2 +- xpinstall/wizard/windows/setup/extern.h | 1 + xpinstall/wizard/windows/setup/extra.c | 170 +++++++++- xpinstall/wizard/windows/setup/extra.h | 1 + xpinstall/wizard/windows/setup/ifuncns.c | 32 +- xpinstall/wizard/windows/setup/ifuncns.h | 1 + xpinstall/wizard/windows/setup/logging.c | 33 +- xpinstall/wizard/windows/setup/nsEscape.cpp | 2 +- xpinstall/wizard/windows/setup/setup.c | 1 + xpinstall/wizard/windows/setup/setup.h | 6 + xpinstall/wizard/windows/setup/xperr.h | 3 + xpinstall/wizard/windows/setup/xpi.c | 1 + xpinstall/wizard/windows/setup/xpnetHook.cpp | 27 +- xpinstall/wizard/windows/setup/xpnetHook.h | 1 + xpinstall/wizard/windows/setuprsc/setuprsc.h | 3 +- xpinstall/wizard/windows/setuprsc/setuprsc.rc | 48 +-- xpinstall/wizard/windows/uninstall/extra.c | 56 +++- 28 files changed, 1069 insertions(+), 380 deletions(-) diff --git a/xpinstall/packager/windows/browser.jst b/xpinstall/packager/windows/browser.jst index 985a14a9fd2e..5e6b11d75f4d 100644 --- a/xpinstall/packager/windows/browser.jst +++ b/xpinstall/packager/windows/browser.jst @@ -1,3 +1,33 @@ +function registerProgramFolderKey(winreg, fFolderPath) +{ + var subkey; + var valname; + var value; + var err; + + /* set the Program Folder Path in the Mozilla key in the Windows Registry */ + subkey = "SOFTWARE\\$CompanyName$"; + winreg.createKey(subkey,""); + + valname = "CurrentVersion"; + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; + winreg.createKey(subkey,""); + + valname = "CurrentVersion"; + value = "$UserAgent$"; + err = winreg.setValueString(subkey, valname, value); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; + winreg.createKey(subkey,""); + + valname = "Program Folder Path"; + value = fFolderPath; + err = winreg.setValueString(subkey, valname, value); +} + function createShortcuts() { var subkey; @@ -48,10 +78,9 @@ function createShortcuts() is_winnt = true; } - if(is_winnt == false) + logComment("is_winnt value: " + is_winnt); + if(!is_winnt || restrictedAccess) { - logComment("is_winnt is false: " + is_winnt); - winreg.setRootKey(winreg.HKEY_CURRENT_USER); subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; valname = "Programs"; @@ -63,8 +92,6 @@ function createShortcuts() } else { - logComment("is_winnt is true: " + is_winnt); - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; valname = "Common Programs"; @@ -84,7 +111,6 @@ function createShortcuts() valname = "Quick Launch"; szFolderQuickLaunch = winreg.getValueString(subkey, valname); - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; valname = "Program Folder Path"; fFolderPathStr = winreg.getValueString(subkey, valname); @@ -113,37 +139,22 @@ function createShortcuts() /* explicitly create the fFolderPath even though the windowsShortcut function creates the folder. * This is so that the folder creation gets logged for uninstall to remove it. */ - File.dirCreate(fFolderPath); + if(!File.exists(fFolderPath)) + File.dirCreate(fFolderPath); /* create the shortcuts */ File.windowsShortcut(fileExe, fFolderDesktop, scExeDesc, fProgram, "", fileExe, 0); File.windowsShortcut(fileExe, fFolderPath, scExeDesc, fProgram, "", fileExe, 0); File.windowsShortcut(fileExe, fFolderPath, scProfileDesc, fProgram, scProfileDescParam, fileExe, 0); -// File.windowsShortcut(fileExe, fFolderPath, "Test Http", "", "", "http://sweetlou/products/client/temp/ssu", 0); - /* set the Program Folder Path in the Mozilla key in the Windows Registry */ - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); - subkey = "SOFTWARE\\$CompanyName$"; - winreg.createKey(subkey,""); - - valname = "CurrentVersion"; - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; - winreg.createKey(subkey,""); - - valname = "CurrentVersion"; - value = "$UserAgent$"; - err = winreg.setValueString(subkey, valname, value); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; - winreg.createKey(subkey,""); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; - winreg.createKey(subkey,""); - - valname = "Program Folder Path"; - value = fFolderPath; - err = winreg.setValueString(subkey, valname, value); + if(!restrictedAccess) + { + winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); + registerProgramFolderKey(winreg, fFolderPath); + } + winreg.setRootKey(winreg.HKEY_CURRENT_USER); + registerProgramFolderKey(winreg, fFolderPath); } else { @@ -151,6 +162,73 @@ function createShortcuts() } } +function registerMainKeys(winreg) +{ + var subkey; //the name of the subkey you are poking around in + var valname; //the name of the value you want to look at + var value; //the data in the value you want to look at. + var err; + + subkey = "SOFTWARE\\$CompanyName$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; + winreg.createKey(subkey,""); + valname = "CurrentVersion"; + value = "$UserAgent$"; + err = winreg.setValueString(subkey, valname, value); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; + winreg.createKey(subkey,""); + + valname = "Install Directory"; + value = fProgram; + err = winreg.setValueString(subkey, valname, value); + + // The following keys are required to be created to supply information + // about the location of the Gecko Embedded Client to 3rd party apps. + // "SOFTWARE\\Mozilla" must not be localized! + subkey = "SOFTWARE\\Mozilla\\$ProductName$ $UserAgentShort$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\Mozilla\\$ProductName$ $UserAgentShort$\\Extensions"; + winreg.createKey(subkey,""); + + valname = "Components"; + value = fProgram + "Components"; + err = winreg.setValueString(subkey, valname, value); + + valname = "Plugins"; + value = fProgram + "Plugins"; + err = winreg.setValueString(subkey, valname, value); + + // We need to set HKEY...\Software\Mozilla\Seamonkey\[ua]\Main + // because Sun's Java installer keys off of this key to locate mozilla's + // installation directory and populate it with java plugins. + // "SOFTWARE\\Mozilla\Seamonkey" must not be localized! + subkey = "SOFTWARE\\Mozilla"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\Mozilla\\Seamonkey"; + winreg.createKey(subkey,""); + valname = "CurrentVersion"; + value = "$UserAgent$"; + err = winreg.setValueString(subkey, valname, value); + + subkey = "SOFTWARE\\Mozilla\\Seamonkey\\$UserAgent$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\Mozilla\\Seamonkey\\$UserAgent$\\Main"; + winreg.createKey(subkey,""); + + valname = "Install Directory"; + value = fProgram; + err = winreg.setValueString(subkey, valname, value); +} + function updateWinReg() { //Notes: @@ -158,64 +236,44 @@ function updateWinReg() // subkeys have to exist before values can be put in. var winreg = getWinRegistry(); var subkey; //the name of the subkey you are poking around in - var valname; // the name of the value you want to look at + var valname; //the name of the value you want to look at var value; //the data in the value you want to look at. + var err; if(winreg != null) { + /* This will check to see if the user has restricted access or not. + * It checks to see if HKEY_LOCALMACHINE\SOFTWARE is writable. If + * it is, then access is not restricted. This is only used to + * determine which Desktop, Programs, and Start Menu folders + * are to used: common or per user + */ winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); - subkey = "SOFTWARE\\$CompanyName$"; - winreg.createKey(subkey,""); + if(winreg.isKeyWritable("SOFTWARE")) + restrictedAccess = false; + else + restrictedAccess = true; - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; - winreg.createKey(subkey,""); - valname = "CurrentVersion"; - value = "$UserAgent$"; - err = winreg.setValueString(subkey, valname, value); + logComment("restrictedAccess value: " + restrictedAccess); + if(!restrictedAccess) + { + winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); + registerMainKeys(winreg); - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; - winreg.createKey(subkey,""); + // set the App Paths key here + subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\$MainExeFile$"; + winreg.createKey(subkey,""); + valname = ""; + value = fProgram + "$MainExeFile$"; + err = winreg.setValueString(subkey, valname, value); - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; - winreg.createKey(subkey,""); - valname = "Install Directory"; - value = fProgram; - err = winreg.setValueString(subkey, valname, value); - - // set the App Paths key here - subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\$MainExeFile$"; - winreg.createKey(subkey,""); - valname = ""; - value = fProgram + "$MainExeFile$"; - err = winreg.setValueString(subkey, valname, value); - - valname = "Path"; - value = fProgram; - err = winreg.setValueString(subkey, valname, value); - - - // We need to set HKEY_LOCAL_MACHINE\Software\Mozilla\Seamonkey\[ua]\Main - // because Sun's Java installer keys off of this key to locate mozilla's - // installation directory and populate it with java plugins. - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); - subkey = "SOFTWARE\\Mozilla"; - winreg.createKey(subkey,""); - - subkey = "SOFTWARE\\Mozilla\\Seamonkey"; - winreg.createKey(subkey,""); - valname = "CurrentVersion"; - value = "$UserAgent$"; - err = winreg.setValueString(subkey, valname, value); - - subkey = "SOFTWARE\\Mozilla\\Seamonkey\\$UserAgent$"; - winreg.createKey(subkey,""); - - subkey = "SOFTWARE\\Mozilla\\Seamonkey\\$UserAgent$\\Main"; - winreg.createKey(subkey,""); - valname = "Install Directory"; - value = fProgram; - err = winreg.setValueString(subkey, valname, value); + valname = "Path"; + value = fProgram; + err = winreg.setValueString(subkey, valname, value); + } + winreg.setRootKey(winreg.HKEY_CURRENT_USER); + registerMainKeys(winreg); } } @@ -228,6 +286,7 @@ var fWindowsSystem; var fileComponentRegStr; var fileComponentReg; var fileMozCtlx; +var restrictedAccess; $Ren8dot3List$ diff --git a/xpinstall/packager/windows/config.it b/xpinstall/packager/windows/config.it index 1a08c35cd658..1cd371a35bd7 100644 --- a/xpinstall/packager/windows/config.it +++ b/xpinstall/packager/windows/config.it @@ -58,13 +58,17 @@ Program Name=$MainExeFile$ ; PERSONAL_SENDTO ; PERSONAL_TEMPLATES ; +; PROGRAMS (Default value is the same as COMMON_PROGRAMS, but if the user +; has restricted access to the system, then it's the same as +; PERSONAL_PROGRAMS) +; ; PROGRAMFILESDIR ; COMMONFILESDIR ; MEDIAPATH ; CONFIGPATH (supported only under Windows95 and Windows98) ; DEVICEPATH Program Folder Name=$ProductName$ -Program Folder Path=[COMMON_PROGRAMS] +Program Folder Path=[PROGRAMS] Uninstall Filename=$UninstallFile$ @@ -615,6 +619,16 @@ Destination=[WINDIR] Fail If Exists=FALSE Do Not Uninstall=TRUE +;Copy the uninstaller to the [Setup Path]\Uninstall folder. +;This copy is to be used when the user installed on a system with +;restricted access. +[Copy File2] +Timing=post smartupdate +Source=[XPI PATH]\$UninstallFile$ +Destination=[SETUP PATH]\Uninstall +Fail If Exists=FALSE +Do Not Uninstall=FALSE + ;Copy File SequentialX sections [Copy File Sequential0] @@ -856,141 +870,6 @@ Overwrite Key=TRUE Overwrite Name=TRUE Timing=pre smartupdate -; These sections (14-22) are to register information for -; Gecko Embedding Clients. This is necessary for 3rd party -; apps to locate this Clients' components or plugins path. -[Windows Registry14] -Root Key=HKEY_LOCAL_MACHINE -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$ -Name= -Name Value= -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry15] -Root Key=HKEY_LOCAL_MACHINE -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$\Extensions -Name= -Name Value= -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry16] -Root Key=HKEY_LOCAL_MACHINE -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$\Extensions -Name=Components -Name Value=[Setup Path]\Components -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry17] -Root Key=HKEY_LOCAL_MACHINE -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$\Extensions -Name=Plugins -Name Value=[Setup Path]\Plugins -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry18] -Root Key=HKEY_CURRENT_USER -Key=Software\Mozilla -Name= -Name Value= -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry19] -Root Key=HKEY_CURRENT_USER -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$ -Name= -Name Value= -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry20] -Root Key=HKEY_CURRENT_USER -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$\Extensions -Name= -Name Value= -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry21] -Root Key=HKEY_CURRENT_USER -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$\Extensions -Name=Components -Name Value=[Setup Path]\Components -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate - -[Windows Registry22] -Root Key=HKEY_CURRENT_USER -; Do Not Localize the "Software\Mozilla" part. It must be "Software\Mozilla" -;*** LOCALIZE ME BABY *** -Key=Software\Mozilla\$ProductName$ $UserAgentShort$\Extensions -Name=Plugins -Name Value=[Setup Path]\Plugins -Type=REG_SZ -Decrypt Key=FALSE -Decrypt Name=FALSE -Decrypt Name Value=TRUE -Overwrite Key=TRUE -Overwrite Name=TRUE -Timing=pre smartupdate ; Values for Show Folder: @@ -1023,13 +902,21 @@ Timing=post smartupdate Show Folder=SHOW Program Folder=[Default Folder] -;[Program Folder0-Shortcut0] -;File=[SETUP PATH]\$MainExeFile$ -;Arguments= -;Working Dir=[SETUP PATH] -;Description=$ProductName$ -;Icon Path=[SETUP PATH]\$MainExeFile$ -;Icon Id=0 +[Program Folder0-Shortcut0] +File=[SETUP PATH]\Uninstall\$UninstallFile$ +Arguments=/ua "$UserAgent$" +Working Dir=[SETUP PATH] +Description=Uninstall $ProductName$ +Icon Path=[SETUP PATH]\Uninstall\$UninstallFile$ +Icon Id=0 + +; Default value: +; IGNORE +; +; Possible values: +; ONLY_RESTRICTED - create shortcut only if user access is restricted +; ONLY_NONRESTRICTED - create shortcut only if user access is not restricted +Restricted Access=ONLY_RESTRICTED ;[Program Folder0-Shortcut1] ;File=[SETUP PATH]\$MainExeFile$ @@ -1111,6 +998,10 @@ IDC Use HTTP=Use &HTTP for downloading files IDC Save Installer Files=&Save installer files locally ;*** LOCALIZE ME BABY *** Message Download Paused=Setup has encountered a network problem and has paused the download. If you have just lost your network connection, please click Resume once your network has been reestablished. +;*** LOCALIZE ME BABY *** +Message NORMAL Restricted Access=Setup has detected that you do not have the appropriate Administrator privileges to this system. It is highly recommended that you do not continue with the installation of $ProductName$, or it may not function properly. Would you still like to continue? +;*** LOCALIZE ME BABY *** +Message AUTO Restricted Access=Setup has detected that you do not have the appropriate Administrator privileges to this system. Setup cannot continue with the installation of $ProductName$. [Site Selector] diff --git a/xpinstall/packager/windows/mail.jst b/xpinstall/packager/windows/mail.jst index 80be868c2db9..4f6f0e206054 100644 --- a/xpinstall/packager/windows/mail.jst +++ b/xpinstall/packager/windows/mail.jst @@ -1,3 +1,33 @@ +function registerProgramFolderKey(winreg, fFolderPath) +{ + var subkey; + var valname; + var value; + var err; + + /* set the Program Folder Path in the Mozilla key in the Windows Registry */ + subkey = "SOFTWARE\\$CompanyName$"; + winreg.createKey(subkey,""); + + valname = "CurrentVersion"; + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; + winreg.createKey(subkey,""); + + valname = "CurrentVersion"; + value = "$UserAgent$"; + err = winreg.setValueString(subkey, valname, value); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; + winreg.createKey(subkey,""); + + valname = "Program Folder Path"; + value = fFolderPath; + err = winreg.setValueString(subkey, valname, value); +} + function createShortcuts() { var subkey; @@ -21,6 +51,7 @@ function createShortcuts() var fFolderPathStr; var is_winnt; var szCurrentVersion; + var restrictedAccess; winreg = getWinRegistry(); fWindows = getFolder("Windows"); @@ -32,6 +63,18 @@ function createShortcuts() scFolderName = "$ProductName$"; if(winreg != null) { + /* This will check to see if the user has restricted access or not. + * It checks to see if HKEY_LOCALMACHINE\SOFTWARE is writable. If + * it is, then access is not restricted. This is only used to + * determine which Desktop, Programs, and Start Menu folders + * are to used: common or per user + */ + winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); + if(winreg.isKeyWritable("SOFTWARE")) + restrictedAccess = false; + else + restrictedAccess = true; + /* determine if the script is running under NT or not */ winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; @@ -47,10 +90,10 @@ function createShortcuts() is_winnt = true; } - if(is_winnt == false) + logComment("is_winnt value: " + is_winnt); + logComment("restrictedAccess value: " + restrictedAccess); + if(!is_winnt || restrictedAccess) { - logComment("is_winnt is false: " + is_winnt); - winreg.setRootKey(winreg.HKEY_CURRENT_USER); subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; valname = "Programs"; @@ -62,8 +105,6 @@ function createShortcuts() } else { - logComment("is_winnt is true: " + is_winnt); - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; valname = "Common Programs"; @@ -83,7 +124,6 @@ function createShortcuts() valname = "Quick Launch"; szFolderQuickLaunch = winreg.getValueString(subkey, valname); - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; valname = "Program Folder Path"; fFolderPathStr = winreg.getValueString(subkey, valname); @@ -112,34 +152,20 @@ function createShortcuts() /* explicitly create the fFolderPath even though the windowsShortcut function creates the folder. * This is so that the folder creation gets logged for uninstall to remove it. */ - File.dirCreate(fFolderPath); + if(!File.exists(fFolderPath)) + File.dirCreate(fFolderPath); /* create the shortcuts */ File.windowsShortcut(fileExe, fFolderPath, scExeDesc, fProgram, scParam, fileExe, 0); - /* set the Program Folder Path in the Mozilla key in the Windows Registry */ - winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); - subkey = "SOFTWARE\\$CompanyName$"; - winreg.createKey(subkey,""); - - valname = "CurrentVersion"; - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; - winreg.createKey(subkey,""); - - valname = "CurrentVersion"; - value = "$UserAgent$"; - err = winreg.setValueString(subkey, valname, value); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; - winreg.createKey(subkey,""); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; - winreg.createKey(subkey,""); - - valname = "Program Folder Path"; - value = fFolderPath; - err = winreg.setValueString(subkey, valname, value); + if(!restrictedAccess) + { + winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); + registerProgramFolderKey(winreg, fFolderPath); + } + winreg.setRootKey(winreg.HKEY_CURRENT_USER); + registerProgramFolderKey(winreg, fFolderPath); } else { diff --git a/xpinstall/packager/windows/xpcom.jst b/xpinstall/packager/windows/xpcom.jst index a0c1ab98b0bd..d337b93353ac 100644 --- a/xpinstall/packager/windows/xpcom.jst +++ b/xpinstall/packager/windows/xpcom.jst @@ -1,3 +1,42 @@ +function registerMainKeys(winreg) +{ + var subkey; //the name of the subkey you are poking around in + var valname; //the name of the value you want to look at + var value; //the data in the value you want to look at. + var err; + + subkey = "SOFTWARE\\$CompanyName$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; + winreg.createKey(subkey,""); + + valname = "CurrentVersion"; + value = "$UserAgent$"; + err = winreg.setValueString(subkey, valname, value); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; + winreg.createKey(subkey,""); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; + winreg.createKey(subkey,""); + + valname = "Install Directory"; + value = fProgram; + err = winreg.setValueString(subkey, valname, value); + + subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Uninstall"; + winreg.createKey(subkey,""); + + valname = "Uninstall Log Folder"; + value = szUninstall; + err = winreg.setValueString(subkey, valname, value); + + valname = "Description"; + value = "$ProductName$ ($UserAgentShort$)"; + err = winreg.setValueString(subkey, valname, value); +} + function updateWinReg() { //Notes: @@ -5,42 +44,26 @@ function updateWinReg() // subkeys have to exist before values can be put in. var winreg = getWinRegistry(); var subkey; //the name of the subkey you are poking around in - var valname; // the name of the value you want to look at + var valname; //the name of the value you want to look at var value; //the data in the value you want to look at. if(winreg != null) { + /* This will check to see if the user has restricted access or not. + * It checks to see if HKEY_LOCALMACHINE\SOFTWARE is writable. If + * it is, then access is not restricted. This is only used to + * determine which Desktop, Programs, and Start Menu folders + * are to used: common or per user + */ winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); - subkey = "SOFTWARE\\$CompanyName$"; - winreg.createKey(subkey,""); + if(winreg.isKeyWritable("SOFTWARE")) + { + winreg.setRootKey(winreg.HKEY_LOCAL_MACHINE); + registerMainKeys(winreg); + } - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$"; - winreg.createKey(subkey,""); - - valname = "CurrentVersion"; - value = "$UserAgent$"; - err = winreg.setValueString(subkey, valname, value); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$"; - winreg.createKey(subkey,""); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Main"; - winreg.createKey(subkey,""); - - valname = "Install Directory"; - value = fProgram; - err = winreg.setValueString(subkey, valname, value); - - subkey = "SOFTWARE\\$CompanyName$\\$ProductName$\\$UserAgent$\\Uninstall"; - winreg.createKey(subkey,""); - - valname = "Uninstall Log Folder"; - value = szUninstall; - err = winreg.setValueString(subkey, valname, value); - - valname = "Description"; - value = "$ProductName$ ($UserAgentShort$)"; - err = winreg.setValueString(subkey, valname, value); + winreg.setRootKey(winreg.HKEY_CURRENT_USER); + registerMainKeys(winreg); } } diff --git a/xpinstall/src/nsInstall.cpp b/xpinstall/src/nsInstall.cpp index 2a08a23a9b75..8d23ca96c129 100644 --- a/xpinstall/src/nsInstall.cpp +++ b/xpinstall/src/nsInstall.cpp @@ -1401,9 +1401,9 @@ nsInstall::RefreshPlugins() PRInt32 -nsInstall::ResetError() +nsInstall::ResetError(PRInt32 aError) { - mLastError = nsInstall::SUCCESS; + mLastError = aError; return NS_OK; } @@ -1445,7 +1445,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis *szRegPackagePath = '0'; *aReturn = nsInstall::SUCCESS; - ResetError(); + ResetError(nsInstall::SUCCESS); mUserCancelled = PR_FALSE; @@ -2230,6 +2230,9 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob) } } + if (error != SUCCESS) + SaveError(error); + if (objString) delete [] objString; diff --git a/xpinstall/src/nsInstall.h b/xpinstall/src/nsInstall.h index a7c2ffbe4dd5..a5fddaa901f9 100644 --- a/xpinstall/src/nsInstall.h +++ b/xpinstall/src/nsInstall.h @@ -173,7 +173,11 @@ class nsInstall CHROME_REGISTRY_ERROR = -239, MALFORMED_INSTALL = -240, - + + KEY_ACCESS_DENIED = -241, + KEY_DOES_NOT_EXIST = -242, + VALUE_DOES_NOT_EXIST = -243, + OUT_OF_MEMORY = -299, GESTALT_UNKNOWN_ERR = -5550, @@ -234,7 +238,7 @@ class nsInstall PRInt32 Patch(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn); PRInt32 RegisterChrome(nsIFile* chrome, PRUint32 chromeType, const char* path); PRInt32 RefreshPlugins(); - PRInt32 ResetError(); + PRInt32 ResetError(PRInt32 aError); PRInt32 SetPackageFolder(nsInstallFolder& aFolder); PRInt32 StartInstall(const nsString& aUserPackageName, const nsString& aPackageName, const nsString& aVersion, PRInt32* aReturn); PRInt32 Uninstall(const nsString& aPackageName, PRInt32* aReturn); diff --git a/xpinstall/src/nsJSInstall.cpp b/xpinstall/src/nsJSInstall.cpp index 15782b0011dd..45ddb7f9fb80 100644 --- a/xpinstall/src/nsJSInstall.cpp +++ b/xpinstall/src/nsJSInstall.cpp @@ -1396,9 +1396,17 @@ InstallResetError(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval * *rval = JSVAL_VOID; // If there's no private data, this must be the prototype, so ignore - if (nativeThis) - nativeThis->ResetError(); + if (!nativeThis) + return JS_TRUE; + // Supported forms: + // void resetError() + // void resetError(int error) + int32 val = 0; + if ( argc >= 1 ) + JS_ValueToECMAInt32(cx, argv[0], &val); + + nativeThis->ResetError(val); return JS_TRUE; } @@ -1768,6 +1776,10 @@ static JSConstDoubleSpec install_constants[] = { nsInstall::CHROME_REGISTRY_ERROR, "CHROME_REGISTRY_ERROR" }, { nsInstall::MALFORMED_INSTALL, "MALFORMED_INSTALL" }, + { nsInstall::KEY_ACCESS_DENIED, "KEY_ACCESS_DENIED" }, + { nsInstall::KEY_DOES_NOT_EXIST, "KEY_DOES_NOT_EXIST" }, + { nsInstall::VALUE_DOES_NOT_EXIST, "VALUE_DOES_NOT_EXIST" }, + { nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" }, { nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" }, @@ -1819,7 +1831,7 @@ static JSFunctionSpec InstallMethods[] = {"performInstall", InstallFinalizeInstall, 0}, {"registerChrome", InstallRegisterChrome, 2}, {"refreshPlugins", InstallRefreshPlugins, 0}, - {"resetError", InstallResetError, 0}, + {"resetError", InstallResetError, 1}, // {"selectChrome", InstallSelectChrome, 2}, {"setPackageFolder", InstallSetPackageFolder, 1}, {"uninstall", InstallUninstall, 1}, diff --git a/xpinstall/src/nsJSWinReg.cpp b/xpinstall/src/nsJSWinReg.cpp index daea8aed9b56..3e9fd4ca3566 100644 --- a/xpinstall/src/nsJSWinReg.cpp +++ b/xpinstall/src/nsJSWinReg.cpp @@ -104,6 +104,126 @@ WinRegSetRootKey(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *r } +// +// Native method KeyExists +// +PR_STATIC_CALLBACK(JSBool) +WinRegKeyExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj); + PRInt32 nativeRet; + nsAutoString b0; + + *rval = JSVAL_FALSE; + + // If there's no private data, this must be the prototype, so ignore + if(nsnull == nativeThis) + { + return JS_TRUE; + } + + if(argc >= 1) + { + // public int keyExists ( String subKey ); + + ConvertJSValToStr(b0, cx, argv[0]); + + if(NS_OK != nativeThis->KeyExists(b0, &nativeRet)) + { + return JS_FALSE; + } + + *rval = BOOLEAN_TO_JSVAL(nativeRet); + } + else + { + JS_ReportError(cx, "WinReg.KeyExists() parameters error"); + } + + return JS_TRUE; +} + +// +// Native method ValueExists +// +PR_STATIC_CALLBACK(JSBool) +WinRegValueExists(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj); + PRInt32 nativeRet; + nsAutoString b0; + nsAutoString b1; + + *rval = JSVAL_FALSE; + + // If there's no private data, this must be the prototype, so ignore + if(nsnull == nativeThis) + { + return JS_TRUE; + } + + if(argc >= 2) + { + // public int valueExists ( String subKey, + // String value ); + + ConvertJSValToStr(b0, cx, argv[0]); + ConvertJSValToStr(b1, cx, argv[1]); + + if(NS_OK != nativeThis->ValueExists(b0, b1, &nativeRet)) + { + return JS_FALSE; + } + + *rval = BOOLEAN_TO_JSVAL(nativeRet); + } + else + { + JS_ReportError(cx, "WinReg.ValueExists() parameters error"); + } + + return JS_TRUE; +} + +// +// Native method IsKeyWritable +// +PR_STATIC_CALLBACK(JSBool) +WinRegIsKeyWritable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsWinReg *nativeThis = (nsWinReg*)JS_GetPrivate(cx, obj); + PRInt32 nativeRet; + nsAutoString b0; + + *rval = JSVAL_FALSE; + + // If there's no private data, this must be the prototype, so ignore + if(nsnull == nativeThis) + { + return JS_TRUE; + } + + if(argc >= 1) + { + // public int isKeyWritable ( String subKey ); + + ConvertJSValToStr(b0, cx, argv[0]); + + if(NS_OK != nativeThis->IsKeyWritable(b0, &nativeRet)) + { + return JS_FALSE; + } + + *rval = BOOLEAN_TO_JSVAL(nativeRet); + } + else + { + JS_ReportError(cx, "WinReg.IsKeyWritable() parameters error"); + } + + return JS_TRUE; +} + // // Native method CreateKey // @@ -330,7 +450,6 @@ WinRegSetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva PRInt32 nativeRet; nsAutoString b0; nsAutoString b1; -// nsAutoString b2; PRInt32 ib2; *rval = JSVAL_NULL; @@ -353,7 +472,6 @@ WinRegSetValueNumber(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva if(JSVAL_IS_INT(argv[2])) { ib2 = JSVAL_TO_INT(argv[2]); -// ConvertJSValToStr(b2, cx, argv[2]); } else { @@ -555,6 +673,9 @@ static JSConstDoubleSpec winreg_constants[] = static JSFunctionSpec WinRegMethods[] = { {"setRootKey", WinRegSetRootKey, 1}, + {"keyExists", WinRegKeyExists, 1}, + {"valueExists", WinRegValueExists, 2}, + {"isKeyWritable", WinRegIsKeyWritable, 1}, {"createKey", WinRegCreateKey, 2}, {"deleteKey", WinRegDeleteKey, 1}, {"deleteValue", WinRegDeleteValue, 2}, diff --git a/xpinstall/src/nsWinReg.cpp b/xpinstall/src/nsWinReg.cpp index 49c1e9654eee..f50bbe146330 100644 --- a/xpinstall/src/nsWinReg.cpp +++ b/xpinstall/src/nsWinReg.cpp @@ -69,7 +69,7 @@ nsWinReg::CreateKey(const nsString& subkey, const nsString& classname, PRInt32* } if(mInstallObject) - mInstallObject->ScheduleForInstall(wi); + *aReturn = mInstallObject->ScheduleForInstall(wi); return 0; } @@ -95,7 +95,7 @@ nsWinReg::DeleteKey(const nsString& subkey, PRInt32* aReturn) } if(mInstallObject) - mInstallObject->ScheduleForInstall(wi); + *aReturn = mInstallObject->ScheduleForInstall(wi); return 0; } @@ -121,7 +121,7 @@ nsWinReg::DeleteValue(const nsString& subkey, const nsString& valname, PRInt32* } if(mInstallObject) - mInstallObject->ScheduleForInstall(wi); + *aReturn = mInstallObject->ScheduleForInstall(wi); return 0; } @@ -147,7 +147,7 @@ nsWinReg::SetValueString(const nsString& subkey, const nsString& valname, const } if(mInstallObject) - mInstallObject->ScheduleForInstall(wi); + *aReturn = mInstallObject->ScheduleForInstall(wi); return 0; } @@ -180,7 +180,7 @@ nsWinReg::SetValueNumber(const nsString& subkey, const nsString& valname, PRInt3 } if(mInstallObject) - mInstallObject->ScheduleForInstall(wi); + *aReturn = mInstallObject->ScheduleForInstall(wi); return 0; } @@ -219,6 +219,126 @@ nsInstall* nsWinReg::InstallObject() return mInstallObject; } +PRInt32 +nsWinReg::KeyExists(const nsString& subkey, + PRInt32* aReturn) +{ + *aReturn = NativeKeyExists(subkey); + return NS_OK; +} + +PRInt32 +nsWinReg::ValueExists(const nsString& subkey, + const nsString& valname, + PRInt32* aReturn) +{ + *aReturn = NativeValueExists(subkey, valname); + return NS_OK; +} + +PRInt32 +nsWinReg::IsKeyWritable(const nsString& subkey, + PRInt32* aReturn) +{ + *aReturn = NativeIsKeyWritable(subkey); + return NS_OK; +} + +PRInt32 +nsWinReg::PrepareCreateKey(PRInt32 root, + const nsString& subkey, + PRInt32* aReturn) +{ + SetRootKey(root); + if(NativeIsKeyWritable(subkey)) + *aReturn = nsInstall::SUCCESS; + else + *aReturn = nsInstall::KEY_ACCESS_DENIED; + + return NS_OK; +} + +PRInt32 +nsWinReg::PrepareDeleteKey(PRInt32 root, + const nsString& subkey, + PRInt32* aReturn) +{ + SetRootKey(root); + if(NativeKeyExists(subkey)) + { + if(NativeIsKeyWritable(subkey)) + *aReturn = nsInstall::SUCCESS; + else + *aReturn = nsInstall::KEY_ACCESS_DENIED; + } + else + *aReturn = nsInstall::KEY_DOES_NOT_EXIST; + + return NS_OK; +} + +PRInt32 +nsWinReg::PrepareDeleteValue(PRInt32 root, + const nsString& subkey, + const nsString& valname, + PRInt32* aReturn) +{ + SetRootKey(root); + if(NativeValueExists(subkey, valname)) + { + if(NativeIsKeyWritable(subkey)) + *aReturn = nsInstall::SUCCESS; + else + *aReturn = nsInstall::KEY_ACCESS_DENIED; + } + else + *aReturn = nsInstall::VALUE_DOES_NOT_EXIST; + + return NS_OK; +} + +PRInt32 +nsWinReg::PrepareSetValueString(PRInt32 root, + const nsString& subkey, + PRInt32* aReturn) +{ + SetRootKey(root); + if(NativeIsKeyWritable(subkey)) + *aReturn = nsInstall::SUCCESS; + else + *aReturn = nsInstall::KEY_ACCESS_DENIED; + + return NS_OK; +} + +PRInt32 +nsWinReg::PrepareSetValueNumber(PRInt32 root, + const nsString& subkey, + PRInt32* aReturn) +{ + SetRootKey(root); + if(NativeIsKeyWritable(subkey)) + *aReturn = nsInstall::SUCCESS; + else + *aReturn = nsInstall::KEY_ACCESS_DENIED; + + return NS_OK; +} + +PRInt32 +nsWinReg::PrepareSetValue(PRInt32 root, + const nsString& subkey, + PRInt32* aReturn) +{ + SetRootKey(root); + if(NativeIsKeyWritable(subkey)) + *aReturn = nsInstall::SUCCESS; + else + *aReturn = nsInstall::KEY_ACCESS_DENIED; + + return NS_OK; +} + PRInt32 nsWinReg::FinalCreateKey(PRInt32 root, const nsString& subkey, const nsString& classname, PRInt32* aReturn) { @@ -270,6 +390,149 @@ nsWinReg::FinalSetValue(PRInt32 root, const nsString& subkey, const nsString& va /* Private Methods */ +PRInt32 +nsWinReg::NativeKeyExists(const nsString& subkey) +{ + HKEY root, newkey; + LONG result; + PRInt32 keyExists = PR_FALSE; + char* subkeyCString = subkey.ToNewCString(); + +#ifdef WIN32 + root = (HKEY)mRootKey; + result = RegOpenKeyEx(root, subkeyCString, 0, KEY_READ, &newkey); + switch(result) + { + case ERROR_SUCCESS: + RegCloseKey(newkey); + keyExists = PR_TRUE; + break; + + case ERROR_FILE_NOT_FOUND: + case ERROR_ACCESS_DENIED: + default: + break; + } +#endif + + if (subkeyCString) Recycle(subkeyCString); + + return keyExists; +} + +PRInt32 +nsWinReg::NativeValueExists(const nsString& subkey, const nsString& valname) +{ + HKEY root; + HKEY newkey; + LONG result; + PRInt32 valueExists = PR_FALSE; + DWORD length = _MAXKEYVALUE_; + unsigned char valbuf[_MAXKEYVALUE_]; + char* subkeyCString = subkey.ToNewCString(); + char* valnameCString = valname.ToNewCString(); + +#ifdef WIN32 + root = (HKEY) mRootKey; + result = RegOpenKeyEx(root, subkeyCString, 0, KEY_READ, &newkey); + switch(result) + { + case ERROR_SUCCESS: + result = RegQueryValueEx(newkey, + valnameCString, + 0, + NULL, + valbuf, + &length); + switch(result) + { + case ERROR_SUCCESS: + valueExists = PR_TRUE; + break; + + case ERROR_FILE_NOT_FOUND: + case ERROR_ACCESS_DENIED: + default: + break; + } + RegCloseKey(newkey); + break; + + case ERROR_FILE_NOT_FOUND: + case ERROR_ACCESS_DENIED: + default: + break; + } +#endif + + if (subkeyCString) Recycle(subkeyCString); + if (valnameCString) Recycle(valnameCString); + + return valueExists; +} + +PRInt32 +nsWinReg::NativeIsKeyWritable(const nsString& subkey) +{ + HKEY root; + HKEY newkey; + LONG result; + char* subkeyCString; + nsString subkeyParent = subkey; + PRInt32 index; + PRInt32 rv = PR_FALSE; + +#ifdef WIN32 + /* In order to check to see if a key is writable (user has write access + * to the key), we need to open the key with KEY_WRITE access. In order + * to open a key, the key must first exist. If the key passed does not + * exist, we need to search for one of its parent key that _does_ exist. + * This do{} loop will search for an existing parent key. */ + do + { + rv = NativeKeyExists(subkeyParent); + if(!rv) + { + index = subkeyParent.RFindChar('\\', PR_FALSE, -1, -1); + if(index > 0) + /* delete everything from the '\\' found to the end of the string */ + subkeyParent.SetLength(index); + else + /* key does not exist and no parent key found */ + break; + } + }while(!rv); + + if(rv) + { + rv = PR_FALSE; + subkeyCString = subkeyParent.ToNewCString(); + if(!subkeyCString) + result = nsInstall::OUT_OF_MEMORY; + else + { + root = (HKEY)mRootKey; + result = RegOpenKeyEx(root, subkeyCString, 0, KEY_WRITE, &newkey); + switch(result) + { + case ERROR_SUCCESS: + RegCloseKey(newkey); + rv = PR_TRUE; + break; + + case ERROR_FILE_NOT_FOUND: + case ERROR_ACCESS_DENIED: + default: + break; + } + if(subkeyCString) + Recycle(subkeyCString); + } + } +#endif + return rv; +} + PRInt32 nsWinReg::NativeCreateKey(const nsString& subkey, const nsString& classname) { @@ -390,12 +653,13 @@ nsWinReg::NativeGetValueString(const nsString& subkey, const nsString& valname, result = RegQueryValueEx( newkey, valnameCString, nsnull, &type, valbuf, &length ); RegCloseKey( newkey ); + + if(type == REG_SZ) + aReturn->AssignWithConversion((char*)valbuf); } - if(ERROR_SUCCESS == result && type == REG_SZ) - { - aReturn->AssignWithConversion((char*)valbuf); - } + if(ERROR_ACCESS_DENIED == result) + result = nsInstall::ACCESS_DENIED; if (subkeyCString) Recycle(subkeyCString); if (valnameCString) Recycle(valnameCString); @@ -447,12 +711,13 @@ nsWinReg::NativeGetValueNumber(const nsString& subkey, const nsString& valname, result = RegQueryValueEx( newkey, valnameCString, nsnull, &type, (LPBYTE)&valbuf, (LPDWORD)&valbuflen); RegCloseKey( newkey ); + + if(type == REG_DWORD) + *aReturn = valbuf; } - if(ERROR_SUCCESS == result && type == REG_DWORD) - { - *aReturn = valbuf; - } + if(ERROR_ACCESS_DENIED == result) + result = nsInstall::ACCESS_DENIED; if (subkeyCString) Recycle(subkeyCString); if (valnameCString) Recycle(valnameCString); diff --git a/xpinstall/src/nsWinReg.h b/xpinstall/src/nsWinReg.h index 1370b38caa07..fac9eb8145e1 100644 --- a/xpinstall/src/nsWinReg.h +++ b/xpinstall/src/nsWinReg.h @@ -76,6 +76,16 @@ class nsWinReg nsInstall* InstallObject(void); + PRInt32 KeyExists(const nsString& subkey, PRInt32* aReturn); + PRInt32 ValueExists(const nsString& subkey, const nsString& valname, PRInt32* aReturn); + PRInt32 IsKeyWritable(const nsString& subkey, PRInt32* aReturn); + PRInt32 PrepareCreateKey(PRInt32 root, const nsString& subkey, PRInt32* aReturn); + PRInt32 PrepareDeleteKey(PRInt32 root, const nsString& subkey, PRInt32* aReturn); + PRInt32 PrepareDeleteValue(PRInt32 root, const nsString& subkey, const nsString& valname, PRInt32* aReturn); + PRInt32 PrepareSetValueString(PRInt32 root, const nsString& subkey, PRInt32* aReturn); + PRInt32 PrepareSetValueNumber(PRInt32 root, const nsString& subkey, PRInt32* aReturn); + PRInt32 PrepareSetValue(PRInt32 root, const nsString& subkey, PRInt32* aReturn); + PRInt32 FinalCreateKey(PRInt32 root, const nsString& subkey, const nsString& classname, PRInt32* aReturn); PRInt32 FinalDeleteKey(PRInt32 root, const nsString& subkey, PRInt32* aReturn); PRInt32 FinalDeleteValue(PRInt32 root, const nsString& subkey, const nsString& valname, PRInt32* aReturn); @@ -91,6 +101,9 @@ class nsWinReg nsInstall* mInstallObject; /* Private Methods */ + PRInt32 NativeKeyExists(const nsString& subkey); + PRInt32 NativeValueExists(const nsString& subkey, const nsString& valname); + PRInt32 NativeIsKeyWritable(const nsString& subkey); PRInt32 NativeCreateKey(const nsString& subkey, const nsString& classname); PRInt32 NativeDeleteKey(const nsString& subkey); PRInt32 NativeDeleteValue(const nsString& subkey, const nsString& valname); diff --git a/xpinstall/src/nsWinRegItem.cpp b/xpinstall/src/nsWinRegItem.cpp index bdaf709a9aba..f7abff7d6c9e 100644 --- a/xpinstall/src/nsWinRegItem.cpp +++ b/xpinstall/src/nsWinRegItem.cpp @@ -198,7 +198,41 @@ char* nsWinRegItem::toString() PRInt32 nsWinRegItem::Prepare() { - return nsnull; + PRInt32 aReturn = NS_OK; + + if (mReg == nsnull) + return nsInstall::OUT_OF_MEMORY; + + switch (mCommand) + { + case NS_WIN_REG_CREATE: + mReg->PrepareCreateKey(mRootkey, *mSubkey, &aReturn); + break; + + case NS_WIN_REG_DELETE: + mReg->PrepareDeleteKey(mRootkey, *mSubkey, &aReturn); + break; + + case NS_WIN_REG_DELETE_VAL: + mReg->PrepareDeleteValue(mRootkey, *mSubkey, *mName, &aReturn); + break; + + case NS_WIN_REG_SET_VAL_STRING: + mReg->PrepareSetValueString(mRootkey, *mSubkey, &aReturn); + break; + + case NS_WIN_REG_SET_VAL_NUMBER: + mReg->PrepareSetValueNumber(mRootkey, *mSubkey, &aReturn); + break; + + case NS_WIN_REG_SET_VAL: + mReg->PrepareSetValue(mRootkey, *mSubkey, &aReturn); + break; + + default: + break; + } + return aReturn; } void nsWinRegItem::Abort() diff --git a/xpinstall/wizard/windows/setup/dialogs.c b/xpinstall/wizard/windows/setup/dialogs.c index 3162867d5d59..5a1852d08db1 100644 --- a/xpinstall/wizard/windows/setup/dialogs.c +++ b/xpinstall/wizard/windows/setup/dialogs.c @@ -631,7 +631,7 @@ LRESULT CALLBACK DlgProcSetupType(HWND hDlg, UINT msg, WPARAM wParam, LONG lPara else ShowWindow(hReadme, SW_SHOW); - SetDlgItemText(hDlg, IDC_STATIC, sgInstallGui.szDestinationDirectory); + SetDlgItemText(hDlg, IDC_DESTINATION, sgInstallGui.szDestinationDirectory); SetDlgItemText(hDlg, IDC_BUTTON_BROWSE, sgInstallGui.szBrowse_); SetDlgItemText(hDlg, IDWIZBACK, sgInstallGui.szBack_); SetDlgItemText(hDlg, IDWIZNEXT, sgInstallGui.szNext_); diff --git a/xpinstall/wizard/windows/setup/extern.h b/xpinstall/wizard/windows/setup/extern.h index 4a74673b9911..9628d3eb6c11 100644 --- a/xpinstall/wizard/windows/setup/extern.h +++ b/xpinstall/wizard/windows/setup/extern.h @@ -72,6 +72,7 @@ extern BOOL gbILUseTemp; extern BOOL gbPreviousUnfinishedDownload; extern BOOL gbIgnoreRunAppX; extern BOOL gbIgnoreProgramFolderX; +extern BOOL gbRestrictedAccess; extern setupGen sgProduct; extern diS diSetup; diff --git a/xpinstall/wizard/windows/setup/extra.c b/xpinstall/wizard/windows/setup/extra.c index a787b34d5370..0ff7d54553ce 100644 --- a/xpinstall/wizard/windows/setup/extra.c +++ b/xpinstall/wizard/windows/setup/extra.c @@ -62,6 +62,8 @@ char *ArchiveExtensions[] = {"zip", "jar", ""}; +#define SETUP_STATE_REG_KEY "Software\\%s\\%s\\%s\\Setup" + typedef struct structVer { ULONGLONG ullMajor; @@ -232,12 +234,55 @@ void Delay(DWORD dwSeconds) SleepEx(dwSeconds * 1000, FALSE); } +BOOL VerifyRestrictedAccess(void) +{ + char szSubKey[MAX_BUF]; + char szSubKeyToTest[] = "Software\\%s - Test Key"; + BOOL bRv; + DWORD dwDisp = 0; + DWORD dwErr; + HKEY hkRv; + + wsprintf(szSubKey, szSubKeyToTest, sgProduct.szCompanyName); + dwErr = RegCreateKeyEx(HKEY_LOCAL_MACHINE, + szSubKey, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_WRITE, + NULL, + &hkRv, + &dwDisp); + if(dwErr == ERROR_SUCCESS) + { + RegCloseKey(hkRv); + switch(dwDisp) + { + case REG_CREATED_NEW_KEY: + RegDeleteKey(HKEY_LOCAL_MACHINE, szSubKey); + break; + + case REG_OPENED_EXISTING_KEY: + break; + } + bRv = FALSE; + } + else + bRv = TRUE; + + return(bRv); +} + void UnsetDownloadState(void) { char szKey[MAX_BUF_TINY]; - wsprintf(szKey, "Software\\%s\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductName, sgProduct.szUserAgent); - DeleteWinRegValue(HKEY_LOCAL_MACHINE, szKey, "Setup State"); + wsprintf(szKey, + SETUP_STATE_REG_KEY, + sgProduct.szCompanyName, + sgProduct.szProductName, + sgProduct.szUserAgent); + DeleteWinRegValue(HKEY_CURRENT_USER, szKey, "Setup State"); } void SetDownloadState(void) @@ -245,14 +290,18 @@ void SetDownloadState(void) char szKey[MAX_BUF_TINY]; char szValue[MAX_BUF_TINY]; - wsprintf(szKey, "Software\\%s\\%s\\%s", sgProduct.szCompanyName, sgProduct.szProductName, sgProduct.szUserAgent); + wsprintf(szKey, + SETUP_STATE_REG_KEY, + sgProduct.szCompanyName, + sgProduct.szProductName, + sgProduct.szUserAgent); lstrcpy(szValue, "downloading"); - SetWinReg(HKEY_LOCAL_MACHINE, szKey, TRUE, "Setup State", TRUE, - REG_SZ, szValue, lstrlen(szValue), FALSE, FALSE); + SetWinReg(HKEY_CURRENT_USER, szKey, TRUE, "Setup State", TRUE, + REG_SZ, szValue, lstrlen(szValue), TRUE, FALSE); } -BOOL CheckForPreviousUnfinishedDownload() +BOOL CheckForPreviousUnfinishedDownload(void) { char szBuf[MAX_BUF_TINY]; char szKey[MAX_BUF_TINY]; @@ -263,11 +312,11 @@ BOOL CheckForPreviousUnfinishedDownload() sgProduct.szUserAgent) { wsprintf(szKey, - "Software\\%s\\%s\\%s", + SETUP_STATE_REG_KEY, sgProduct.szCompanyName, sgProduct.szProductName, sgProduct.szUserAgent); - GetWinReg(HKEY_LOCAL_MACHINE, szKey, "Setup State", szBuf, sizeof(szBuf)); + GetWinReg(HKEY_CURRENT_USER, szKey, "Setup State", szBuf, sizeof(szBuf)); if(lstrcmpi(szBuf, "downloading") == 0) bRv = TRUE; } @@ -280,11 +329,11 @@ void UnsetSetupCurrentDownloadFile(void) char szKey[MAX_BUF]; wsprintf(szKey, - "Software\\%s\\%s\\%s", + SETUP_STATE_REG_KEY, sgProduct.szCompanyName, sgProduct.szProductName, sgProduct.szUserAgent); - DeleteWinRegValue(HKEY_LOCAL_MACHINE, + DeleteWinRegValue(HKEY_CURRENT_USER, szKey, "Setup Current Download"); } @@ -294,11 +343,11 @@ void SetSetupCurrentDownloadFile(char *szCurrentFilename) char szKey[MAX_BUF]; wsprintf(szKey, - "Software\\%s\\%s\\%s", + SETUP_STATE_REG_KEY, sgProduct.szCompanyName, sgProduct.szProductName, sgProduct.szUserAgent); - SetWinReg(HKEY_LOCAL_MACHINE, + SetWinReg(HKEY_CURRENT_USER, szKey, TRUE, "Setup Current Download", @@ -306,7 +355,7 @@ void SetSetupCurrentDownloadFile(char *szCurrentFilename) REG_SZ, szCurrentFilename, lstrlen(szCurrentFilename), - FALSE, + TRUE, FALSE); } @@ -324,11 +373,11 @@ char *GetSetupCurrentDownloadFile(char *szCurrentDownloadFile, sgProduct.szUserAgent) { wsprintf(szKey, - "Software\\%s\\%s\\%s", + SETUP_STATE_REG_KEY, sgProduct.szCompanyName, sgProduct.szProductName, sgProduct.szUserAgent); - GetWinReg(HKEY_LOCAL_MACHINE, + GetWinReg(HKEY_CURRENT_USER, szKey, "Setup Current Download", szCurrentDownloadFile, @@ -1617,6 +1666,7 @@ long RetrieveArchives() if(bDownloadTriggered) LogISDownloadStatus("ok", NULL); + UnsetSetupCurrentDownloadFile(); UnsetDownloadState(); } else if(bDownloadTriggered) @@ -4355,7 +4405,7 @@ void DeInitDSNode(dsN **dsnComponentDSRequirement) DsNodeDelete(&dsNTemp); dsNTemp = (*dsnComponentDSRequirement)->Prev; } - DsNodeDelete(&dsNTemp); + DsNodeDelete(dsnComponentDSRequirement); } BOOL ResolveComponentDependency(siCD *siCDInDependency) @@ -5140,6 +5190,49 @@ HRESULT ParseConfigIni(LPSTR lpszCmdLine) if(lstrcmpi(szBuf, "TRUE") == 0) sgProduct.bLockPath = TRUE; + gbRestrictedAccess = VerifyRestrictedAccess(); + if(gbRestrictedAccess) + { + /* Detected user does not have the appropriate + * privileges on this system */ + char szTitle[MAX_BUF_TINY]; + int iRvMB; + + switch(sgProduct.dwMode) + { + case NORMAL: + if(!GetPrivateProfileString("Messages", "MB_WARNING_STR", "", szBuf, sizeof(szBuf), szFileIniInstall)) + lstrcpy(szTitle, "Setup"); + else + wsprintf(szTitle, szBuf, sgProduct.szProductName); + + GetPrivateProfileString("Strings", "Message NORMAL Restricted Access", "", szBuf, sizeof(szBuf), szFileIniConfig); + iRvMB = MessageBox(hWndMain, szBuf, szTitle, MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2); + break; + + case AUTO: + ShowMessage(szMsgInitSetup, FALSE); + GetPrivateProfileString("Strings", "Message AUTO Restricted Access", "", szBuf, sizeof(szBuf), szFileIniConfig); + ShowMessage(szBuf, TRUE); + Delay(5); + ShowMessage(szBuf, FALSE); + iRvMB = IDNO; + break; + + default: + iRvMB = IDNO; + break; + } + + if(iRvMB == IDNO) + { + /* User chose not to continue with the lack of + * appropriate access privileges */ + PostQuitMessage(1); + return(1); + } + } + /* get main install path */ if(LocatePreviousPath("Locate Previous Product Path", szPreviousPath, sizeof(szPreviousPath)) == FALSE) { @@ -5530,6 +5623,7 @@ HRESULT ParseConfigIni(LPSTR lpszCmdLine) GetPrivateProfileString("Strings", "Message Unfinished Download Restart", "", szBuf, sizeof(szBuf), szFileIniConfig); if(MessageBox(hWndMain, szBuf, szTitle, MB_YESNO | MB_ICONQUESTION) == IDNO) { + UnsetSetupCurrentDownloadFile(); UnsetDownloadState(); /* unset the download state so that the archives can be deleted */ DeleteArchives(DA_ONLY_IF_NOT_IN_ARCHIVES_LST); } @@ -5870,6 +5964,18 @@ HRESULT DecryptVariable(LPSTR szVariable, DWORD dwVariableSize) GetWinReg(HKEY_LOCAL_MACHINE, szWRMSShellFolders, "Common Startup", szVariable, dwVariableSize); } } + else if(lstrcmpi(szVariable, "PROGRAMS") == 0) + { + /* parse for the "C:\WINNT40\Profiles\All Users\Start Menu\\Programs" directory */ + if((gSystemInfo.dwOSType & OS_WIN9x) || gbRestrictedAccess) + { + GetWinReg(HKEY_CURRENT_USER, szWRMSShellFolders, "Programs", szVariable, dwVariableSize); + } + else + { + GetWinReg(HKEY_LOCAL_MACHINE, szWRMSShellFolders, "Common Programs", szVariable, dwVariableSize); + } + } else if(lstrcmpi(szVariable, "COMMON_PROGRAMS") == 0) { /* parse for the "C:\WINNT40\Profiles\All Users\Start Menu\\Programs" directory */ @@ -6324,6 +6430,24 @@ BOOL NeedReboot() return(diReboot.dwShowDialog); } +BOOL DeleteWGetLog(void) +{ + char szFile[MAX_BUF]; + BOOL bFileExists = FALSE; + + ZeroMemory(szFile, sizeof(szFile)); + + lstrcpy(szFile, szTempDir); + AppendBackSlash(szFile, sizeof(szFile)); + lstrcat(szFile, FILE_WGET_LOG); + + if(FileExists(szFile)) + bFileExists = TRUE; + + DeleteFile(szFile); + return(bFileExists); +} + BOOL DeleteIdiGetConfigIni() { char szFileIdiGetConfigIni[MAX_BUF]; @@ -6529,10 +6653,15 @@ void DeInitialize() if((szPartialEscapedURL = nsEscape(gErrorMessageStream.szMessage, url_Path)) != NULL) { + char szWGetLog[MAX_BUF]; char szMsg[MAX_BUF]; char *szFullURL = NULL; DWORD dwSize; + lstrcpy(szWGetLog, szTempDir); + AppendBackSlash(szWGetLog, sizeof(szWGetLog)); + lstrcat(szWGetLog, FILE_WGET_LOG); + /* take into account '?' and '\0' chars */ dwSize = lstrlen(gErrorMessageStream.szURL) + lstrlen(szPartialEscapedURL) + 2; @@ -6564,20 +6693,26 @@ void DeInitialize() szConfirmationMessage, sgProduct.szProductName, MB_OKCANCEL | MB_ICONQUESTION) == IDOK) - // PrintError(szMsg, ERROR_CODE_HIDE); + { + //PrintError(szMsg, ERROR_CODE_HIDE); WGet(szFullURL, + szWGetLog, diAdvancedSettings.szProxyServer, diAdvancedSettings.szProxyPort, diAdvancedSettings.szProxyUser, diAdvancedSettings.szProxyPasswd); + } } else if(!gErrorMessageStream.bShowConfirmation) + { //PrintError(szMsg, ERROR_CODE_HIDE); WGet(szFullURL, + szWGetLog, diAdvancedSettings.szProxyServer, diAdvancedSettings.szProxyPort, diAdvancedSettings.szProxyUser, diAdvancedSettings.szProxyPasswd); + } FreeMemory(&szFullURL); } @@ -6601,6 +6736,7 @@ void DeInitialize() if(hbmpBoxUnChecked) DeleteObject(hbmpBoxUnChecked); + DeleteWGetLog(); CleanTempFiles(); DirectoryRemove(szTempDir, FALSE); diff --git a/xpinstall/wizard/windows/setup/extra.h b/xpinstall/wizard/windows/setup/extra.h index 3ca5e4fa6dc8..88d7ddb922f9 100644 --- a/xpinstall/wizard/windows/setup/extra.h +++ b/xpinstall/wizard/windows/setup/extra.h @@ -202,6 +202,7 @@ void UnsetSetupCurrentDownloadFile(void); void SetSetupCurrentDownloadFile(char *szCurrentFilename); char *GetSetupCurrentDownloadFile(char *szCurrentDownloadFile, DWORD dwCurrentDownloadFileBufSize); +BOOL DeleteWGetLog(void); #endif /* _EXTRA_H_ */ diff --git a/xpinstall/wizard/windows/setup/ifuncns.c b/xpinstall/wizard/windows/setup/ifuncns.c index 00b68fe5b97e..a150bb4d4eee 100644 --- a/xpinstall/wizard/windows/setup/ifuncns.c +++ b/xpinstall/wizard/windows/setup/ifuncns.c @@ -1271,6 +1271,20 @@ HRESULT ProcessRunApp(DWORD dwTiming, char *szSectionPrefix) return(FO_SUCCESS); } +DWORD ParseRestrictedAccessKey(LPSTR szKey) +{ + DWORD dwKey; + + if(lstrcmpi(szKey, "ONLY_RESTRICTED") == 0) + dwKey = RA_ONLY_RESTRICTED; + else if(lstrcmpi(szKey, "ONLY_NONRESTRICTED") == 0) + dwKey = RA_ONLY_NONRESTRICTED; + else + dwKey = RA_IGNORE; + + return(dwKey); +} + HKEY ParseRootKey(LPSTR szRootKey) { HKEY hkRootKey; @@ -1696,6 +1710,7 @@ HRESULT ProcessProgramFolder(DWORD dwTiming, char *szSectionPrefix) DWORD dwIndex0; DWORD dwIndex1; DWORD dwIconId; + DWORD dwRestrictedAccess; char szIndex1[MAX_BUF]; char szBuf[MAX_BUF]; char szSection0[MAX_BUF]; @@ -1739,11 +1754,18 @@ HRESULT ProcessProgramFolder(DWORD dwTiming, char *szSectionPrefix) else dwIconId = 0; - CreateALink(szFile, szProgramFolder, szDescription, szWorkingDir, szArguments, szIconPath, dwIconId); - lstrcpy(szBuf, szProgramFolder); - AppendBackSlash(szBuf, sizeof(szBuf)); - lstrcat(szBuf, szDescription); - UpdateInstallLog(KEY_WINDOWS_SHORTCUT, szBuf, FALSE); + GetPrivateProfileString(szSection1, "Restricted Access", "", szBuf, sizeof(szBuf), szFileIniConfig); + dwRestrictedAccess = ParseRestrictedAccessKey(szBuf); + if((dwRestrictedAccess == RA_IGNORE) || + ((dwRestrictedAccess == RA_ONLY_RESTRICTED) && gbRestrictedAccess) || + ((dwRestrictedAccess == RA_ONLY_NONRESTRICTED) && !gbRestrictedAccess)) + { + CreateALink(szFile, szProgramFolder, szDescription, szWorkingDir, szArguments, szIconPath, dwIconId); + lstrcpy(szBuf, szProgramFolder); + AppendBackSlash(szBuf, sizeof(szBuf)); + lstrcat(szBuf, szDescription); + UpdateInstallLog(KEY_WINDOWS_SHORTCUT, szBuf, FALSE); + } ++dwIndex1; itoa(dwIndex1, szIndex1, 10); diff --git a/xpinstall/wizard/windows/setup/ifuncns.h b/xpinstall/wizard/windows/setup/ifuncns.h index f7a11d55e68c..1be2142baf02 100644 --- a/xpinstall/wizard/windows/setup/ifuncns.h +++ b/xpinstall/wizard/windows/setup/ifuncns.h @@ -85,6 +85,7 @@ HRESULT ProcessSetVersionRegistry(DWORD dwTiming, char *szSectionPrefix); char *BuildNumberedString(DWORD dwIndex, char *szInputStringPrefix, char *szInputString, char *szOutBuf, DWORD dwOutBufSize); void GetUserAgentShort(char *szUserAgent, char *szOutUAShort, DWORD dwOutUAShortSize); void CleanupPreviousVersionRegKeys(void); +DWORD ParseRestrictedAccessKey(LPSTR szKey); #endif /* _IFUNCNS_H_ */ diff --git a/xpinstall/wizard/windows/setup/logging.c b/xpinstall/wizard/windows/setup/logging.c index 1ede590cac59..ada5bc284a45 100644 --- a/xpinstall/wizard/windows/setup/logging.c +++ b/xpinstall/wizard/windows/setup/logging.c @@ -424,12 +424,7 @@ void LogMSDownloadStatus(int iDownloadStatus) wsprintf(szMessageStream, "&DownloadStatus=%d", iDownloadStatus); AppendToGlobalMessageStream(szMessageStream); - - if(((iDownloadStatus == E_USER_CANCEL) && - !gErrorMessageStream.bShowConfirmation) || - ((iDownloadStatus != E_USER_CANCEL) && - (iDownloadStatus != WIZ_OK))) - gErrorMessageStream.bSendMessage = TRUE; + gErrorMessageStream.bSendMessage = TRUE; } void LogMSDownloadFileStatus(void) @@ -466,17 +461,23 @@ void LogMSDownloadFileStatus(void) void LogMSXPInstallStatus(char *szFile, int iErr) { char szMessageStream[MAX_BUF]; + static BOOL bAlreadyLogged = FALSE; + + if(bAlreadyLogged) + return; if(szFile) - { - wsprintf(szMessageStream, "&XPInstallStatus=%d&File=%s", iErr, szFile); - AppendToGlobalMessageStream(szMessageStream); - if((iErr != E_REBOOT) && - (((iErr == E_USER_CANCEL) && - !gErrorMessageStream.bShowConfirmation) || - ((iErr != E_USER_CANCEL) && - (iErr != WIZ_OK)))) - gErrorMessageStream.bSendMessage = TRUE; - } + wsprintf(szMessageStream, "&XPInstallStatus=%d&XPInstallFile=%s", iErr, szFile); + else + wsprintf(szMessageStream, "&XPInstallStatus=%d", iErr); + + AppendToGlobalMessageStream(szMessageStream); + bAlreadyLogged = TRUE; + if((iErr != E_REBOOT) && + (((iErr == E_USER_CANCEL) && + !gErrorMessageStream.bShowConfirmation) || + ((iErr != E_USER_CANCEL) && + (iErr != WIZ_OK)))) + gErrorMessageStream.bSendMessage = TRUE; } diff --git a/xpinstall/wizard/windows/setup/nsEscape.cpp b/xpinstall/wizard/windows/setup/nsEscape.cpp index e21e11542697..4cfff0f87dc3 100644 --- a/xpinstall/wizard/windows/setup/nsEscape.cpp +++ b/xpinstall/wizard/windows/setup/nsEscape.cpp @@ -54,7 +54,7 @@ const int netCharType[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 1x */ 0,0,0,0,0,0,0,0,0,0,7,4,0,7,7,4, /* 2x !"#$%&'()*+,-./ */ - 7,7,7,7,7,7,7,7,7,7,0,0,0,0,0,0, /* 3x 0123456789:;<=>? */ + 7,7,7,7,7,7,7,7,7,7,0,0,0,7,0,0, /* 3x 0123456789:;<=>? */ 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, /* 4x @ABCDEFGHIJKLMNO */ /* bits for '@' changed from 7 to 0 so '@' can be escaped */ /* in usernames and passwords in publishing. */ diff --git a/xpinstall/wizard/windows/setup/setup.c b/xpinstall/wizard/windows/setup/setup.c index e903dd6ed6e2..22ba39d74040 100644 --- a/xpinstall/wizard/windows/setup/setup.c +++ b/xpinstall/wizard/windows/setup/setup.c @@ -74,6 +74,7 @@ BOOL gbILUseTemp; BOOL gbPreviousUnfinishedDownload; BOOL gbIgnoreRunAppX; BOOL gbIgnoreProgramFolderX; +BOOL gbRestrictedAccess; setupGen sgProduct; diS diSetup; diff --git a/xpinstall/wizard/windows/setup/setup.h b/xpinstall/wizard/windows/setup/setup.h index 547780b25d9f..786c48698968 100644 --- a/xpinstall/wizard/windows/setup/setup.h +++ b/xpinstall/wizard/windows/setup/setup.h @@ -59,6 +59,7 @@ typedef int PRInt32; #define FILE_IDI_GETARCHIVES "getarchives.idi" #define FILE_IDI_GETREDIRECT "getredirect.idi" #define FILE_INI_REDIRECT "redirect.ini" +#define FILE_WGET_LOG "wget.log" #define WIZ_TEMP_DIR "ns_temp" #define FILE_INSTALL_LOG "install_wizard.log" #define FILE_INSTALL_STATUS_LOG "install_status.log" @@ -87,6 +88,11 @@ typedef int PRInt32; #define UP_FTP 0 #define UP_HTTP 1 +/* RA: Restricted Access */ +#define RA_IGNORE 0 +#define RA_ONLY_RESTRICTED 1 +#define RA_ONLY_NONRESTRICTED 2 + /* LIS: Log Install Status */ #define LIS_SUCCESS 0 #define LIS_FAILURE 1 diff --git a/xpinstall/wizard/windows/setup/xperr.h b/xpinstall/wizard/windows/setup/xperr.h index d1b2f287c623..d3ff2b8e67cb 100644 --- a/xpinstall/wizard/windows/setup/xperr.h +++ b/xpinstall/wizard/windows/setup/xperr.h @@ -67,6 +67,9 @@ char *XpErrorList[] = {"0" , "OK", "-238", "UNABLE_TO_LOAD_LIBRARY", "-239", "CHROME_REGISTRY_ERROR", "-240", "MALFORMED_INSTALL", + "-241", "KEY_ACCESS_DENIED", + "-242", "KEY_DOES_NOT_EXIST", + "-243", "VALUE_DOES_NOT_EXIST", "-299", "OUT_OF_MEMORY", "-322", "INIT_STUB_ERROR", "-5550", "GESTALT_UNKNOWN_ERR", diff --git a/xpinstall/wizard/windows/setup/xpi.c b/xpinstall/wizard/windows/setup/xpi.c index 5c5c868e09e1..aaef0e7e6ce4 100644 --- a/xpinstall/wizard/windows/setup/xpi.c +++ b/xpinstall/wizard/windows/setup/xpi.c @@ -319,6 +319,7 @@ HRESULT SmartUpdateJars() siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL); } /* while(siCObject) */ + LogMSXPInstallStatus(NULL, hrResult); pfnXpiExit(); DeInitProgressDlg(); } diff --git a/xpinstall/wizard/windows/setup/xpnetHook.cpp b/xpinstall/wizard/windows/setup/xpnetHook.cpp index 36264c17f5f8..a8392074606d 100644 --- a/xpinstall/wizard/windows/setup/xpnetHook.cpp +++ b/xpinstall/wizard/windows/setup/xpnetHook.cpp @@ -467,6 +467,7 @@ ProcessWndMsgCB() /* Function used only to send the message stream error */ int WGet(char *szUrl, + char *szFile, char *szProxyServer, char *szProxyPort, char *szProxyUser, @@ -505,7 +506,7 @@ int WGet(char *szUrl, rv = conn->Open(); if(rv == WIZ_OK) { - rv = conn->Get(NULL, NULL); + rv = conn->Get(NULL, szFile); conn->Close(); } @@ -519,8 +520,12 @@ int DownloadViaProxy(char *szUrl, char *szProxyServer, char *szProxyPort, char * { int rv; char proxyURL[kProxySrvrLen]; + char *host = NULL; + char *path = NULL; + char *file = NULL; + int port; - rv = nsHTTPConn::OK; + rv = nsHTTPConn::ParseURL(kHTTP, szUrl, &host, &port, &path); memset(proxyURL, 0, kProxySrvrLen); wsprintf(proxyURL, "http://%s:%s", szProxyServer, szProxyPort); @@ -544,7 +549,10 @@ int DownloadViaProxy(char *szUrl, char *szProxyServer, char *szProxyPort, char * if((rv = conn->Open()) != WIZ_OK) return(rv); - rv = conn->Get(ProgressCB, NULL); // use leaf from URL + if(strrchr(path, '/') != (path + strlen(path))) + file = strrchr(path, '/') + 1; // set to leaf name + + rv = conn->Get(ProgressCB, file); // use leaf from URL conn->Close(); if(conn) @@ -555,9 +563,13 @@ int DownloadViaProxy(char *szUrl, char *szProxyServer, char *szProxyPort, char * int DownloadViaHTTP(char *szUrl) { - int rv; + int rv; + char *host = NULL; + char *path = NULL; + char *file = NULL; + int port; - rv = nsHTTPConn::OK; + rv = nsHTTPConn::ParseURL(kHTTP, szUrl, &host, &port, &path); nsHTTPConn *conn = new nsHTTPConn(szUrl, ProcessWndMsgCB); if(conn == NULL) { @@ -572,7 +584,10 @@ int DownloadViaHTTP(char *szUrl) if((rv = conn->Open()) != WIZ_OK) return(rv); - rv = conn->Get(ProgressCB, NULL); + if(strrchr(path, '/') != (path + strlen(path))) + file = strrchr(path, '/') + 1; // set to leaf name + + rv = conn->Get(ProgressCB, file); conn->Close(); if(conn) diff --git a/xpinstall/wizard/windows/setup/xpnetHook.h b/xpinstall/wizard/windows/setup/xpnetHook.h index 08461f3eb7d2..48213f8c3d40 100644 --- a/xpinstall/wizard/windows/setup/xpnetHook.h +++ b/xpinstall/wizard/windows/setup/xpnetHook.h @@ -24,6 +24,7 @@ #define _XPNETHOOK_H_ int WGet(char *szUrl, + char *szFile, char *szProxyServer, char *szProxyPort, char *szProxyUser, diff --git a/xpinstall/wizard/windows/setuprsc/setuprsc.h b/xpinstall/wizard/windows/setuprsc/setuprsc.h index 1c8f9de7dc2f..f2179c3e05a2 100644 --- a/xpinstall/wizard/windows/setuprsc/setuprsc.h +++ b/xpinstall/wizard/windows/setuprsc/setuprsc.h @@ -91,6 +91,7 @@ #define IDC_STATUS_STATUS 1071 #define IDC_USE_HTTP 1073 #define IDC_USE_FTP 1074 +#define IDC_DESTINATION 1074 #define DLG_WELCOME 2001 #define DLG_LICENSE 2002 #define DLG_SETUP_TYPE 2003 @@ -133,7 +134,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 115 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1074 +#define _APS_NEXT_CONTROL_VALUE 1075 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/xpinstall/wizard/windows/setuprsc/setuprsc.rc b/xpinstall/wizard/windows/setuprsc/setuprsc.rc index 938c836cb4d8..9d68e3cd9daa 100644 --- a/xpinstall/wizard/windows/setuprsc/setuprsc.rc +++ b/xpinstall/wizard/windows/setuprsc/setuprsc.rc @@ -69,10 +69,9 @@ BEGIN WS_EX_STATICEDGE END -DLG_SETUP_TYPE DIALOG DISCARDABLE 51, 56, 315, 205 +DLG_SETUP_TYPE DIALOG DISCARDABLE 51, 56, 315, 205 STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION ":" CLASS "MozillaSetupDlg" FONT 8, "MS Sans Serif" BEGIN @@ -85,11 +84,14 @@ BEGIN CONTROL "",IDC_RADIO_ST3,"Button",BS_AUTORADIOBUTTON,102,112,64, 12 LTEXT "",IDC_STATIC_ST0_DESCRIPTION,175,31,126,24 - LTEXT "",IDC_STATIC_ST3_DESCRIPTION,175,114,126,25 LTEXT "",IDC_STATIC_ST1_DESCRIPTION,175,59,126,24 LTEXT "",IDC_STATIC_ST2_DESCRIPTION,175,86,126,24 - GROUPBOX "",IDC_STATIC,101,147,204,27 + LTEXT "",IDC_STATIC_ST3_DESCRIPTION,175,114,126,25 + GROUPBOX "",IDC_DESTINATION,101,147,204,27 + CONTROL "",IDC_EDIT_DESTINATION,"Static",SS_LEFTNOWORDWRAP | + WS_GROUP,107,160,143,9 PUSHBUTTON "",IDC_BUTTON_BROWSE,255,156,46,14 + PUSHBUTTON "",IDC_README,11,186,83,14 PUSHBUTTON "",IDWIZBACK,134,186,53,14 DEFPUSHBUTTON "",IDWIZNEXT,188,186,53,14 PUSHBUTTON "",IDCANCEL,252,186,53,14 @@ -98,9 +100,6 @@ BEGIN WS_EX_CLIENTEDGE CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,11,179,295,1, WS_EX_STATICEDGE - PUSHBUTTON "",IDC_README,11,186,83,14 - CONTROL "",IDC_EDIT_DESTINATION,"Static",SS_LEFTNOWORDWRAP | - WS_GROUP,107,160,143,9 END DLG_SELECT_COMPONENTS DIALOG DISCARDABLE 51, 56, 315, 205 @@ -252,18 +251,19 @@ BEGIN CTEXT "",IDC_MESSAGE,0,0,236,34,SS_CENTERIMAGE END -DLG_EXTRACTING DIALOG DISCARDABLE 0, 0, 193, 73 +DLG_EXTRACTING DIALOG DISCARDABLE 0, 0, 312, 154 STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CLASS "MozillaSetupDlg" FONT 8, "MS Sans Serif" BEGIN - CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,9,52,175,11 + CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,12,110,286,11 CONTROL "",IDC_STATUS0,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX | - WS_GROUP,9,9,175,8 + WS_GROUP,12,64,286,8 CONTROL "",IDC_STATUS3,"Static",SS_LEFTNOWORDWRAP | SS_NOPREFIX | - WS_GROUP,9,40,175,8 - CONTROL "",IDC_GAUGE_ARCHIVE,"GaugeArchive",0x0,9,21,175,11 + WS_GROUP,12,98,286,8 + CONTROL "",IDC_GAUGE_ARCHIVE,"GaugeArchive",0x0,12,77,286,11 + CONTROL 114,IDC_STATIC,"Static",SS_BITMAP,0,0,312,34 END DLG_ADVANCED_SETTINGS DIALOG DISCARDABLE 51, 56, 315, 205 @@ -336,7 +336,7 @@ BEGIN DEFPUSHBUTTON "",IDWIZBACK,162,139,53,14 END -DLG_DOWNLOAD_OPTIONS DIALOG DISCARDABLE 51, 56, 315, 205 +DLG_DOWNLOAD_OPTIONS DIALOG DISCARDABLE 51, 56, 315, 205 STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CLASS "MozillaSetupDlg" @@ -369,21 +369,21 @@ BEGIN PUSHBUTTON "",IDRESUME,187,134,50,14,WS_GROUP PUSHBUTTON "",IDCANCEL,252,134,50,14,WS_GROUP LTEXT "",IDC_MESSAGE0,9,39,293,23 - LTEXT "",IDC_STATIC3,9,83,37,8,SS_NOPREFIX + LTEXT "",IDC_STATIC3,9,81,37,8,SS_NOPREFIX CONTROL "",IDC_STATUS_URL,"Static",SS_LEFTNOWORDWRAP | - SS_NOPREFIX | WS_GROUP,49,83,253,8 - LTEXT "",IDC_STATIC1,9,103,37,8,SS_NOPREFIX + SS_NOPREFIX | WS_GROUP,49,81,253,8 + LTEXT "",IDC_STATIC1,9,101,37,8,SS_NOPREFIX CONTROL "",IDC_STATUS_STATUS,"Static",SS_LEFTNOWORDWRAP | - SS_NOPREFIX | WS_GROUP,49,103,253,8 - LTEXT "",IDC_STATIC2,9,74,37,8,SS_NOPREFIX + SS_NOPREFIX | WS_GROUP,49,101,253,8 + LTEXT "",IDC_STATIC2,9,72,37,8,SS_NOPREFIX CONTROL "",IDC_STATUS_FILE,"Static",SS_LEFTNOWORDWRAP | - SS_NOPREFIX | WS_GROUP,49,74,253,8 - CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,24,114,256,11 - LTEXT "",IDC_PERCENTAGE,282,115,20,8,SS_NOPREFIX + SS_NOPREFIX | WS_GROUP,49,72,253,8 + CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,9,114,271,11 + LTEXT "",IDC_PERCENTAGE,283,115,20,8,SS_NOPREFIX CONTROL 114,IDC_STATIC,"Static",SS_BITMAP,0,0,312,34 - LTEXT "",IDC_STATIC4,9,93,37,8,SS_NOPREFIX + LTEXT "",IDC_STATIC4,9,91,37,8,SS_NOPREFIX CONTROL "",IDC_STATUS_TO,"Static",SS_LEFTNOWORDWRAP | - SS_NOPREFIX | WS_GROUP,49,93,253,8 + SS_NOPREFIX | WS_GROUP,49,91,253,8 END @@ -417,7 +417,7 @@ GUIDELINES DESIGNINFO DISCARDABLE BEGIN DLG_EXTRACTING, DIALOG BEGIN - BOTTOMMARGIN, 72 + BOTTOMMARGIN, 153 END DLG_UPGRADE, DIALOG diff --git a/xpinstall/wizard/windows/uninstall/extra.c b/xpinstall/wizard/windows/uninstall/extra.c index 371db76db1c1..614065c2cdfd 100644 --- a/xpinstall/wizard/windows/uninstall/extra.c +++ b/xpinstall/wizard/windows/uninstall/extra.c @@ -994,6 +994,45 @@ int CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew) return(0); } +BOOL VerifyRestrictedAccess(void) +{ + char szSubKey[MAX_BUF]; + char szSubKeyToTest[] = "Software\\%s - Test Key"; + BOOL bRv; + DWORD dwDisp = 0; + DWORD dwErr; + HKEY hkRv; + + wsprintf(szSubKey, szSubKeyToTest, ugUninstall.szCompanyName); + dwErr = RegCreateKeyEx(HKEY_LOCAL_MACHINE, + szSubKey, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_WRITE, + NULL, + &hkRv, + &dwDisp); + if(dwErr == ERROR_SUCCESS) + { + RegCloseKey(hkRv); + switch(dwDisp) + { + case REG_CREATED_NEW_KEY: + RegDeleteKey(HKEY_LOCAL_MACHINE, szSubKey); + break; + + case REG_OPENED_EXISTING_KEY: + break; + } + bRv = FALSE; + } + else + bRv = TRUE; + + return(bRv); +} + BOOL CheckLegacy(HWND hDlg) { char szSection[MAX_BUF]; @@ -1087,6 +1126,7 @@ HRESULT GetUninstallLogPath() char szErrorMsg[MAX_BUF]; char szEUninstallLogFolder[MAX_BUF]; char szRootKey[MAX_BUF]; + BOOL bRestrictedAccess; HKEY hkRoot; if(*ugUninstall.szUserAgent != '\0') @@ -1104,11 +1144,19 @@ HRESULT GetUninstallLogPath() strcpy(szKey, ugUninstall.szWrKey); } + bRestrictedAccess = VerifyRestrictedAccess(); + if(bRestrictedAccess) + hkRoot = HKEY_CURRENT_USER; + GetWinReg(hkRoot, szKey, "Uninstall Log Folder", szLogFolder, sizeof(szLogFolder)); - GetWinReg(hkRoot, szKey, "Description", ugUninstall.szUninstallKeyDescription, sizeof(szLogFolder)); - lstrcpy(szWindowsUninstallKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); - lstrcat(szWindowsUninstallKey, ugUninstall.szUninstallKeyDescription); - GetWinReg(HKEY_LOCAL_MACHINE, szWindowsUninstallKey, "DisplayName", ugUninstall.szDescription, sizeof(szLogFolder)); + GetWinReg(hkRoot, szKey, "Description", ugUninstall.szUninstallKeyDescription, MAX_BUF); + + if(!bRestrictedAccess) + { + lstrcpy(szWindowsUninstallKey, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); + lstrcat(szWindowsUninstallKey, ugUninstall.szUninstallKeyDescription); + GetWinReg(HKEY_LOCAL_MACHINE, szWindowsUninstallKey, "DisplayName", ugUninstall.szDescription, MAX_BUF); + } /* if the DisplayName was not found in the windows registry, * use the description from read in from config.ini file */