From 9fecbae030f33a31b131a75cf41b243c6ea36751 Mon Sep 17 00:00:00 2001 From: Don HO Date: Fri, 25 Jan 2019 02:10:11 +0100 Subject: [PATCH] Move plugins home from %ProgramData% to %ProgramFiles% for the sake of security Whole specs here: https://notepad-plus-plus.org/community/topic/16996/new-plugins-home-round-2 --- .../nsisInclude/binariesComponents.nsh | 8 +----- .../nsisInclude/mainSectionFuncs.nsh | 28 ++++++------------- PowerEditor/src/Parameters.cpp | 16 +++-------- PowerEditor/src/shortcuts.xml | 2 +- 4 files changed, 15 insertions(+), 39 deletions(-) diff --git a/PowerEditor/installer/nsisInclude/binariesComponents.nsh b/PowerEditor/installer/nsisInclude/binariesComponents.nsh index af160ec1..5233e411 100644 --- a/PowerEditor/installer/nsisInclude/binariesComponents.nsh +++ b/PowerEditor/installer/nsisInclude/binariesComponents.nsh @@ -148,16 +148,10 @@ SectionGroup un.Plugins RMDir "$PLUGIN_INST_PATH\mimeTools" SectionEnd - Section un.PluginManager - Delete "$INSTDIR\plugins\PluginManager.dll" - Delete "$UPDATE_PATH\plugins\Config\PluginManager.ini" - Delete "$INSTDIR\updater\gpup.exe" - RMDir "$INSTDIR\updater\" - SectionEnd - Section un.DSpellCheck Delete "$INSTDIR\plugins\DSpellCheck.dll" + Delete "$INSTDIR\plugins\DSpellCheck\DSpellCheck.dll" Delete "$PLUGIN_INST_PATH\DSpellCheck\DSpellCheck.dll" Delete "$UPDATE_PATH\plugins\Config\DSpellCheck.ini" Delete "$ALLUSERS_PLUGIN_CONF_PATH\DSpellCheck.ini" diff --git a/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh b/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh index d6432cbb..e41b2277 100644 --- a/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh +++ b/PowerEditor/installer/nsisInclude/mainSectionFuncs.nsh @@ -47,39 +47,28 @@ initUpdatePath: SetOutPath "$INSTDIR\" + StrCpy $PLUGIN_INST_PATH "$INSTDIR\plugins" + StrCpy $ALLUSERS_PLUGIN_CONF_PATH "$PLUGIN_INST_PATH\Config" + ${If} $noUserDataChecked == ${BST_CHECKED} File "..\bin\doLocalConf.xml" - StrCpy $PLUGIN_INST_PATH "$INSTDIR\plugins" - StrCpy $ALLUSERS_PLUGIN_CONF_PATH "$INSTDIR\plugins\Config" - StrCpy $USER_PLUGIN_CONF_PATH "$INSTDIR\plugins\Config" + StrCpy $USER_PLUGIN_CONF_PATH "$ALLUSERS_PLUGIN_CONF_PATH" CreateDirectory $PLUGIN_INST_PATH\config ${ELSE} IfFileExists $INSTDIR\doLocalConf.xml 0 +2 Delete $INSTDIR\doLocalConf.xml - ; "SetShellVarContext all" makes "$APPDATA\${APPNAME}\plugins" to "%PROGRAMDATA%\Notepad++\plugins" - SetShellVarContext all - StrCpy $PLUGIN_INST_PATH "$APPDATA\${APPNAME}\plugins" - StrCpy $ALLUSERS_PLUGIN_CONF_PATH "$APPDATA\${APPNAME}\plugins\Config" - - CreateDirectory $PLUGIN_INST_PATH - AccessControl::GrantOnFile "$PLUGIN_INST_PATH" "(S-1-5-32-545)" "ListDirectory + GenericRead + GenericExecute" - - CreateDirectory $ALLUSERS_PLUGIN_CONF_PATH - AccessControl::GrantOnFile "$ALLUSERS_PLUGIN_CONF_PATH" "(S-1-5-32-545)" "FullAccess" - - SetShellVarContext current StrCpy $USER_PLUGIN_CONF_PATH "$APPDATA\${APPNAME}\plugins\Config" StrCpy $UPDATE_PATH "$APPDATA\${APPNAME}" CreateDirectory $UPDATE_PATH\plugins\config ${EndIf} - WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "UPDATE_PATH" $UPDATE_PATH - WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "PLUGIN_INST_PATH" $PLUGIN_INST_PATH - WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "USER_PLUGIN_CONF_PATH" $USER_PLUGIN_CONF_PATH - WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "ALLUSERS_PLUGIN_CONF_PATH" $ALLUSERS_PLUGIN_CONF_PATH + ; WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "UPDATE_PATH" $UPDATE_PATH + ; WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "PLUGIN_INST_PATH" $PLUGIN_INST_PATH + ; WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "USER_PLUGIN_CONF_PATH" $USER_PLUGIN_CONF_PATH + ; WriteIniStr "$INSTDIR\uninstall.ini" "Uninstall" "ALLUSERS_PLUGIN_CONF_PATH" $ALLUSERS_PLUGIN_CONF_PATH alreadyDone: FunctionEnd @@ -91,6 +80,7 @@ Function un.setPathAndOptions ReadINIStr $ALLUSERS_PLUGIN_CONF_PATH "$INSTDIR\uninstall.ini" "Uninstall" "ALLUSERS_PLUGIN_CONF_PATH" FunctionEnd + Function copyCommonFiles SetOverwrite off SetOutPath "$UPDATE_PATH\" diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 57bb6904..1034815f 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -1012,14 +1012,13 @@ bool NppParameters::load() } } + _pluginRootDir = _nppPath; + PathAppend(_pluginRootDir, TEXT("plugins")); + generic_string nppPluginRootParent; if (_isLocal) { _userPath = nppPluginRootParent = _nppPath; - - _pluginRootDir = _nppPath; - PathAppend(_pluginRootDir, TEXT("plugins")); - _userPluginConfDir = _pluginRootDir; PathAppend(_userPluginConfDir, TEXT("Config")); } @@ -1039,18 +1038,11 @@ bool NppParameters::load() if (!PathFileExists(_userPluginConfDir.c_str())) ::CreateDirectory(_userPluginConfDir.c_str(), NULL); - - _pluginRootDir = getSpecialFolderLocation(CSIDL_COMMON_APPDATA); - PathAppend(_pluginRootDir, TEXT("Notepad++")); - nppPluginRootParent = _pluginRootDir; - - PathAppend(_pluginRootDir, TEXT("plugins")); - // For PluginAdmin to launch the wingup with UAC setElevationRequired(true); } - _pluginConfDir = _pluginRootDir; + _pluginConfDir = _pluginRootDir; // for plugin list home PathAppend(_pluginConfDir, TEXT("Config")); if (!PathFileExists(nppPluginRootParent.c_str())) diff --git a/PowerEditor/src/shortcuts.xml b/PowerEditor/src/shortcuts.xml index e479684d..de19bed3 100644 --- a/PowerEditor/src/shortcuts.xml +++ b/PowerEditor/src/shortcuts.xml @@ -10,7 +10,7 @@